(no commit message)
[atyndall/cits2231.git] / scene.c
diff --git a/scene.c b/scene.c
index 42b717c..55b1856 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -216,66 +216,6 @@ void mouse(int button, int state, int x, int y) {
   }\r
 }\r
 \r
-/**\r
- * Keybord event handler\r
- * w/s increase/decrease the z\r
- * a/d increase/decrease the x\r
- * q/e increase/decrease the y\r
- * z/x increase/decrease the angle\r
- * @param key Key pressed\r
- * @param x x co-ordinate of mouse\r
- * @param y y co-ordinate of mouse\r
- */\r
-void keyboard(unsigned char key, int x, int y) {\r
-  switch(key) {\r
-    case 'w':\r
-    case 'W':\r
-      camz -= factor;\r
-      break;\r
-    case 'a':\r
-    case 'A':\r
-      camx -= factor;\r
-      break;\r
-    case 's':\r
-    case 'S':\r
-      camz += factor;\r
-      break;\r
-    case 'd':\r
-    case 'D':\r
-      camx += factor;\r
-      break;\r
-    case 'q':\r
-    case 'Q':\r
-      camy += factor;\r
-      break;\r
-    case 'e':\r
-    case 'E':\r
-      camy -= factor;\r
-      break;\r
-    case 'z':\r
-    case 'Z':\r
-      keyrot += factor;\r
-      break;\r
-    case 'x':\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, keyrot);\r
-  glutPostRedisplay();\r
-}\r
-\r
 /**\r
  * Called when motion event occurs\r
  * @param x Mouse x position\r
@@ -347,19 +287,24 @@ void motion(int x, int y) {
       break;\r
 \r
     case STATE_LIGHT_1_MOVE:\r
-    case STATE_LIGHT_2_MOVE:;\r
+    case STATE_LIGHT_2_MOVE:\r
+      ; // Semi-colon required to allow variable declaration below\r
       \r
       int i = 0;\r
       if ( manipulateState == STATE_LIGHT_2_MOVE ) i = 1;\r
 \r
       if ( buttonSelected == GLUT_LEFT_BUTTON ) {\r
+        // w: left/right, h: near/far\r
         float angler = 2 * M_PI * ( (rotate*camRotateFactor)/360.0 );\r
-        lightObjs[i].position[0] += diffx * cos(angler) * leftrightFactor + diffy * cos(M_PI/2 + angler) * nearfarFactor;\r
-        lightObjs[i].position[2] += diffx * sin(angler) * leftrightFactor + diffy * sin(M_PI/2 + angler) * nearfarFactor;\r
-        \r
+        lightObjs[i].position[0] += diffx * cos(angler) * lleftrightFactor + diffy * cos(M_PI/2 + angler) * lnearfarFactor;\r
+        lightObjs[i].position[2] += diffx * sin(angler) * lleftrightFactor + diffy * sin(M_PI/2 + angler) * lnearfarFactor;\r
 \r
       } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) {\r
+        // w: increase/decrease some light param\r
+        // **NOTE: Currently not implemented\r
 \r
+        // h: up/down\r
+        lightObjs[i].position[1] -= diffy * updownFactor;\r
       }\r
 \r
       break;\r
@@ -497,32 +442,19 @@ int main(int argc, char **argv) {
   glDepthRange(0,1);\r
   glEnable(GL_DEPTH_TEST); // Enables Depth Testing\r
   glDepthFunc(GL_LEQUAL);  // the type\r
-  glEnable(GL_NORMALIZE);\r
-  glLineWidth(2.0);\r
+  //glEnable(GL_CULL_FACE);\r
+  glLineWidth(1.0);\r
 \r
   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);\r
 \r
   glutReshapeFunc(windowReshape);\r
   glutDisplayFunc(display);\r
   glutMouseFunc(mouse);\r
-  glutKeyboardFunc(keyboard);\r
   glutMotionFunc(motion);\r
 \r
   makeMenu();\r
-\r
   initializeLights();\r
-\r
-  /* Initial light 0 position. */\r
-  lightObjs[0].position[0] = 4;\r
-  lightObjs[0].position[1] = 5;\r
-  lightObjs[0].position[2] = 6;\r
-  lightObjs[0].position[3] = 0.0;\r
-\r
-  /* Initial light 1 position. */\r
-  lightObjs[1].position[0] = -4;\r
-  lightObjs[1].position[1] = 5;\r
-  lightObjs[1].position[2] = -6;\r
-  lightObjs[1].position[3] = 0.0;\r
+  initializeState();\r
 \r
   glutMainLoop();\r
 }
\ No newline at end of file

UCC git Repository :: git.ucc.asn.au