Artificial Intelligence
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends

GamePipe::AIAgent Class Reference

AI Agent class. Represents an AI which is binded to Lua, Havok, and Havok/Ogre animations. More...

#include <AIAgent.h>

Inheritance diagram for GamePipe::AIAgent:
OpenSteer::SimpleVehicle

List of all members.

Public Member Functions

 AIAgent (Ogre::String, GraphicsObject *, PhysicsObject *, AnimationManager::AnimatedEntity *)
 AI Agent constructor.
virtual ~AIAgent ()
 AIAgent destructor.
void addDestination (Ogre::Vector3)
void addType (int)
 Adds a type to the current AI's type.
void addTypes (unsigned long)
 Add multiple types at once to the AI's type.
Ogre::Vector3 getDestination ()
 Returns the destination the AIAgent is attempting to reach.
int getKnownLuaStackSize ()
 Returns the known Lua stack size.
Ogre::Real getMaxLinearSpeed ()
 Returns the max speed of the agent.
Ogre::String getName ()
 Returns the name of the agent.
Ogre::Vector3 getPosition ()
 Returns the position of the AIAgent.
unsigned long getType ()
 Returns a unsigned long representing 64 possible types the AI may be unsigned long to. Each toggled bit of the unsigned long represent a different type.
std::vector< int > getTypes ()
 Convenience method to return a vector of ints representing each of the types the AI beunsigned longs to.

Returns:
Vector of ints ranging from 1 to 64, otherwise a vector containing the int 0 representing that the AI is not part of any type. </return>

void initialize ()
 Initialize the AIAgent, called when the scene is initialized.
void initializeLua ()
 Initialize the Lua stack.
bool isDebug ()
 Return whether debug information is being shown.
void reloadLua ()
 Reloads the lua stack based on the lua filename.
void setDestination (Ogre::Vector3)
 Sets the position the AIAgent will attempt to reach.
void setDebug (bool)
 Set whether to show debug information about the AI Agent.
void setDebugText (Ogre::String)
 Sets the debug text that hovers above the AI Agent.
void setMaxLinearSpeed (Ogre::Real)
 Sets the max linear speed the AI Agent may move at.
void setName (Ogre::String)
 Sets the AI name.
void setType (int)
 Overrides the current type of the AI.
void setTypes (unsigned long)
 Overrides the current types of the AI.
void update (const float, const float)
 Update loop called during each update loop.
bool setDefautAnimation (Ogre::String defaultAnimName)
 Set the default animation.
Ogre::String getDefaultAnimation ()
 Get the name of the default animation.
bool playAnimation (Ogre::String newAnimName, bool loop, Ogre::String transitionAnimation="")
 Play the current animation.
bool stopAnimation ()
 stop the current animation
std::vector< std::string > getAnimations ()
 return names of all the animations this agent has
bool setBlendFrame (float blendFrame)
 set the default number of frames used when blending animations
float getBlendFrame ()
 return the default number of frames used when blending animations
Ogre::String getActiveAnimation ()
 get current active animation
void setSeekTarget (Ogre::Vector3 seekTarget)
 Sets the Seek Target.
void setFleeTarget (Ogre::Vector3 fleeTarget)
 Sets the Flee Target.
void setArriveTarget (Ogre::Vector3 arriveTarget)
 Sets the Arrive Target.
void setOnBehaviors (Ogre::String name)
 Switching ON the behaviors.
void reset (void)
float mass (void) const
float setMass (float m)
Vec3 velocity (void) const
float speed (void) const
float setSpeed (float s)
float radius (void) const
float setRadius (float m)
float maxForce (void) const
float setMaxForce (float mf)
float maxSpeed (void) const
float setMaxSpeed (float ms)
float relativeSpeed (void) const
void applySteeringForce (const Vec3 &force, const float deltaTime)
virtual void regenerateLocalSpace (const Vec3 &newVelocity, const float elapsedTime)
void regenerateLocalSpaceForBanking (const Vec3 &newVelocity, const float elapsedTime)
virtual Vec3 adjustRawSteeringForce (const Vec3 &force, const float deltaTime)
void applyBrakingForce (const float rate, const float deltaTime)
Vec3 predictFuturePosition (const float predictionTime) const
float curvature (void) const
float smoothedCurvature (void)
float resetSmoothedCurvature (float value=0)
Vec3 smoothedAcceleration (void)
Vec3 resetSmoothedAcceleration (const Vec3 &value=Vec3::zero)
Vec3 smoothedPosition (void)
Vec3 resetSmoothedPosition (const Vec3 &value=Vec3::zero)
void annotationVelocityAcceleration (float maxLengthA, float maxLengthV)
void annotationVelocityAcceleration (float maxLength)
void annotationVelocityAcceleration (void)
void randomizeHeadingOnXZPlane (void)

