Im trying to get the Y rotation from a object to and transfer it to another.

so, to get the angle im using:

`localRotation.toAngleAxis(new Vector3f(Vector3f.UNIT_Y))`

and to set:

`Quaternion quaternion = new Quaternion();`

quaternion.fromAngleAxis(rotation, Vector3f.UNIT_Y);

setLocalRotation(quaternion);

localRotation.normalize();

it works well till 180 degree, then it starts to rotate counter-clockwise, then when it back to 0 dregree it back to normal.

Someone knows what I'm doing wrong?

Come one guys… there's such a few documentation and the tutorials are so out of date…

so i just have you ppl… give me a hand here.

hvilela said:

Im trying to get the Y rotation from a object to and transfer it to another.

if the X and Z rotation of the 2nd object are always, 0 something like this could work.

box2.getLocalRotation().y = box.getLocalRotation().y;

box2.getLocalRotation().w = box.getLocalRotation().w;

i also tried a few other ways but i couldn't get it to work hehe.

my math kung fu is very limited

Yes, the other 2 axis are always zero, and your code does works.

But, I was wondering how to get just one value that represents the rotation on the Y axis, because I'm transfering it over the net (it's a multiplayer game), so it would reduce my data size.

My "get" code works well, juts my "set" code is buggy.

If you want to just transfer the value accross the net as an angle ( eg 180 degrees ), then in JME you will need to convert that angle to radians

getLocalTranslation().y = FastMath.DEG_TO_RAD * 180;

My Problem is not about convert to degree, I can transfer the value in radian too.

My problem is that on a quaternion the Y value by it self do not represent all the rotation on the Y axis. That happen because a quaternion is represented by 4 values instead 3: x, y, z and w.

The code above can get the REAL y rotation:

`localRotation.toAngleAxis(new Vector3f(Vector3f.UNIT_Y))`

But now I can't set it.

I think both funcions was wrong.

Now I discovered that a quaternion can be build from 3 angles and transformed to this too, so now it's solved:

Get:

`localRotation.toAngles(null)[1]`

Set:

`setLocalRotation(new Quaternion(new float[] {0, rotation, 0}));`