I'm trying to set up a 3D camera with the gluLookAt method. So I have got a 10x10x10 cube and now i want to move the camera inside that cube. I have something like that:
gluLookAt( camera->x,camera->y,camera->z, camera->eyeX, camera->eyeY, camera->eyeZ, 0, 1, 0 );
now I'm moving forward/backward:
if(GetKeyState(VK_UP) <0)
{
camera->x += sin(camera->angleX)*0.1f;
camera->eyeX += sin(camera->angleX)*0.1f;
camera->z -= cos(camera->angleX)*0.1f;
camera->eyeZ -= cos(camera->angleX)*0.1f;
}
now I'm rotating left/right:
if(GetKeyState(VK_LEFT) <0)
{
camera->angleX -=0.1f;
camera->eyeX = sin(camera->angleX) +camera->x;
camera->eyeZ = -cos(camera->angleX) + camera->z;
}
So that all works perfectly but now i want to rotate up/down while the SHIFT button is pressed. So i have something like that:
if(GetKeyState(VK_SHIFT) <0)
{
if(GetKeyState(VK_UP)<0)
{
camera->angleY +=0.1f;
camera->eyeY = sin(camera->angleY) +camera->y;
}
And actually something strange happens. The camera keeps bouncing up and down all the time and slowly moving forward. Additionaly I want to add that when I look up and move forward the camera actually goes there where it looks. So basicaly the situation looks like that: I'm a ghost trapped in a 10x10x10 cube and can walk wherever I want. I want to move to the upper right corner? I JUST GO THERE. So... any ideas what should I change/add?