Public Attributes

GraphicsObject * m_graphicsObject
 Graphics rendering object, may be null.
PhysicsObject * m_physicsObject
 Physics object, may be null.
AnimationManager::AnimatedEntity * m_animationEntity
 Animation object, may be null.
CollisionListener * m_collisionListener
 Phantom Shape object, may be null.
SteeringBehaviorm_steeringBehavior
 Steering Behavior.
AIAgentManagerm_aiAgentManger
 The AIAgentManager the agent belongs to. This may be null if the AI is not part of any AIAgentManager. This is only set by the AIAgentManager when the AI is added to it.
Ogre::Vector3 m_velocity
 Velocity of the AI Agent.
Ogre::Vector3 m_vHeading
 Heading of the AI Agent.
Ogre::Vector3 m_vSide
 Side Component of the AI Agent.
double m_dTimeElapsed
 Time Elapsed each update func call of the AI Agent.
double m_dMaxForce
double m_dMaxTurnRate
OpenSteer::AVGroupobstacles
int serialNumber

Static Public Attributes

static int serialNumberCounter = 0

Protected Attributes

bool m_debug
 The AIAgentManager the agent belongs to. This may be null if the AI is not part of any AIAgentManager. This is only set by the AIAgentManager when the AI is added to it.
std::list< DebugObject * > * m_debugObjects
 Debug graphic objects.
std::list< Ogre::SceneNode * > * m_debugPathNodes
 Nodes used for debugging purposes only.
std::list< DebugObject * > * m_debugPathObjects
Ogre::SceneNode * m_debugDestNode
DebugObjectm_text
DebugObjectm_debugDest
DebugObjectm_debugSelf
Ogre::Vector3 m_destination
 Destination the AI is attempting to reach, may be the AI's current position if the AI has no current destination.
Ogre::LogManager * m_log
Ogre::String m_luaFileName
 Filename of the lua script.
lua_State * m_luaVM
 Lua state, represents the interface between this AI Agent and Lua.
bool m_luaInitilize
int m_luaStackSize
Ogre::Real m_maxSpeed
Ogre::String m_name
 Name of the AI Agent.
Ogre::Vector3 m_position
 Position of the AI, updated every update call. Based off of physics if present, otherwise based off the graphics if present, otherwise kept internally by the AI Agent.
Ogre::String m_state
 Current state the AI is in.
unsigned long m_type
 Type/Types which this AI Agent is a part of. Each toggled bit represents a different type the AI is. The maximum.

Private Member Functions

void bindAI ()
 Binds the AI to the Lua stack.

Private Attributes

Ogre::Vector3 m_moveTo
 this member stores the direction the AIAgent is moving to now
float m_blendFrame
 The number of frames used when blending the animation.
bool m_remove
 Flag to remove the AI. The AI stops updating if true.

Static Private Attributes

static TextFileManager * m_tfm
 Text file manager which is used to load in Lua scripts.

Friends

class AIAgentManager

Detailed Description

AI Agent class. Represents an AI which is binded to Lua, Havok, and Havok/Ogre animations.

<author>David Young dayoung@goliathdesigns.com</author>


Constructor & Destructor Documentation

AIAgent::AIAgent ( Ogre::String  fileName,
GraphicsObject *  graphics,
PhysicsObject *  havok,
AnimationManager::AnimatedEntity *  animation 
)

AI Agent constructor.

Parameters:
fileNameLua script file
graphicsOgre renderable graphics object
havokHavok physics object
animationGeneric animation object
AIAgent::~AIAgent ( ) [virtual]

AIAgent destructor.


Member Function Documentation

void GamePipe::AIAgent::addDestination ( Ogre::Vector3  )
void AIAgent::addType ( int  type)

Adds a type to the current AI's type.

Parameters:
typeRepresents a number from 1 to 64 specifying which bit the new type is.
void AIAgent::addTypes ( unsigned long  types)

Add multiple types at once to the AI's type.

Parameters:
typesMultiple types indicated by 1 bits.
OpenSteer::Vec3 OpenSteer::SimpleVehicle::adjustRawSteeringForce ( const Vec3 force,
const float  deltaTime 
) [virtual, inherited]
void OpenSteer::SimpleVehicle::annotationVelocityAcceleration ( void  ) [inline, inherited]
void OpenSteer::SimpleVehicle::annotationVelocityAcceleration ( float  maxLengthA,
float  maxLengthV 
) [inherited]
void OpenSteer::SimpleVehicle::annotationVelocityAcceleration ( float  maxLength) [inline, inherited]
void OpenSteer::SimpleVehicle::applyBrakingForce ( const float  rate,
const float  deltaTime 
) [inherited]
void OpenSteer::SimpleVehicle::applySteeringForce ( const Vec3 force,
const float  deltaTime 
) [inherited]
void AIAgent::bindAI ( ) [private]

