コード例 #1
0
        // Define the model.
        private void DefineModel(Model3DGroup group)
        {
            // Make a non-smooth sphere.
            MeshGeometry3D mesh1 = new MeshGeometry3D();

            mesh1.AddSphere(new Point3D(-1.75, 0, 1.75), 1.5, 20, 10);
            group.Children.Add(mesh1.MakeModel(Brushes.Pink));

            // Make a smooth sphere.
            MeshGeometry3D mesh2 = new MeshGeometry3D();

            mesh2.AddSphere(new Point3D(1.75, 0, 1.75), 1.5, 20, 10, true);
            group.Children.Add(mesh2.MakeModel(Brushes.Pink));

            // Make a non-smooth textured sphere.
            MeshGeometry3D mesh3 = new MeshGeometry3D();

            mesh3.AddTexturedSphere(new Point3D(-1.75, 0, -1.75), 1.5, 20, 10);
            group.Children.Add(mesh3.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh3.Positions.Add(new Point3D());
            mesh3.TextureCoordinates.Add(new Point(1.01, 1.01));

            // Make a smooth textured sphere.
            MeshGeometry3D mesh4 = new MeshGeometry3D();

            mesh4.AddTexturedSphere(new Point3D(1.75, 0, -1.75), 1.5, 20, 10, true);
            group.Children.Add(mesh4.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh4.Positions.Add(new Point3D());
            mesh4.TextureCoordinates.Add(new Point(1.01, 1.01));

            // Show the axes.
            MeshExtensions.AddAxes(group);
        }
コード例 #2
0
        // Define the model.
        private void DefineModel(Model3DGroup group)
        {
            MeshGeometry3D mesh1  = new MeshGeometry3D();
            Point3D        center = new Point3D(-2, 0, 2);

            mesh1.AddTexturedSphere(center, 1.5, 20, 10, true);
            group.Children.Add(mesh1.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh1.Positions.Add(new Point3D());
            mesh1.TextureCoordinates.Add(new Point(1.01, 1.01));

            MeshGeometry3D mesh2 = new MeshGeometry3D();

            center = new Point3D(-2, 0, -2);
            mesh2.AddTexturedSphere(center, 1.5, 20, 10, true);
            group.Children.Add(mesh2.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh2.Positions.Add(new Point3D());
            mesh2.TextureCoordinates.Add(new Point(1.01, 1.01));

            // Modify the normals.
            for (int i = 0; i < mesh2.Normals.Count; i++)
            {
                if (mesh2.Normals[i].X > 0)
                {
                    mesh2.Normals[i] *= 1000;
                }
                else
                {
                    mesh2.Normals[i] /= 1000;
                }
                // Console.WriteLine(mesh2.Normals[i].Length);
            }

            MeshGeometry3D mesh3 = new MeshGeometry3D();

            center = new Point3D(2, 0, 2);
            mesh3.AddTexturedSphere(center, 1.5, 20, 10, true);
            //mesh3.ApplyTransformation(new ScaleTransform3D(new Vector3D(1, 0.5, 1), center));
            mesh3.ApplyTransformation(D3.Rotate(D3.XVector(), center, 90));
            group.Children.Add(mesh3.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh3.Positions.Add(new Point3D());
            mesh3.TextureCoordinates.Add(new Point(1.01, 1.01));

            MeshGeometry3D mesh4 = new MeshGeometry3D();

            center = new Point3D(2, 0, -2);
            mesh4.AddTexturedSphere(center, 1.5, 20, 10, true);
            //mesh4.ApplyTransformation(new ScaleTransform3D(new Vector3D(1, 0.5, 1), center));
            mesh4.ApplyTransformation(D3.Rotate(D3.XVector(), center, 90));
            group.Children.Add(mesh4.MakeModel("world.jpg"));
            // Add a point to redefine the texture area to hide the "seam."
            mesh4.Positions.Add(new Point3D());
            mesh4.TextureCoordinates.Add(new Point(1.01, 1.01));

            // Modify the normals.
            for (int i = 0; i < mesh4.Normals.Count; i++)
            {
                if (mesh4.Normals[i].X > 0)
                {
                    mesh4.Normals[i] *= 1000;
                }
                else
                {
                    mesh4.Normals[i] /= 1000;
                }
                // Console.WriteLine(mesh4.Normals[i].Length);
            }

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