A Boid that can swarm in a flock.
More...
#include <ai.h>
|
| | Boid (Terrain *terrain, RigidbodyHandler *rigidbodyHandler) |
| | Create a new boid.
|
| |
| void | setTargetDirection (glm::vec2 direction) |
| | Setter for targetDirection.
|
| |
| void | updateDirection (float speed, float transition) |
| | Updates the direction of the boid towards the target direction.
|
| |
| std::vector< Boid * > | findNeighbours (std::vector< Boid * > totalBoids, float radius, float visionAngle) |
| | Finds the neighbouring boids within a given radius and vision angle.
|
| |
| glm::vec2 | applyCohesion (std::vector< Boid * >neighbours, float strength) const |
| | Creates a direction vector towards the average position of the neighbouring boids.
|
| |
| glm::vec2 | applyAlignment (std::vector< Boid * >neighbours, float strength) const |
| | Creates a direction vector towards the average direction of the neighbouring boids.
|
| |
| glm::vec2 | applySeparation (std::vector< Boid * > neighbours, float strength, float radius) const |
| | Creates a direction vector away from the neighbouring boids.
|
| |
| glm::vec2 | avoidEdges (float strength) |
| | Creates a direction vector away from the edges of the simulation space.
|
| |
| glm::vec2 | avoidObstacles (RigidbodyHandler *rigidbodyHandler, float strength) |
| | Creates a direction vector away from the obstacles in the simulation space.
|
| |
| void | setRigidbody (float radius, glm::vec3 pos) |
| | Sets the rigidbody of the boid.
|
| |
A Boid that can swarm in a flock.
◆ Boid()
Create a new boid.
- Parameters
-
| terrain | The terrain to set the boid's height |
| rigidbodyHandler | The rigidbody handler to create the boid's rigidbody |
◆ applyAlignment()
| glm::vec2 Boid::applyAlignment |
( |
std::vector< Boid * > | neighbours, |
|
|
float | strength ) const |
Creates a direction vector towards the average direction of the neighbouring boids.
- Parameters
-
| neighbours | - A vector of pointers to the neighbouring boids. |
| strength | - The strength of the alignment rule. |
- Returns
- glm::vec2 The direction vector created by the alignment rule.
◆ applyCohesion()
| glm::vec2 Boid::applyCohesion |
( |
std::vector< Boid * > | neighbours, |
|
|
float | strength ) const |
Creates a direction vector towards the average position of the neighbouring boids.
- Parameters
-
| neighbours | - A vector of pointers to the neighbouring boids. |
| strength | - The strength of the cohesion rule. |
- Returns
- glm::vec2 The direction vector created by the cohesion rule.
◆ applySeparation()
| glm::vec2 Boid::applySeparation |
( |
std::vector< Boid * > | neighbours, |
|
|
float | strength, |
|
|
float | radius ) const |
Creates a direction vector away from the neighbouring boids.
- Parameters
-
| neighbours | - A vector of pointers to the neighbouring boids. |
| strength | - The strength of the separation rule. |
| radius | - The radius within which to apply the separation rule. |
- Returns
- glm::vec2 The direction vector created by the separation rule.
◆ avoidEdges()
| glm::vec2 Boid::avoidEdges |
( |
float | strength | ) |
|
Creates a direction vector away from the edges of the simulation space.
- Parameters
-
| strength | - The strength of the rule. |
- Returns
- glm::vec2 The direction vector created by the rule.
◆ avoidObstacles()
Creates a direction vector away from the obstacles in the simulation space.
- Parameters
-
| rigidbodyHandler | - The rigidbody handler to get the obstacles from. |
| strength | - The strength of the rule. |
- Returns
- glm::vec2 The direction vector created by the rule.
◆ findNeighbours()
| std::vector< Boid * > Boid::findNeighbours |
( |
std::vector< Boid * > | totalBoids, |
|
|
float | radius, |
|
|
float | visionAngle ) |
Finds the neighbouring boids within a given radius and vision angle.
- Parameters
-
| totalBoids | - A vector of pointers to all boids in the simulation space. |
| radius | - The radius within which to search for neighbours. |
| visionAngle | - The angle within which to search for neighbours. |
- Returns
- std::vector<Boid*> A vector of pointers to the neighbouring boids.
◆ setRigidbody()
| void Boid::setRigidbody |
( |
float | radius, |
|
|
glm::vec3 | pos ) |
Sets the rigidbody of the boid.
- Parameters
-
| radius | - The radius of the boid. |
| pos | - The position of the boid. |
◆ setTargetDirection()
| void Aire::Boid::setTargetDirection |
( |
glm::vec2 | direction | ) |
|
|
inline |
Setter for targetDirection.
- Parameters
-
| direction | - Given direction to set targetDirection to. |
◆ updateDirection()
Updates the direction of the boid towards the target direction.
- Parameters
-
| speed | - The speed at which the boid moves. |
| transition | - The transition speed between the current and target direction. |
◆ currentDirection
| glm::vec2 Aire::Boid::currentDirection |
Current 2D direction the boid is moving to
◆ currentPosition
| glm::vec2 Aire::Boid::currentPosition |
Current 2D position of the boid
◆ model2world
| glm::mat4 Aire::Boid::model2world |
◆ rigidbody
The documentation for this class was generated from the following files:
- source/utils/ai.h
- source/utils/ai.cpp