hi there, I am trying to get a camera working in 3D so i can freely navigate a room. This is how I have set it up so far. My WM_SIZE function hold the perpective operations etc…
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
//sets projection matrix
glLoadIdentity(); //resets projection matrix
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
OK so the rest of it is really just the render function and the input funciton…
//Variables for tranlation and rotation
GLfloat planeZ = -4.0f;
GLfloat yRotate = 0.0f;
glLoadIdentity();
//sets initial camera location to -4 so you can see the scene.
glTranslatef(0.0, 0.0, planeZ);
Then the input function is…
if([VK_UP])
planeZ += (0.1f);
Now, i have a simple object located at the origin of the scene(0,0,0). When up is pressed, the camera moves forward, but when it passes the object and you turn around, forward now moves backwards and vice versa. I understand I must use vector manipulation to achive efficent and proper camera manipulation, but none of the many tutorials on the web want to explain any of this. There examples work well but the code is not explained, and im not in to taking peoples code. Even if its free, i need to understand how it works.
Also I have tried LookAt but same results.
One more thing, it will only tranlate in a straight line even once i rotate. Can thi be fixed by modifying the up vector of a LookAt function.
Thanks for your help