Fallen_Angel
03-29-2002, 08:10 PM
I'm basically trying to zoom in and out on my object using the mouse. However, when i zoom out as far as possible my object gets rotated upside down and starts zooming back in. Any help would be appreciated.
static void display()
{
glRotatef(Spin, SpinX, SpinY, SpinZ);
}
static void spinDisplay(void)
{
if (bRotating)
{
Spin += 1.0;
if (Spin > 360.0)
Spin -= 360.0;
}
else if (bZooming)
{
if (Spin > 360.0)
Spin = 360.0;
}
glutPostRedisplay();
}
//Mouse button is pressed.
static void mouseClick(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON)
{
if (state == GLUT_DOWN)
bRotate = true;
if (state == GLUT_UP)
bRotate = false;
}
if (button == GLUT_MIDDLE_BUTTON)
{
if (state == GLUT_DOWN)
bZoom = true;
if (state == GLUT_UP)
bZoom = false;
}
}
//Mouse is moved.
static void mouseMotion(int x, int y)
{
if (bRotate)
{
bRotating = true;
SpinY = 1;
Spin = x;
}
if (bZoom)
{
bZooming = true;
SpinY = 0;
Spin = y;
}
}
static void display()
{
glRotatef(Spin, SpinX, SpinY, SpinZ);
}
static void spinDisplay(void)
{
if (bRotating)
{
Spin += 1.0;
if (Spin > 360.0)
Spin -= 360.0;
}
else if (bZooming)
{
if (Spin > 360.0)
Spin = 360.0;
}
glutPostRedisplay();
}
//Mouse button is pressed.
static void mouseClick(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON)
{
if (state == GLUT_DOWN)
bRotate = true;
if (state == GLUT_UP)
bRotate = false;
}
if (button == GLUT_MIDDLE_BUTTON)
{
if (state == GLUT_DOWN)
bZoom = true;
if (state == GLUT_UP)
bZoom = false;
}
}
//Mouse is moved.
static void mouseMotion(int x, int y)
{
if (bRotate)
{
bRotating = true;
SpinY = 1;
Spin = x;
}
if (bZoom)
{
bZooming = true;
SpinY = 0;
Spin = y;
}
}