All steering functions are templated for easy application to objects inheriting from Agent. Because of this, it is easy to add into any type of design - be it a class hierarchy or a more advanced data structure or system (such as an entity component system). All functions return a steer::steer::Vector2 that can be used to calculate a force with which the entity should be moved given each type of behavior. Combine each calculated force with a weight (any scalar value - but keep it sane or behavior could become strange). Simply multiply each weight, or weights, by the force generated by each behavior's return value to fine-tune it. In addition to the steering functions themselves, this file contains various utilities used by them to perform their work.
More...
|
template<class T , class conT > |
void | TagVehiclesWithinViewRange (const T &entity, const conT &neighbors, float viewDistance) |
|
template<class T , class conT > |
void | TagObstaclesWithinViewRange (const T &entity, const conT &obstacles, float boxLength) |
|
template<class T , class conT > |
void | TagNeighbors (const T &entity, const conT &neighbors, float radius) |
|
template<class T , class conT > |
void | TagObstacles (const T &entity, const conT &obstacles, float radius) |
|
bool | TwoCirclesOverlapped (float x1, float y1, float r1, float x2, float y2, float r2) |
| Tests for circle-to-circle overlap.
|
|
bool | TwoCirclesOverlapped (Vector2 c1, float r1, Vector2 c2, float r2) |
| Tests for circle-to-circle overlap.
|
|
template<class T , class conT > |
bool | Overlapped (const T *ob, const conT &conOb, float MinDistBetweenObstacles) |
|
bool | LineIntersection2D (steer::Vector2 A, steer::Vector2 B, steer::Vector2 C, steer::Vector2 D, float &dist, steer::Vector2 &point) |
| Checks for an intersection between two lines, given beginning and end points for both lines.
|
|
void | WrapAround (steer::Vector2 &pos, int MaxX, int MaxY) |
| Calculates the vector useful for wrapping around the steering vector of an agent to fit in the bounds of a rectangle (the screen, for example).
|
|
template<class T , class N > |
steer::Vector2 | calculateTarget (const T &agent, const N &other) |
|
template<class T , class N , class P > |
steer::Vector2 | calculateTarget (const T &agent, const N &otherA, const P &otherB) |
|
template<class T > |
steer::Vector2 | Seek (const T &agent) |
|
template<class T > |
steer::Vector2 | Seek (const T &agent, steer::Vector2 target) |
| A function returning the value necessary to steer an agent towards a target.
|
|
template<class T , class conT > |
steer::Vector2 | Alignment (const T &agent, const conT &neighbors) |
|
template<class T , class conT > |
steer::Vector2 | Separation (const T &agent, const conT &neighbors) |
|
template<class T , class conT > |
steer::Vector2 | Cohesion (const T &agent, const conT &neighbors) |
|
template<class T > |
steer::Vector2 | Arrive (const T &agent, Uint32 deceleration) |
|
template<class T , class N > |
steer::Vector2 | Pursuit (const T &agent, const N &evader) |
|
template<class T , class N > |
steer::Vector2 | OffsetPursuit (const T &agent, const N &leader, const steer::BehaviorParameters ¶meters) |
|
template<class T > |
steer::Vector2 | Flee (const T &agent) |
|
template<class T , class N > |
steer::Vector2 | Evade (const T &agent, const N &other) |
|
steer::Vector2 | findPosition (const steer::Vector2 &goalPosition, const float radius, const steer::Vector2 &avoidPosition, float distanceBuffer) |
| This function calculates a position located on the other side of some position in space, given a radius, that is out of reach from an undesirable position (for example, a pursuing agent).
|
|
template<class T , class N , class conT > |
steer::Vector2 | Hide (const T &agent, const N &other, const conT &obstacles, const steer::BehaviorParameters ¶meters) |
|
template<class T , class N , class P > |
steer::Vector2 | Interpose (const T &agent, const N &otherA, const P &otherB, const steer::BehaviorParameters ¶meters) |
|
template<class T > |
steer::Vector2 | Wander (const T &agent) |
|
template<class T , class conT > |
steer::Vector2 | ObstacleAvoidance (const T &agent, const conT &obstacles, const steer::BehaviorParameters ¶meters) |
|
template<class T > |
steer::Vector2 | WallAvoidance (const T &agent, const std::vector< steer::Wall * > &walls) |
|
template<class T > |
steer::Vector2 | PathFollowing (const T &agent, steer::Path *path, const steer::BehaviorParameters ¶ms) |
|
std::vector< steer::Vector2 > | WorldTransform (std::vector< steer::Vector2 > &points, const steer::Vector2 &pos, const steer::Vector2 &forward, const steer::Vector2 &side, const steer::Vector2 &scale) |
| Given a std::vector of steer::Vector2, a position, orientation, and scale, this function transforms the std::vector of steer::Vector2 into the object's world space.
|
|
std::vector< steer::Vector2 > | WorldTransform (std::vector< steer::Vector2 > &points, const steer::Vector2 &pos, const steer::Vector2 &forward, const steer::Vector2 &side) |
| Given a std::vector of steer::Vector2, a position, and orientation, this function transforms the std::vector of steer::Vector2 into the object's world space.
|
|
steer::Vector2 | PointToWorldSpace (const steer::Vector2 &point, const steer::Vector2 &AgentHeading, const steer::Vector2 &AgentSide, const steer::Vector2 &AgentPosition) |
| Transforms a point from the agent's local space into world space.
|
|
steer::Vector2 | VectorToWorldSpace (const steer::Vector2 &vec, const steer::Vector2 &AgentHeading, const steer::Vector2 &AgentSide) |
| Transforms a vector from the agent's local space into world space.
|
|
steer::Vector2 | PointToLocalSpace (const steer::Vector2 &point, const steer::Vector2 &AgentHeading, const steer::Vector2 &AgentSide, const steer::Vector2 &AgentPosition) |
| Transforms a vector from world space into the agent's local space.
|
|
steer::Vector2 | VectorToLocalSpace (const steer::Vector2 &vec, const steer::Vector2 &AgentHeading, const steer::Vector2 &AgentSide) |
| Transforms a vector from world space into the agent's local space.
|
|
void | Vec2DRotateAroundOrigin (steer::Vector2 &v, float ang) |
| Rotates a vector by an angle in radians around the origin.
|
|
std::vector< steer::Vector2 > | CreateWhiskers (unsigned int NumWhiskers, float WhiskerLength, float fov, steer::Vector2 facing, steer::Vector2 origin) |
| Given an origin, a facing direction, a 'field of view' describing the limit of the outer whiskers, a whisker length and the number of whiskers this method returns a vector containing the end positions of a series of whiskers radiating away from the origin and with equal distance between them. (like the spokes of a wheel clipped to a specific segment size);.
|
|
template<typename T > |
bool | isNaN (T val) |
|
float | DegreesToRadians (float degrees) |
|
bool | IsZero (float val) |
| Returns true if the parameter is equal to zero.
|
|
bool | InRange (float start, float end, float val) |
| Returns true if the third parameter is in the range described by the first two parameters.
|
|
template<class T > |
T | Maximum (const T &v1, const T &v2) |
|
int | RandInt (int x, int y) |
| Returns a random integer between x and y.
|
|
float | RandFloat () |
| Returns a random float between 1 and the maximum value for a float.
|
|
float | RandInRange (float x, float y) |
| Returns a random float between x and y.
|
|
bool | RandBool () |
| Returns true or false randomly.
|
|
float | RandomClamped () |
| Returns a random float in the range -1 < n < 1.
|
|
float | RandGaussian (float mean=0.0, float standard_deviation=1.0) |
| Returns a random number with a normal distribution. See method at http://www.taygeta.com/random/gaussian.html.
|
|
float | Sigmoid (float input, float response=1.0) |
| Returns a value from the sigmoid (S-curve) function based on input and response.
|
|
template<class T > |
T | MaxOf (const T &a, const T &b) |
|
template<class T > |
T | MinOf (const T &a, const T &b) |
|
template<class T , class U , class V > |
void | Clamp (T &arg, const U &minVal, const V &maxVal) |
|
int | Rounded (float val) |
| Rounds a double up or down depending on its value.
|
|
int | RoundUnderOffset (float val, float offset) |
| rounds a double up or down depending on whether its mantissa is higher or lower than offset.
|
|
bool | isEqual (float a, float b) |
| Compares two real numbers. Returns true if they are equal.
|
|
bool | isEqual (double a, double b) |
| Compares two real numbers. Returns true if they are equal.
|
|
template<class T > |
float | Average (const std::vector< T > &v) |
|
float | StandardDeviation (const std::vector< float > &v) |
| Finds the standard deviation from a std::vector of floats.
|
|
template<class container > |
void | DeleteSTLContainer (container &c) |
|
template<class map > |
void | DeleteSTLMap (map &m) |
|
Vector2 | operator* (const Vector2 &lhs, double rhs) |
|
Vector2 | operator* (double lhs, const Vector2 &rhs) |
|
Vector2 | operator- (const Vector2 &lhs, const Vector2 &rhs) |
|
Vector2 | operator+ (const Vector2 &lhs, const Vector2 &rhs) |
|
Vector2 | operator/ (const Vector2 &lhs, double val) |
|
Vector2 | Vec2DNormalize (const Vector2 &v) |
|
double | Vec2DDistance (const Vector2 &v1, const Vector2 &v2) |
|
double | Vec2DDistanceSq (const Vector2 &v1, const Vector2 &v2) |
|
double | Vec2DLength (const Vector2 &v) |
|
double | Vec2DLengthSq (const Vector2 &v) |
|
bool | NotInsideRegion (Vector2 p, Vector2 top_left, Vector2 bot_rgt) |
|
bool | InsideRegion (Vector2 p, Vector2 top_left, Vector2 bot_rgt) |
|
bool | InsideRegion (Vector2 p, int left, int top, int right, int bottom) |
|
bool | isSecondInFOVOfFirst (Vector2 posFirst, Vector2 facingFirst, Vector2 posSecond, double fov) |
|
All steering functions are templated for easy application to objects inheriting from Agent. Because of this, it is easy to add into any type of design - be it a class hierarchy or a more advanced data structure or system (such as an entity component system). All functions return a steer::steer::Vector2 that can be used to calculate a force with which the entity should be moved given each type of behavior. Combine each calculated force with a weight (any scalar value - but keep it sane or behavior could become strange). Simply multiply each weight, or weights, by the force generated by each behavior's return value to fine-tune it. In addition to the steering functions themselves, this file contains various utilities used by them to perform their work.