Jump to content
  • Advertisement
Sign in to follow this  
fuchiefck

Rewinding animations

This topic is 4781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to rewind an animation using AnimationController::AdvanceTime()? I know AdvanceTime doesn't take in timedelta values of 0 or negative.... thanks in advance. More precisely, I am trying to control an animation with a slider control, much like the slider bar you find in most media players... So firstly, use the animationset->GetPeriod() function to set the range of the slider... then in OnHScroll(), the event handler for the slider, I do something like this...
m_dCurrentPos = m_Slider1.GetPos();

double timedelta = m_dCurrentPos - m_dLastPos;
renderer->SetAdvanceTime(timedelta); //Advance the animation by timedelta
renderer->Update(); //update animation pose

m_dLastPos = m_dCurrentPos;
Currently, when I drag forwad the slider bar, everything seems ok, but now I want the animation to rewind if I drag the slider backwards, and I don' know how to do this. Many thanks... -fuchiefck

Share this post


Link to post
Share on other sites
Advertisement
I've been playing around with animations a bit the last week or so. So I may not be the most qualified to answer, but I'll try to answer the best I can, so I apologize in advance.

Now, one appraoch may be to detect when the slider is going backward by comparing the new slider position to the old one. Once you've determined it's going backward, you might be able to send in a negative timedelta value. I've never tried this before, but it's worth a try.

If that doesn't work. Try setting the position manually using AnimationController::SetTrackPosition and just have a variable to track the position of your animation. If you are using one animation, you are most likely on track 0, so send in 0 for the index of the track parameter.

I hope this helped in some way.

Share this post


Link to post
Share on other sites
Thanks for the reply, LilTrooper.

Anyways I have tried the first suggestion before but as I said, the AdvanceTime function does not take in values of less or equal to zero, so yeah... doesn't work.

I have looked at the SetTrackPosition function, but I don't quite understand what its used for, could it be for blending the switch between two animations? I tried using it by passing in some values but nothing seems to happen yet. Anyway it could be my solution, I will look deeper into it... if any luck I will post my solution here. and thanks for your suggestions again.

-fuchiefck

Share this post


Link to post
Share on other sites
LilTrooper you're a genius! All I did was:


m_dCurrentPos = m_Slider1.GetPos();

double timedelta = m_dCurrentPos - m_dLastPos;
renderer->SetAdvanceTime(abs(timedelta)); //abs'ed the timedelta ///CHANGED
renderer->GetAnimationController()->SetTrackPosition(0, m_dCurrentPos); ///ADDED
renderer->Update(); //update animation pose

m_dLastPos = m_dCurrentPos;


Now I can drag the slider back and forth... hours of fun...

rating++ for you my man!

-fuchiefck

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!