Hey folks,
I am desperately trying to only rotate a Spatial with an attached PhysicsControl (here: PhysicsRigidBody) on the Y-Axis and to set the rotation on the X- and Z-Axes to 0.
To apply a rotation on the Y-Axis, I use the following code (works fine):
[java]
Matrix3f rotMatrix = new Matrix3f();
rotMatrix.loadIdentity();
if (xAxis) {
rotMatrix.fromAngleAxis((positiveDir ? 1f : -1f) * 5f * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);
lastSelectedNode.p.setPhysicsRotation(lastSelectedNode.p.getPhysicsRotationMatrix().mult(rotMatrix));
}
[/java]
However, I tried to set up matrices with 0 degrees rotation on X and Z and to multiply them in many ways, and nothing works. So, any hint on how to restrict the movement only to the Y-Axis (as you see in the code, I want to maintain the already applied rotation on that axis)?