Hello,
I need to perform multiple rotations on a node, but:
node.getLocalRotation().fromAngleAxis(PI, Vector3f.UNIT_X).fromAngleAxis(PI, Vector3f.UNIT_Y);
just does the last rotation.
What is the correctway of rotating a node several times (acculating the rotation) ?
Thank you in advance
The fromAngleAxis method sets the Quaternion to the desired value… in other words, it always overwrites whatever the value you had, and replaces it with a Quaternion that represents a rotation (from identity) along one axis… What you want to achieve can be done by chaining the rotation with multiplication:
Quaternion local = new Quaternion();
local.fromAngleAxis(PI, Vector3f.UNIT_X);
node.getLocalRotation().multLocal( local );
local.fromAngleAxis(PI, Vector3f.UNIT_Y);
node.getLocalRotation().multLocal( local );
It's also possible with Quaternion.fromAngles, it takes 3 angles, one for UNIT_X, UNIT_Y and UNIT_Z and combines them together…
Thank you very much my friends, that did it.