Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglKeyFrameAnimation Class Reference

#include <sglKeyFrameAnimation.hpp>

Inheritance diagram for sglKeyFrameAnimation::

sglAnimation sglGroup sglNode sglObject List of all members.

Public Methods

 sglKeyFrameAnimation ()
virtual ~sglKeyFrameAnimation ()
virtual bool addChild (sglNode *node)
virtual bool insertChild (unsigned int index, sglNode *node)
virtual bool removeChild (sglNode *node)
virtual sglNoderemoveChild (unsigned int index)
void setOffsetFrame (unsigned int frame_offset)
unsigned int getOffsetFrame () const
bool setDuration (sglNode *node, unsigned int num_frames)
unsigned int getDuration (sglNode *node) const
bool setDuration (unsigned int index, unsigned int num_frames)
unsigned int getDuration (unsigned int index) const
virtual sglBound::IntersectResultEnum intersect (sglIntersectf &isector) const
virtual sglBound::IntersectResultEnum intersect (sglIntersectd &isector) const
virtual void pick (sglPickf &pick_state, unsigned int cull_flags) const
virtual void pick (sglPickd &pick_state, unsigned int cull_flags) const
virtual void preDraw (const PreDrawStruct &trav_state)
virtual sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

virtual void cull (sglCull< float > &trav_state, unsigned int cull_flags) const
virtual void cull (sglCull< double > &trav_state, unsigned int cull_flags) const
virtual void computeValues ()
sglNodecomputeChild (int frame) const
sglNodeselectChild (unsigned int current_frame) const
void copyTo (sglKeyFrameAnimation *dst, unsigned int mode) const

Protected Attributes

vector<unsigned int> m_frame_counts
unsigned int m_start_frame
unsigned int m_pause_frame
unsigned int m_frame_offset
unsigned int m_total_frames
unsigned int m_total_frames2
unsigned int m_forward_frames
unsigned int m_return_frames

Detailed Description

A subclass of sglAnimation, this node selects one child as a function of the current frame count (not time) and the animation mode. As each child is added to this node the default number of frames it is to be displayed is set to zero. This value can be changed by calling one of the setDuration(..) member functions and identifying the child either by pointer or index and specifying the number of frames.

Example:

   sglKeyFrameAnimation *animation = new sglKeyFrameAnimation;
   for (unsigned int ix=0; ix<10; ++ix)
   {
      sglGeode *geode = new sglGeode;
      animation->addChild(geode);
      animation->setDuration(ix, 10);  // display for 10 frames
   }
   animation->setMode(sglAnimation::eSWING);  // back and forth
   animation->setRange(3, 8);                 // display 3...8
   animation->setSpeed(2.5f);                 // 2.5 times faster (4 fr. each)
   animation->setNumCycles(0);                // continuous

   // set the animation to start on the next frame (after preDraw()).
   animation->setState(sglAnimation::eSTART);

Definition at line 65 of file sglKeyFrameAnimation.hpp.


Constructor & Destructor Documentation

sglKeyFrameAnimation::sglKeyFrameAnimation ( )
 

default constructor.

sglKeyFrameAnimation::~sglKeyFrameAnimation ( ) [virtual]
 

virtual destructor.


Member Function Documentation

virtual bool sglKeyFrameAnimation::addChild ( sglNode * node ) [virtual]
 

Add child to the end of the list.

Parameters:
child   Pointer to node to be added.
Returns:
false if child pointer is NULL; otherwise, true.

Reimplemented from sglGroup.

virtual bool sglKeyFrameAnimation::insertChild ( unsigned int index,
sglNode * node ) [virtual]
 

Insert a child at a specific index. Valid indices are in the range [0,getNumChildren()].

Parameters:
index   Position at which node is to be inserted.
child   Pointer to node to be inserted.
Returns:
false if child is NULL or index is out of range; otherwise, true.

Reimplemented from sglGroup.

virtual bool sglKeyFrameAnimation::removeChild ( sglNode * node ) [virtual]
 

Remove the last instance of the child from the list

Parameters:
child   Pointer to the node to be removed.
Returns:
false if child pointer is NULL or not found in child list; otherwise, true.

Reimplemented from sglGroup.

virtual sglNode* sglKeyFrameAnimation::removeChild ( unsigned int index ) [virtual]
 

Removes child at position index (valid indices: [0,getNumChildren()-1]). Nodes after this in the list then shift down one index.

Parameters:
index   Index of child to be removed.
Returns:
The child previously at position index, or NULL on error.

Reimplemented from sglGroup.

void sglKeyFrameAnimation::setOffsetFrame ( unsigned int frame_offset ) [inline]
 

