本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddRegularIcosahedron方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddRegularIcosahedron方法的具体用法?C# MeshBuilder.AddRegularIcosahedron怎么用?C# MeshBuilder.AddRegularIcosahedron使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddRegularIcosahedron方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUnitSphere
/// <summary>
/// Gets a unit sphere from the cache.
/// </summary>
/// <param name="subdivisions">
/// The number of subdivisions.
/// </param>
/// <returns>
/// A unit sphere mesh.
/// </returns>
private static MeshGeometry3D GetUnitSphere(int subdivisions)
{
if (UnitSphereCache.Value.ContainsKey(subdivisions))
{
return UnitSphereCache.Value[subdivisions];
}
var mb = new MeshBuilder(false, false);
mb.AddRegularIcosahedron(new Point3D(), 1, false);
for (int i = 0; i < subdivisions; i++)
{
mb.SubdivideLinear();
}
for (int i = 0; i < mb.positions.Count; i++)
{
var v = mb.Positions[i].ToVector3D();
v.Normalize();
mb.Positions[i] = v.ToPoint3D();
}
var mesh = mb.ToMesh();
UnitSphereCache.Value[subdivisions] = mesh;
return mesh;
}
示例2: AddIcosahedron
/// <summary>
/// Add an icosahedron geometry object centred at (0,0,0).
/// </summary>
/// <param name="shapeName">The 3DView object.</param>
/// <param name="radius">The radius of the icosahedron.</param>
/// <param name="colour">A colour or gradient brush for the object.</param>
/// <param name="materialType">A material for the object.
/// The available options are:
/// "E" Emmissive - constant brightness.
/// "D" Diffusive - affected by lights.
/// "S" Specular - specular highlights.
/// </param>
/// <returns>The 3DView Geometry name.</returns>
public static Primitive AddIcosahedron(Primitive shapeName, Primitive radius, Primitive colour, Primitive materialType)
{
UIElement obj;
try
{
if (_objectsMap.TryGetValue((string)shapeName, out obj))
{
InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
{
try
{
if (obj.GetType() == typeof(Viewport3D))
{
MeshBuilder builder = new MeshBuilder(true, true);
builder.AddRegularIcosahedron(new Point3D(0, 0, 0), radius, false);
MeshGeometry3D mesh = builder.ToMesh();
Viewport3D viewport3D = (Viewport3D)obj;
return AddGeometry(viewport3D, mesh.Positions, mesh.TriangleIndices, mesh.Normals, mesh.TextureCoordinates, colour, materialType);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
});
return FastThread.InvokeWithReturn(ret).ToString();
}
else
{
Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
}