For those who hate the idea of having a scalar speed negative, I have modified CAnimatedMeshSceneNode so that setFrameLoop(startFrame,endFrame) really uses startFrame as a start and endFrame as an end because right now, if endFrame < startFrame they are switch and you need to set a negative speed to play the reverse animation. Not only is that illogical - at least for me - but also it prevents you from setting an animation speed without taking into consideration startFrame and endFrame which might be a pain from pragmatical consideration:
old code:
Code: Select all
const int currentFrame = _animatedNode->getFrameNr();
if(targetedFrame < currentFrame)
{
_animatedNode->setAnimationSpeed(-5);
}
else if(targetedFrame > currentFrame )
{
_animatedNode->setAnimationSpeed(5);
}
// if targetedFrame == curentFrame
else
{
_LOG_WARNING << "Frames are equal";
return false;
}
if( _animatedNode->setFrameLoop(currentFrame,targetedFrame) )
Code: Select all
_animatedNode->setAnimationSpeed(5);
_animatedNode->setFrameLoop(currentFrame,targetedFrame)
http://downloads.tuxfamily.org/bluecosm ... Loop.patch
As possible improvements, one might also add getAnimationProgress(); (would return a float between 0 and 1 as the percentage) and a isTransforming() functions. I could do it too though it's easy to implement.