Binds the AI to the Lua stack.

float OpenSteer::SimpleVehicle::curvature ( void  ) const [inline, inherited]
Ogre::String AIAgent::getActiveAnimation ( )

get current active animation

Returns:
Returns the name of the active animation.
std::vector< std::string > AIAgent::getAnimations ( )

return names of all the animations this agent has

float AIAgent::getBlendFrame ( )

return the default number of frames used when blending animations

Ogre::String AIAgent::getDefaultAnimation ( )

Get the name of the default animation.

Ogre::Vector3 AIAgent::getDestination ( )

Returns the destination the AIAgent is attempting to reach.

int AIAgent::getKnownLuaStackSize ( )

Returns the known Lua stack size.

Returns:
Lua stack size.
Ogre::Real AIAgent::getMaxLinearSpeed ( )

Returns the max speed of the agent.

Returns:
Speed of the agent.
Ogre::String AIAgent::getName ( )

Returns the name of the agent.

Returns:
Name of the agent.
Ogre::Vector3 AIAgent::getPosition ( )

Returns the position of the AIAgent.

Returns:
Position of the agent.
unsigned long AIAgent::getType ( )

Returns a unsigned long representing 64 possible types the AI may be unsigned long to. Each toggled bit of the unsigned long represent a different type.

Returns:
Types of the AI.</return>
vector< int > AIAgent::getTypes ( )

Convenience method to return a vector of ints representing each of the types the AI beunsigned longs to.

Returns:
Vector of ints ranging from 1 to 64, otherwise a vector containing the int 0 representing that the AI is not part of any type. </return>

void AIAgent::initialize ( )

Initialize the AIAgent, called when the scene is initialized.

void AIAgent::initializeLua ( )

Initialize the Lua stack.

bool AIAgent::isDebug ( )

Return whether debug information is being shown.

Returns:
Debug toggle.</return>
float OpenSteer::SimpleVehicle::mass ( void  ) const [inline, inherited]
float OpenSteer::SimpleVehicle::maxForce ( void  ) const [inline, inherited]
float OpenSteer::SimpleVehicle::maxSpeed ( void  ) const [inline, inherited]
bool AIAgent::playAnimation ( Ogre::String  newAnimName,
bool  loop,
Ogre::String  transitionAnimation = "" 
)

Play the current animation.

Parameters:
newAnimNamethe name of the animation
loopwhether the animation play once or forever
transitionAnimationset the transition animation between the active one and the new animation
OpenSteer::Vec3 OpenSteer::SimpleVehicle::predictFuturePosition ( const float  predictionTime) const [inherited]
float OpenSteer::SimpleVehicle::radius ( void  ) const [inline, inherited]
void OpenSteer::SimpleVehicle::randomizeHeadingOnXZPlane ( void  ) [inline, inherited]
void OpenSteer::SimpleVehicle::regenerateLocalSpace ( const Vec3 newVelocity,
const float  elapsedTime 
) [virtual, inherited]
void OpenSteer::SimpleVehicle::regenerateLocalSpaceForBanking ( const Vec3 newVelocity,
const float  elapsedTime 
) [inherited]
float OpenSteer::SimpleVehicle::relativeSpeed ( void  ) const [inline, inherited]
void AIAgent::reloadLua ( )

Reloads the lua stack based on the lua filename.

void OpenSteer::SimpleVehicle::reset ( void  ) [inline, inherited]
Vec3 OpenSteer::SimpleVehicle::resetSmoothedAcceleration ( const Vec3 value = Vec3::zero) [inline, inherited]
float OpenSteer::SimpleVehicle::resetSmoothedCurvature ( float  value = 0) [inline, inherited]
Vec3 OpenSteer::SimpleVehicle::resetSmoothedPosition ( const Vec3 value = Vec3::zero) [inline, inherited]
void AIAgent::setArriveTarget ( Ogre::Vector3  arriveTarget)

Sets the Arrive Target.

bool AIAgent::setBlendFrame ( float  blendFrame)

set the default number of frames used when blending animations

Parameters:
blendFramethe number user want to set
void AIAgent::setDebug ( bool  debug)

Set whether to show debug information about the AI Agent.

Parameters:
enableEnable or disable debug information.
void AIAgent::setDebugText ( Ogre::String  text)

Sets the debug text that hovers above the AI Agent.

Parameters:
textText to set.
bool AIAgent::setDefautAnimation ( Ogre::String  defaultAnimName)

Set the default animation.

Parameters:
defaultAnimNamethe name of the animation want to play
void AIAgent::setDestination ( Ogre::Vector3  destination)

