From: Ash Tyndall Date: Sat, 22 Oct 2011 07:09:38 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=commitdiff_plain;h=df4a1058cbb4a92922dd61c514c827392ba1330e;ds=sidebyside --- diff --git a/scene.c b/scene.c index d047289..42b717c 100644 --- a/scene.c +++ b/scene.c @@ -87,7 +87,7 @@ void processMaterialEvents(int id) { void processLightEvents(int id) { switch (id) { case M_LIGHT_MOVE_LIGHT_1: - // Do stuff + manipulateState = STATE_LIGHT_1_MOVE; break; case M_LIGHT_RGBALL_LIGHT_1: @@ -95,7 +95,7 @@ void processLightEvents(int id) { break; case M_LIGHT_MOVE_LIGHT_2: - // Do stuff + manipulateState = STATE_LIGHT_2_MOVE; break; case M_LIGHT_RGBALL_LIGHT_2: @@ -346,6 +346,24 @@ void motion(int x, int y) { break; + case STATE_LIGHT_1_MOVE: + case STATE_LIGHT_2_MOVE:; + + int i = 0; + if ( manipulateState == STATE_LIGHT_2_MOVE ) i = 1; + + if ( buttonSelected == GLUT_LEFT_BUTTON ) { + float angler = 2 * M_PI * ( (rotate*camRotateFactor)/360.0 ); + lightObjs[i].position[0] += diffx * cos(angler) * leftrightFactor + diffy * cos(M_PI/2 + angler) * nearfarFactor; + lightObjs[i].position[2] += diffx * sin(angler) * leftrightFactor + diffy * sin(M_PI/2 + angler) * nearfarFactor; + + + } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { + + } + + break; + } starty = y; @@ -389,21 +407,6 @@ void display() { glRotatef(camAngle*camAngleFactor, 1.0, 0.0, 0.0); // Set camera angle upward - /* Reposition the light source 0. */ - lightObjs[0].position[0] = 4; - lightObjs[0].position[1] = 5; - lightObjs[0].position[2] = 6;//12*sin(0); - lightObjs[0].position[3] = 0.0; - - /* Reposition the light source 1. */ - lightObjs[1].position[0] = -4; - lightObjs[1].position[1] = 5; - lightObjs[1].position[2] = -6;//12*sin(90); - lightObjs[1].position[3] = 0.0; - - //direction0[0] = lightPosition0[0]; - //direction0[2] = lightPosition0[2]; - glPushMatrix(); /* Perform scene rotations based on user mouse/keyboard input. */ @@ -509,5 +512,17 @@ int main(int argc, char **argv) { initializeLights(); + /* Initial light 0 position. */ + lightObjs[0].position[0] = 4; + lightObjs[0].position[1] = 5; + lightObjs[0].position[2] = 6; + lightObjs[0].position[3] = 0.0; + + /* Initial light 1 position. */ + lightObjs[1].position[0] = -4; + lightObjs[1].position[1] = 5; + lightObjs[1].position[2] = -6; + lightObjs[1].position[3] = 0.0; + glutMainLoop(); } \ No newline at end of file diff --git a/types.h b/types.h index 56cb1fa..e18c6f4 100644 --- a/types.h +++ b/types.h @@ -94,7 +94,9 @@ enum menu { enum manipulateStates { STATE_CAMERA_ROTATE_MOVE, STATE_OBJECT_POSITION_SCALE, - STATE_OBJECT_ROTATION_TEXTURE_SCALE + STATE_OBJECT_ROTATION_TEXTURE_SCALE, + STATE_LIGHT_1_MOVE, + STATE_LIGHT_2_MOVE, }; #endif /* TYPES_H */ \ No newline at end of file