Beispiel #1
0
        public static Mesh CreateMesh(DrawablePolygon poly, int height, TextMap textmap, bool reverseVerts = false)
        {
            //Create a new mesh
            var mesh = new Mesh();

            poly.SetHeight(height);

            //Vertices
            var vertex = poly.GetVertices();

            //UVs
            var uvs = poly.GetUVs();

            //Triangles
            var tris = poly.GetTriangles(reverseVerts);

            //Assign data to mesh
            mesh.vertices  = vertex;
            mesh.uv        = uvs;
            mesh.triangles = tris;

            //Recalculations
            mesh.RecalculateNormals();
            mesh.RecalculateBounds();
            //mesh.Optimize();

            //Name the mesh
            mesh.name = "DynamicMesh";

            //Return the mesh
            return(mesh);
        }
Beispiel #2
0
        public static GameObject CreateCeiling(DrawablePolygon poly, int height, Transform parent, TextMap textmap, Material mat, string name = "Floor")
        {
            var meshObject = new GameObject();

            meshObject.transform.parent = parent;
            meshObject.name             = name;

            var meshFilter   = meshObject.AddComponent <MeshFilter>();
            var meshRenderer = meshObject.AddComponent <MeshRenderer>();

            var mesh = CreateMesh(poly, height, textmap, true);

            meshRenderer.material = mat;

            meshFilter.mesh = mesh;

            return(meshObject);
        }