An example implementation of the evasion steering behavior. The agent will flee from the target while predicting it's trajectory. More...
#include <EvadeComponent.hpp>
Public Member Functions | |
EvadeComponent (steer::BehaviorParameters *params) | |
void | setWeight (const float weight) |
Set the value of the weight multiplier for the Evade component. | |
float | getWeight () const |
Get the value of the weight multiplier for the Evade component. | |
void | setRotation (float r) |
Set the value of the Evade component rotation. | |
float | getRotation () |
Get the value of the Evade component rotation. | |
virtual bool | on (steer::behaviorType behavior) |
This pure virtual function tests if a specific bit of m_iFlags is set using bitwise operations. Must be overridden in derived classes. | |
void | evadeOn () |
bool | isEvadeOn () |
void | evadeOff () |
void | setTargetAgent (steer::Agent *a) |
steer::Agent * | getTargetAgent () const |
virtual Vector2 | Calculate () |
A pure virtual method for calculating the steering vector. | |
void | Update (float dt) |
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 | calculateWeightedSum () |
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. | |
Additional Inherited Members | |
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 evasion steering behavior. The agent will flee from the target while predicting it's trajectory.
|
inlinevirtual |
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.
|
inline |
Set the value of the weight multiplier for the Evade component.
weight | - a plain old float. |