Hi all i trying to accumulate rotation something like this
First rotate 90 degree (Y axis)
Segond, after the object was affected by the first rotation, i want rotate the same object 37 degree in difierent axis
now i using object.setLocalRotation() and quaternions, but when i use again object.setLocalRotation() i didn't get the expected result, any clue on how to do that ?
use something like this:
float[] angles = {.65f,1.57f, 0}; // {x-axis rotation, y rotation, z rotation} (in radians)
object.getLocalRotation().fromAngles(angles);
hi all here is the new code, but i don get the spected result
Quaternion q1 = new Quaternion();
q1.fromAngleAxis(this.getRotationSpin(), new Vector3f(0,1,0));
obj.setLocalRotation(q1);
q1.fromAngleAxis(-90, new Vector3f(1,0,0));
obj.getLocalRotation().multLocal(q1);
any clue of why my object ratate wired
thanks in advance for yout help!
setLocalRotation() will overwrite the currently set rotation, i think you need to multiply the current with the rotation you want to add.
try: object.getLocalRotation().multLocal(rotationQuaternion)
Well, actually I don't know the the result of getRotationSpin() but fromAngleAxis
expects radians not degree. That means you have to convert your 90
In Zathras Beginners FAQ theres some nice predefined Quaternions (scroll down to about middle of page). Maybe these can be helpful?
Hi all here is the code working your information was so helpful , thanks to all!!!
Quaternion q1 = new Quaternion();
Quaternion q2 = new Quaternion();
q1.fromAngleAxis(this.getRotationSpin(), new Vector3f(0,1,0));
planetShape.setLocalRotation(q1);
q2.fromAngleAxis(-90*FastMath.DEG_TO_RAD, new Vector3f(1,0,0));
planetShape.getLocalRotation().multLocal(q2);