Rotation problems

  1. The below code rotates my camera node, but I assumed I would have to call cameraNode.setLocalRotation(vert); to rotate it, but I don't.


Quaternion vert = _cameraNode.getLocalRotation().fromAngleAxis(
             -FastMath.PI/_tank.getTurretElevation() , new Vector3f(1,0,0));



2)  I want to rotate in two directions at the same time but with this code it rotates only in the horizontal direction.

Quaternion vert = _cameraNode.getLocalRotation().fromAngleAxis(
             -FastMath.PI/_tank.getTurretElevation() , new Vector3f(1,0,0));
       
       Quaternion hor = _cameraNode.getLocalRotation().fromAngleAxis(
             FastMath.PI/_tank.getTurretHorizontal() , new Vector3f(0,1,0));

For your second question, you can multiply (Quaternion.multLocal) the vert quaternion by the hor quaternion to combine both rotations.

With multLocal only the horizontal works.  Nothing happens with the vertical.  However I think this may be involved with problem 1.  This is all of my code:


Quaternion vert = _cameraNode.getLocalRotation().fromAngleAxis( -FastMath.PI/_tank.getTurretElevation() , new Vector3f(1,0,0));
       
Quaternion hor = _cameraNode.getLocalRotation().fromAngleAxis( FastMath.PI/_tank.getTurretHorizontal() , new Vector3f(0,1,0));
       
Quaternion both = vert.multLocal( hor );
       
_cameraNode.setLocalRotation( both );



Vert works alone when that 1 line of code is all I have, but after I add the line where I assign hor.  Vert does nothing and only hor works.

You are not doing it correctly, getLocalRotation().fromAngleAxis() does not create a new quaternion so you are modifying the same quaternion as vert, which simply overwrites the vertical rotation. You need to multiply the rotation by a new quaternion.