void keyboard(unsigned char key, int x, int y) {\r
switch(key) {\r
case 'w':\r
- camz = camz - 1;\r
+ case 'W':\r
+ camz -= factor;\r
break;\r
case 'a':\r
- camx = camx - 1;\r
+ case 'A':\r
+ camx -= factor;\r
break;\r
case 's':\r
- camz = camz + 1;\r
+ case 'S':\r
+ camz -= factor;\r
break;\r
case 'd':\r
- camx = camx + 1;\r
+ case 'D':\r
+ camx += factor;\r
break;\r
case 'q':\r
- camy = camy + 1;\r
+ case 'Q':\r
+ camy += factor;\r
break;\r
case 'e':\r
- camy = camy - 1;\r
+ case 'E':\r
+ camy -= factor;\r
break;\r
case 'z':\r
- rot = rot + 1;\r
+ case 'Z':\r
+ keyrot += factor;\r
break;\r
case 'x':\r
- rot = rot - 1;\r
+ case 'X':\r
+ keyrot += factor;\r
break;\r
+ case '=':\r
+ case '+':\r
+ factor += 0.1;\r
+ printf("Factor of change is now %f\n", factor);\r
+ break;\r
+ case '-':\r
+ case '_':\r
+ factor -= 0.1;\r
+ printf("Factor of change is now %f\n", factor);\r
+ break;\r
+\r
}\r
- printf("Camera is now at (%f, %f, %f), angle %f\n", camx, camy, camz, rot);\r
+ printf("Camera is now at (%f, %f, %f), angle %f\n", camx, camy, camz, keyrot);\r
glutPostRedisplay();\r
}\r
\r
*/\r
void motion(int x, int y) {\r
if (moving) {\r
- zoomFactor += (y - starty);\r
- rotateFactor += (x - startx);\r
+ zoom += (y - starty);\r
+ rotate += (x - startx);\r
startx = x;\r
starty = y;\r
glutPostRedisplay();\r
glLoadIdentity();\r
\r
gluLookAt(\r
- 0.0, 0.0, 5.0 + (zoomFactor*0.2), /* eye is at (x,y,z) */\r
+ 0.0, 0.0, 5.0 + (zoom*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
lightPosition[2] = 12*sin(lightAngle);\r
lightPosition[3] = 0.0;\r
\r
-\r
- //glRotatef(angle, 0.0, 1.0, 0.0);\r
- // glRotatef(angle2, 1.0, 0.0, 0.0);\r
-\r
glPushMatrix();\r
\r
/* Perform scene rotations based on user mouse/keyboard input. */\r
- glRotatef(rotateFactor*0.5, 0.0, 1.0, 0.0);\r
- //glTranslatef(camx, camy, camz);\r
- //glRotatef(rot, 1.0, 0.0, 0.0);\r
+ glRotatef(rotate*rotateFactor, 0.0, 1.0, 0.0);\r
+ glTranslatef(camx, camy, camz);\r
+ glRotatef(keyrot, 1.0, 0.0, 0.0);\r
\r
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);\r
\r
* init function; sets initial OpenGL state\r
*/\r
void init() {\r
- glLightfv(GL_LIGHT0, GL_POSITION, light0_pos);\r
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);\r
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);\r
glLightfv(GL_LIGHT0, GL_SPECULAR, specular0);\r