I am attempting to provide a simple navigation for users walking thru 3d worlds. It is set up so that the arrow keys move the user forward, backward, strafe left, and strafe right and that the mouse is what turns the user. If the user moves the mouse to the left hand of the screen, then one turns right, to the right hand side and one turns to the right.
Now, here for my problem. If i use:
gluLookAt(headx, heady, headz,
lookatx, lookaty, lookatz,
0, 1.0, 0);
// does the left/right viewing
glTranslatef(headx, 0.0, headz);
glRotatef(rotateWorldy, 0, 1, 0);
glTranslatef(-headx, 0.0, -headz);
where headx,heady,headz are the current position of the user, and lookatx,y,z is some arbitary point further down the z axis.
Using the above code, the user turns like he is supposed to, but the forward, back, strafe left/right stay the same in relation to the original view. Ie. If the person turns 180 degrees then the forward and back keys are inverted.
if I use the following code:
// does the left/right viewing
glTranslatef(-headx, 0.0, -headz);
glRotatef(rotateWorldy, 0, 1, 0);
glTranslatef(headx, 0.0, headz);
then the forward/back/left/right keys adjust depending on the view and forward will always be forward. However, by doing this, when I rotate the world, it does not rotate about me, but rather about some other point.
So, how would I go about implementing this navigation structure where 1) the forward/back/left/right keys are always relative to the current view and not the origianal world parameters and 2) that when the user looks left/right that the world rotates about the camera and not about some arbitrary point.