void special(int special_key, int x, int y) { switch(special_key) { case GLUT_KEY_RIGHT: camera.setYaw(-0.1); break; case GLUT_KEY_LEFT: camera.setYaw(0.1); break; case GLUT_KEY_UP: camera.setPitch(0.1); break; case GLUT_KEY_DOWN: camera.setPitch(-0.1); break; case GLUT_KEY_END: camera.reset(); break; } }
void update() { if (key_pressed[' ']) { camera.moveForward(MOVE_SPEED); } if (key_pressed['w'] || key_pressed['W']) { camera.moveUp(MOVE_SPEED); } if (key_pressed['a'] || key_pressed['A']) { camera.moveLeft(MOVE_SPEED); } if (key_pressed['s'] || key_pressed['S']) { camera.moveDown(MOVE_SPEED); } if (key_pressed['d'] || key_pressed['D']) { camera.moveRight(MOVE_SPEED); } if (key_pressed['h']) { Vector3 origin = Vector3::ZERO; Vector3 direction_to_origin; direction_to_origin = origin - camera.getPosition(); camera.rotateToVector(direction_to_origin, THETA); } if (key_pressed[','] || key_pressed['<']) { camera.setRoll(THETA); } if (key_pressed['.'] || key_pressed['>']) { camera.setRoll(-THETA); } if (key_pressed['/'] || key_pressed['?']) { camera.moveBackward(MOVE_SPEED); } if (special_key_pressed[GLUT_KEY_RIGHT]) { camera.setYaw(-THETA); } if (special_key_pressed[GLUT_KEY_LEFT]) { camera.setYaw(THETA); } if (special_key_pressed[GLUT_KEY_UP]) { camera.setPitch(THETA); } if (special_key_pressed[GLUT_KEY_DOWN]) { camera.setPitch(-THETA); } sleep(1.0 / 60.0); glutPostRedisplay(); }