An example implementation of the an agent with every steering behavior implemented. More...
#include <SuperComponent.hpp>
Public Member Functions | |
SuperComponent (steer::BehaviorParameters *params) | |
void | setParams (steer::BehaviorParameters *params) |
steer::BehaviorParameters * | getParams () |
void | Update (float dt) |
float | getRotation () |
Get the value of the seek component rotation. | |
void | setNeighbors (std::vector< SuperComponent * > *n) |
std::vector< SuperComponent * > * | getNeighbors () |
void | setObstacles (std::vector< SphereObstacle * > *o) |
std::vector< SphereObstacle * > * | getObstacles () |
void | setWalls (std::vector< Wall * > *w) |
std::vector< Wall * > * | getWalls () |
void | setPath (steer::Path *p) |
steer::Path * | getPath () const |
virtual bool | on (steer::behaviorType behavior) override |
This pure virtual function tests if a specific bit of m_iFlags is set using bitwise operations. Must be overridden in derived classes. | |
void | alignmentOn () |
void | separationOn () |
void | cohesionOn () |
void | seekOn () |
void | wanderOn () |
void | wallAvoidanceOn () |
void | obstacleAvoidanceOn () |
void | pursuitOn () |
void | offsetPursuitOn () |
void | interposeOn () |
void | hideOn () |
void | pathFollowingOn () |
void | fleeOn () |
void | evadeOn () |
void | arriveOn () |
void | cohesionOff () |
void | separationOff () |
void | alignmentOff () |
void | seekOff () |
void | wanderOff () |
void | wallAvoidanceOff () |
void | obstacleAvoidanceOff () |
void | pursuitOff () |
void | offsetPursuitOff () |
void | interposeOff () |
void | hideOff () |
void | pathFollowingOff () |
void | fleeOff () |
void | evadeOff () |
void | arriveOff () |
bool | isCohesionOn () |
bool | isSeparationOn () |
bool | isAlignmentOn () |
bool | isSeekOn () |
bool | isWanderOn () |
bool | isWallAvoidanceOn () |
bool | isObstacleAvoidanceOn () |
bool | isFlockingOn () |
bool | isPursuitOn () |
bool | isOffsetPursuitOn () |
bool | isInterposeOn () |
bool | isHideOn () |
bool | isPathFollowingOn () |
bool | isFleeOn () |
bool | isEvadeOn () |
bool | isArriveOn () |
void | flockingOn () |
void | flockingOff () |
bool | targetAcquired () |
void | setEvadeAgent (steer::Agent *a) |
steer::Agent * | getEvadeAgent () const |
void | setPursuitAgent (steer::Agent *a) |
steer::Agent * | getPursuitAgent () const |
void | setLeader (steer::Agent *l) |
steer::Agent * | getLeader () const |
void | setInterposeAgents (steer::Agent *a, steer::Agent *b) |
void | setInterposeAgentA (steer::Agent *a) |
void | setInterposeAgentB (steer::Agent *b) |
steer::Agent * | getInterposeAgentA () const |
steer::Agent * | getInterposeAgentB () const |
void | setHideAgent (steer::Agent *a) |
steer::Agent * | getHideAgent () const |
virtual Vector2 | Calculate () override |
A pure virtual method for calculating the steering vector. | |
virtual Vector2 | calculateWeightedSum () override |
Public Member Functions inherited from steer::Agent | |
Agent () | |
Default constructor. | |
Agent (steer::Vector2 position, float radius, steer::Vector2 velocity, steer::Vector2 heading, steer::Vector2 side, float mass, float maxSpeed, float maxForce, float maxTurnRate) | |
Construct agent from values. | |
Agent (steer::BehaviorParameters *params) | |
Construct agent from struct of parameters. | |
virtual | ~Agent () |
Destructor. | |
steer::Vector2 | getPosition () const |
Gets the position of the entity. | |
void | setPosition (steer::Vector2 newPosition) |
Sets the position of the entity. | |
float | getBoundingRadius () const |
Gets the bounding radius of the entity. | |
void | setBoundingRadius (float radius) |
Sets the bounding radius of the entity. | |
bool | taggedInGroup () const |
Gets the tagged status (tagged in a group) of the entity. | |
void | Tag () |
Tags the entity for an action. | |
void | unTag () |
Untags the entity. | |
steer::Vector2 | getScale () const |
Returns the entity's scale. | |
void | setScale (steer::Vector2 val) |
Sets the entity's scale from an steer::Vector2. | |
void | setScale (float val) |
Sets the entity's scale from a float. | |
steer::Vector2 | getVelocity () const |
Gets the velocity of the agent. | |
float | getMass () const |
Gets the mass of the agent. Mass is set on construction of the agent only. | |
steer::Vector2 | getSide () const |
Gets the side vector (vector perpendicular to the direction the agent is heading) of the agent. Side is set on construction of the agent only. | |
void | setSide (const steer::Vector2 side) |
Sets the side vector (vector perpendicular to the direction the agent is heading) of the agent. Side is set on construction of the agent only. | |
float | getMaxSpeed () const |
Gets the max speed of the agent. | |
void | setMaxSpeed (float newSpeed) |
Sets the velocity of the agent. | |
float | getMaxForce () const |
Gets the max force of the agent. | |
void | setMaxForce (float maxForce) |
Sets the max force of the agent. | |
steer::Vector2 | getForce () const |
Convenience method, gets the current steering force for the owner agent. Force is public data used for calculating steering force, therefore there is no setter. | |
bool | speedMaxedOut () const |
Determines if the speed of the agent is maxed out or not. | |
float | getSpeed () const |
Gets the speed of the agent. | |
float | getSpeedSquared () const |
Gets the speed squared of the agent. | |
steer::Vector2 | getHeading () const |
Gets the heading of the agent. | |
void | setHeading (steer::Vector2 newHeading) |
Sets the heading of the agent. | |
bool | rotateHeadingToFacePosition (steer::Vector2 target) |
Returns true when the heading is rotated to the target position, returns false otherwise. | |
float | getMaxTurnRate () const |
Gets the max turn rate of the agent. | |
void | setMaxTurnRate (float maxTurnRate) |
Sets the max turn rate of the agent. | |
float | getForwardComponent () |
Calculates the component of the steering force that is parallel with the vehicle heading. | |
float | getSideComponent () |
Calculates the component of the steering force that is perpendicular with the vehicle heading. | |
void | setTarget (const steer::Vector2 target) |
Sets the current target for the owner agent. | |
steer::Vector2 | getTarget () const |
Gets the current target for the owner agent. | |
void | setThreatRange (const float range) |
Set the value of the range the object of interest must be in to trigger evasive action. | |
float | getThreatRange () const |
Get the value of the range the object of interest must be in to trigger evasive action. | |
void | setDecelerationTweaker (const float deceleration) |
Set the value for tweaking deceleration for the arrive component. | |
float | getDecelerationTweaker () const |
Get the value for tweaking deceleration for the arrive component. | |
void | setWanderTarget (const steer::Vector2 target) |
Set the wander target. | |
steer::Vector2 | getWanderTarget () const |
Get the wander target. | |
void | setWanderJitter (const float jitter) |
Set the wander jitter. | |
float | getWanderJitter () const |
Get the wander jitter. | |
void | setWanderRadius (const float radius) |
Set the radius that the agent will wander toward. | |
float | getWanderRadius () const |
Get the radius the agent is wandering toward. | |
void | setWanderDistance (const float distance) |
Set the distance the agent will wander. | |
float | getWanderDistance () const |
Get the distance the agent will wander. | |
void | setDistanceBuffer (const float buffer) |
Set the value for the buffer which dictates the minimum distance from a given area (for example, a hiding spot behind an obstacle). | |
float | getDistanceBuffer () const |
Get the value for the distance buffer (minimum distance between self and a given area). | |
void | setOffset (const steer::Vector2 offset) |
Sets the current steering offset for the owner agent - used for tweaking steering force. | |
steer::Vector2 | getOffset () const |
Gets the current steering offset for the owner agent -. | |
void | createFeelers () |
A method for creating the feelers used for obstacle and wall avoidance;. | |
float | boxLength () const |
Returns the value of box length used for obstacle and wall avoidance;. | |
void | setBoxLength (const float length) |
Returns the value of box length used for obstacle and wall avoidance;. | |
const std::vector < steer::Vector2 > & | getFeelers () const |
Returns a reference to the feelers used for obstacle and wall avoidance;. | |
virtual void | setSummingMethod (Uint32 sumMethod) |
A virtual method used for setting the summing method for steering forces. | |
virtual bool | accumulateForce (steer::Vector2 &startingForce, steer::Vector2 forceToAdd) |
A virtual method used to accumulate forces from a combination of behaviors. Does nothing, override and implement in derived classes. | |
virtual steer::Vector2 | calculatePrioritized () |
float | getElapsedTime () |
Get the time elapsed since the last frame. | |
float | setElapsedTime (float e) |
Set the time elapsed since the last frame. | |
Public Attributes | |
float | m_weightSeek |
Multiplier - can be adjusted to effect strength of the seeking behavior. | |
float | m_weightFlee |
Multiplier - can be adjusted to effect strength of the fleeing behavior. | |
float | m_weightArrive |
Multiplier - can be adjusted to effect strength of the arriving behavior. | |
float | m_weightPursuit |
Multiplier - can be adjusted to effect strength of the pursuing behavior. | |
float | m_weightEvade |
Multiplier - can be adjusted to effect strength of the evading behavior. | |
float | m_weightInterpose |
Multiplier - can be adjusted to effect strength of the interposing behavior. | |
float | m_weightHide |
Multiplier - can be adjusted to effect strength of the hiding behavior. | |
float | m_weightOffsetPursuit |
Multiplier - can be adjusted to effect strength of the offset pursuit behavior. | |
float | m_weightWander |
Multiplier - can be adjusted to effect strength of the wander behavior. | |
float | m_weightAlignment |
Multiplier - can be adjusted to effect strength of the alignment behavior. | |
float | m_weightSeparation |
Multiplier - can be adjusted to effect strength of the separation behavior. | |
float | m_weightCohesion |
Multiplier - can be adjusted to effect strength of the cohesion behavior. | |
float | m_weightObstacleAvoidance |
Multiplier - can be adjusted to effect strength of the obstacle avoidance behavior. | |
float | m_weightWallAvoidance |
Multiplier - can be adjusted to effect strength of the wall avoidance behavior. | |
float | m_weightPathFollowing |
Multiplier - can be adjusted to effect strength of the Path Following behavior. | |
Public Attributes inherited from steer::Agent | |
steer::Vector2 | m_agentPosition |
The Entity's internal position value. | |
steer::Vector2 | m_scale |
The Entity's internal scale value. | |
bool | m_tag |
float | m_boundingRadius |
Generic flag to indicate that the entity is flagged for some process. | |
steer::Vector2 | m_steeringForce |
For calculating the steering force internally from all combined behaviors. | |
float | m_waypointSeekDistanceSquared |
the distance (squared) a vehicle has to be from a path waypoint before it starts seeking to the next waypoint | |
std::vector< steer::Vector2 > | m_feelers |
a vertex buffer to contain the feelers for wall avoidance | |
steer::Vector2 | m_velocity |
Storage for the agent's velocity. | |
steer::Vector2 | m_heading |
Storage for the agent's normalized vector pointing in the direction it is headed. | |
steer::Vector2 | m_side |
A vector perpendicular to the direction the agent is heading. | |
float | m_mass |
Mass of the agent. | |
float | m_timeElapsed |
The time elapsed since the last frame - useful for some steering behavior calcuations. | |
steer::Vector2 | m_offset |
any offset used for formations or offset pursuit | |
float | m_viewDistance |
how far the agent can 'see' | |
Uint32 | m_deceleration |
Deceleration type (slow, normal, fast) - SEE DECLERATION ENUM in BEHAVIORHELPERS.HPP. | |
float | m_boxLength |
length of the 'detection box' utilized in obstacle avoidance | |
float | m_wallDetectionFeelerLength |
the length of the 'feeler/s' used in wall detection | |
float | m_maxSpeed |
The maximum speed at which the agent can travel. | |
float | m_maxForce |
The maximum force the agent can use to propel itself. | |
float | m_maxTurnRate |
The maximum rate at which the agent can rotate. | |
steer::Vector2 | m_target |
For setting the agent's target. | |
float | m_threatRange |
Range the object of interest must be in to trigger evasive action. | |
float | m_decelerationTweaker |
Value used to tweak deceleration. | |
float | m_distanceBuffer |
Value used to set the distance buffer. | |
steer::Vector2 | m_wanderTarget |
the current position on the wander circle the agent is attempting to steer towards | |
float | m_wanderJitter |
Amount of displacement along the constraining circle for the wandering agent. | |
float | m_wanderRadius |
The radius of the constraining circle for the wandering agent. | |
float | m_wanderDistance |
Distance the wander circle is projected in front of the agent. | |
An example implementation of the an agent with every steering behavior implemented.
|
inlineoverridevirtual |
This pure virtual function tests if a specific bit of m_iFlags is set using bitwise operations. Must be overridden in derived classes.
behavior | - enum behaviorType. |
Implements steer::Agent.