Rotation problem

As this is my first post, let me just pass on my thanks to all the jME devs for creating such a great package of software!

I've been climbing the learning curve for the last ten days and I've finally run across something that has me stumped.

I have a model (let's say it's a jet), whose normal orientation is level flight, pointing away from the cam along Z axis. I want to rotate it along the X axis so it's pointing 'up', then rotate it along the Z axis so that it's pointing 90 clockwise. These rotations are done in the game init to create the starting position for the model.

I can get it to do one or the other but I can't get the combination to work correctly.

// create quat to rotate 90 on X axis

Quaternion qX90 = new Quaternion();

qX90.fromAngleAxis(FastMath.DEG_TO_RAD * 90, new Vector3f(1, 0, 0));

// create quat to rotate 90 on Z axis

Quaternion qZ90 = new Quaternion();

// look to 3 o'clock

qZ90.lookAt(new Vector3f(1, 0, 0), new Vector3f(0, 1, 0));

Matrix3f matrixXZ = new Matrix3f();

matrixXZ.set( qZ90.add( qX90 ) );

// set Rotation

mesh.setLocalRotation( matrixZ );

// Arg!

It points to 10:30 on the clock and about -45 degrees on the Y axis.

Thanks in advance for your help!

try to multiply instead of adding the quaternions

Core-Dump said:

try to multiply instead of adding the quaternions

swapping the order and multiplying did the trick!
matrixXZ.set( qX90.mult( qZ90 ) );

Thanks, Core-Dump!!!