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 diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 27d43e753..5ee6a5030 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -2546,8 +2546,9 @@ private: // need to convert from TRS order to SRT? if(reverse_order) { - aiVector3D def_scale, def_translate; - aiQuaternion def_rot; + aiVector3D def_scale = PropertyGet(props,"Lcl Scaling",aiVector3D(1.f,1.f,1.f)); + aiVector3D def_translate = PropertyGet(props,"Lcl Translation",aiVector3D(0.f,0.f,0.f)); + aiVector3D def_rot = PropertyGet(props,"Lcl Rotation",aiVector3D(0.f,0.f,0.f)); KeyFrameListList scaling; KeyFrameListList translation; @@ -2556,24 +2557,14 @@ private: if(chain[TransformationComp_Scaling] != iter_end) { scaling = GetKeyframeList((*chain[TransformationComp_Scaling]).second, start, stop); } - else { - def_scale = PropertyGet(props,"Lcl Scaling",aiVector3D(1.f,1.f,1.f)); - } if(chain[TransformationComp_Translation] != iter_end) { translation = GetKeyframeList((*chain[TransformationComp_Translation]).second, start, stop); } - else { - def_translate = PropertyGet(props,"Lcl Translation",aiVector3D(0.f,0.f,0.f)); - } if(chain[TransformationComp_Rotation] != iter_end) { rotation = GetKeyframeList((*chain[TransformationComp_Rotation]).second, start, stop); } - else { - def_rot = EulerToQuaternion(PropertyGet(props,"Lcl Rotation",aiVector3D(0.f,0.f,0.f)), - target.RotationOrder()); - } KeyFrameListList joined; joined.insert(joined.end(), scaling.begin(), scaling.end()); @@ -2790,7 +2781,7 @@ private: // ------------------------------------------------------------------------------------------------ void InterpolateKeys(aiVectorKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs, - const bool geom, + const aiVector3D& def_value, double& max_time, double& min_time) @@ -2804,10 +2795,7 @@ private: next_pos.resize(inputs.size(),0); BOOST_FOREACH(KeyTimeList::value_type time, keys) { - float result[3] = {0.0f, 0.0f, 0.0f}; - if(geom) { - result[0] = result[1] = result[2] = 1.0f; - } + float result[3] = {def_value.x, def_value.y, def_value.z}; for (size_t i = 0; i < count; ++i) { const KeyFrameList& kfl = inputs[i]; @@ -2832,12 +2820,7 @@ private: const double factor = timeB == timeA ? 0. : static_cast((time - timeA) / (timeB - timeA)); const float interpValue = static_cast(valueA + (valueB - valueA) * factor); - if(geom) { - result[kfl.get<2>()] *= interpValue; - } - else { - result[kfl.get<2>()] += interpValue; - } + result[kfl.get<2>()] = interpValue; } // magic value to convert fbx times to seconds @@ -2857,7 +2840,7 @@ private: // ------------------------------------------------------------------------------------------------ void InterpolateKeys(aiQuatKey* valOut,const KeyTimeList& keys, const KeyFrameListList& inputs, - const bool geom, + const aiVector3D& def_value, double& maxTime, double& minTime, Model::RotOrder order) @@ -2866,7 +2849,7 @@ private: ai_assert(valOut); boost::scoped_array temp(new aiVectorKey[keys.size()]); - InterpolateKeys(temp.get(),keys,inputs,geom,maxTime, minTime); + InterpolateKeys(temp.get(), keys, inputs, def_value, maxTime, minTime); aiMatrix4x4 m; @@ -2908,20 +2891,20 @@ private: Model::RotOrder order, const aiVector3D& def_scale, const aiVector3D& def_translate, - const aiQuaternion& def_rotation) + const aiVector3D& def_rotation) { if (rotation.size()) { - InterpolateKeys(out_quat, times, rotation, false, maxTime, minTime, order); + InterpolateKeys(out_quat, times, rotation, def_rotation, maxTime, minTime, order); } else { for (size_t i = 0; i < times.size(); ++i) { out_quat[i].mTime = CONVERT_FBX_TIME(times[i]) * anim_fps; - out_quat[i].mValue = def_rotation; + out_quat[i].mValue = EulerToQuaternion(def_rotation, order); } } if (scaling.size()) { - InterpolateKeys(out_scale, times, scaling, true, maxTime, minTime); + InterpolateKeys(out_scale, times, scaling, def_scale, maxTime, minTime); } else { for (size_t i = 0; i < times.size(); ++i) { @@ -2931,7 +2914,7 @@ private: } if (translation.size()) { - InterpolateKeys(out_translation, times, translation, false, maxTime, minTime); + InterpolateKeys(out_translation, times, translation, def_translate, maxTime, minTime); } else { for (size_t i = 0; i < times.size(); ++i) { @@ -2985,7 +2968,7 @@ private: na->mNumScalingKeys = static_cast(keys.size()); na->mScalingKeys = new aiVectorKey[keys.size()]; if (keys.size() > 0) - InterpolateKeys(na->mScalingKeys, keys, inputs, true, maxTime, minTime); + InterpolateKeys(na->mScalingKeys, keys, inputs, aiVector3D(1.0f, 1.0f, 1.0f), maxTime, minTime); } @@ -3005,7 +2988,7 @@ private: na->mNumPositionKeys = static_cast(keys.size()); na->mPositionKeys = new aiVectorKey[keys.size()]; if (keys.size() > 0) - InterpolateKeys(na->mPositionKeys, keys, inputs, false, maxTime, minTime); + InterpolateKeys(na->mPositionKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime); } @@ -3026,7 +3009,7 @@ private: na->mNumRotationKeys = static_cast(keys.size()); na->mRotationKeys = new aiQuatKey[keys.size()]; if (keys.size() > 0) - InterpolateKeys(na->mRotationKeys, keys, inputs, false, maxTime, minTime, order); + InterpolateKeys(na->mRotationKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime, order); }