Looking with Camera?

Hey, I’m trying to make a camera but when I use the arrow keys to look around like a head, I can only look 90 degrees in any direction. How do I get it to go a complete circle?

Store facing angle in a variable, and glRotate modelview with it (provided you use reset the modelview each frame, and you should).

Then each time the left key is down, increment it with rotSpeed/frameTime. When right key is down, decrement.

If still can not solve it yourself, be more precise about what you have written, and post some code in proper [ code ] tags.

I was trying to something similar, I have:

``````
gluLookAt(cam.Posx, cam.Posy, cam.Posz,  cam.ForwardX, cam.ForwardY, cam.ForwardZ,  cam.upx, cam.upy, cam.upz);

``````

So every frame I increment/decrement Forward.x to look around, I then tried incrementing ForwardZ when turning right but that still only allowed me to rotate 180 no matter what I set it too.

rotate 180 no matter what I set it too.

Well that’s 90 degrees better than in your first post

Post some code, properly formatted so we can see your camera code.

Haha, still not much use though. Heres my Camera code:

``````
void CameraUpdate()
{

float cosR, cosP, cosY;
float sinR, sinP, sinY;

cosY = cosf(cam.GetYaw()*3.1415/180);
cosP = cosf(cam.GetPitch()*3.1415/180);
cosR = cosf(cam.GetRoll()*3.1415/180);
sinY = sinf(cam.GetYaw()*3.1415/180);
sinP = sinf(cam.GetPitch()*3.1415/180);
sinR = sinf(cam.GetRoll()*3.1415/180);

ForwardVectorX = sinY * cosP*360;
ForwardVectorZ = sinP*360;
ForwardVectorY = cosP * -cosY*360;

// Look At Point
cam.ForwardX = cam.Posx + ForwardVectorX;
cam.ForwardY = cam.Posy + ForwardVectorZ;
cam.ForwardZ = cam.Posz + ForwardVectorY;

// Up Vector
cam.upx = -cosY * sinR - sinY * sinP * cosR;
cam.upy = cosP * cosR;
cam.upz = -sinY * sinR - sinP * cosR * -cosY;
}
``````

Yaw, Pitch and Roll are all 1.0,
I then put the values into gluLookAt and changed them using:

``````
if (keys[VK_RIGHT])
{
cam.ForwardX+=2.0f;
}

if (keys[VK_LEFT])
{
cam.ForwardX-=2.0f;
}

if (keys[VK_UP])
{
cam.ForwardY+=2.0f;
}

if (keys[VK_DOWN])
{
cam.ForwardY-=2.0f;
}

``````

Thats for the 90 degrees turn, for 180 I just incremented/decremented cam.ForwardZ aswell.