X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=9c6d0c4d690359025dc245a7508a0def863b6259;hp=a988ca8181184aef170a5d173b519e59282fa749;hb=bf3cf131a6c4b18ca07a2a85156c063ff3bdcd04;hpb=9474fe66d5e0a92856c91ea19d53edac236c443c diff --git a/scene.c b/scene.c index a988ca8..9c6d0c4 100644 --- a/scene.c +++ b/scene.c @@ -226,28 +226,37 @@ void mouse(int button, int state, int x, int y) { } } -void keyboard(unsigned char key, int x1, int y1) { +/** + * Keybord event handler + * w/s increase/decrease the z + * a/d increase/decrease the x + * q/e increase/decrease the y + * @param key Key pressed + * @param x x co-ordinate of mouse + * @param y y co-ordinate of mouse + */ +void keyboard(unsigned char key, int x, int y) { switch(key) { case 'w': - z = z - 1; + camz = camz - 1; break; case 'a': - x = x - 1; + camx = camx - 1; break; case 's': - z = z + 1; + camz = camz + 1; break; case 'd': - x = x + 1; + camx = camx + 1; break; case 'q': - y = y + 1; + camy = camy + 1; break; case 'e': - y = y - 1; + camy = camy - 1; break; } - printf("Camera is now at (%f, %f, %f)\n", x, y, z); + printf("Camera is now at (%f, %f, %f)\n", camx, camy, camz); glutPostRedisplay(); } @@ -282,10 +291,10 @@ void display() { gluLookAt( 0.0, 0.0, 10.0, /* eye is at (x,y,z) */ 0.0, 0.0, 0.0, /* center is at (x,y,z) */ - 0.0, 1.0, 0.0 /* up is in postivie Y direction */ + 0.0, -1.0, 0.0 /* up is in postivie Y direction */ ); - glTranslatef(x, y, z); + glTranslatef(camx, camy, camz); // **NOTE: Currently this rotation function is all that moves the camera off // the flat surface. Need to integrate function into gluLookAt