From 24b68b1e3d6423994dddd21a4dd38f2dc3d63ece Mon Sep 17 00:00:00 2001 From: Danke Xie Date: Thu, 19 Nov 2015 03:41:26 -0800 Subject: [PATCH] Support instance_image in Collada 1.5 files The tag in sampler2D elements is not expected by ColladaParser. This patch parses the instance_image element and gets the image ID. --- code/ColladaParser.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index cdc3cedeb..b239dbe88 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1509,7 +1509,7 @@ void ColladaParser::ReadEffectParam( Collada::EffectParam& pParam) // don't care for remaining stuff SkipElement( "surface"); } - else if( IsElement( "sampler2D")) + else if( IsElement( "sampler2D") && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) { // surface ID is given inside tags TestOpening( "source"); @@ -1520,6 +1520,19 @@ void ColladaParser::ReadEffectParam( Collada::EffectParam& pParam) // don't care for remaining stuff SkipElement( "sampler2D"); + } + else if( IsElement( "sampler2D")) + { + // surface ID is given inside tags + TestOpening( "instance_image"); + int attrURL = GetAttribute("url"); + const char* url = mReader->getAttributeValue( attrURL); + if( url[0] != '#') + ThrowException( "Unsupported URL format in instance_image"); + url++; + pParam.mType = Param_Sampler; + pParam.mReference = url; + SkipElement( "sampler2D"); } else { // ignore unknown element