2
0
Эх сурвалжийг харах

- 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

ulfjorensen 16 жил өмнө
parent
commit
f85d7b63ef

+ 39 - 9
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));

+ 3 - 0
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);