[2.2] Ogre::SkeletonAnimation->setTime() behaviour Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
old_man_auz
Greenskin
Posts: 100
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

[2.2] Ogre::SkeletonAnimation->setTime() behaviour

Post by old_man_auz »

Hi, I think I have weird behaviour with Ogre::SkeletonAnimation->setTime(). I want to move the animation to the end. So I do:

Code: Select all

Ogre::SkeletonAnimation* m_pSK;
Ogre::SkeletonInstance* ski = item3->getSkeletonInstance();
m_pSK = ski->getAnimation("Right");
m_pSK->setEnabled(true);
m_pSK->setTime(m_pSK->getDuration()); // or m_pSK->setFrame(m_pSK->getNumFrames());
nothing happens to the animation. To get the animation to move to the end I need to do:

Code: Select all

m_pSK->setTime(m_pSK->getDuration()-0.0001);
Is this expected behaviour, a bug or a problem with my animated mesh?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.2] Ogre::SkeletonAnimation->setTime() behaviour

Post by dark_sylinc »

Hi!

Expected behavior.

It depends on whether's it's set to loop or not (SkeletonAnimation::setLoop).

If it's looping and you set it exactly to getDuration, it's going to warp back to 0. (i.e. if the animation lasts 3 seconds, then it's going to be 0, 1, 2.... 2.999999.... 0, 1, 2.... 2.999999 and so on)
If not looping, it's going to stick to maximum duration.

If you want it to loop, probably the best is to substract a tiny amount like you're doing right now, e.g. m_pSK->setTime(m_pSK->getDuration()-0.0001);

You could alternatively disable looping, set the duration, then enable looping again:

Code: Select all

m_pSK->setLoop( false );
m_pSK->setTime( m_pSK->getDuration() );
m_pSK->setLoop( true );
Post Reply