Sets the position the AIAgent will attempt to reach.

void AIAgent::setFleeTarget ( Ogre::Vector3  fleeTarget)

Sets the Flee Target.

float OpenSteer::SimpleVehicle::setMass ( float  m) [inline, inherited]
float OpenSteer::SimpleVehicle::setMaxForce ( float  mf) [inline, inherited]
void AIAgent::setMaxLinearSpeed ( Ogre::Real  speed)

Sets the max linear speed the AI Agent may move at.

float OpenSteer::SimpleVehicle::setMaxSpeed ( float  ms) [inline, inherited]
void AIAgent::setName ( Ogre::String  name)

Sets the AI name.

void AIAgent::setOnBehaviors ( Ogre::String  name)

Switching ON the behaviors.

float OpenSteer::SimpleVehicle::setRadius ( float  m) [inline, inherited]
void AIAgent::setSeekTarget ( Ogre::Vector3  seekTarget)

Sets the Seek Target.

<author>hrudesh.doke@gmail.com</author>

float OpenSteer::SimpleVehicle::setSpeed ( float  s) [inline, inherited]
void AIAgent::setType ( int  type)

Overrides the current type of the AI.

Parameters:
typeSet the AI type based on a number from 1 to 64.
void AIAgent::setTypes ( unsigned long  types)

Overrides the current types of the AI.

Parameters:
typesSet the AI type based on toggled bits on the param.
Vec3 OpenSteer::SimpleVehicle::smoothedAcceleration ( void  ) [inline, inherited]
float OpenSteer::SimpleVehicle::smoothedCurvature ( void  ) [inline, inherited]
Vec3 OpenSteer::SimpleVehicle::smoothedPosition ( void  ) [inline, inherited]
float OpenSteer::SimpleVehicle::speed ( void  ) const [inline, inherited]
bool AIAgent::stopAnimation ( )

stop the current animation

void AIAgent::update ( const float  currentTime,
const float  deltaTime 
)

Update loop called during each update loop.

Vec3 OpenSteer::SimpleVehicle::velocity ( void  ) const [inline, inherited]

Friends And Related Function Documentation

friend class AIAgentManager [friend]

Member Data Documentation

The AIAgentManager the agent belongs to. This may be null if the AI is not part of any AIAgentManager. This is only set by the AIAgentManager when the AI is added to it.

AnimationManager::AnimatedEntity* GamePipe::AIAgent::m_animationEntity

Animation object, may be null.

The number of frames used when blending the animation.

Phantom Shape object, may be null.

Collision Listener, may be null.

bool GamePipe::AIAgent::m_debug [protected]

The AIAgentManager the agent belongs to. This may be null if the AI is not part of any AIAgentManager. This is only set by the AIAgentManager when the AI is added to it.

Whether debugging is enabled or disabled for this object.

Ogre::SceneNode* GamePipe::AIAgent::m_debugDestNode [protected]

Debug graphic objects.

std::list<Ogre::SceneNode*>* GamePipe::AIAgent::m_debugPathNodes [protected]

Nodes used for debugging purposes only.

Ogre::Vector3 GamePipe::AIAgent::m_destination [protected]

Destination the AI is attempting to reach, may be the AI's current position if the AI has no current destination.

Time Elapsed each update func call of the AI Agent.

Graphics rendering object, may be null.

Ogre::LogManager* GamePipe::AIAgent::m_log [protected]
Ogre::String GamePipe::AIAgent::m_luaFileName [protected]

Filename of the lua script.

lua_State* GamePipe::AIAgent::m_luaVM [protected]

Lua state, represents the interface between this AI Agent and Lua.

Ogre::Real GamePipe::AIAgent::m_maxSpeed [protected]
Ogre::Vector3 GamePipe::AIAgent::m_moveTo [private]

this member stores the direction the AIAgent is moving to now

Ogre::String GamePipe::AIAgent::m_name [protected]

Name of the AI Agent.

Physics object, may be null.

Ogre::Vector3 GamePipe::AIAgent::m_position [protected]

Position of the AI, updated every update call. Based off of physics if present, otherwise based off the graphics if present, otherwise kept internally by the AI Agent.

Flag to remove the AI. The AI stops updating if true.

Ogre::String GamePipe::AIAgent::m_state [protected]

Current state the AI is in.

Steering Behavior.

TextFileManager * AIAgent::m_tfm [static, private]

Text file manager which is used to load in Lua scripts.

unsigned long GamePipe::AIAgent::m_type [protected]

Type/Types which this AI Agent is a part of. Each toggled bit represents a different type the AI is. The maximum.

Velocity of the AI Agent.

Heading of the AI Agent.

Side Component of the AI Agent.

int OpenSteer::SimpleVehicle::serialNumberCounter = 0 [static, inherited]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines