Interpolate rotation

I am driving a vehicle along a set path that is stored as a Vector[3f] vertices (coming in live from a Google maps application I've built). Unfortunately quaternions are still a bit confusing to me :wink: I can easily use Spatial.lookAt() to orient the vehicle to the next vertex and then accelerate to that point, however the vehicle should ideally take some time to turn towards that point. I have considered two ways of approaching this and hacked around with some code to accomplish these things but not in a way that I'm happy.


  1. Interpolate between the current vehicle rotation and the desired rotation over a period of time. I think quaternion slerp might be the ticket here? But I haven't figured out a good way to return a quaternion from the desired rotation other than executing a lookAt() on a spatial and then getting the quaternion with getLocalRotation().


  2. I am using a vehicle input handler based upon the flag rush tutorial. Can I determine the direction the vehicle needs to turn and just call the turn right or turn left input actions? I have experimented with returning angles from the vehicle and another spatial which is rotated toward the destination and then comparing these two. This seems rather sloppy too though.



    Anyone have ideas for how to cleanly and simply execute either of these approaches?



    Thanks!
  1. slerp is fine - use Quaternion.lookAt instead of Spatial.lookAt (beware: slightly different parameters - see code of Spatial.lookAt)
  2. not sure what you mean here