Пример #1
0
        void TransformUVs(Polygon polygon, UVUtility.UVTransformation transformationMethod, UVUtility.TransformData transformData)
        {
            // Update the source polygon, so rebuilding is correct
            for (int vertexIndex = 0; vertexIndex < polygon.Vertices.Length; vertexIndex++)
            {
                polygon.Vertices[vertexIndex].UV = transformationMethod(polygon.Vertices[vertexIndex].UV, transformData);
            }

            // Update the built polygons in case we need to use them for something else
            Polygon[] builtPolygons = csgModel.BuiltPolygonsByIndex(polygon.UniqueIndex);
            for (int polygonIndex = 0; polygonIndex < builtPolygons.Length; polygonIndex++)
            {
                Polygon builtPolygon = builtPolygons[polygonIndex];
                for (int vertexIndex = 0; vertexIndex < builtPolygon.Vertices.Length; vertexIndex++)
                {
                    builtPolygon.Vertices[vertexIndex].UV = transformationMethod(builtPolygon.Vertices[vertexIndex].UV, transformData);
                }
            }

            // Update the actual built mesh
            PolygonDirectory.PolygonMeshMapping mapping = csgModel.PolygonDirectory.FindMapping(polygon);
            if(mapping != null)
            {
                Vector2[] uv = mapping.Mesh.uv;
                for (int vertexIndex = 0; vertexIndex < mapping.VertexIndices.Count; vertexIndex++)
                {
                    uv[mapping.VertexIndices[vertexIndex]] = transformationMethod(uv[mapping.VertexIndices[vertexIndex]], transformData);
                }
                mapping.Mesh.uv = uv;
            }
        }
Пример #2
0
 void TransformUVs(UVUtility.UVTransformation transformationMethod, UVUtility.TransformData transformData)
 {
     for (int polygonIndex = 0; polygonIndex < selectedSourcePolygons.Count; polygonIndex++)
     {
         Polygon polygon = selectedSourcePolygons[polygonIndex];
         TransformUVs(polygon, transformationMethod, transformData);
     }
 }