Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | Namespace Members | Class Members

AgentCore Class Reference

#include <src/AgentCore.h>

Inheritance diagram for AgentCore:

Inheritance graph
[legend]
Collaboration diagram for AgentCore:

Collaboration graph
[legend]
List of all members.

Detailed Description

The base class of all agents.

It defines all the core features of an agent, like its physical properties, but does not provide any of the AI stuff.

It is tied to osg, all the features of each agent implemented in each subclass another solution would be to delegate the graphics part, but I don't want to add an extra indirection layer for this simple system, and the graphics can be de-activated for batch mode anyway.

Local space is oriented the OSG way: X right, Y forward, Z up. The agent is supposed to be looking toward Y to begin with, load your models accordingly.

Position and quaternion attitude control how this local space is translated to OSG world space.

Default appearance is a white cube of side 1. Default position is centered on 0

Author:
Nicolas Brodu


Public Member Functions

virtual void setEnergyFootprintRatio (double newRatio)
 In scenario with energy, set this conversion ratio to simulate the body mass necessary to hold this energy.
virtual double getEnergyFootprintRatio ()
virtual void setSelfMaintainEnergyCost (double newCost)
 Self-maintainance energy cost models the fact an agent need energy to live.
virtual double getSelfMaintainEnergyCost ()
virtual void setMaxEnergy (double newMax)
 Maximum energy models the physical fact a predator stomach has limited capacity, and a car fuel tank too.
virtual double getMaxEnergy ()
virtual void setMaxForce (double newMax)
 max Force models the phyical limitations of an agent.
virtual double getMaxForce ()
virtual double getMaxForceSquared ()
virtual void setMaxSpeed (double newMax)
 max Speed models the phyical limitations of an agent.
virtual double getMaxSpeed ()
virtual double getMaxSpeedSquared ()
virtual const osg::Vec3d & getPosition () const
 accessors to the protected members
virtual const osg::Quat & getAttitude () const
virtual const osg::Vec3d & getScale () const
virtual const osg::Vec3d & getPivotPoint () const
virtual void setPosition (const osg::Vec3d &pos)
 These require a bit more work, to allow async.
virtual void setPosition (const double &x, const double &y, const double &z)
virtual void setAttitude (const osg::Quat &quat)
virtual void setAttitude (const double &x, const double &y, const double &z, const double &w)
virtual void setScale (const osg::Vec3d &sca)
virtual void setScale (const double &x, const double &y, const double &z)
virtual void setPivotPoint (const osg::Vec3d &pivot)
virtual void setPivotPoint (const double &x, const double &y, const double &z)
virtual void addAvatarToGroup (osg::Group *group, bool delayToNextFrame=false)
 Add this agent avatar to the scene graph External API.
osg::Node * getNode ()
 Returns the osg Node for this agent, including the position/attitude transformation of the agent's avatar.
double getRadius ()
 Returns the radius for this agent.

Static Public Member Functions

static void setDefaultEnergyFootprintRatio (double newRatio)
 static versions to set the values for this class, and default for non-overloaded versions
static double getDefaultEnergyFootprintRatio ()
static void setDefaultInitialMass (double mass)
 Initial mass to give to the agents.
static double getDefaultInitialMass ()
static void setDefaultSelfMaintainEnergyCost (double newCost)
 static versions to set the values for this class, and default for non-overloaded versions
static double getDefaultSelfMaintainEnergyCost ()
static void setDefaultMaxEnergy (double newMax)
 static versions to set the values for this class, and default for non-overloaded versions
static double getDefaultMaxEnergy ()
static void setDefaultMaxForce (double newMax)
 static versions to set the values for this class, and default for non-overloaded versions
static double getDefaultMaxForce ()
static double getDefaultMaxForceSquared ()
static void setDefaultMaxSpeed (double newMax)
 static versions to set the values for this class, and default for non-overloaded versions
static double getDefaultMaxSpeed ()
static double getDefaultMaxSpeedSquared ()

Public Attributes

double mass
 Mass to damp the effect of forces : a = f / m.
double energy
 For use in games with limited energy, the agent has limited resources and is supposed to find a way to resplenish it from time to time.

Static Public Attributes

static bool optimizeBounds = true
 Optimize bound recomputations for OSG.

Protected Member Functions

