Browse Source

ColladaParser: skip over extra <camera>,<light>,<material>,.. chunks contained within <extra> blocks. Thanks to Juha Vesanen for the fix.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@793 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 15 years ago
parent
commit
dbcc1902ed
1 changed files with 16 additions and 6 deletions
  1. 16 6
      code/ColladaParser.cpp

+ 16 - 6
code/ColladaParser.cpp

@@ -727,7 +727,10 @@ void ColladaParser::ReadImage( Collada::Image& pImage)
 	{
 	{
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT){
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT){
 			// Need to run different code paths here, depending on the Collada XSD version
 			// Need to run different code paths here, depending on the Collada XSD version
-			if(  IsElement( "init_from"))
+			if (IsElement("image")) {
+                SkipElement();
+            }
+			else if(  IsElement( "init_from"))
 			{
 			{
 				if (mFormat == FV_1_4_n) 
 				if (mFormat == FV_1_4_n) 
 				{
 				{
@@ -922,7 +925,10 @@ void ColladaParser::ReadMaterial( Collada::Material& pMaterial)
 	while( mReader->read())
 	while( mReader->read())
 	{
 	{
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
-			if( IsElement( "instance_effect"))
+			if (IsElement("material")) {
+                SkipElement();
+            }
+			else if( IsElement( "instance_effect"))
 			{
 			{
 				// referred effect by URL
 				// referred effect by URL
 				int attrUrl = GetAttribute( "url");
 				int attrUrl = GetAttribute( "url");
@@ -955,7 +961,10 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
 	while( mReader->read())
 	while( mReader->read())
 	{
 	{
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
-			if (IsElement("spot")) {
+            if (IsElement("light")) {
+                SkipElement();
+            }
+			else if (IsElement("spot")) {
 				pLight.mType = aiLightSource_SPOT;
 				pLight.mType = aiLightSource_SPOT;
 			}
 			}
 			else if (IsElement("ambient")) {
 			else if (IsElement("ambient")) {
@@ -967,7 +976,6 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
 			else if (IsElement("point")) {
 			else if (IsElement("point")) {
 				pLight.mType = aiLightSource_POINT;
 				pLight.mType = aiLightSource_POINT;
 			}
 			}
-
 			else if (IsElement("color")) {
 			else if (IsElement("color")) {
 				// text content contains 3 floats
 				// text content contains 3 floats
 				const char* content = GetTextContent();
 				const char* content = GetTextContent();
@@ -1033,8 +1041,10 @@ void ColladaParser::ReadCamera( Collada::Camera& pCamera)
 	while( mReader->read())
 	while( mReader->read())
 	{
 	{
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
 		if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
-
-			if (IsElement("orthographic")) {
+			if (IsElement("camera")) {
+                SkipElement();
+            }
+			else if (IsElement("orthographic")) {
 				pCamera.mOrtho = true;
 				pCamera.mOrtho = true;
 			}
 			}
 			else if (IsElement("xfov") || IsElement("xmag")) {
 			else if (IsElement("xfov") || IsElement("xmag")) {