Set a frame offset when starting the animation. Only positive offsets are allowed, which will start the animation further forward into the sequence. This will only take effect the next time the state is changed to START.

Parameters:
offset_frame   Offset in number of frames

Definition at line 86 of file sglKeyFrameAnimation.hpp.

unsigned int sglKeyFrameAnimation::getOffsetFrame ( ) const [inline]
 

Query the current frame offset.

Returns:
The current frame offset.

Definition at line 92 of file sglKeyFrameAnimation.hpp.

bool sglKeyFrameAnimation::setDuration ( sglNode * node,
unsigned int num_frames )
 

Sets the duration, in number of frames, of the first child in the list that matches the pointer.

Parameters:
node   Pointer to child to set the duration.
num_frames   Number of frames to display the child. Setting to zero disables the display of this particular child.
Returns:
true if the node pointer is one of this node's children; otherwise false

unsigned int sglKeyFrameAnimation::getDuration ( sglNode * node ) const
 

Gets the current duration of the child specified by the node pointer.

Parameters:
node   Pointer to child to get the duration from.
Returns:
duration of the specified node (zero if the node was not a child).

bool sglKeyFrameAnimation::setDuration ( unsigned int index,
unsigned int num_frames )
 

Sets the duration, in number of frames, of the child specified by the index.

Parameters:
index   Index of child to set the duration.
num_frames   Number of frames to display the child. Setting to zero disables the display of this particular child.
Returns:
true if the index is valid; otherwise false

unsigned int sglKeyFrameAnimation::getDuration ( unsigned int index ) const
 

Gets the current duration of the child corresponding to the index.

Parameters:
index   Index of child to set the duration.
Returns:
duration of the specified node (zero if the index was out of range.

virtual sglBound::IntersectResultEnum sglKeyFrameAnimation::intersect ( sglIntersectf & isector ) const [virtual]
 

The single precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.

Parameters:
isector   A reference to a single precision intersection state

Reimplemented from sglGroup.

virtual sglBound::IntersectResultEnum sglKeyFrameAnimation::intersect ( sglIntersectd & isector ) const [virtual]
 

The double precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.

Parameters:
isector   A reference to a double precision intersection state

Reimplemented from sglGroup.

virtual void sglKeyFrameAnimation::pick ( sglPickf & pick_state,
unsigned int cull_flags ) const [virtual]
 

The single precision pick traversal function which returns all objects that fall within the pick frustum.

Parameters:
pick_state   A reference to a single precision pick state.
cull_flags   Bit flags that indicate which planes of the pick frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free picking can be accomplished by setting this to 0.

Reimplemented from sglGroup.

virtual void sglKeyFrameAnimation::pick ( sglPickd & pick_state,
unsigned int cull_flags ) const [virtual]
 

The double precision pick traversal function which returns all objects that fall within the pick frustum.

Parameters:
pick_state   A reference to a double precision pick state.
cull_flags   Bit flags that indicate which planes of the pick frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free picking can be accomplished by setting this to 0.

Reimplemented from sglGroup.

virtual void sglKeyFrameAnimation::preDraw ( const PreDrawStruct & trav_state ) [virtual]
 

This is the pre-draw traversal function which should be called before intersecting or culling the scene graph. This "cleans" the tree by computing the bound boxes and spheres that have been marked as dirty, building display lists for geometry that has changed, binding textures that need to be, updating the animation nodes whose state has changed. This should be called with a valid graphics context current.

Parameters:
trav_state   A struct containing state information needed by the preDraw traversal (currently frame time and count for animation nodes).

Reimplemented from sglGroup.

virtual sglNode* sglKeyFrameAnimation::clone ( unsigned int mode ) const [virtual]
 

Make a copy of the scenegraph rooted at this node.

Parameters:
mode   Bit masks to control the behaviour of the clone. These are OR-ed together from the mode values in sglObject::CloneModeEnum.
Returns:
Pointer to root of cloned scene graph.

Reimplemented from sglGroup.

virtual void sglKeyFrameAnimation::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]
 

Output the state of this node to the specified ostream.

Parameters:
ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglAnimation.

virtual void sglKeyFrameAnimation::cull ( sglCull< float > & trav_state,
unsigned int cull_flags ) const [protected, virtual]
 

The single precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.

Parameters:
trav_state   The single precision traversal state that collects all the state and geometry information that passes the cull.
cull_flags   Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0.

Reimplemented from sglGroup.

virtual void sglKeyFrameAnimation::cull ( sglCull< double > & trav_state,
unsigned int cull_flags ) const [protected, virtual]
 

The double precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.

Parameters:
trav_state   The single precision traversal state that collects all the state and geometry information that passes the cull.
cull_flags   Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0.

Reimplemented from sglGroup.


The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:08 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001