#include #include "vgl.h" #include "CameraClass.h" extern float theta_G; extern GLfloat worldRotateX_G, worldRotateY_G, worldRotateZ_G; extern void reset(void); extern void DoProjection(); extern bool ortho_G; extern CameraClass camera_G; using namespace std; void SpecialKeypress(int key, int x, int y) { if(camera_G.SpecialKeypress(key)) { glutPostRedisplay(); } return; } void KeyUp(unsigned char key, int x, int y) { return; } void SpecialUp(int key, int x, int y) { return; } bool DoAnimation = false; int delay = 1000/60; void Animate(int value) { theta_G += 0.5; if(DoAnimation) { glutTimerFunc(delay, Animate,0); } glutPostRedisplay(); return; } void StartAnimation() { glutTimerFunc(delay, Animate,0); DoAnimation = true; return; } void StopAnimation() { DoAnimation = false;; return; } void KeyHelp() { cout << endl; cout << "Keys " << endl; cout << "\tm\tStart Animation" << endl; cout << "\tM\tStop Animation" << endl; cout << "\tw\tAdd a wheel" << endl; cout << "\tq,Q\tQuit" << endl; cout << "\th,?\tHelp" << endl; cout << "\txX,yY,zZ\t +/- rotation about axis" << endl; cout << "\tr\treset" << endl; cout << "\tR\tRedisplay" << endl; camera_G.Usage(); cout << endl; return; } void Keypress(unsigned char key, int x, int y) { static int state = 1; bool redisplay = false; if (camera_G.Keypress(key)) { redisplay = true; } else { switch (key) { case 'm': StartAnimation(); break; case 'M': StopAnimation(); break; case 'h': case '?': KeyHelp(); break; case 'p': ortho_G = !ortho_G; DoProjection(); redisplay= true; break; case 'x': worldRotateX_G += 1; redisplay=true; break; case 'X': worldRotateX_G -= 1; redisplay=true; break; case 'y': worldRotateY_G += 1; redisplay=true; break; case 'Y': worldRotateY_G -= 1; redisplay=true; break; case 'z': worldRotateZ_G += 1; redisplay=true; break; case 'Z': worldRotateZ_G -= 1; redisplay=true; break; case 'Q': case 'q': exit(0); case 'r': reset(); redisplay=true; break; case 'R': redisplay = true; break; } } if (redisplay) { glutPostRedisplay(); } return; }