// Add the model to the Model3DGroup. private void DefineModel(Model3DGroup model_group) { // Make the normal and selected materials. NormalMaterial = new DiffuseMaterial(Brushes.LightGreen); SelectedMaterial = new DiffuseMaterial(Brushes.Red); // Create some cubes. for (int x = -5; x <= 3; x += 4) { for (int y = -5; y <= 3; y += 4) { for (int z = -5; z <= 3; z += 4) { // Make a cube with lower left corner (x, y, z). MeshGeometry3D mesh = new MeshGeometry3D(); mesh.AddBox(x, y, z, 2, 2, 2); GeometryModel3D model = new GeometryModel3D(mesh, NormalMaterial); model_group.Children.Add(model); // Remember that this model is selectable. SelectableModels.Add(model); } } } // test cage adding MeshGeometry3D cagemesh = new MeshGeometry3D(); cagemesh.AddCage(5, 5, 5, 2, 2, 2, 0.05); var cagemodel = new GeometryModel3D(cagemesh, NormalMaterial); model_group.Children.Add(cagemodel); SelectableModels.Add(cagemodel); // test cylinder adding MeshGeometry3D cylindermesh = new MeshGeometry3D(); cylindermesh.AddSmoothCylinder(new Point3D(7, 7, 7), new Vector3D(1, 1, 1), 0.5, 20); var cylindermodel = new GeometryModel3D(cylindermesh, NormalMaterial); model_group.Children.Add(cylindermodel); SelectableModels.Add(cylindermodel); // test sphere adding MeshGeometry3D spheremesh = new MeshGeometry3D(); spheremesh.AddSmoothSphere(new Point3D(8.5, 8.5, 8.5), Math.Sqrt(3 * 0.5 + 0.5 * 0.5), 20, 40); var spheremodel = new GeometryModel3D(spheremesh, NormalMaterial); model_group.Children.Add(spheremodel); SelectableModels.Add(spheremodel); // add cone MeshGeometry3D conemesh = new MeshGeometry3D(); conemesh.AddCone(new Point3D(9, 9, 9), new Vector3D(1, 1, 1), 0.5, -0.2, 20); var conemodel = new GeometryModel3D(conemesh, NormalMaterial); model_group.Children.Add(conemodel); SelectableModels.Add(conemodel); // X axis. MeshGeometry3D mesh_x = MeshExtensions.XAxisArrow(1, 7); model_group.Children.Add(mesh_x.SetMaterial(Brushes.Red, false)); var forwardmodel = "前方".To3DLabel(new Point3D(8.5, 0.5, 0), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), Brushes.Red, 0.5); model_group.Children.Add(forwardmodel); // Y axis. MeshGeometry3D mesh_y = MeshExtensions.YAxisArrow(1, 7); model_group.Children.Add(mesh_y.SetMaterial(Brushes.Green, false)); var upmodel = "上方".To3DLabel(new Point3D(0, 8.5, 0), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), Brushes.Green, 0.5); model_group.Children.Add(upmodel); // Z axis. MeshGeometry3D mesh_z = MeshExtensions.ZAxisArrow(1, 7); model_group.Children.Add(mesh_z.SetMaterial(Brushes.Blue, false)); var rightmodel = "右方".To3DLabel(new Point3D(0, 0, 9), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), Brushes.Blue, 0.5); model_group.Children.Add(rightmodel); }