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

sglTimedAnimation Class Reference

#include <sglTimedAnimation.hpp>

Inheritance diagram for sglTimedAnimation::

sglAnimation sglGroup sglNode sglObject List of all members.

Public Methods

 sglTimedAnimation ()
virtual ~sglTimedAnimation ()
virtual bool addChild (sglNode *node)
virtual bool insertChild (unsigned int index, sglNode *node)
virtual bool removeChild (sglNode *node)
virtual sglNoderemoveChild (unsigned int index)
void setOffsetTime (const sglTimespec &offset_time)
const sglTimespec& getOffsetTime () const
bool setDuration (sglNode *node, float sec)
float getDuration (sglNode *node) const
bool setDuration (unsigned int index, float sec)
float 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 (double atime) const
sglNodeselectChild (const sglTimespec &current_time) const
void copyTo (sglTimedAnimation *dst, unsigned int mode) const

Protected Attributes

vector<float> m_durations
sglTimespec m_start_time
sglTimespec m_pause_time
sglTimespec m_offset_time
double m_pause_diff
float m_total_time
float m_total_time2
float m_forward_time
float m_return_time

Detailed Description

A subclass of sglAnimation, this node selects one child as a function of the current frame time (not count) and the animation mode. As each child is added to this node the default number of seconds 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 seconds.

Example:

   sglTimedAnimation *animation = new sglTimedAnimation;
   for (unsigned int ix=0; ix<10; ++ix)
   {
      sglGeode *geode = new sglGeode;
      animation->addChild(geode);
      animation->setDuration(ix, 0.6f);  // display for 0.6 seconds
   }
   animation->setMode(sglAnimation::eCYCLE); // forward only
   animation->setRange();                    // display all
   animation->setSpeed(0.75f);               // .75 of normal speed
                                             //    (0.8 seconds each)
   animation->setNumCycles(1);               // one-shot

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

Definition at line 67 of file sglTimedAnimation.hpp.


Constructor & Destructor Documentation

sglTimedAnimation::sglTimedAnimation ( )
 

default constructor.

sglTimedAnimation::~sglTimedAnimation ( ) [virtual]
 

virtual destructor.


Member Function Documentation

virtual bool sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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* sglTimedAnimation::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 sglTimedAnimation::setOffsetTime ( const sglTimespec & offset_time )
 

Set an offset time when starting the animation. Only positive times 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_time   Timespec containing the offset (in secs, nsecs)

const sglTimespec & sglTimedAnimation::getOffsetTime ( ) const [inline]
 

Query the current time offset.

Returns:
The current time offset in an sglTimespec object.

Definition at line 93 of file sglTimedAnimation.hpp.

bool sglTimedAnimation::setDuration ( sglNode * node,
float sec )
 

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

Parameters:
node   Pointer to child to set the duration.
sec   Number of seconds 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

float sglTimedAnimation::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 sglTimedAnimation::setDuration ( unsigned int index,
float sec )
 

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

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

float sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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* sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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 sglTimedAnimation::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:11 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001