free viewing


I’am really new at this, but i’am trying to figure out how things work.
I have made a small world with some geometric objects in it. Now i wanna
navigate freely in it with my keyboard. So if i first use glTranslate()
wich moves the coordinate system origin to the point specified by x,y,z
(the viewer are located in x,y,z, so he is always standing in the origin)
and after that do a glRotate() everything should be fine, the problems is
that it always rotate about the “old” origin and not about the origin i have
“defined” in glTranslate. I could offcourse first do a glRotate() and then a
glTranslate() but if i then turn 180 degres the forwardbutton become a
backwardbutton (and so it should do to). My first guess is that there is
some lack of understanding from my side. :slight_smile: How should i do?

You are almost there. You have to have the rotations before the translations, otherwise the rotation will be from the last axis. this is because the transformations are put in a stack and stack works in FIFO(first in first out) So if your glTranslate is before (in your code) than the rotation, it will actually be done after the rotations.

Now, what you can got to understand, is that moving forward isn’t just moving on one axis. It’s actually a vector and it depends on the angles.

So if your Z- goes in the screen and the Y+ goes up and X+ goes left, and the starting position is looking at Z-

let’s call roty the rotation around the y axis.

moving forward is actually :

xmov = speedsin(roty);
zmov = -speed

[This message has been edited by Gorg (edited 03-23-2000).]

Sorry to be late in this topic :wink:

how the example given by Gorg can be extended to use Y axis rotation AND X axis rotation like in quake 3 arena spectator view mode ??