- Bugfix: Collada parser did not skip unknown material properties correctly, leading to strange XML error messages

- Bugfix: Collada parser should read tangents / bitangents correctly now

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@503 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
ulfjorensen 2009-11-22 12:46:49 +00:00
parent 35cfb90e6f
commit f85d7b63ef
2 changed files with 42 additions and 9 deletions

View File

@ -1069,9 +1069,29 @@ void ColladaParser::ReadEffectLibrary()
void ColladaParser::ReadEffect( Collada::Effect& pEffect) void ColladaParser::ReadEffect( Collada::Effect& pEffect)
{ {
// for the moment we don't support any other type of effect. // 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 while( mReader->read())
TestOpening( "profile_COMMON"); {
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()) while( mReader->read())
{ {
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
@ -1144,16 +1164,26 @@ void ColladaParser::ReadEffect( Collada::Effect& pEffect)
pEffect.mFaceted = ReadBoolFromTextContent(); pEffect.mFaceted = ReadBoolFromTextContent();
TestClosing( "faceted"); TestClosing( "faceted");
} }
#if 0 else
else { {
// ignore the rest // ignore the rest
SkipElement(); SkipElement();
} }
#endif
} }
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
if( strcmp( mReader->getNodeName(), "effect") == 0) {
if( strcmp( mReader->getNodeName(), "technique") == 0)
{
// ignore silently - just syntactic sugar
}
else if( strcmp( mReader->getNodeName(), "profile_COMMON") == 0)
{
break; 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; return IT_Color;
else if( pSemantic == "VERTEX") else if( pSemantic == "VERTEX")
return IT_Vertex; return IT_Vertex;
else if( pSemantic == "BINORMAL") else if( pSemantic == "BINORMAL" || pSemantic == "TEXBINORMAL")
return IT_Bitangent; return IT_Bitangent;
else if( pSemantic == "TANGENT") else if( pSemantic == "TANGENT" || pSemantic == "TEXTANGENT")
return IT_Tangent; return IT_Tangent;
DefaultLogger::get()->warn( boost::str( boost::format( "Unknown vertex input type \"%s\". Ignoring.") % pSemantic)); DefaultLogger::get()->warn( boost::str( boost::format( "Unknown vertex input type \"%s\". Ignoring.") % pSemantic));

View File

@ -128,6 +128,9 @@ protected:
/** Reads an effect entry into the given effect*/ /** Reads an effect entry into the given effect*/
void ReadEffect( Collada::Effect& pEffect); void ReadEffect( Collada::Effect& pEffect);
/** Reads an COMMON effect profile */
void ReadEffectProfileCommon( Collada::Effect& pEffect);
/** Read sampler properties */ /** Read sampler properties */
void ReadSamplerProperties( Collada::Sampler& pSampler); void ReadSamplerProperties( Collada::Sampler& pSampler);