Browse Source

Merge branch 'master' of https://github.com/assimp/assimp

Kim Kulling 12 years ago
parent
commit
85db7d234e
3 changed files with 15 additions and 1 deletions
  1. 2 0
      code/ColladaHelper.h
  2. 6 1
      code/ColladaLoader.cpp
  3. 7 0
      code/ColladaParser.cpp

+ 2 - 0
code/ColladaHelper.h

@@ -321,6 +321,8 @@ struct Mesh
 		for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
 			mNumUVComponents[i] = 2;
 	}
+    
+    std::string mName;
 
 	// just to check if there's some sophisticated addressing involved...
 	// which we don't support, and therefore should warn about.

+ 6 - 1
code/ColladaLoader.cpp

@@ -521,7 +521,10 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
 
 				// assign the material index
 				dstMesh->mMaterialIndex = matIdx;
-        dstMesh->mName = mid.mMeshOrController;			
+                if(dstMesh->mName.length == 0)
+                {
+                    dstMesh->mName = mid.mMeshOrController;
+                }
       }
 		}
 	}
@@ -541,6 +544,8 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
 	const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace)
 {
 	aiMesh* dstMesh = new aiMesh;
+    
+    dstMesh->mName = pSrcMesh->mName;
 
 	// count the vertices addressed by its faces
 	const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace,

+ 7 - 0
code/ColladaParser.cpp

@@ -1492,6 +1492,13 @@ void ColladaParser::ReadGeometryLibrary()
 				// create a mesh and store it in the library under its ID
 				Mesh* mesh = new Mesh;
 				mMeshLibrary[id] = mesh;
+                
+                // read the mesh name if it exists
+                const int nameIndex = TestAttribute("name");
+                if(nameIndex != -1)
+                {
+                    mesh->mName = mReader->getAttributeValue(nameIndex);
+                }
 
 				// read on from there
 				ReadGeometry( mesh);