public AddRegularIcosahedron ( System.Windows.Media.Media3D.Point3D center, double radius, bool shareVertices ) : void | ||
center | System.Windows.Media.Media3D.Point3D | /// The center. /// |
radius | double | /// The radius. /// |
shareVertices | bool |
/// Share vertices if set to |
return | void |
/// <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; }
/// <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 ""; }