GLfloat nearClip = -200;
GLfloat farClip = 200;
-/* Zoom factor for mouse movements */
-GLfloat zoomFactor = 1.0;
-
/* Recursion level for floor drawing */
int drawFloorRecurse = 8;
GLfloat diffuse[] = {1.0, 0.8, 0.0, 1.0};
GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
+/* Zoom and rotate tracking */
+GLfloat zoomFactor = 0.0, rotateFactor = 0.0;
+
/* Beginning width, height */
int width = 500, height = 500;
\ No newline at end of file
extern GLfloat nearClip;
extern GLfloat farClip;
-/* Zoom factor for mouse movements */
-extern GLfloat zoomFactor;
-
/* Recursion level for floor drawing */
extern int drawFloorRecurse;
/* Beginning width, height */
extern int width, height;
+/* Zoom and rotate tracking */
+GLfloat zoomFactor, rotateFactor;
+
#endif /* GLOBALS_H */
\ No newline at end of file
moving = 0;\r
}\r
}\r
- if (button == GLUT_MIDDLE_BUTTON) {\r
- if (state == GLUT_DOWN) {\r
- lightMoving = 1;\r
- lightStartX = x;\r
- lightStartY = y;\r
- }\r
- if (state == GLUT_UP) {\r
- lightMoving = 0;\r
- }\r
- }\r
}\r
\r
/**\r
*/\r
void motion(int x, int y) {\r
if (moving) {\r
- angle = angle + (x - startx);\r
- angle2 = angle2 + (y - starty);\r
+ zoomFactor += (x - startx);\r
+ rotateFactor += (y - starty);\r
startx = x;\r
starty = y;\r
glutPostRedisplay();\r
}\r
- if (lightMoving) {\r
- lightAngle += (x - lightStartX)/40.0;\r
- lightHeight += (lightStartY - y)/20.0;\r
- lightStartX = x;\r
- lightStartY = y;\r
- glutPostRedisplay();\r
- }\r
}\r
\r
/**\r
glLoadIdentity();\r
\r
gluLookAt(\r
- 0.0, 0.0, 5.0, /* eye is at (x,y,z) */\r
+ 0.0, 0.0, 5.0 + zoomFactor, /* eye is at (x,y,z) */\r
0.0, 0.0, 0.0, /* center is at (x,y,z) */\r
0.0, 1.0, 0.0 /* up is in postivie Y direction */\r
);\r
\r
glRotatef(75.0, 1.0, 0.0, 0.0);\r
\r
- /* Reposition the light source. */\r
- lightPosition[0] = 12*cos(lightAngle);\r
- lightPosition[1] = lightHeight;\r
- lightPosition[2] = 12*sin(lightAngle);\r
- lightPosition[3] = 0.0;\r
-\r
glPushMatrix();\r
\r
/* Perform scene rotations based on user mouse/keyboard input. */\r
- glRotatef(angle, 0.0, 1.0, 0.0);\r
- glRotatef(angle2, 1.0, 0.0, 0.0);\r
- glTranslatef(camx, camy, camz);\r
- glRotatef(rot, 1.0, 0.0, 0.0);\r
+ glRotatef(rotateFactor, 0.0, 0.0, 1.0);\r
+ //glTranslatef(camx, camy, camz);\r
+ //glRotatef(rot, 1.0, 0.0, 0.0);\r
\r
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);\r
\r