static Predator() { var egg = new MeshBuilder(); egg.AddPyramid(new Point3D(0, 0, 0), 0.2, 0.4); eggGeometry = egg.ToMesh(); var child = new MeshBuilder(); child.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1); child.AddSphere(new Point3D(0.2, 0.2, 1), 0.2, 12, 24); child.AddSphere(new Point3D(0.2, -0.2, 1), 0.2, 12, 24); childGeometry = child.ToMesh(); var creature = new MeshBuilder(); creature.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1); creature.AddCone(new Point3D(0.2, 0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12); creature.AddCone(new Point3D(0.2, -0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12); creatureGeometry = creature.ToMesh(); var coffin = new MeshBuilder(); coffin.AddCylinder(new Point3D(0, 0, 0), new Point3D(0, 0, 0.25), 1, 12); deadGeometry = coffin.ToMesh(); maleMaterial = MaterialHelper.CreateMaterial(Brushes.Navy); femaleMaterial = MaterialHelper.CreateMaterial(Brushes.Violet); eggMaterial = MaterialHelper.CreateMaterial(Brushes.AntiqueWhite); deadMaterial = MaterialHelper.CreateMaterial(Brushes.Black); }
private void CreateModel() { var points = new Point3DCollection(); var edges = new Int32Collection(); var triangles = new Int32Collection(); switch (CurrentModelType) { case ModelTypes.StellatedOctahedron: case ModelTypes.Tetrahedron: points.Add(+1, +1, +1); points.Add(-1, -1, 1); points.Add(-1, +1, -1); points.Add(+1, -1, -1); edges.Add(0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3); triangles.Add(0, 1, 2, 0, 3, 1, 1, 3, 2, 2, 3, 0); break; } switch (CurrentModelType) { case ModelTypes.StellatedOctahedron: // http://en.wikipedia.org/wiki/Compound_of_two_tetrahedra points.Add(-1, +1, +1); points.Add(1, -1, 1); points.Add(1, +1, -1); points.Add(-1, -1, -1); edges.Add(4, 5, 5, 6, 6, 4, 4, 7, 5, 7, 6, 7); triangles.Add(4, 5, 6, 4, 7, 5, 5, 7, 6, 6, 7, 4); break; } var m = new Model3DGroup(); // Add the nodes var gm = new MeshBuilder(); foreach (var p in points) { gm.AddSphere(p, 0.1); } m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold)); // Add the triangles var tm = new MeshBuilder(); for (int i = 0; i < triangles.Count; i += 3) { tm.AddTriangle(points[triangles[i]], points[triangles[i + 1]], points[triangles[i + 2]]); } m.Children.Add(new GeometryModel3D(tm.ToMesh(), Materials.Red) { BackMaterial = Materials.Blue }); // Add the edges var em = new MeshBuilder(); for (int i = 0; i < edges.Count; i += 2) { em.AddCylinder(points[edges[i]], points[edges[i + 1]], 0.08, 10); } m.Children.Add(new GeometryModel3D(em.ToMesh(), Materials.Gray)); Model = m; }