//////////////////////////////////////////////////////////////////////////////// // spinningCubeEngine.h // //////////////////////////////////////////////////////////////////////////////// #ifndef SPINNING_CUBE_ENGINE_H #define SPINNING_CUBE_ENGINE_H #include #include namespace animal{ /// This is a simple engine in order to show how to use AnimAL engines, and /// events. This engine makes an object, more precisely a cube, turn around /// the z axe: move(dt). It can be init and drawn: init() and draw(). /// The position of the object and the angular velocity can be set. class SpinningCubeEngine : public Engine { public : SpinningCubeEngine(); //=============================================================== /** @name Virtual methods */ //@{ /// Initialize the positions virtual void reset(); /// Move the object virtual void move(double dt); /// Draw the object virtual void draw(); /// Compute the bounding box of the object virtual void getBoundingBox( float & minX, float & minY, float & minZ, float & maxX, float & maxY, float & maxZ); //====================== Mouse and key board events /// Deal with key press event. virtual void keyPressEvent(KeyEvent *e); /// Deal with mouse double-click event. virtual void mouseDoubleClickEvent(MouseEvent * e); /// Deal with mouse move event. virtual void mouseMoveEvent(MouseEvent * e); /// Deal with mouse press event. virtual void mousePressEvent(MouseEvent * e); /// Deal with mouse release event. virtual void mouseReleaseEvent(MouseEvent * e); //@} //================================================================ //====================== Getters /// Get the angular velocity (Rad/s) float * getAngularVelocity(){ return & angularVelocity; } //====================== Setters /// Set the angular velocity (Rad/s) void setAngularVelocity(float v){ angularVelocity = v;} public: // Attributes /// The angular velocity (Rad/s) float angularVelocity; private: /// The rotation angle around the z axe float rotation_z; /// The size of the object which is a cube float cubeSize; }; }//namespace animal #endif