I use the following code to rotate in cinematics:
[java]
// create an animation event
AnimationFactory factory = new AnimationFactory(animationDuration,
animationID);
factory.addTimeTranslation(0, new Vector3f(oldX, oldY, oldZ));
factory.addTimeRotationAngles(0, 0, 0, rotRad);
factory.addTimeRotationAngles(animationDuration, 0, 0,
(float) Conversions.degreesToRad(newAngle));
// attach anim to this spatial
AnimControl control = spatial.getControl(AnimControl.class);
if (control == null) {
control = new AnimControl();
spatial.addControl(control);
}
control.addAnim(factory.buildAnimation());
[/java]
it works fine except that to rotate from -90 degrees to 180 degrees it does the whole turn positively rather than a short rotation negatively. In other words it does not treat 180 and -180 degrees the same way. Any work around that ? or I should treat them differently?
You are running into the usual problems with rotations and euler angles, just use direction vectors and lookAt.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies