From a6ddce7758119c51e9c26232af002cbb1bec14c4 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:11:23 -0400 Subject: [PATCH 1/4] Added name member to Collada::Mesh. --- code/ColladaHelper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index f9bd4fb5a..956665198 100644 --- a/code/ColladaHelper.h +++ b/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. From a540c6255c55fd2192367f9408d597d1b0a86dc2 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:12:58 -0400 Subject: [PATCH 2/4] Added parsing of Collada mesh names. --- code/ColladaParser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 442896a39..767347695 100644 --- a/code/ColladaParser.cpp +++ b/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); From 57e34cc90a84b3179e67d4e41839771b5fb086c3 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:14:19 -0400 Subject: [PATCH 3/4] Added loading of mesh name from Collada mesh to aiMesh struct. --- code/ColladaLoader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index a97ea2c6a..c40d3b8f2 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -541,6 +541,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, From d23430c4bdc740e6682e7efc793b80f10a3040e6 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:21:00 -0400 Subject: [PATCH 4/4] Collada mesh name is copied from id only if there was no name attribute in the node. --- code/ColladaLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index c40d3b8f2..7e4704b8f 100644 --- a/code/ColladaLoader.cpp +++ b/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; + } } } }