Documentation


engine.h

Go to the documentation of this file.
00001 #ifndef ENGINE_H
00002 #define ENGINE_H
00003 
00004 #include <list>
00005 #include <float.h>
00006 #include <GL/glut.h>
00007 #include <animal/event/keyEvent.h>
00008 #include <animal/event/mouseEvent.h>
00009 #include <animal/picking.h>
00010 #include <animal/world.h>
00011 
00012 namespace animal {
00013 
00024 class Engine
00025 {
00026    public:
00027     
00029     Engine(): drawBBox(false), drawEngine(true), moveEngine(true), resetEngine(true){}
00030     
00032     virtual void init(){ reset(); }
00033     
00035     virtual void reset(){}
00037     virtual void postReset(){}
00038 
00040     virtual void move(double){}
00042     virtual void postMove(double){}
00043     
00045     virtual void draw(){}
00046     
00048     virtual void getBoundingBox( float & minX, float & minY, float & minZ,
00049                                  float & maxX, float & maxY, float & maxZ)
00050     {
00051       // FLT_MAX is defined in float.h
00052       minX=minY=minZ=1.0e+35;
00053       maxX=maxY=maxZ=-1.0e+35;
00054     }
00055     
00056     //====================== Mouse and key board events
00058     virtual void keyPressEvent(KeyEvent *){ }
00060     virtual void mouseDoubleClickEvent(MouseEvent * ){ }
00062     virtual void mouseMoveEvent(MouseEvent *){ }
00064     virtual void mousePressEvent(MouseEvent *){ }
00066     virtual void mouseReleaseEvent(MouseEvent *){ }
00067     // ----------  FF: picking -----------------------------
00069     virtual ConstrainedItem* pickPoint( float*, float*, float  ){ return 0; }
00070     // ----------  end FF: picking -----------------------------
00071     
00074     static World * world(){ return theWorld; }
00077     static void setWorld(World * w){ theWorld = w; }
00078     
00080     void drawBoundingBox()
00081     {
00082       if (drawBBox)
00083       {
00084         glPushAttrib(GL_ALL_ATTRIB_BITS);
00085           glDisable(GL_LIGHTING);
00086           float minX, minY, minZ, maxX, maxY, maxZ;
00087           getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
00088           glColor3d(1.0, 1.0, 1.0);
00089           glPushMatrix();
00090             glTranslatef((minX+maxX)/2.0, (minY+maxY)/2.0, (minZ+maxZ)/2.0);
00091             glScalef(maxX-minX, maxY-minY, maxZ-minZ);
00092             glutWireCube(1.0);
00093           glPopMatrix();
00094         glPopAttrib();
00095       }
00096     }
00097         
00098     //====================== Attributes
00100     bool drawBBox;
00102     bool drawEngine;
00104     bool moveEngine;
00106     bool resetEngine;
00107   
00108   private:
00112     static World * theWorld;
00113     
00114 };
00115 
00116 
00117 }  //namespace animal
00118 #endif //ENGINE_H
00119 
00120 

Generated on Thu Dec 23 13:52:24 2004 by doxygen 1.3.6