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

sglNode Class Reference

#include <sglNode.hpp>

Inheritance diagram for sglNode::

sglObject sglGeode sglGroup sglLight sglViewPlatform sglAnimation sglBillboard sglBitMaskSwitch sglCallback sglDefaultStateNode sglDiscriminator sglDistanceSwitch sglLayer sglLOD sglLODStateNode sglOrderedGroup sglOverrideStateNode sglScale sglScene sglSwitch sglTransform sglTranslate sglUnProject sglUnScale sglUnScaleRange sglDirectionalLight sglPositionalLight List of all members.

Public Methods

 sglNode ()
virtual ~sglNode ()
unsigned int getNumParents () const
sglGroupgetParent (unsigned int index) const
void setBound (const sglSphereBound< float > *sphere, sglBound::ModeEnum mode)
const sglSphereBound<float>& getBound ()
sglBound::ModeEnum getBoundMode () const
const sglSphereBound<float>& getPrevBound () const
virtual void preDraw (const PreDrawStruct &trav_state)
virtual void computeTxToParent (sglMat4f &) const
virtual void computeTxToParent (sglMat4d &) const
virtual sglBound::IntersectResultEnum intersect (sglIntersectf &) const
virtual sglBound::IntersectResultEnum intersect (sglIntersectd &) const
virtual void pick (sglPickf &, unsigned int) const
virtual void pick (sglPickd &, unsigned int) const
virtual void cull (sglCull< float > &trav_state, unsigned int cull_flags) const=0
virtual void cull (sglCull< double > &trav_state, unsigned int cull_flags) const=0
virtual sglNode* clone (unsigned int mode) const=0
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Types

enum  DirtyEnum {
  eBOUND = 0x01,
  eDLIST = 0x02,
  eANIMATION = 0x04
}

Protected Methods

virtual void computeBound ()=0
virtual void computeBoundsRecursiveDown ()
virtual void dirty (unsigned char mask)
void copyTo (sglNode *dst, unsigned int mode) const

Protected Attributes

sglSphereBound<float> m_sphere
sglBound::ModeEnum m_bound_mode
unsigned char m_dirty

Friends

class  sglDrawable
class  sglGroup

Detailed Description

The abstract base class for all scene graph node types including sglGroup, sglGeode, sglViewPlatform, and sglLight nodes. It provides management functionality needed to make the traversal functions more efficient as described in the following sections.

Parent Lists

Whenever a node is added as a child to a group node, not only does the child get placed in a list of children in the group, but also the parent node gets placed in a list of parents in the child node. This latter step does not increase the reference count of the parent. sglNodes provide the functionality to manage the parent list of the nodes. For reasons of efficiency, a group will not appear more than once in a child's parent list even if that child is added more than once to the same sglGroup.

Bounding Spheres

The cull traversal compares the spatial bounds of each node with the view frustum specified by the user to determine which nodes are completely out of the frustum, and which are either partially of wholly inside the view frustum. sglNodes contain the definition and management functions of bounding spheres. Under default conditions, an sglNode's bounding sphere will be automatically computed to be large enough to contain the bounding spheres of all of its children.

For reasons of efficiency, these spheres do not get updated immediately upon addition of a new child. Rather, a bounds dirty flag is propagated up the tree from the point of insertion to the root of the tree (along multiple paths in the case where nodes have more then one parent). Before traversing the tree, the user must call preDraw to compute all the new bounding spheres for those nodes with the bounds dirty flag set.

