//**************************************************************************** //! \file engine.hpp //! \date 12-02-2003 //! \class GLView //! \brief The engine of the Weird Demo //! \struct Tcoord //! \brief the koordinates phasespace //! \struct TGLObject //! \brief derifed struct designed to contain GL Object lists //! \struct TGLLight //! \brief derived struct designed to contain GL Lights //**************************************************************************** // This file is part of the Weird Demo. // // The Weird Demo is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // The Weird Demo is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with DataView; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //**************************************************************************** #ifndef ENGINE_HPP #define ENGINE_HPP #include #include #include #include #include #include #include static const double P2 = 18/M_PI; static const double P3 = 180/M_PI; using namespace std; //*************************************************************************** struct Tcoord //---------------------------------------------------------------------------- //! base class for all object characterisation structs; containing coordinates, //! the speed vector, the eulerian angles und the rotation vector //! used as Camera coordinate container //! \todo get rid of the double coordinate representation and introduce vectors //*************************************************************************** { double x;//!< the position x coordinate double y;//!< the position y coordinate double z;//!< the position z coordinate double vx;//!< the position x speed coordinate double vy;//!< the position y speed coordinate double vz;//!< the position z speed coordinate double ax;//!< the position euler angle around x axis double ay;//!< the position euler angle around y axis double az;//!< the position euler angle around z axis double vax;//!< the position rotation speed around x axis double vay;//!< the position rotation speed around y axis double vaz;//!< the position rotation speed around z axis //! \brief The constructor //! \param ix the position x coordinate //! \param iy the position y coordinate //! \param iz the position z coordinate //! \param ivx the position x speed coordinate //! \param ivy the position y speed coordinate //! \param ivz the position z speed coordinate //! \param iax the position euler angle around x axis //! \param iay the position euler angle around y axis //! \param iaz the position euler angle around z axis //! \param ivax the position rotation speed around x axis //! \param ivay the position rotation speed around y axis //! \param ivaz the position rotation speed around z axis Tcoord( double ix, double iy, double iz, double ivx, double ivy, double ivz, double iax, double iay, double iaz, double ivax, double ivay, double ivaz) : x( ix), y( iy), z( iz), vx( ivx), vy( ivy), vz( ivz), ax( iax), ay( iay), az( iaz), vax( ivax), vay( ivay), vaz( ivaz) { } }; //*************************************************************************** struct TGLObject : public Tcoord //---------------------------------------------------------------------------- //! class for GL display list characterisation //! \todo get rid of the double coordinate representation and introduce vectors //*************************************************************************** { unsigned int *obj;//!< pointer to the GL display List represented by the TGLObject //! \brief The constructor //! \param io pointer to the GL List represented by the TGLObject //! \param ix the position x coordinate //! \param iy the position y coordinate //! \param iz the position z coordinate //! \param ivx the position x speed coordinate //! \param ivy the position y speed coordinate //! \param ivz the position z speed coordinate //! \param iax the position euler angle around x axis //! \param iay the position euler angle around y axis //! \param iaz the position euler angle around z axis //! \param ivax the position rotation speed around x axis //! \param ivay the position rotation speed around y axis //! \param ivaz the position rotation speed around z axis TGLObject( unsigned int *io, double ix, double iy, double iz, double ivx, double ivy, double ivz, double iax, double iay, double iaz, double ivax, double ivay, double ivaz) : Tcoord( ix, iy, iz, ivx, ivy, ivz, iax, iay, iaz, ivax, ivay, ivaz), obj( io) { } }; //*************************************************************************** struct TGLLight : public Tcoord //---------------------------------------------------------------------------- //! class for GL lights characterisation //! \todo get rid of the double coordinate representation and introduce vectors //*************************************************************************** { GLenum id; //! ois; vector::iterator itois; vector lights; vector::iterator itlights; vector shades; vector:: iterator itshades; map textures; //! \brief overloaded member function inherited from QGLWidget sets up all OpenGL related stuff virtual void initializeGL(); //! \brief overloaded member function inherited from QGLWidget handles everything when resizing comes to term //! \param w new window width //! \param h new window height void resizeGL( const int w, const int h); //! \brief overloaded member function inherited from QGLWidget does the actual drawing void paintGL(); //! \brief mouse key response void mousePressEvent( QMouseEvent *); //! \brief mouse move response (e.g. scrolling or zooming) void mouseMoveEvent( QMouseEvent *); //! \brief mouse release -> return to normal state void mouseReleaseEvent( QMouseEvent *); //! \brief response to key events needed for moving of reference point void keyPressEvent( QKeyEvent *); //! \brief to be overwritten in derived classes for Key events virtual void evKeyPress( QKeyEvent *) {}; //! \brief timer for the demo void timerEvent( QTimerEvent *); //! This function acts as a kind of film script for the demo //! \brief this is the function that actually directs the demo virtual void director() {}; //! \brief moves the lights according to their velocities (actually no need to overload) virtual void adjustLights() {}; //! \brief moves the camera according to its velocities (actually no need to overload either) virtual void adjustCamera() {}; //! \brief moves the objects in the scene according to their velocities virtual void adjustScene() {}; //! \brief makes if activated the objects shadows //! \attention only support for non rotating cubes till now virtual void makeShades() {}; virtual void makeCont() {}; private: void initMoving( bool esc = false); void moveCursor( QMouseEvent *); // object making functions void makeCursor(); void makeAxes(); void makeGrid(); bool axis; bool doscr; //!< mouse scroll enabled bool dozoo; //!< mouse zoom enabled bool domoo; //!< mouse move enabled unsigned int mcursor; GLUquadricObj *quadratic; //!< used for displaying a sphere (e.g. cursor in move function) int timerID; //!< ID of the timer used to control the replay speed int timeIndex; //!< what time it is (during the replay) int timeIntervall; //!< intervall of the timer id est replay speed GLfloat xm, ym, zm; double zoom; //!< speed factor of mouse zoom bool lbut, rbut, showGrid; int curs, curs2; QPoint cPos, cPos2, GPoint; double Rx, Ry, Rz, cx1, cy1, cursx, cursy, cursz, cxh, cyh; }; #endif