#ifndef GAMEOBJECT_H_
#define GAMEOBJECT_H_
#include <OgreSceneManager.h>
#include <OgreEntity.h>
#include <OgreFrameListener.h>
#include <OgreString.h>
class Ball;
class Wall;
class Paddle;
class Block;
class GameObject {
public:
static const Ogre::Real HEIGHT = 1;
static unsigned int s_id;
GameObject();
virtual ~GameObject();
/**
* Initialize the game object so it can be used as part of a scene.
* This method will most likely be called when you create a scene.
* Only call this method once for an object.
*
* Parameters:
* sceneMgr: the scene manager to add to
* name: the name of the new object
* position: where to place this object
* mesh: the name of the mesh to use with this object
* material: (optional) the name of the material to be used with
* this object
*
*/
virtual void init(Ogre::SceneManager *sceneMgr,
Ogre::String name,
Ogre::Vector3 position,
Ogre::String mesh,
Ogre::String material = "");
/**
* Update the game object in the scene.
* This method will most likely be called when the rest of the
* scene is updated e.g. from the frameRenderingQueued method.
*
* Parameters:
* evt: The frame event sent for the update.
*
* Returns false if the object has removed itself from the scene and
* needs to be removed from the game.
*/
virtual bool update(const Ogre::FrameEvent& evt);
/**
* Returns true if this object has been initialized.
*/
virtual bool isInitialized();
/**
* Get this objects direction vector as a reference.
*
* The fact that it returns a reference means that the
* method call can be used to change the stored direction.
*
*/
virtual Ogre::Vector3 &getDirection();
/**
* Set this object's direction.
*
* Parameter:
* direction: the new direction for this object
*/
virtual void setDirection(Ogre::Vector3 direction);
/**
* Set whether or not this object is selected.
*
* Parameter:
* select: if true select the object, if false deselect it.
*/
virtual void setSelected(bool select);
/**
* Return true if this object is selected, false otherwise
*/
virtual bool isSelected();
/**
* Return the name of this object.
*/
virtual Ogre::String getName();
/**
* Return the name of this object's Entity.
*/
virtual Ogre::String getEntityName();
/**
* Return the name of this object's SceneNode.
*/
virtual Ogre::String getNodeName();
/**
* Return the unique id of this object
*/
virtual unsigned int getId();
/**
* Get the scaled bounding box for this object
*/
virtual Ogre::AxisAlignedBox getTransformedBoundingBox();
/**
* Move one step back. This will undo a collision.
*/
virtual void stepBack();
virtual Ogre::uint32 getQueryFlag();
virtual void setInScene(bool in);
virtual bool getInScene();
virtual Ogre::Entity *getEntity();
virtual Ogre::SceneNode *getSceneNode();
virtual Ogre::Real getSpeed();
virtual void setSpeed(Ogre::Real speed);
virtual Ogre::Vector3 getPosition();
virtual void setPosition( Ogre::Vector3 pos);
virtual void collidesWith(GameObject *hit, bool useDir = false,
Ogre::Vector3 dir = Ogre::Vector3::ZERO);
virtual void collidesWithBall(Ball *hit, bool useDir = false,
Ogre::Vector3 dir = Ogre::Vector3::ZERO);
virtual void collidesWithWall(Wall *hit, bool useDir = false,
Ogre::Vector3 dir = Ogre::Vector3::ZERO);
virtual void collidesWithPaddle(Paddle *hit, bool useDir = false,
Ogre::Vector3 dir = Ogre::Vector3::ZERO);
virtual void collidesWithBlock(Block *hit, bool useDir = false,
Ogre::Vector3 dir = Ogre::Vector3::ZERO);
virtual void dumpInfo();
protected:
virtual Ogre::String getIdString();
/**
* A pointer to the SceneManager object to which this object belongs.
*/
Ogre::SceneManager *m_sceneMgr;
/**
* A pointer to the Entity object representing the geometry in the scene graph.
*/
Ogre::Entity *m_entity;
/**
* A pointer to the SceneNode object representing the transforms in the scene graph.
*/
Ogre::SceneNode *m_node;
Ogre::String m_name;
/**
* Indicates the object has been initialized so it can be used in a scene.
*/
bool m_isInitialized;
/**
* Indicates the object is selected.
*/
bool m_isSelected;
/**
* Indicates the direction this object should be moving
*/
Ogre::Vector3 m_direction;
Ogre::Vector3 m_position;
Ogre::Vector3 m_oldPosition;
Ogre::uint32 m_queryFlag;
unsigned int m_id;
bool m_isInScene;
Ogre::Real m_speed;
};
#endif