Hello, so I’m having a tough time figuring out how to make my car’s wheel rotate properly. When I rotate it in one axis, it works fine, however once I rotate it around another axis as well, the wheel behaves funny. I read up a little on this issue, and it seems to be because the axes of rotation are rotated with the object when GL.glRotatef() is called.
This is the code I use to transform the wheel before I render it.
GL.glScalef(scale, scale, scale);
if (centered) {
GL.glTranslatef(-center[0] + translation[0], -center[1] + translation[1], -center[2] + translation[2]);
} else {
GL.glTranslatef(translation[0], translation[1], translation[2]);
}
// i read somewhere that z x y is the proper rotation order, however this hasn't helped.
if (rotation[2] != 0) {
GL.glRotatef(rotation[2], 0.0f, 0.0f, 1.0f);
}
if (rotation[0] != 0) {
GL.glRotatef(rotation[0], 1.0f, 0.0f, 0.0f);
}
if (rotation[1] != 0) {
GL.glRotatef(rotation[1], 0.0f, 1.0f, 0.0f);
}
I’m just trying to make the wheel on the car rotate forward on the x axis (when the car moves forward) and turning on the y axis (when the car turns)