Advertisement Jump to content
Sign in to follow this  
BoubQC

Animation lerping.

This topic is 1876 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

Hi guys, I read some old posts about different animations systems, lerping, blending and all of this. I really like to think that I could get to the point that I only need one method to lerp everything... But I don't see how you can lerp Quaternions the same way you lerp Vector3... 

 

Ex: In the system we use at the moment if we want to lerp to quaternions we first check the shortest way using the dot product and then lerp and then normalize...

 

The normalize no problem with that I can deal with it later... but how do you handle the shortest way check... Is there some way to pre-compute everything so when I blend two animations or I lerp between frames, I can handle quaternions the way I handle Vector3!?

 

To lerp between frames my first impression is that I can resample the animations at let's say 30fps and check each and every frame to make sure they use the shortest way and then run an optimisation algo on the keys... Pretty sure it will work... but what happens when blending animations!?

 

Thanks for your help guys!

Share this post


Link to post
Share on other sites
Advertisement

The shortest way check is achieved by taking the 4D dot product of the start and end quaternion, and if it is negative negate one of the quaternions, either one will do.

 

Don't handle quaternions in the same way as Vector3, they have 4 components so you need to lerp all of them.

 

As long as the quaternions aren't too different you can get away with doing a normalised lerp (nlerp) but if that doesn't look good you can use slerp function instead; source code for that is on the internet. EDIT: Most systems look at the magnitude of the lerp required (which is again the dot product) and choose nlerp or slerp depending on a threshold.

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

What I meant by saying handling Quaternions like Vector3 is to be able to lerp each and every component individually. So I can have a method that takes two float values and a ratio and lerp them... 

 

ex: 

 

"Vector3 Lerp (aVecA Vector3, aVecB Vector3, aRatio Float)" is equivalent to doing a "Float Lerp (aFloatA Float, aFloatB Float, aRatio Float)" for each and every component.

 

for the quaternions in the other hand I can't just lerp all the components individually since I need to check them as a whole and negate them if needed.

Share this post


Link to post
Share on other sites

You only need to do the dot product check when you change the start or end quaternion though. Or you can do the check in Quaternion Lerp(Quaternion a, Quaternion b, float amount) and then just call the float lerp 4 times in that function.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!