With gluLookAt, am rotating the camera around my object. but at a certain angle the object flips around, so i see it upside down. what can cuase that? and how can i arrange that?
here’s the function. when the user clicks the left button, i want it to zoom where the user clicked. (that is working perfectly) and when the user clicks on the middle button i want to rotate the cam around the object.
void Viewer::mouseDrag(int x, int y)
{
Viewer *ViewerPointer = Viewer::GetInstance ();
ViewerPointer->FrameRate = 0;
if (ViewerPointer->LeftMouseDown)
{
if (y > ViewerPointer->LastMouseY)
{
ViewerPointer->eyez += 2;
ViewerPointer->Rayon += 2;
}
if (y < ViewerPointer->LastMouseY)
{
ViewerPointer->eyez -= 2;
ViewerPointer->Rayon -= 2;
}
}
if (ViewerPointer->MiddleMouseDown)
{
if (x > ViewerPointer->LastMouseX)
{
ViewerPointer->eyey = ViewerPointer->Rayon * sin(ViewerPointer->RotationAngle);
ViewerPointer->eyez = ViewerPointer->Rayon * cos(ViewerPointer->RotationAngle);
ViewerPointer->RotationAngle -= 0.01;
}
if (x < ViewerPointer->LastMouseX)
{
ViewerPointer->eyey = ViewerPointer->Rayon * sin(ViewerPointer->RotationAngle);
ViewerPointer->eyez = ViewerPointer->Rayon * cos(ViewerPointer->RotationAngle);
ViewerPointer->RotationAngle += 0.01;
}
}
ViewerPointer->LastMouseX = x;
ViewerPointer->LastMouseY = y;
glutPostRedisplay();
}