예제 #1
0
        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));
        }
예제 #2
0
        // 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)
        {
            // Show the axes.
            MeshExtensions.AddAxes(group);

            const double scale = 2;

            // Make a solid tetrahedron.
            MeshGeometry3D mesh1 = new MeshGeometry3D();

            mesh1.AddTetrahedron(true);
            mesh1.ApplyTransformation(new ScaleTransform3D(scale, scale, scale));
            mesh1.ApplyTransformation(D3.Rotate(D3.YVector(), D3.Origin, 180));
            mesh1.ApplyTransformation(D3.Rotate(D3.XVector(), D3.Origin, 180));
            group.Children.Add(mesh1.MakeModel(Brushes.LightBlue));

            // Make a translucent tetrahedron.
            MeshGeometry3D mesh2 = new MeshGeometry3D();

            mesh2.AddTetrahedron(true);
            mesh2.ApplyTransformation(new ScaleTransform3D(scale * 3, scale * 3, scale * 3));
            Brush         brush  = new SolidColorBrush(Color.FromArgb(128, 128, 255, 128));
            MaterialGroup group3 = D3.MakeMaterialGroup(
                new DiffuseMaterial(brush),
                new SpecularMaterial(Brushes.White, 100));

            group.Children.Add(mesh2.MakeModel(group3));

            // Mark both tetrahedrons' vertices.
            MeshGeometry3D mesh3 = new MeshGeometry3D();

            foreach (Point3D point in mesh1.Positions)
            {
                mesh3.AddSphere(point, 0.1, 20, 10, true);
            }
            foreach (Point3D point in mesh2.Positions)
            {
                mesh3.AddSphere(point, 0.1, 20, 10, true);
            }
            group.Children.Add(mesh3.MakeModel(Brushes.Red));
        }