Exemplo n.º 1
0
        // Generates sphere with radius 1 in position (0,0,0)
        static void Generate(MeshGeometry3D mesh, int divisions)
        {
            nextIndex = 0;

            AddBaseTriangle(mesh, new Point3D(0, 0, 1), new Point3D(1, 0, 0), new Point3D(0, 1, 0));
            AddBaseTriangle(mesh, new Point3D(1, 0, 0), new Point3D(0, 0, -1), new Point3D(0, 1, 0));
            AddBaseTriangle(mesh, new Point3D(0, 0, -1), new Point3D(-1, 0, 0), new Point3D(0, 1, 0));
            AddBaseTriangle(mesh, new Point3D(-1, 0, 0), new Point3D(0, 0, 1), new Point3D(0, 1, 0));
            AddBaseTriangle(mesh, new Point3D(1, 0, 0), new Point3D(0, 0, 1), new Point3D(0, -1, 0));
            AddBaseTriangle(mesh, new Point3D(0, 0, -1), new Point3D(1, 0, 0), new Point3D(0, -1, 0));
            AddBaseTriangle(mesh, new Point3D(-1, 0, 0), new Point3D(0, 0, -1), new Point3D(0, -1, 0));
            AddBaseTriangle(mesh, new Point3D(0, 0, 1), new Point3D(-1, 0, 0), new Point3D(0, -1, 0));

            for (int division = 1; division < divisions; division++) Divide(mesh);
            mesh.GenerateSphericalTextureCoordinates(new Vector3D(1, 0, 0));
        }