瀏覽代碼

Merge pull request #3859 from spotaws/UVStreamNames

preserve UV Stream names in FBX files
Kim Kulling 4 年之前
父節點
當前提交
40f9d37a38
共有 3 個文件被更改,包括 11 次插入2 次删除
  1. 5 2
      code/AssetLib/Assxml/AssxmlFileWriter.cpp
  2. 2 0
      code/AssetLib/FBX/FBXConverter.cpp
  3. 4 0
      include/assimp/mesh.h

+ 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])
                 if (!mesh->mTextureCoords[a])
                     break;
                     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 (!shortened) {
                     if (mesh->mNumUVComponents[a] == 3) {
                     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_uv++ = aiVector3D(v.x, v.y, 0.0f);
         }
         }
 
 
+        out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
+
         out_mesh->mNumUVComponents[i] = 2;
         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];
     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.
     /** Specifies the number of components for a given UV channel.
     * Up to three channels are supported (UVW, for accessing volume
     * Up to three channels are supported (UVW, for accessing volume
     * or cube maps). If the value is 2 for a given channel n, the
     * or cube maps). If the value is 2 for a given channel n, the