Quaternion start = new Quaternion().set( desktopNode.getLocalRotation() );
Quaternion finish = new Quaternion().set( desktopNode.getLocalRotation() ).multLocal(
new Quaternion().fromAngleNormalAxis( 0.5f, new Vector3f( 0, 1, 0 ) ) );
desktopNode.getLocalRotation().slerp( finish, start, 0.5f );
I have to do
desktopNode.getLocalRotation().normalize();
to avoid some weird positioning of children of desktopNode.
Why? :?
Is there a problem with slerp or does one always have to normalize a slerp'ed Quaternion?
Well, I thought that Quaternion.fromAngleNormalAxis would return a normalized Quaternion, no? So 'finish' should be a normalized one, too… (given that the local rotation was normalized before)
but out of curiosity, have you tried normalizing it prior to slerp? Might as well narrow it down so you know slerp is definitely to blame. Just for fun (and yes, before you say "well, I don't need to because X is already normalized" just try it…) add:
Comparing our calculations to Eric Lengyel's discussion of Quaternion slerp in his book, our calculations look spot on for doing it in such a way as to return a unit Quat... The problem way be in the following check:
// Check if the angle between the 2 quaternions was big enough to
// warrant such calculations
if ((1 - result) > 0.1f) {// Get the angle between the 2 quaternions,
// and then store the sin() of that angle
...because if it fails that if statement, it still goes on to modify the contents of the quat with values that I doubt could be completely valid. Maybe it needs to basically leave things alone if that check fails?
I know I'm bringing up an old thread, but I happened to run into a similar problem and it seems like this was never resolved.
I was blending between two animations and I was getting a strange scaling effect on some of the joints. It turned out that the problem the quaternion that Quaternion.slerp was returning wasn't normalised. The reason is the same as before, the fact that for small angles it doesn't seem to work properly. I have added a conditional Quaternion.normalize() providing the angle is small enough and that worked like a charm.