X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=8ce005bade04a86858131ec1ddd995dd027dc1bb;hb=9ef3cb688ee424d11b9b9549ec3cb3dac29334c4;hp=de52ab893e4877ecc94830012c10a9543b9658a8;hpb=71a79323a397f78dba55423678096176a98106cb;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index de52ab8..8ce005b 100644 --- a/scene.c +++ b/scene.c @@ -226,6 +226,30 @@ void mouse(int button, int state, int x, int y) { } } +void keyboard(unsigned char key, int x1, int y1) { + switch(key) { + case 'w': + z = z - 1; + break; + case 'a': + x = x - 1; + break; + case 's': + z = z + 1; + break; + case 'd': + x = x + 1; + break; + case 'q': + y = y + 1; + break; + case 'e': + y = y - 1; + break; + } + printf("Camera is now at (%f, %f, %f)\n", x, y, z); +} + /** * Called when motion event occurs * @param x Mouse x position @@ -260,7 +284,8 @@ void display() { 0.0, 1.0, 0.0 /* up is in postivie Y direction */ ); - + glTranslatef(x, y, z); + // **NOTE: Currently this rotation function is all that moves the camera off // the flat surface. Need to integrate function into gluLookAt glRotatef(30.0, 1.0, 0.0, 0.0); @@ -314,8 +339,8 @@ void init() { gluPerspective( 60.0, /* field of view in degree */ 1.0, /* aspect ratio */ - near, /* Z near */ - far /* Z far */ + nearClip, /* Z near */ + farClip /* Z far */ ); glMatrixMode(GL_MODELVIEW); @@ -376,6 +401,7 @@ int main(int argc, char **argv) { //glutReshapeFunc(windowReshape); glutDisplayFunc(display); glutMouseFunc(mouse); + glutKeyboardFunc(keyboard); glutMotionFunc(motion); makeMenu();