X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=d351afaf6e46642280b1830f3b0e92eee9e3b025;hp=31eff0e3ffdd3fdbf6f39e1606596f0928202ac0;hb=3252ebe3045e51d4cf9ee40f24e7204e230492d6;hpb=36aa202c760cb524f105a465007983f224cb97e3 diff --git a/scene.c b/scene.c index 31eff0e..d351afa 100644 --- a/scene.c +++ b/scene.c @@ -25,17 +25,14 @@ void processMainEvents(int id) { switch (id) { case M_ROTATE_MOVE_CAMERA: - // Do stuff + manipulateState = STATE_CAMERA_ROTATE_MOVE; break; - case M_POSITION_SCALE: - // Do stuff + manipulateState = STATE_OBJECT_POSITION_SCALE; break; - case M_ROTATION_TEXTURE_SCALE: - // Do stuff + manipulateState = STATE_OBJECT_ROTATION_TEXTURE_SCALE; break; - case M_EXIT: exit(EXIT_SUCCESS); @@ -115,6 +112,7 @@ void processLightEvents(int id) { void processObjectEvents(int id) { // **NOTE: For the testing phase, only have the teapot addSceneObject(id); + glutPostRedisplay(); } /** @@ -165,10 +163,10 @@ void makeMenu() { // Construct main menu glutCreateMenu(processMainEvents); - //glutAddMenuEntry("Rotate/Move Camera", M_ROTATE_MOVE_CAMERA); - //glutAddSubMenu("Add object", objectMenu); - //glutAddMenuEntry("Position/Scale", M_POSITION_SCALE); - //glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); + glutAddMenuEntry("Rotate/Move Camera", M_ROTATE_MOVE_CAMERA); + glutAddSubMenu("Add object", objectMenu); + glutAddMenuEntry("Position/Scale", M_POSITION_SCALE); + glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); //glutAddSubMenu("Material", materialMenu); //glutAddSubMenu("Texture", textureMenu); glutAddSubMenu("Ground texture", gTextureMenu); @@ -293,7 +291,6 @@ void motion(int x, int y) { } starty = y; - printf("zoom is %f, y is %d starty is %d\n", zoom, y, starty); startx = x; break; @@ -388,17 +385,18 @@ void display() { drawFloor(); // Draw sceneObjs array - glPushMatrix(); - for ( int i = 0; i < nObjects; i++ ) { + for ( int i = 0; i < nObjects; i++ ) { + glPushMatrix(); SceneObject so = sceneObjs[i]; // Apply rotation vector - vector* rv = so.rotation.vect; - glRotatef(so.rotation.parameter, *rv[0], *rv[1], *rv[2]); + //GLfloat* rv = &so.rotation.vector; + printf("%f, %f, %f\n", so.rotation.vector[0], so.rotation.vector[1], so.rotation.vector[2]); + glRotatef(so.rotation.amount, so.rotation.vector[0], so.rotation.vector[1], so.rotation.vector[2]); // Apply scaling vector - vector* sv = so.scale; - glScalef(*sv[0], *sv[1], *sv[2]); + //GLfloat* sv = &so.scale; + glScalef(so.scale[0], so.scale[1], so.scale[2]); // Apply translation vector glTranslatef(so.x, so.y, so.z); @@ -408,7 +406,6 @@ void display() { getTexture(so.texture); glBindTexture(GL_TEXTURE_2D, so.texture); } else { - getTexture(0); glBindTexture(GL_TEXTURE_2D, 0); } @@ -423,8 +420,9 @@ void display() { } glBindTexture(GL_TEXTURE_2D, 0); - } - glPopMatrix(); + glPopMatrix(); + } + // Draw a white ball over the light source glPushMatrix();