Rewinding animations

Started by
2 comments, last by fuchiefck 18 years, 10 months ago
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
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel
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.
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
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel
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 ///CHANGEDrenderer->GetAnimationController()->SetTrackPosition(0, m_dCurrentPos); ///ADDEDrenderer->Update(); //update animation posem_dLastPos = m_dCurrentPos;


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

rating++ for you my man!

-fuchiefck
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel

This topic is closed to new replies.

Advertisement