SPIN Framework
Public Types | Public Member Functions | Protected Types | Protected Attributes

spin::AttractorNode Class Reference

A node to attract (or repulse) other nodes. More...

#include <AttractorNode.h>

Inheritance diagram for spin::AttractorNode:
spin::GroupNode spin::ReferencedNode

List of all members.

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_

Detailed Description

A node to attract (or repulse) other nodes.


Member Enumeration Documentation

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.

Enumerator:
EXTRINSIC 

translates the attracted target by a small amount each time increment

INTRINSIC 

changes the velocity of the attracted target


Member Function Documentation

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]
Returns:
a float which indicates how the attractive force of the node decays as a function of incidence to the attractor's current orientation (i.e. at what angle objects are from the attractive node)
int spin::AttractorNode::getAttractorMode ( ) const [inline]
Returns:
an int indicating the attractor mode currently set for the node, see the attractorMode enum for types
float spin::AttractorNode::getDistanceDecay ( ) const [inline]
Returns:
a float that indicates the decay of the node's attractive force as a function of distance from the node
float spin::AttractorNode::getForce ( ) const [inline]
Returns:
a float which indicates the attractive force of the node
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)


The documentation for this class was generated from the following files: