The class for modeling a freestyle formation.
More...
#include <FreeFormation.h>
|
| static Resource * | load (const std::string &fileName) |
| | Parses a formation definition and returns a pointer to it. More...
|
| |
|
|
static const std::string | LABEL |
| | The unique label for this data type to be used with resource management.
|
| |
|
|
std::map< size_t, size_t > | _agent_formationPoint |
| | Maps formation point identifiers to agent identifiers. Why identifiers?
|
| |
|
std::map< size_t, size_t > | _formationPoint_agent |
| | Maps agent identifiers to formation point identifiers. Why identifiers?
|
| |
std::map< size_t,
FormationPoint * > | _agentPoints |
| | Maps agent identifiers to formation points. This lets me seach over a space instead of doing a lot of vector math each timestep ? WHAT ?
|
| |
|
std::vector< FormationPoint * > | _formationPoints |
| | The formation points defining the formation.
|
| |
|
std::vector< FormationPoint * > | _borderPoints |
| | A separate cache of border points – this is a subset of _formationPoints.
|
| |
|
Vector2 | _direction |
| | The formation's direction of travel.
|
| |
|
float | _speed |
| | The preferred speed of the formation.
|
| |
|
Vector2 | _pos |
| | The location of the formation center in world space (0,0).
|
| |
|
float | _agentRadius |
| | The instantaneous max distance from the center of the formation to normalized agent positions ??
|
| |
|
std::map< size_t, Vector2 > | _agentPrefDirs |
| | A cache of previoius agent preferred directions. Maps agent identifiers to directions.
|
| |
|
std::map< size_t, Vector2 > | _agentPrefVels |
| | A cache of previoius agent preferred velocities. Maps agent identifiers to velocities.
|
| |
| std::map< size_t, float > | _agentWeights |
| | A cache of previoius agent preferred weights. Maps agent identifiers to weights. More...
|
| |
std::map< size_t, const
Agents::BaseAgent * > | _agents |
| | A cache of previoius agent preferred directions. Maps agent identifiers to agents.
|
| |
The class for modeling a freestyle formation.
| Formations::FreeFormation::FreeFormation |
( |
const std::string & |
name | ) |
|
Constructor.
- Parameters
-
| name | The name of the file containing the target formation. |
| void Formations::FreeFormation::addAgent |
( |
const Agents::BaseAgent * |
agt | ) |
|
Adds an agent to this formation.
Only agents "added" to the formation will be mapped considered. ?? What happens if more agents htan formation points are added?
- Parameters
-
| agt | The agent to add to the formation. |
| void Formations::FreeFormation::addAgentPoint |
( |
const Agents::BaseAgent * |
agt | ) |
|
|
protected |
Adds an agent to the formation.
- Parameters
-
| agt | The agent to add to the formation. |
| void Formations::FreeFormation::addFormationPoint |
( |
Vector2 |
pt, |
|
|
bool |
borderPoint, |
|
|
float |
weight |
|
) |
| |
|
protected |
Adds a point to the formation.
- Parameters
-
| pt | A point (in formation space). |
| borderPoint | True if the point should be considered a border point (false otherwise). |
| weight | The weight of the point. |
A custom distance metric to apply to formation points. Used for evaluating "similarity" between formation points.
- Parameters
-
| pt1 | the first point to check |
| pt2 | the other point to check |
- Returns
- The "distance" between the two formatin points.
| bool Formations::FreeFormation::getGoalForAgent |
( |
const Agents::BaseAgent * |
agt, |
|
|
Agents::PrefVelocity & |
pVel, |
|
|
Vector2 & |
target |
|
) |
| |
Provides an intermediate goal for the agent.
This assumes that the agent provided is a member of the formation. It only checks in debug mode (via an assertion).
- Parameters
-
| agt | The agent for whom the goal is provided. |
| pVel | The agent's preferred velocity...does it change?? |
| target | The intermediate goal value is stored in this vector. |
- Returns
- True if the an intermediate goal exists and is set in target, false otherwise.
| virtual const std::string& Formations::FreeFormation::getLabel |
( |
| ) |
const |
|
inlinevirtual |
Reports the message label for this resource.
- Returns
- The label for formations.
Implements Menge::Resource.
| Resource * Formations::FreeFormation::load |
( |
const std::string & |
fileName | ) |
|
|
static |
Parses a formation definition and returns a pointer to it.
This function works in conjunction with the ResourceManager. That is why it returns a pointer, not to a Formation, but to a Resource. The ResourceManager uses it to load and instantiateResource instances.
- Parameters
-
| fileName | The path to the file containing the Formation definition. |
- Returns
- A pointer to the new Formation (if the file is valid), NULL if invalid.
| void Formations::FreeFormation::mapAgentsToFormation |
( |
const BFSM::FSM * |
fsm | ) |
|
Computes the mapping from tracked agents to formation points.
- Parameters
-
| void Formations::FreeFormation::mapAgentToPoint |
( |
const Agents::BaseAgent * |
agt | ) |
|
|
protected |
Maps a single agent to a sentinel point.
- Parameters
-
| agt | The agent to map to a sentinel point. |
| void Formations::FreeFormation::mapPointToAgent |
( |
FormationPoint * |
pt | ) |
|
|
protected |
Maps a border point to one of the agents in the formation.
- Parameters
-
| pt | A border point to map to an agent. |
| void Formations::FreeFormation::normalizeFormation |
( |
| ) |
|
|
protected |
Finalize the formation representation for use.
Normalizing the formation defines distances between the formation center and formation points relative to the size of the formation. This allows for arbitrary scales.
| void Formations::FreeFormation::removeAgent |
( |
const Agents::BaseAgent * |
agt | ) |
|
Removes an agent from the formation.
- Parameters
-
| std::map< size_t, float > Formations::FreeFormation::_agentWeights |
|
protected |
A cache of previoius agent preferred weights. Maps agent identifiers to weights.
TODO: Currently, these are always 1.0. Provide mechanism for defininig non-unit weights.
The documentation for this class was generated from the following files:
- src/Plugins/Formations/FreeFormation.h
- src/Plugins/Formations/FreeFormation.cpp