OpenGL Rotation/Translation Problem
I use glRotatef & glTranslatef to "rotate my camera".
glRotatef(-zanglecamera, 0, 0, 1);
glRotatef(-yanglecamera, 0, 1, 0);
glRotatef(-xanglecamera, 1, 0, 0);
glTranslatef(-xposcamera, -yposcamera, -zposcamera);
The problem is that my input is translation and rotation in a global-coordinate-system. That means that the x-axis stays the same after rotation around the z axis.
The same is true for the translation after the rotation. This does not work with the code shown above as opengl rotates the coordinate system.
I think the translation problem is solved by doing the translation before the rotation. If that is true then i still have the problem with the rotations.
I hope someone can help me with this problem.
Why don't you make the use of homogeneous matrices?
You can calculate the translation and rotation matrices and then apply a uniform matrix for all of them (rotation+translation) by loading the matrix before your drawing.
Have you test with only two rotations axis at the same time ?
With three rotations axis, the result is sometime very surprising because the last rotation "modify/destroy" the two firsts rotations that are make before ...
If you want to rotate around an arbitrary axis, take a look at http://www.siggraph.org/education/ma...ran/3drota.htm or http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/ for example
Tags for this Thread