public Geometry Sqrt3(Geometry geometry) { geometry.BuildEdges(); geometry = new Sqrt3GeometryOperation(geometry).Destination; geometry = new Sqrt3GeometryOperation(geometry).Destination; geometry = new Sqrt3GeometryOperation(geometry).Destination; geometry = new Sqrt3GeometryOperation(geometry).Destination; geometry = new Sqrt3GeometryOperation(geometry).Destination; return(geometry); }
public void Sqrt3(Model model) { if (model == null) { return; } GeometryMesh mesh = model.Batch.MeshSource as GeometryMesh; if (mesh == null) { return; } Geometry newGeometry = new Sqrt3GeometryOperation(mesh.Geometry).Destination; newGeometry.ComputePolygonCentroids(); newGeometry.ComputePolygonNormals(); //newGeometry.ComputeCornerNormals(2.0f * (float)Math.PI); newGeometry.SmoothNormalize("corner_normals", "polygon_normals", (2.0f * (float)Math.PI)); newGeometry.BuildEdges(); MeshModified op = new MeshModified( model, new MeshModified.State( model.Name, model.Batch ), new MeshModified.State( "Sqrt3(" + model.Name + ")", new Batch( new GeometryMesh( newGeometry, NormalStyle.PointNormals ), model.Batch.Material ) ) ); operationStack.Do(op); }
private List <Vector3> PointsOnSphereSubdividedIcosahedron(int subdivisions) { var points = new List <Vector3>(); Geometry g = new RenderStack.Geometry.Shapes.Icosahedron(1.0); g.BuildEdges(); for (int i = 0; i < subdivisions; ++i) { g = new Sqrt3GeometryOperation(g).Destination; } var pointLocations = g.PointAttributes.FindOrCreate <Vector3>("point_locations"); foreach (var point in g.Points) { Vector3 pos = pointLocations[point]; if (pos.Y <= 0.0f) { continue; } points.Add(pos); } return(points); }