SPIN Framework
Public Types | Public Member Functions | Protected Attributes

spin::AnimationNode Class Reference

Node for encapsulating 3D animation. More...

#include <AnimationNode.h>

Inheritance diagram for spin::AnimationNode:
spin::GroupNode spin::ReferencedNode

List of all members.

Public Types

enum  LoopMode { SWING, LOOP, NO_LOOPING }

Public Member Functions

 AnimationNode (SceneManager *sceneManager, const char *initID)
virtual void callbackUpdate (osg::NodeVisitor *nv)
bool doUpdate (double timestamp)
void setIndex (float index)
void setUpdateRate (float hz)
 Set the update rate (in Hz).
float getUpdateRate () const
void setPlay (int p)
int getPlay () const
void setRecord (int r)
int getRecord () const
void setLoopMode (LoopMode mode)
int getLoopMode () const
virtual void setTranslation (float x, float y, float z)
virtual void setOrientation (float pitch, float roll, float yaw)
virtual void setScale (float x, float y, float z)
void storeCurrentPosition ()
void storeCurrentPosition (double timestamp)
void controlPoint (double timestamp, float x, float y, float z, float rotX, float rotY, float rotZ, float rotW, float scaleX, float scaleY, float scaleZ)
void clear ()
virtual std::vector< lo_message > getState () const

Protected Attributes

bool _play
bool _record
osg::Timer_t _startTime
osg::Timer_t _lastTick
float _updateRate
osg::ref_ptr< osg::AnimationPath > _animationPath

Detailed Description

Node for encapsulating 3D animation.


Member Function Documentation

void spin::AnimationNode::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.

void spin::AnimationNode::clear ( )

Clears the current animation sequence

void spin::AnimationNode::controlPoint ( double  timestamp,
float  x,
float  y,
float  z,
float  rotX,
float  rotY,
float  rotZ,
float  rotW,
float  scaleX,
float  scaleY,
float  scaleZ 
)

Explicitely adds a control point into the animation sequence

bool spin::AnimationNode::doUpdate ( double  timestamp)

Performs the actual update of translation, orientation, and scale given a timestamp into the animation

int spin::AnimationNode::getLoopMode ( ) const [inline]
Returns:
the loop mode for the animation. eg, SWING, LOOP, NO_LOOPING.
int spin::AnimationNode::getPlay ( ) const [inline]
Returns:
a boolean value which indicates whether the animation is playing or not
int spin::AnimationNode::getRecord ( ) const [inline]
Returns:
a boolean value which indicates whether the node is recording or not
std::vector< lo_message > spin::AnimationNode::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.

float spin::AnimationNode::getUpdateRate ( ) const [inline]
Returns:
update rate in hz
void spin::AnimationNode::setIndex ( float  index)

A client interface that allows for setting the animation time using a normalized index in the range [0,1]

void spin::AnimationNode::setLoopMode ( LoopMode  mode)

Sets the loop mode for the animation. eg, SWING, LOOP, NO_LOOPING.

void spin::AnimationNode::setOrientation ( float  pitch,
float  roll,
float  yaw 
) [virtual]

Override setOrientation so we can store updates in record mode

Reimplemented from spin::GroupNode.

void spin::AnimationNode::setPlay ( int  p)

Turns animation on/off.

void spin::AnimationNode::setRecord ( int  r)

Turns on/off automatic recording. This implies that whenever the node gets an update of translation or orientation, a new position will be saved. Each position will be added with a timestamp relative to the start of the recording.

void spin::AnimationNode::setScale ( float  x,
float  y,
float  z 
) [virtual]

Override setScale so we can store updates in record mode

Reimplemented from spin::GroupNode.

void spin::AnimationNode::setTranslation ( float  x,
float  y,
float  z 
) [virtual]

Override setTranslation so we can store updates in record mode

Reimplemented from spin::GroupNode.

void spin::AnimationNode::setUpdateRate ( float  hz)

Set the update rate (in Hz).

The animation will send setTranslation, setOrientation, and setScale events at this rate (assuming there is a change). Values will be interpolated in between control points.

Parameters:
hzUpdate rate in hz
void spin::AnimationNode::storeCurrentPosition ( )

Stores the node's current position/rotation/scale as a control point in the animation sequence

void spin::AnimationNode::storeCurrentPosition ( double  timestamp)

Adds the current position/rotation/scale into the animation sequence at the specified time offset, overriding any previous position at that time.


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