// Define the model. private void DefineModel(Model3DGroup group) { // Make a dodecahedron. MeshGeometry3D mesh1 = new MeshGeometry3D(); mesh1.AddDodecahedron(); group.Children.Add(mesh1.MakeModel(Brushes.LightGreen)); // Make a wireframe for the dodecahedron. MeshGeometry3D mesh2 = new MeshGeometry3D(); mesh2 = mesh1.ToWireframe(0.05); group.Children.Add(mesh2.MakeModel(Brushes.Green)); }
// Define the model. private void DefineModel(Model3DGroup group) { //// Verify the dodecahedron calculations. //MeshExtensions.VerifyDodecahedron(); // Show the axes. MeshExtensions.AddAxes(group); // Make a dodecahedron. MeshGeometry3D mesh2 = new MeshGeometry3D(); mesh2.AddDodecahedron(); group.Children.Add(mesh2.MakeModel(Brushes.LightGreen)); }
// Define the model. private void DefineModel(Model3DGroup group) { // Make a dodecahedron. MeshGeometry3D mesh1 = new MeshGeometry3D(); mesh1.AddDodecahedron(); group.Children.Add(mesh1.MakeModel(Brushes.LightGreen)); // Make a wireframe for the dodecahedron. MeshGeometry3D mesh2 = new MeshGeometry3D(); HashSet <Edge> edges = new HashSet <Edge>(); double thickness = 0.05; mesh2.AddDodecahedron(edges, thickness); group.Children.Add(mesh2.MakeModel(Brushes.Green)); }
// Define the model. private void DefineModel(Model3DGroup group) { //// Verify the icosahedron calculations. //MeshExtensions.VerifyIcosahedron(); // Show the axes. MeshExtensions.AddAxes(group); const double scale = 0.8; // Make a solid dodecahedron. MeshGeometry3D mesh1 = new MeshGeometry3D(); mesh1.AddDodecahedron(); mesh1.ApplyTransformation(new ScaleTransform3D(scale, scale, scale)); group.Children.Add(mesh1.MakeModel(Brushes.Red)); // Make a translucent icosahedron. MeshGeometry3D mesh2 = new MeshGeometry3D(); mesh2.AddIcosahedron(); double icoScale = scale * G3.DodecahedronCircumradius() / G3.IcosahedronInradius(); mesh2.ApplyTransformation(new ScaleTransform3D(icoScale, icoScale, icoScale)); mesh2.ApplyTransformation(D3.Rotate(D3.YVector(), D3.Origin, 180)); Brush brush = new SolidColorBrush(Color.FromArgb(128, 128, 255, 128)); MaterialGroup group2 = D3.MakeMaterialGroup( new DiffuseMaterial(brush), new SpecularMaterial(Brushes.White, 100)); group.Children.Add(mesh2.MakeModel(group2)); // Make a translucent dodecahedron. MeshGeometry3D mesh3 = new MeshGeometry3D(); mesh3.AddDodecahedron(); double dodScale = icoScale * G3.IcosahedronCircumradius() / G3.DodecahedronInradius(); mesh3.ApplyTransformation(new ScaleTransform3D(dodScale, dodScale, dodScale)); MaterialGroup group3 = D3.MakeMaterialGroup( new DiffuseMaterial(brush), new SpecularMaterial(Brushes.White, 100)); group.Children.Add(mesh3.MakeModel(group3)); }
// Define the model. private void DefineModel(Model3DGroup group) { //// Verify the dodecahedron calculations. //MeshExtensions.VerifyDodecahedron(); // Show the axes. MeshExtensions.AddAxes(group); const double scale = 1.25; // Make a solid insphere. MeshGeometry3D mesh1 = new MeshGeometry3D(); mesh1.AddSphere(D3.Origin, G3.DodecahedronInradius(), 60, 30, true); mesh1.ApplyTransformation(new ScaleTransform3D(scale, scale, scale)); group.Children.Add(mesh1.MakeModel(Brushes.Red)); // Make a translucent dodecahedron. MeshGeometry3D mesh2 = new MeshGeometry3D(); mesh2.AddDodecahedron(); mesh2.ApplyTransformation(new ScaleTransform3D(scale, scale, scale)); Brush brush = new SolidColorBrush(Color.FromArgb(128, 128, 255, 128)); MaterialGroup group2 = D3.MakeMaterialGroup( new DiffuseMaterial(brush), new SpecularMaterial(Brushes.White, 100)); group.Children.Add(mesh2.MakeModel(group2)); // Make a translucent circumsphere. MeshGeometry3D mesh3 = new MeshGeometry3D(); mesh3.AddSphere(D3.Origin, G3.DodecahedronCircumradius(), 60, 30, true); mesh3.ApplyTransformation(new ScaleTransform3D(scale, scale, scale)); MaterialGroup group3 = D3.MakeMaterialGroup( new DiffuseMaterial(brush), new SpecularMaterial(Brushes.White, 100)); group.Children.Add(mesh3.MakeModel(group3)); }
// Define the model. private void DefineModel(Model3DGroup group) { // Axes. MeshExtensions.AddAxes(group); MeshGeometry3D mesh1 = new MeshGeometry3D(); MeshGeometry3D mesh2 = new MeshGeometry3D(); MeshGeometry3D mesh3 = new MeshGeometry3D(); MeshGeometry3D mesh4 = new MeshGeometry3D(); double x0 = -5; Point3D center = new Point3D(x0, 0, 4.5); // Box. mesh1.AddBox(center + new Vector3D(-0.5, 0, -1), D3.XVector(1), D3.YVector(3), D3.ZVector(2)); center.X += 2; // Box wrapped. mesh2.AddBoxWrapped(center + new Vector3D(-0.5, 0, -1), D3.XVector(1), D3.YVector(3), D3.ZVector(2)); center.X += 2; // Cone. Point3D[] circle = G3.MakePolygonPoints(20, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddCone(center, circle, D3.YVector(4)); center.X += 2; // Cone frustum. circle = G3.MakePolygonPoints(20, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddConeFrustum(center, circle, D3.YVector(4), 3); center.X += 2; // Cone frustum w/cutting plane. circle = G3.MakePolygonPoints(20, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddConeFrustum(center, circle, D3.YVector(4), center + new Vector3D(0, 2, 0), new Vector3D(0, 1, 1)); center.X += 2; // Start a new row. center.X = x0; center.Z -= 3; // Cube. MeshGeometry3D cubeMesh = new MeshGeometry3D(); cubeMesh.AddCube(); cubeMesh.ApplyTransformation(new ScaleTransform3D(1, 1.5, 0.5)); cubeMesh.ApplyTransformation( new TranslateTransform3D(center.X, center.Y + 1.5, 0)); mesh3.Merge(cubeMesh); center.X += 2; // Cylinder. Point3D[] polygon = G3.MakePolygonPoints(7, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddCylinder(polygon, new Vector3D(0, 2, -1)); center.X += 2; // Cylinder. circle = G3.MakePolygonPoints(20, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddCylinder(circle, new Vector3D(0, 2, -1), true); center.X += 2; // Cylinder w/cutting planes. polygon = G3.MakePolygonPoints(7, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddCylinder(polygon, new Vector3D(0, 1, 0), center + new Vector3D(0, 2, 0), new Vector3D(0, 2, 1), center + new Vector3D(0, -2, 0), new Vector3D(0, 2, -1)); center.X += 2; // Cylinder w/cutting planes. polygon = G3.MakePolygonPoints(7, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddCylinder(polygon, new Vector3D(0, 1, 0), center + new Vector3D(0, 2, 0), new Vector3D(0, 2, 1), center + new Vector3D(0, -2, 0), new Vector3D(0, 2, -1), true); center.X += 2; // Start a new row. center.X = x0; center.Z -= 3; // Dodecahedron. MeshGeometry3D dodMesh = new MeshGeometry3D(); dodMesh.AddDodecahedron(); double dodScale = 1 / G3.DodecahedronCircumradius(); dodMesh.ApplyTransformation(new ScaleTransform3D(dodScale, dodScale, dodScale)); dodMesh.ApplyTransformation( new TranslateTransform3D(center.X, center.Y + 0.5, center.Z)); mesh3.Merge(dodMesh); center.X += 2; // Frustum. polygon = G3.MakePolygonPoints(5, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddFrustum(center, polygon, D3.YVector(4), 2); center.X += 2; // Icosahedron. MeshGeometry3D icoMesh = new MeshGeometry3D(); icoMesh.AddIcosahedron(); double icoScale = 1 / G3.IcosahedronCircumradius(); icoMesh.ApplyTransformation(new ScaleTransform3D(icoScale, icoScale, icoScale)); icoMesh.ApplyTransformation( new TranslateTransform3D(center.X, center.Y + 0.5, center.Z)); mesh3.Merge(icoMesh); center.X += 2; // Octahedron. MeshGeometry3D octMesh = new MeshGeometry3D(); octMesh.AddOctahedron(); double octScale = 1 / G3.OctahedronCircumradius(); octMesh.ApplyTransformation(new ScaleTransform3D(octScale, octScale, octScale)); octMesh.ApplyTransformation( new TranslateTransform3D(center.X, center.Y + 0.5, center.Z)); mesh3.Merge(octMesh); center.X += 2; // Pyramid. polygon = G3.MakePolygonPoints(6, center, D3.XVector(1), D3.ZVector(-1)); mesh1.AddPyramid(center, polygon, D3.YVector(3)); center.X += 2; // Start a new row. center.X = x0; center.Z -= 3; // Sphere. mesh1.AddSphere(center + new Vector3D(0, 1, 0), 1, 20, 10); center.X += 2; // Tetrahedron. MeshGeometry3D tetMesh = new MeshGeometry3D(); tetMesh.AddTetrahedron(); double tetScale = 1 / G3.TetrahedronCircumradius(); tetMesh.ApplyTransformation(new ScaleTransform3D(tetScale, tetScale, tetScale)); tetMesh.ApplyTransformation( new TranslateTransform3D(center.X, center.Y + 0.5, center.Z)); mesh3.Merge(tetMesh); center.X += 2; // Textured sphere. mesh4.Positions.Add(new Point3D()); mesh4.TextureCoordinates.Add(new Point(1.01, 1.01)); mesh4.AddTexturedSphere(center + new Vector3D(0, 1, 0), 1, 20, 10); center.X += 2; // Textured torus. mesh4.AddTexturedTorus(center + new Vector3D(0, 1, 0), 0.6, 0.4, 30, 15); center.X += 2; // Torus. mesh1.AddTorus(center + new Vector3D(0, 1, 0), 0.6, 0.4, 30, 15); center.X += 2; // Start a new row. center.X = x0; center.Z -= 3; group.Children.Add(mesh1.MakeModel(Brushes.LightGreen)); group.Children.Add(mesh2.MakeModel("wrapper.png")); group.Children.Add(mesh3.MakeModel(Brushes.LightBlue)); group.Children.Add(mesh4.MakeModel("world.jpg")); }