00001 #ifndef __GL_WINDOW_H__ 00002 #define __GL_WINDOW_H__ 00003 00004 00005 #include <ngl/Camera.h> 00006 #include <ngl/Colour.h> 00007 #include <ngl/TransformStack.h> 00008 #include <ngl/Text.h> 00009 #include <ngl/Light.h> 00010 #include "Environment.h" 00011 #include <QEvent> 00012 #include <QTime> 00013 #include <QResizeEvent> 00014 #include "Agent.h" 00015 00024 class GLWindow : public QGLWidget 00025 { 00026 Q_OBJECT // must include this if you use Qt signals/slots 00027 public : 00030 GLWindow(QWidget *_parent); 00032 ~GLWindow(); 00033 00035 void addParticles(); 00037 void clearParticles(); 00039 inline void toggleAnimation() { m_animate ^=true;} 00041 void inline resetObject(){ m_environment->resetObject();} 00043 void inline drawBox(){ m_environment->drawBox();} 00045 void inline startPong(){m_environment->startPong();} 00046 00047 //---------------------------------------------------------------------------------------------------------------------- 00048 void processKeyDown( 00049 QKeyEvent *_event 00050 ); 00051 //---------------------------------------------------------------------------------------------------------------------- 00055 //---------------------------------------------------------------------------------------------------------------------- 00056 void processKeyUp( 00057 QKeyEvent *_event 00058 ); 00059 00060 private : 00061 00063 int m_spinXFace; 00065 int m_spinYFace; 00067 bool m_rotate; 00069 int m_origX; 00071 int m_origY; 00073 //---------------------------------------------------------------------------------------------------------------------- 00074 int m_origXPos; 00075 //---------------------------------------------------------------------------------------------------------------------- 00077 //---------------------------------------------------------------------------------------------------------------------- 00078 int m_origYPos; 00079 //---------------------------------------------------------------------------------------------------------------------- 00081 ngl::Camera *m_cam; 00083 ngl::TransformStack m_transformStack; 00085 Environment *m_environment; 00087 ngl::Text *m_text; 00089 QTime currentTime; 00090 int m_updateTimer; 00091 bool m_animate; 00092 bool m_translate; 00093 ngl::Vec3 m_modelPos; 00094 ngl::Light m_light; 00095 ngl::Real m_lightAngle; 00096 int m_agentTimer; 00097 00098 00099 00100 protected: 00101 00104 void initializeGL(); 00105 00109 void resizeGL(const int _w, const int _h); 00110 00112 // be re-drawn 00113 void paintGL(); 00114 00115 00116 private : 00119 00120 void mouseMoveEvent (QMouseEvent * _event); 00124 00125 void mousePressEvent (QMouseEvent *_event); 00126 00130 void mouseReleaseEvent (QMouseEvent *_event); 00131 00133 void timerEvent(QTimerEvent *_event); 00134 00135 //---------------------------------------------------------------------------------------------------------------------- 00139 //---------------------------------------------------------------------------------------------------------------------- 00140 void wheelEvent( 00141 QWheelEvent *_event 00142 ); 00143 00144 void updateLight(); 00145 00146 00147 00148 00149 00150 }; 00151 00152 #endif