public static void AddZAxis(Model3DGroup group, double length = 4, double thickness = 0.1) { MeshGeometry3D mesh = new MeshGeometry3D(); Point3D origin = D3.Origin - D3.XVector(thickness / 2) - D3.YVector(thickness / 2) - D3.ZVector(thickness / 2); mesh.AddBox(origin, D3.XVector(thickness), D3.YVector(thickness), D3.ZVector(length)); group.Children.Add(mesh.MakeModel(Brushes.Blue)); }
// Make a cube at the origin. public static void AddOrigin(Model3DGroup group, double cubeThickness = 0.102) { MeshGeometry3D mesh = new MeshGeometry3D(); Point3D origin = D3.Origin - D3.XVector(cubeThickness / 2) - D3.YVector(cubeThickness / 2) - D3.ZVector(cubeThickness / 2); mesh.AddBox(origin, D3.XVector(cubeThickness), D3.YVector(cubeThickness), D3.ZVector(cubeThickness)); group.Children.Add(mesh.MakeModel(Brushes.Black)); }
// Define the model. private void DefineModel(Model3DGroup group) { const int numTheta = 30; const int numPhi = 60; // Make a smooth torus. MeshGeometry3D mesh1 = new MeshGeometry3D(); Point3D center = new Point3D(1, 0, 1); mesh1.AddTexturedTorus(center, 1, 0.5, numTheta, numPhi, true); mesh1.ApplyTransformation(new TranslateTransform3D(0, -1, -1)); group.Children.Add(mesh1.MakeModel("donut4.jpg")); //group.Children.Add(mesh1.MakeModel(Brushes.Pink)); // Make a smooth torus. MeshGeometry3D mesh2 = new MeshGeometry3D(); center = new Point3D(0, 0.6, 2.5); mesh2.AddTexturedTorus(center, 1, 0.5, numTheta, numPhi, true); mesh2.ApplyTransformation(D3.Rotate(D3.ZVector(), center, 40)); mesh2.ApplyTransformation(D3.Rotate(D3.YVector(), center, 90)); mesh2.ApplyTransformation(new TranslateTransform3D(0, -1, -1)); group.Children.Add(mesh2.MakeModel("donut2.jpg")); //group.Children.Add(mesh2.MakeModel(Brushes.LightGreen)); // Make a smooth torus. MeshGeometry3D mesh3 = new MeshGeometry3D(); center = new Point3D(-0.75, 1, -0.75); mesh3.AddTexturedTorus(center, 1.1, 0.55, numTheta, numPhi, true); mesh3.ApplyTransformation(D3.Rotate(D3.XVector(), center, 90)); mesh3.ApplyTransformation(D3.Rotate(D3.YVector(), center, 45)); mesh3.ApplyTransformation(new TranslateTransform3D(0, -1, 0)); mesh3.Positions.Add(new Point3D()); mesh3.TextureCoordinates.Add(new Point(1.01, 1.01)); group.Children.Add(mesh3.MakeModel("donut3.jpg")); //group.Children.Add(mesh3.MakeModel(Brushes.LightBlue)); // Show the axes. MeshExtensions.AddAxes(group); }