[LWJGL] Regards to rotations

I have a question about rotations in lwjgl, by using something along the lines of:

GL11.glRotatef(pitch, 1, 0, 0);
GL11.glRotatef(roll,  0, 1, 0);
GL11.glRotatef(yaw,   0, 0, 1);

Now this works for a camera, but not always for a model. If I rotate say… JUST the pitch, or JUST the yaw rotations work fine, but when I begin to rotate multiple axis, I run into trouble.

Look at these two pictures:

The first one is fine, as I am ONLY rotating based on the cameras yaw.
Once I start to rotate by both yaw, AND pitch, the model starts to rotate as if it is roll (however, when I ONLY rotate based on yaw, it works fine).

That’s because rolling is around the z axis, and you’re trying to roll around the y axis. Change the roll and yaw rotate functions so that yaw is the second rotate call.

Z axis is yaw in my game. I prefer z as height than y.

Why the z-axis as the normal y-axis?

Disregard ueler angles, convert to quaternions and rotation matrix.
Ueler angles has a lot of nasty problems when using them in 3d space.

I tried googling for some documentation, but I couldn’t find anything useful.
Would you happen to have any resources I can look at? :slight_smile:

Here is a short post introduce you to quaternions:

http://iquilezles.org/www/articles/quaternions/quaternions.htm