Jump to content
  • Advertisement
Sign in to follow this  
Jan K

Smooth Interpolation of Camera Rotation on a Spline Path

This topic is 3659 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 I use splines for camera paths. So far i can smoothly interpolate the position of the camera. At each node of the path i also store the rotation of the camera as a quaternion. When calculating the position of the camera i get a time t between 0 and 1, which is used to interpolate (using the spline function) between the two positions of a spline segment. I use the same value to lerp my two camera rotation quaternions. This works, but results in pretty bad quality, because every time the camera passes the next node on a path the velocity of the rotations changes abruptly. What i would like to do is to interpolate the rotations similar to how i interpolate the positions. However my math-skills are not good enough to figure this out by myself, whether / how i can do that for rotations. Can anyone give me some pointers? Maybe i should add this: My camera is NOT fixed on looking into the direction it is traveling in. So the camera's rotation is not dependent on the position / direction it is moving into, but it really needs to interpolate between the two given rotations of the previous and next node. Thanks, Jan.

Share this post


Link to post
Share on other sites
Advertisement
I "solved" my problem. Maybe someone wants to know sometime, so i'll post how i did it:

Interpolating Quaternions for smooth orientations on a spline-path is a nightmare. Even code that i got from book CDs did not work properly (sudden rotations into wrong directions, still pretty yerky motion, etc.) and google only turns up either half-baked solutions or mathematically so complicated solutions, that i were not able to implement them (i know, i suck at maths).

So i took a step back, ditched quaternions altogether and solved it differently. I have one spline that interpolates the camera's position. Now i added two splines, that interpolate (as position) the look-at and camera-up vectors. That's pretty simple. Simply use the position at a node and add (using the orientation) the "forward" and "up" vector to it, which gives you two slightly shifted splines to your position-spline.

When sampling the splines, i first sample the position-spline, which returns the camera-position AND the spline-segment [0;n] and segment-time [0;1], that was used. I then sample the "dir" and "up" spline at precisely the same segment and time and use the difference-vectors to create a look-at matrix.

This works perfectly fine, orientation interpolation is reliable and quite smooth (much better than anything else i got partially working).

Maybe this will be useful to someone stumbling on this post in the future.
Jan.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!