X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=9a803cbd3b401a9dfd0f1e847ace1a53a914a3fe;hp=eefeec1d5359f35fc00e76105bc8f3af1d486845;hb=78ee002d22bec0b0084d791e6f5146be4400bac0;hpb=0bf9a194f13fd3e429d83da842d5107db8dbf967 diff --git a/scene.c b/scene.c index eefeec1..9a803cb 100644 --- a/scene.c +++ b/scene.c @@ -153,8 +153,8 @@ void makeMenu() { // Construct light menu int lightMenu = glutCreateMenu(processLightEvents); glutAddMenuEntry("Move Light 1", M_LIGHT_MOVE_LIGHT_1); - glutAddMenuEntry("R/G/B/All Light 1", M_LIGHT_RGBALL_LIGHT_1); - glutAddMenuEntry("Move Light 2", M_LIGHT_MOVE_LIGHT_2); + //glutAddMenuEntry("R/G/B/All Light 1", M_LIGHT_RGBALL_LIGHT_1); + //glutAddMenuEntry("Move Light 2", M_LIGHT_MOVE_LIGHT_2); glutAddMenuEntry("R/G/B/All Light 2", M_LIGHT_RGBALL_LIGHT_2); // Construct object menu @@ -173,7 +173,7 @@ void makeMenu() { //glutAddSubMenu("Material", materialMenu); glutAddSubMenu("Texture", textureMenu); glutAddSubMenu("Ground texture", gTextureMenu); - //glutAddSubMenu("Lights", lightMenu); + glutAddSubMenu("Lights", lightMenu); glutAddMenuEntry("Exit", M_EXIT); // Bind to right mouse button @@ -305,11 +305,9 @@ void motion(int x, int y) { if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far - - // **NOTE: Currently a work in progress, does not work correctly - printf("cam angle: %f\n", rotate*camRotateFactor); - sceneObjs[curObject].x += diffx * sin(rotate*camRotateFactor); - sceneObjs[curObject].z += diffx * cos(rotate*camRotateFactor); + float angler = 2 * M_PI * ( (rotate*camRotateFactor)/360.0 ); + sceneObjs[curObject].x += diffx * cos(angler) * leftrightFactor + diffy * cos(M_PI/2 + angler) * nearfarFactor; + sceneObjs[curObject].z += diffx * sin(angler) * leftrightFactor + diffy * sin(M_PI/2 + angler) * nearfarFactor; } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { // w: big/small @@ -426,6 +424,9 @@ void display() { glPushMatrix(); SceneObject so = sceneObjs[i]; + // Apply translation vector + glTranslatef(so.x, so.y, so.z); + // Apply independant rotation vectors glRotatef(so.rotation.x, 1.0, 0.0, 0.0); glRotatef(so.rotation.y, 0.0, 1.0, 0.0); @@ -434,9 +435,6 @@ void display() { // Apply scaling vector glScalef(so.scale[0], so.scale[1], so.scale[2]); - // Apply translation vector - glTranslatef(so.x, so.y, so.z); - // Apply texture if ( so.texture.id > 0 ) { getTexture(so.texture.id); @@ -461,7 +459,6 @@ void display() { glBindTexture(GL_TEXTURE_2D, 0); glPopMatrix(); } - // Draw a white ball over the light sources glDisable(GL_LIGHTING); @@ -469,12 +466,12 @@ void display() { glPushMatrix(); glTranslatef(lightPosition0[0], lightPosition0[1], lightPosition0[2]); - glutSolidSphere(0.5, 50, 50); + glutSolidSphere(lightBallSize, 20, 20); glPopMatrix(); glPushMatrix(); glTranslatef(lightPosition1[0], lightPosition1[1], lightPosition1[2]); - glutSolidSphere(0.5, 50, 50); + glutSolidSphere(lightBallSize, 20, 20); glPopMatrix(); glEnable(GL_LIGHTING);