void FCDocument::SetCurrentTime(float time) { for (FCDAnimatedSet::iterator itA = animatedValues.begin(); itA != animatedValues.end(); ++itA) { FCDAnimated* animated = (*itA).first; animated->Evaluate(time); } // We must evaluate all our child documents as well! for (size_t i = 0; i < externalReferenceManager->GetPlaceHolderCount(); i++) { FCDPlaceHolder* placeHolder = externalReferenceManager->GetPlaceHolder(i); if (placeHolder->IsTargetLoaded()) placeHolder->GetTarget()->SetCurrentTime(time); } }
FMMatrix44 ColladaSceneNode::CalculateTransformForTime(FCDSceneNode * originalNode, float32 time) { FMMatrix44 colladaLocalMatrix; colladaLocalMatrix = FMMatrix44::Identity;// = FMMatrix44::Identity(); for (int t = 0; t < (int)originalNode->GetTransformCount(); ++t) { FCDTransform * transform = originalNode->GetTransform(t); if (transform->IsAnimated()) // process all animations to make CalculateWorldTransform work { FCDAnimated * animated = transform->GetAnimated(); animated->Evaluate(time); } if (transform->GetType() == FCDTransform::TRANSLATION) { FCDTTranslation * translation = dynamic_cast<FCDTTranslation*>(transform); FMVector3 point = FMVector3(0.0f, 0.0f, 0.0f); point = translation->GetTranslation(); if (transform->IsAnimated()) { FCDAnimationCurve* curve; // look for x animation curve = transform->GetAnimated()->FindCurve(".X"); if (curve != 0) point.x = curve->Evaluate(time); // look for y animation curve = transform->GetAnimated()->FindCurve(".Y"); if (curve != 0) point.y = curve->Evaluate(time); // look for z animation curve = transform->GetAnimated()->FindCurve(".Z"); if (curve != 0) point.z = curve->Evaluate(time); } colladaLocalMatrix = colladaLocalMatrix * FMMatrix44::TranslationMatrix(point); }else if (transform->GetType() == FCDTransform::ROTATION) { FCDTRotation * rotation = dynamic_cast<FCDTRotation*>(transform); FMVector3 axis = FMVector3(0.0f, 0.0f, 0.0f); float angle = 0; axis = rotation->GetAxis(); angle = rotation->GetAngle(); if (rotation->IsAnimated()) { FCDAnimationCurve* curve; // look for x animation curve = rotation->GetAnimated()->FindCurve(".X"); if (curve != 0) axis.x = curve->Evaluate(time); // look for y animation curve = rotation->GetAnimated()->FindCurve(".Y"); if (curve != 0) axis.y = curve->Evaluate(time); // look for z animation curve = rotation->GetAnimated()->FindCurve(".Z"); if (curve != 0) axis.z = curve->Evaluate(time); // look for z animation curve = rotation->GetAnimated()->FindCurve(".ANGLE"); if (curve != 0) angle = curve->Evaluate(time); } colladaLocalMatrix = colladaLocalMatrix * FMMatrix44::AxisRotationMatrix(axis, angle * PI / 180.0f); }else { colladaLocalMatrix = colladaLocalMatrix * transform->ToMatrix(); } } return colladaLocalMatrix; }