diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 58af57cf2..4c34020e6 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1069,9 +1069,29 @@ void ColladaParser::ReadEffectLibrary() void ColladaParser::ReadEffect( Collada::Effect& pEffect) { // for the moment we don't support any other type of effect. - // TODO: (thom) Rewrite this so that it ignores the whole effect instead of bailing out - TestOpening( "profile_COMMON"); + while( mReader->read()) + { + if( mReader->getNodeType() == irr::io::EXN_ELEMENT) + { + if( IsElement( "profile_COMMON")) + ReadEffectProfileCommon( pEffect); + else + SkipElement(); + } + else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) + { + if( strcmp( mReader->getNodeName(), "effect") != 0) + ThrowException( "Expected end of \"effect\" element."); + break; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// Reads an COMMON effect profile +void ColladaParser::ReadEffectProfileCommon( Collada::Effect& pEffect) +{ while( mReader->read()) { if( mReader->getNodeType() == irr::io::EXN_ELEMENT) @@ -1144,16 +1164,26 @@ void ColladaParser::ReadEffect( Collada::Effect& pEffect) pEffect.mFaceted = ReadBoolFromTextContent(); TestClosing( "faceted"); } -#if 0 - else { + else + { // ignore the rest SkipElement(); } -#endif } - else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { - if( strcmp( mReader->getNodeName(), "effect") == 0) + else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) + { + if( strcmp( mReader->getNodeName(), "technique") == 0) + { + // ignore silently - just syntactic sugar + } + else if( strcmp( mReader->getNodeName(), "profile_COMMON") == 0) + { break; + } else + { + // might also be the end of "phong", "blinn", "constant" or "lambert" + // ThrowException( "Expected end of \"profile_COMMON\" element."); + } } } } @@ -2669,9 +2699,9 @@ Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& pSemant return IT_Color; else if( pSemantic == "VERTEX") return IT_Vertex; - else if( pSemantic == "BINORMAL") + else if( pSemantic == "BINORMAL" || pSemantic == "TEXBINORMAL") return IT_Bitangent; - else if( pSemantic == "TANGENT") + else if( pSemantic == "TANGENT" || pSemantic == "TEXTANGENT") return IT_Tangent; DefaultLogger::get()->warn( boost::str( boost::format( "Unknown vertex input type \"%s\". Ignoring.") % pSemantic)); diff --git a/code/ColladaParser.h b/code/ColladaParser.h index 27292ed22..9aecb9110 100644 --- a/code/ColladaParser.h +++ b/code/ColladaParser.h @@ -128,6 +128,9 @@ protected: /** Reads an effect entry into the given effect*/ void ReadEffect( Collada::Effect& pEffect); + /** Reads an COMMON effect profile */ + void ReadEffectProfileCommon( Collada::Effect& pEffect); + /** Read sampler properties */ void ReadSamplerProperties( Collada::Sampler& pSampler);