2
0
Эх сурвалжийг харах

Merge pull request #3859 from spotaws/UVStreamNames

preserve UV Stream names in FBX files
Kim Kulling 4 жил өмнө
parent
commit
40f9d37a38

+ 5 - 2
code/AssetLib/Assxml/AssxmlFileWriter.cpp

@@ -598,8 +598,11 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene,
                 if (!mesh->mTextureCoords[a])
                     break;
 
-                ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" num_components=\"%u\"> \n", mesh->mNumVertices,
-                        a, mesh->mNumUVComponents[a]);
+                ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" name=\"%s\" num_components=\"%u\"> \n",
+                         mesh->mNumVertices,
+                         a,
+                         mesh->mTextureCoordsNames[a].C_Str(),
+                         mesh->mNumUVComponents[a]);
 
                 if (!shortened) {
                     if (mesh->mNumUVComponents[a] == 3) {

+ 2 - 0
code/AssetLib/FBX/FBXConverter.cpp

@@ -1126,6 +1126,8 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
             *out_uv++ = aiVector3D(v.x, v.y, 0.0f);
         }
 
+        out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
+
         out_mesh->mNumUVComponents[i] = 2;
     }
 

+ 4 - 0
include/assimp/mesh.h

@@ -674,6 +674,10 @@ struct aiMesh {
     */
     C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
 
+    /** Vertex stream names.
+     */
+    C_STRUCT aiString mTextureCoordsNames[AI_MAX_NUMBER_OF_TEXTURECOORDS];
+
     /** Specifies the number of components for a given UV channel.
     * Up to three channels are supported (UVW, for accessing volume
     * or cube maps). If the value is 2 for a given channel n, the