SPIN Framework
|
A node to attract (or repulse) other nodes. More...
#include <AttractorNode.h>
Public Types | |
enum | attractorMode { EXTRINSIC, INTRINSIC } |
Public Member Functions | |
AttractorNode (SceneManager *sceneManager, const char *initID) | |
virtual void | callbackUpdate (osg::NodeVisitor *nv) |
void | setDistanceDecay (float decay) |
float | getDistanceDecay () const |
void | setAngularDecay (float decay) |
float | getAngularDecay () const |
void | setAttractorMode (attractorMode m) |
int | getAttractorMode () const |
void | setForce (float force) |
float | getForce () const |
void | addTarget (const char *targetID) |
void | removeTarget (const char *targetID) |
virtual std::vector< lo_message > | getState () const |
Protected Types | |
typedef std::vector < osg::observer_ptr< GroupNode > > | targetVector |
Protected Attributes | |
float | force_ |
attractorMode | mode_ |
float | distanceDecay_ |
float | angularDecay_ |
targetVector | targets_ |
A node to attract (or repulse) other nodes.
There are two types of attractorMode. An EXTRINSIC attractor will simply move or translate the target by a small amount each time increment (this is the default behaviour). An INTRISIC attractor actually changes the velocity of the target.
void spin::AttractorNode::addTarget | ( | const char * | targetID | ) |
Add a target node to the list
void spin::AttractorNode::callbackUpdate | ( | osg::NodeVisitor * | nv | ) | [virtual] |
For nodes that require regular programmatic control, there is a callback that is evaluated with every refresh. This function can thus be used for animations, or any other periodic updates.
Note that changes to the scene graph structure (eg, moving/deleting nodes should NOT be done within this callback because traversals stacks will become corrupted. The technique is rather to enable a flag and then do the actual change in the SceneManager::updateGraph() method.
Reimplemented from spin::GroupNode.
float spin::AttractorNode::getAngularDecay | ( | ) | const [inline] |
int spin::AttractorNode::getAttractorMode | ( | ) | const [inline] |
float spin::AttractorNode::getDistanceDecay | ( | ) | const [inline] |
float spin::AttractorNode::getForce | ( | ) | const [inline] |
std::vector< lo_message > spin::AttractorNode::getState | ( | ) | const [virtual] |
For each subclass of ReferencedNode, we override the getState() method to fill the vector with the correct set of methods for this particular node
Reimplemented from spin::GroupNode.
void spin::AttractorNode::removeTarget | ( | const char * | targetID | ) |
Remove a target from the list
void spin::AttractorNode::setAngularDecay | ( | float | decay | ) |
setAngularDecay specifies how the attractive force decays as a function of incidence to the attractor's current orientation. ie, whether the force falls off linearly (1.0), exponentially (>1), logarithmically (<1), or not at all (0.0) if the attractor is not pointing directly at the target.
void spin::AttractorNode::setAttractorMode | ( | attractorMode | m | ) |
Change the mode (see attractorMode enum).
void spin::AttractorNode::setDistanceDecay | ( | float | decay | ) |
setDistanceDecay specifies how the attractive force decays as a function of distance. A decay of 1.0 is a linear decay; greater than 1 is exponential (slow at start, faster as you approach the attractor); less than 1 is logarithmic (fast at start, slower as you approach); and zero implies a constant decay (independent of distance).
void spin::AttractorNode::setForce | ( | float | force | ) |
Set the attractive force (negative force for repulsion)