In my OpenGL application, I have a camera which is controlled using the keyboard (movement) and mouse (looking around).
Everythings been working perfectly fine up until now, I have noticed that if I move my camera above 300 in the Y axis, it starts to mess up when moving the mouse. For example, if I go to Y =310, and move the mouse up, as it starts to look up it starts turning to the left as well.
I am not sure what the reason for this is. Can anyone help?
Heres the code to work out forward and up position for gluLookAt()
double cosR, cosP, cosY; //temp values for sin/cos from double sinR, sinP, sinY; //the inputed roll/pitch/yaw
if(Yaw > 359) Yaw = 0;
if(Pitch > 359) Pitch = 0;
if(Yaw < 0) Yaw = 359;
if(Pitch < 0) Pitch = 359;
cosY = cosf(Yaw*3.1415/180);
cosP = cosf(Pitch*3.1415/180);
cosR = cosf(Roll*3.1415/180);
sinY = sinf(Yaw*3.1415/180);
sinP = sinf(Pitch*3.1415/180);
sinR = sinf(Roll*3.1415/180);
//forward position
forwardPos.x = sinY * cosP*360;
forwardPos.y = sinP * 360;
forwardPos.z = cosP * -cosY*360;
//up position
upPos.x = -cosY * sinR - sinY * sinP * cosR;
upPos.y = cosP * cosR;
upPos.z = -sinY * sinR - sinP * cosR * -cosY;