The user can override the default behaviour (autocomputation of the bounding sphere) by calling the setBound function with sglBound::eSTATIC token for the mode. This is useful for nodes whose child list may change often, but the user knows the smallest sphere that will contain all of the possibilities. Setting the static bounds prevents the upward bounds computation from proceding up the tree past this point (from the parents perspective, the bounding sphere of a child with static bound doesn't change).

Traversal Functions

All the traversal functions make their first appearance in the class hierarchy in the sglNode class. Currently single and double precision versions of the segment intersection (intersect), frustum intersection (pick), and view frustum culling (cull) traversals, and the preDraw functions are currently defined. See the documentation on Traversals for more information.

Example:

   sglGroup *node = new sglGroup;
   unsigned int num_parents = node->getNumParents();  // returns 0

   sglSphereBoundf sph;                       // single precision
   sph.setCenter(1.0f, 1.3f, -3.2f);
   sph.setRadius(13.3f);
   node->setBound(&sph, sglBound::eSTATIC);   // set a static bound

   node->setBound(NULL, sglBound::eSTATIC);   // set static bound but compute
                                              // bounds based on children's
                                              // bounds (see sglGroup).

   node->setBound(NULL, sglBound::eDYNAMIC);  // set dynamic bounds computation

Definition at line 124 of file sglNode.hpp.


Constructor & Destructor Documentation

sglNode::sglNode ( )
 

default constructor.

sglNode::~sglNode ( ) [virtual]
 

destructor.


Member Function Documentation

unsigned int sglNode::getNumParents ( ) const [inline]
 

Get the number of nodes (parents) that reference this one.

Returns:
number of parents

Definition at line 135 of file sglNode.hpp.

sglGroup * sglNode::getParent ( unsigned int index ) const
 

Get a pointer to the i-th parent.

Parameters:
index   index of parent node. If index is out of range then NULL is returned.
Returns:
a pointer to the parent node

void sglNode::setBound ( const sglSphereBound< float > * sphere,
sglBound::ModeEnum mode )
 

Set the bounding sphere and its update behaviour.

Parameters:
sphere   A pointer to a bounding sphere. If the pointer is NULL, the bounding sphere is computed (immediately if mode is sglBound::eSTATIC) based on the scene graph below this node; otherwise, it is copied from the one passed in.
mode   If equal to sglBound::eDYNAMIC, then the bounding sphere will be automatically computed by preDraw() or the traversers, and updated when the scene graph below this node changes. If it is set to sglBound::eSTATIC, the the bounding sphere will not be recomputed even if the underlying graph changes.

const sglSphereBound< float > & sglNode::getBound ( )
 

Get the current bounding sphere. If the bound mode is set to sglBound::eDYNAMIC and the bounding sphere is dirty, it will be computed immediately before returning the refernce

Returns:
reference to the current bounding sphere.

sglBound::ModeEnum sglNode::getBoundMode ( ) const [inline]
 

Get the current bound recomputation mode.

Returns:
the current bound mode: either sglBound::eSTATIC or sglBound::eDYNAMIC.

Definition at line 168 of file sglNode.hpp.

const sglSphereBound< float > & sglNode::getPrevBound ( ) const [inline]
 

Returns the bounding volume as it was last computed.

Definition at line 171 of file sglNode.hpp.

void sglNode::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 in sglGeode, sglGroup, sglKeyFrameAnimation, sglScene, and sglTimedAnimation.

void sglNode::computeTxToParent ( sglMat4f & curr_mat ) const [inline, virtual]
 

Compute a single precision transform to parent and append (via multiplication) the matrix passed in. This is part of an upward traversal, which most commonly begins with an sglViewPlatform and used for computing the position and orientation of said platform. This is the default implementation for all nodes that do not affect this matrix and therefore this function does nothing.

Parameters:
curr_mat   The current view matrix for nodes below this one.

Reimplemented in sglScale, sglTransform, and sglTranslate.

Definition at line 200 of file sglNode.hpp.

void sglNode::computeTxToParent ( sglMat4d & curr_mat ) const [inline, virtual]
 

Compute a double precision transform to parent and append (via multiplication) the matrix passed in. This is part of an upward traversal, which most commonly begins with an sglViewPlatform and used for computing the position and orientation of said platform. This is the default implementation for all nodes that do not affect this matrix and therefore this function does nothing.

Parameters:
curr_mat   The current view matrix for nodes below this one.

Reimplemented in sglScale, sglTransform, and sglTranslate.

Definition at line 210 of file sglNode.hpp.

sglBound::IntersectResultEnum sglNode::intersect ( sglIntersectf & isector ) const [inline, 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 in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

Definition at line 217 of file sglNode.hpp.

sglBound::IntersectResultEnum sglNode::intersect ( sglIntersectd & isector ) const [inline, 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 in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

Definition at line 227 of file sglNode.hpp.

void sglNode::pick ( sglPickf & pick_state,
unsigned int cull_flags ) const [inline, 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 in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

Definition at line 240 of file sglNode.hpp.

void sglNode::pick ( sglPickd & pick_state,
unsigned int cull_flags ) const [inline, 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 in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

Definition at line 250 of file sglNode.hpp.

void sglNode::cull ( sglCull< float > & trav_state,
unsigned int cull_flags ) const [pure 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 in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLayer, sglLight, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglScale, sglScene, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, sglUnScaleRange, and sglViewPlatform.

void sglNode::cull ( sglCull< double > & trav_state,
unsigned int cull_flags ) const [pure 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 in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglKeyFrameAnimation, sglLayer, sglLight, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglScale, sglScene, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, sglUnScaleRange, and sglViewPlatform.

sglNode * sglNode::clone ( unsigned int mode ) const [pure 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 in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDirectionalLight, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglIndexedBitMaskSwitch, sglKeyFrameAnimation, sglLayer, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglPositionalLight, sglScale, sglScene, sglSphericalTransform, sglSpotLight, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, sglUnScaleRange, and sglViewPlatform.

virtual void sglNode::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 sglObject.

Reimplemented in sglAnimation, sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDirectionalLight, sglDiscriminator, sglDistanceSwitch, sglLOD, sglGeode, sglGroup, sglIndexedBitMaskSwitch, sglKeyFrameAnimation, sglLayer, sglLight, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglPositionalLight, sglScale, sglScene, sglSphericalTransform, sglSpotLight, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, sglUnScaleRange, and sglViewPlatform.


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