X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=54ef0d84ea2e0e5e256d95eb39185d418bb83827;hp=eefeec1d5359f35fc00e76105bc8f3af1d486845;hb=057887dfb66573803c3e127d47e88a29c02bd6f8;hpb=0bf9a194f13fd3e429d83da842d5107db8dbf967 diff --git a/scene.c b/scene.c index eefeec1..54ef0d8 100644 --- a/scene.c +++ b/scene.c @@ -307,9 +307,14 @@ void motion(int x, int y) { // w: left/right, h: near/far // **NOTE: Currently a work in progress, does not work correctly + float angler = 2 * M_PI * ( (rotate*camRotateFactor)/360.0 ); printf("cam angle: %f\n", rotate*camRotateFactor); - sceneObjs[curObject].x += diffx * sin(rotate*camRotateFactor); - sceneObjs[curObject].z += diffx * cos(rotate*camRotateFactor); + + sceneObjs[curObject].x += diffx * cos(angler) * 0.1; + sceneObjs[curObject].z += diffx * sin(angler) * 0.1; + + sceneObjs[curObject].x += diffy * sin(angler) * 0.1; + sceneObjs[curObject].z += diffy * cos(angler) * 0.1; } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { // w: big/small @@ -426,6 +431,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 +442,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 +466,6 @@ void display() { glBindTexture(GL_TEXTURE_2D, 0); glPopMatrix(); } - // Draw a white ball over the light sources glDisable(GL_LIGHTING);