private static Mesh BuildMeshFromCoordsAndFaces(ulong meshKey, List <Coord> coords, List <Face> faces)
        {
            Mesh mesh = new Mesh(meshKey, coords.Count, faces.Count);

            for (int i = 0; i < coords.Count; i++)
            {
                Coord c = coords[i];
                mesh.AddMeshVertex(c.X, c.Y, c.Z);
            }

            for (int i = 0; i < faces.Count; i++)
            {
                Face f = faces[i];
                mesh.Add(f.v1, f.v2, f.v3);
            }

            return(mesh);
        }
        /// <summary>
        /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
        /// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail
        /// for some reason
        /// </summary>
        /// <param name="minX"></param>
        /// <param name="maxX"></param>
        /// <param name="minY"></param>
        /// <param name="maxY"></param>
        /// <param name="minZ"></param>
        /// <param name="maxZ"></param>
        /// <returns></returns>
        private Mesh CreateSimpleBoxMesh(float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
        {
            Mesh box = new Mesh(0, 8, 12);

            // bottom
            box.AddMeshVertex(minX, maxY, minZ);
            box.AddMeshVertex(maxX, maxY, minZ);
            box.AddMeshVertex(maxX, minY, minZ);
            box.AddMeshVertex(minX, minY, minZ);

            box.Add(0, 1, 2);
            box.Add(0, 2, 3);

            // top

            box.AddMeshVertex(maxX, maxY, maxZ);
            box.AddMeshVertex(minX, maxY, maxZ);
            box.AddMeshVertex(minX, minY, maxZ);
            box.AddMeshVertex(maxX, minY, maxZ);

            box.Add(4, 5, 6);
            box.Add(4, 6, 7);

            // sides
            box.Add(5, 0, 3);
            box.Add(5, 3, 6);

            box.Add(1, 0, 5);
            box.Add(1, 5, 4);

            box.Add(7, 1, 4);
            box.Add(7, 2, 1);

            box.Add(3, 2, 7);
            box.Add(3, 7, 6);

            return(box);
        }
Exemple #3
0
        /// <summary>
        /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
        /// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail
        /// for some reason
        /// </summary>
        /// <param name="minX"></param>
        /// <param name="maxX"></param>
        /// <param name="minY"></param>
        /// <param name="maxY"></param>
        /// <param name="minZ"></param>
        /// <param name="maxZ"></param>
        /// <returns></returns>
        private Mesh CreateSimpleBoxMesh(float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
        {
            Mesh box = new Mesh(0, 8, 12);

            // bottom
            box.AddMeshVertex(minX, maxY, minZ);
            box.AddMeshVertex(maxX, maxY, minZ);
            box.AddMeshVertex(maxX, minY, minZ);
            box.AddMeshVertex(minX, minY, minZ);

            box.Add(0, 1, 2);
            box.Add(0, 2, 3);

            // top

            box.AddMeshVertex(maxX, maxY, maxZ);
            box.AddMeshVertex(minX, maxY, maxZ);
            box.AddMeshVertex(minX, minY, maxZ);
            box.AddMeshVertex(maxX, minY, maxZ);

            box.Add(4, 5, 6);
            box.Add(4, 6, 7);

            // sides
            box.Add(5, 0, 3);
            box.Add(5, 3, 6);

            box.Add(1, 0, 5);
            box.Add(1, 5, 4);

            box.Add(7, 1, 4);
            box.Add(7, 2, 1);

            box.Add(3, 2, 7);
            box.Add(3, 7, 6);

            return box;
        }
Exemple #4
0
        private static Mesh BuildMeshFromCoordsAndFaces(ulong meshKey, List<Coord> coords, List<Face> faces)
        {
            Mesh mesh = new Mesh(meshKey, coords.Count, faces.Count);

            for (int i = 0; i < coords.Count; i++)
            {
                Coord c = coords[i];
                mesh.AddMeshVertex(c.X, c.Y, c.Z);
            }

            for (int i = 0; i < faces.Count; i++)
            {
                Face f = faces[i];
                mesh.Add(f.v1, f.v2, f.v3);
            }

            return mesh;
        }