I am trying to have 2 cubes rotate differently.
to set the rotation, I do this.
GL11.glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
GL11.glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
GL11.glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
Instead of using GL11.glLoadIdentity() to reset the rotation, inside the cube class, I do something like this.
GL11.glRotatef(rot[0] * -1.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(rot[1] * -1.0f, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(rot[2] * -1.0f, 0.0f, 0.0f, 1.0f);
This should reset the rotation of each axis.
The array "rot" holds the x, y, and z rotations, and is updated through these 3 methods in the cube class.
public void pitch(float angle) {
rot[0] = angle;
}
public void yaw(float angle) {
rot[1] = angle;
}
public void roll (float angle) {
rot[2] = angle;
}
Individually, each "GL11.glRotatef(etc,etc,etc,etc) and GL11.glRotatef(etc * -1.0f, etc,etc,etc)" works fine, but when they are all together, strange rotations happen.
I'm not sure if this is something to do with Gimbal Lock or my code, please help.
Thanks in advance.