X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=57803e56aa52f479d83ef5b7066fece38a930337;hp=99ccfa0b902ca7fdbc6102addaf2b1708302d733;hb=d0f6e6b044c64e148d5a699a66b49fecdb8b37a9;hpb=7862999a5314cfc2b287d719e3d2dde05df21ae8 diff --git a/scene.c b/scene.c index 99ccfa0..57803e5 100644 --- a/scene.c +++ b/scene.c @@ -305,12 +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); - // float arc = arctan() - 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