示例#1
0
        // Define the model.
        private void DefineModel(Model3DGroup group)
        {
            // Show the axes.
            MeshExtensions.AddAxes(group);


            MeshGeometry3D mesh1 = new MeshGeometry3D();
            double         dx    = 3 / Math.Sqrt(3);

            mesh1.AddBox(new Point3D(-dx, -dx, -dx),
                         D3.XVector(2 * dx), D3.YVector(2 * dx), D3.ZVector(2 * dx));
            group.Children.Add(mesh1.MakeModel(new SolidColorBrush(Colors.LightBlue)));

            const int      numTheta = 60;
            const int      numPhi   = 30;
            MeshGeometry3D mesh2    = new MeshGeometry3D();
            Point3D        center   = new Point3D(0, 0, 0);

            mesh2.AddSphere(center, 3, numTheta, numPhi, true);

            MaterialGroup material = new MaterialGroup();
            Color         color    = Color.FromArgb(64, 128, 128, 128);

            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(color)));
            material.Children.Add(new SpecularMaterial(Brushes.White, 100));

            group.Children.Add(mesh2.MakeModel(material));
        }
        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));
        }