Weird Transform3D.rot[XYZ] problems. [WITH SOLUTION]

To move my viewport (as when moving around in my game), I do:


	Vector3f	translate	= new Vector3f();
	Transform3D	trans3D		= new Transform3D();
	translate.set ((float) posX + eyeOffX, (float) posY + eyeOffY, (float) posZ + eyeOffZ);
//	trans3D.rotZ (lookBank);
//	trans3D.rotX (lookPitch);
	trans3D.rotY (lookHeading);
	trans3D.setTranslation (translate);
	setSchedulingBounds (new BoundingSphere (new Point3d (translate), 10f));
	viewTrans.setTransform (trans3D);

…which works fine BUT, if I comment-in the two commented-out lines, things go “all kablooey.” I’ve tried rotating the XYZ in various orders (ZXY, ZYX, XZY, etc), but can’t seem to get it to do what I want.

What I want is to set lookPitch to a few degrees this way or that and have my camera look down or up a little.

Hints?

Thanks!

Ok, I got it.


	Vector3f	translate	= new Vector3f();
	Transform3D	trans3D		= new Transform3D();
	translate.set ((float) posX + eyeOffX, (float) posY + eyeOffY, (float) posZ + eyeOffZ);
	Transform3D	trans3DX	= new Transform3D();
	Transform3D	trans3DY	= new Transform3D();
	Transform3D	trans3DZ	= new Transform3D();

	trans3DX.rotX (lookPitch);
	trans3DY.rotY (lookHeading);
	trans3DZ.rotZ (lookBank);

	trans3DY.mul (trans3DX);
	trans3DZ.mul (trans3DY);
	trans3D .mul (trans3DZ);		//* Superfluous
	trans3D.setTranslation (translate);
	viewTrans.setTransform (trans3D);

Basically, you have to do the rotations separately, then mul() them together. Odd that that’s different from applying them in a row – but I guess I don’t understand the matrix manipulations as well as I thought.