Example #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));
        }
Example #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)
        {
            // Make a box.
            MeshGeometry3D mesh1 = new MeshGeometry3D();

            mesh1.AddBox(new Point3D(1, -1, 0),
                         D3.XVector(2), D3.YVector(2), D3.ZVector(2),
                         D3.UnitTextures);
            group.Children.Add(mesh1.MakeModel("wood.jpg"));

            // Make a cube with every face different.
            MeshGeometry3D mesh2 = new MeshGeometry3D();

            Point[][] textureCoords = D3.SectionTextureCoords(2, 3);
            mesh2.AddBox(new Point3D(0, 1, -2),
                         D3.XVector(2), D3.YVector(2), D3.ZVector(2),
                         textureCoords[0], textureCoords[1], textureCoords[2],
                         textureCoords[3], textureCoords[4], textureCoords[5]);
            group.Children.Add(mesh2.MakeModel("all.jpg"));

            // Make a green parallelepiped.
            MeshGeometry3D mesh3 = new MeshGeometry3D();

            mesh3.AddBox(new Point3D(-4, -1, -3),
                         new Vector3D(2, 0.5, -0.5),
                         new Vector3D(0, 2, -0.5),
                         new Vector3D(-0.5, 0, 2));
            group.Children.Add(mesh3.MakeModel(Brushes.LightGreen));

            // Make a wrapped box.
            MeshGeometry3D mesh4 = new MeshGeometry3D();

            mesh4.AddBoxWrapped(new Point3D(-3, -1, 0),
                                D3.XVector(2), D3.YVector(2), D3.ZVector(2));
            group.Children.Add(mesh4.MakeModel("wrapper.png"));

            // Show the axes.
            MeshExtensions.AddAxes(group);
        }