virtual osg::Node * buildAvatar ()
 Build this agent avatar. Default is a white box of dimensions (1,2,0.5). For subclasses to override.

Protected Attributes

osg::Quat attitude
osg::Vec3d scale
osg::Vec3d pivotPoint
bool transformDirtyBound
NoDirtyBoundTransformtransform
double radius

Classes

class  NoDirtyBoundTransform
 Overload OSG transform to avoid unecessary dirty node checks. More...


Member Function Documentation

void AgentCore::addAvatarToGroup osg::Group *  group,
bool  delayToNextFrame = false
[virtual]
 

Add this agent avatar to the scene graph External API.

Subclasses should override buildAvatar In particular, a transform is inserted to handle positioning in this higher-level class Warning: caller responsibility to call this function at the right moment. the delay parameter may be used to postpone addition of the avatar to the next viewer update

double AgentCore::getRadius  )  [inline]
 

Returns the radius for this agent.

Especially important for reproducible results in batch mode, where we don't have graphical object bounding sphere.

void AgentCore::setDefaultInitialMass double  mass  )  [static]
 

Initial mass to give to the agents.

Default is 1.0.

void AgentCore::setEnergyFootprintRatio double  newRatio  )  [virtual]
 

In scenario with energy, set this conversion ratio to simulate the body mass necessary to hold this energy.

Ex: prey/predator => this is the energy stored in stomach => more predator mass Ex2: car race => this is the weight of carburant... or nothing for solar cars Set this to 0 to simulate an infinite amount of energy can be store without mass increase : necessary_mass = energy * ratio.

This is a property shared by all agents by default. But the previous examples make it clear this value can be changed to compare different models (solar car, etc...) in different subclasses, so each subclass may decide what to do. The functions in class agent call getEnergyFootprintRatio(), so they will call the subclasses version.

void AgentCore::setMaxEnergy double  newMax  )  [virtual]
 

Maximum energy models the physical fact a predator stomach has limited capacity, and a car fuel tank too.

Default is infinity.

void AgentCore::setMaxForce double  newMax  )  [virtual]
 

max Force models the phyical limitations of an agent.

As above, it largely depends on what is modeled (prey, car...), and is by default shared among all agents of this class. See comment for getEnergyFootprintRatio(). If overloading these, please overload both the plain and squared versions

void AgentCore::setMaxSpeed double  newMax  )  [virtual]
 

max Speed models the phyical limitations of an agent.

As above, it largely depends on what is modeled (prey, car...), and is by default shared among all agents of this class. See comment for getEnergyFootprintRatio(). If overloading these, please overload both the plain and squared versions

void AgentCore::setPosition const osg::Vec3d &  pos  )  [virtual]
 

These require a bit more work, to allow async.

updates at any time and only one update to the graphics layer when necessary (no more than once per frame) Also, don't bother with this when running in batch mode

Reimplemented from Localized.

void AgentCore::setSelfMaintainEnergyCost double  newCost  )  [virtual]
 

Self-maintainance energy cost models the fact an agent need energy to live.

Default is 0, meaning an agent can live without remaining energy. In this case, it will be completely passive as it cannot apply its steering behaviors. If an agent energy drops below 0 after its maintainance is applied (when it applies!), then this agent is destroyed


Member Data Documentation

double AgentCore::energy
 

For use in games with limited energy, the agent has limited resources and is supposed to find a way to resplenish it from time to time.

Ex: prey/predator, car race stops, etc... This may be set to a very large number to simulate infinity, ex: solar cars!

bool AgentCore::optimizeBounds = true [static]
 

Optimize bound recomputations for OSG.

When an agent moves, its parent bounding sphere normally is marked invalid. Unfortunately when 1000+ agents are moving each frame, this means a lot of recursive list run-through for OSG. With this flag set to true, this is no longer the case, the parent bounds aren't changed. If you set it to true, be careful to update the parent bound once a frame, because it won't be updated automatically. Alternatively, if the agents are constrained in an environment, then the parent bound may be set initially to the environment fixed size and remain so forever. This is done implicitly when the agent's parent is a cyclic terrain for example... Default is true.


The documentation for this class was generated from the following files:
Generated on Mon Mar 28 11:26:50 2005 for Crogai by  doxygen 1.4.1