From fba2f78e064485d2f3601c022b2c75f42270fc4c Mon Sep 17 00:00:00 2001 From: ulfjorensen Date: Fri, 19 Nov 2010 12:49:51 +0000 Subject: [PATCH] Added a workaround to guess which material applies to anonymous Collada geometry subgroups. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@841 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ColladaLoader.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 9448f923d..d27cc5b16 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -431,16 +431,21 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll continue; // find material assigned to this submesh + std::string meshMaterial; std::map::const_iterator meshMatIt = mid.mMaterials.find( submesh.mMaterial); - const Collada::SemanticMappingTable* table; + const Collada::SemanticMappingTable* table = NULL; if( meshMatIt != mid.mMaterials.end()) + { table = &meshMatIt->second; - else { - table = NULL; - DefaultLogger::get()->warn( boost::str( boost::format( "Collada: No material specified for subgroup \"%s\" in geometry \"%s\".") % submesh.mMaterial % mid.mMeshOrController)); + meshMaterial = table->mMatName; + } + else + { + DefaultLogger::get()->warn( boost::str( boost::format( "Collada: No material specified for subgroup \"%s\" in geometry \"%s\".") % submesh.mMaterial % mid.mMeshOrController)); + if( !mid.mMaterials.empty() ) + meshMaterial = mid.mMaterials.begin()->second.mMatName; } - const std::string& meshMaterial = table ? table->mMatName : ""; // OK ... here the *real* fun starts ... we have the vertex-input-to-effect-semantic-table // given. The only mapping stuff which we do actually support is the UV channel.