Menge Plugin Examples
A Collection of Example Plugins for the Menge Framework
|
Modify the preferred velocity based on a height field. More...
#include <VelModHeightField.h>
Public Member Functions | |
HeightFieldModifier () | |
Default constructor. | |
HeightFieldModifier (HeightFieldPtr hfPtr) | |
Constructor. More... | |
void | setHeightField (HeightFieldPtr hfPtr) |
Sets the height field for this velocity modifier object to use. More... | |
BFSM::VelModifier * | copy () const |
Copy method for this velocity modifier. | |
void | adaptPrefVelocity (const Agents::BaseAgent *agent, Agents::PrefVelocity &pVel) |
adapt preferred velocity by pushing it away from the heightfield gradient More... | |
Protected Attributes | |
HeightFieldPtr | _field |
The height field used to query elevation and gradient. | |
float | _turnWeight |
The weighting factor for how the gradient effects direction. | |
float | _upHillScale |
The uphill scale factor. | |
float | _downHillScale |
The downhill scale factor. | |
Friends | |
class | HeightFieldModifierFactory |
Modify the preferred velocity based on a height field.
Agents preferred velocities can be sped up, slowed, and turned based on their attempt to traverse a heightfield. The gradient of the height field is used to determine the new preferred velocity.
Direction is determined by a re-normalized, weighted sum of the gradient with the input preferred direction.
The resultant speed is a scaled factor of the input speed with the steepness of the gradient. Uphill and downhill speed changes are controlled separately – gradients which lie perpindicular to the input preferred direction will cause a direction change, but no speed change.
The output preferred velocity becomes a single velocity (instead of an arc). If the input preferred velocity spanned an arc, it will be collapsed to a single direction.
Terrain::HeightFieldModifier::HeightFieldModifier | ( | HeightFieldPtr | hfPtr | ) |
Constructor.
hfPtr | A pointer to a height-field resource. |
void Terrain::HeightFieldModifier::adaptPrefVelocity | ( | const Agents::BaseAgent * | agent, |
Agents::PrefVelocity & | pVel | ||
) |
adapt preferred velocity by pushing it away from the heightfield gradient
agent | The agent for which to modify preferred vel |
pVel | The agent's current preferred velocity (having potentially been modified) |
|
inline |
Sets the height field for this velocity modifier object to use.
hfPtr | A managed pointer to the height field. |