X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=cf969764d25b892d4d766b92d800c07819d656be;hp=c62831e33f41fb3e816b3ed6c23794ba4818a738;hb=bf419bc7b47235edddd11094230ed0f02cf5d8c7;hpb=9e42797448ba7fc0349cc275baec55230e595a26 diff --git a/scene.c b/scene.c index c62831e..cf96976 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); @@ -206,6 +204,8 @@ void mouse(int button, int state, int x, int y) { } else if ( state == GLUT_UP ) { buttonSelected = -1; } + startx = x; + starty = y; break; } } @@ -285,7 +285,6 @@ void motion(int x, int y) { if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: rotate, h: zoom zoom += (y - starty); - printf("zoom is %f\n", zoom); } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { // w: rotate, h: tilt camAngle += (y - starty); @@ -386,27 +385,24 @@ 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]); + //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]); + //glScalef(so.scale[0], so.scale[1], so.scale[2]); // Apply translation vector - glTranslatef(so.x, so.y, so.z); + //glTranslatef(so.x, so.y, so.z); // Apply texture if ( so.texture > 0 ) { getTexture(so.texture); glBindTexture(GL_TEXTURE_2D, so.texture); } else { - getTexture(0); glBindTexture(GL_TEXTURE_2D, 0); } @@ -421,8 +417,9 @@ void display() { } glBindTexture(GL_TEXTURE_2D, 0); - } - glPopMatrix(); + glPopMatrix(); + } + // Draw a white ball over the light source glPushMatrix();