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

sglGroup Class Reference

#include <sglGroup.hpp>

Inheritance diagram for sglGroup::

sglNode sglObject sglAnimation sglBillboard sglBitMaskSwitch sglCallback sglDefaultStateNode sglDiscriminator sglDistanceSwitch sglLayer sglLOD sglLODStateNode sglOrderedGroup sglOverrideStateNode sglScale sglScene sglSwitch sglTransform sglTranslate sglUnProject sglUnScale sglUnScaleRange List of all members.

Public Methods

 sglGroup ()
virtual ~sglGroup ()
unsigned int getNumChildren () const
virtual bool addChild (sglNode *child)
virtual bool removeChild (sglNode *child)
virtual bool insertChild (unsigned int index, sglNode *child)
virtual sglNodereplaceChild (unsigned int index, sglNode *child)
virtual sglNoderemoveChild (unsigned int index)
sglNodegetChild (unsigned int index)
int searchChild (sglNode *child, unsigned int start=0) 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 computeBound ()
virtual void computeBoundsRecursiveDown ()
virtual void cull (sglCull< float > &trav_state, unsigned int cull_flags) const
virtual void cull (sglCull< double > &trav_state, unsigned int cull_flags) const
void copyTo (sglGroup *dst, unsigned int mode) const

Protected Attributes

vector<sglNode*> m_child_list

Detailed Description

The scene graph is a directed, acyclic graph (DAG). As such, interior nodes of the scene graph can have multiple children. The sglGroup node is the base class (concrete) for all such nodes. It has the ability of managing a list of child nodes (any subclass of sglNode). There are functions to get the number of children currently attached to this node, add new children to the end of the list, insert children at a desired index, remove children, get the nth child, and search for a given child. For the sake of subclasses like sglSwitch and sglLOD children can be added to the list more than once. The user may not add a NULL as a child, however.

When the traversal funtions get to an sglGroup node it will visit all of the children. Note that just because the child list is internally stored as an ordered list of sglNode's, this order does not in any way determine the order in which children get traversed or rendered (unless a subclass dictates otherwise.

Example:

   sglGroup *parent = new sglGroup;
   sglGroup *child1 = new sglGroup;
   unsigned int num;

   parent->addChild(child1);
   num = parent->getRefCount();           // returns 0
   num = parent->getNumChildren();        // returns 1
   num = child1->getRefCount();           // returns 1
   num = child1->getNumParents();         // returns 1

   parent->remove(child1);
   num = parent->getNumChildren();        // returns 0
   num = child1->getRefCount();           // returns 0
   num = child1->getNumParents();         // returns 0

Definition at line 77 of file sglGroup.hpp.


Constructor & Destructor Documentation

sglGroup::sglGroup ( )
 

default constructor.

sglGroup::~sglGroup ( ) [virtual]
 

destructor.


Member Function Documentation

unsigned int sglGroup::getNumChildren ( ) const [inline]
 

Get the number of child nodes in this group.

Returns:
number of children

Definition at line 88 of file sglGroup.hpp.

bool sglGroup::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 in sglKeyFrameAnimation, and sglTimedAnimation.

bool sglGroup::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 in sglKeyFrameAnimation, and sglTimedAnimation.

bool sglGroup::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 in sglKeyFrameAnimation, and sglTimedAnimation.

sglNode * sglGroup::replaceChild ( unsigned int index,
sglNode * child ) [virtual]
 

Replace child at given index where the valid range is [0,getNumChildren()-1].

Parameters:
index   Position at which node is to be placed.
child   Pointer to node to be added.
Returns:
Pointer to the child previously at position index or NULL on error (NULL child pointer, index out of range).

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

sglNode * sglGroup::getChild ( unsigned int index )
 

Get a pointer to the child at the given index (valid indices: [0,getNumChildren()-1]).

Parameters:
index   Index of the desired child.
Returns:
The child at position index or NULL on error (if index is out of range.

int sglGroup::searchChild ( sglNode * child,
unsigned int start = 0 ) const
 

Find the index of the first occurrence of a specified child at or after a particular index.

Parameters:
child   Pointer of child to search for.
start   The start index of the search.
Returns:
Index of the first child found, or -1 on error (child is NULL or start is >= getNumChildren()).

virtual sglBound::IntersectResultEnum sglGroup::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 sglNode.

Reimplemented in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

virtual sglBound::IntersectResultEnum sglGroup::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 sglNode.

Reimplemented in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

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

Reimplemented in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

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

Reimplemented in sglBillboard, sglBitMaskSwitch, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLOD, sglLODStateNode, sglScale, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

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

Reimplemented in sglKeyFrameAnimation, sglScene, and sglTimedAnimation.

Referenced by sglScene::preDraw().

virtual sglNode* sglGroup::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 sglNode.

Reimplemented in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDiscriminator, sglDistanceSwitch, sglLOD, sglIndexedBitMaskSwitch, sglKeyFrameAnimation, sglLayer, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglScale, sglScene, sglSphericalTransform, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

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

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

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

Reimplemented in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLayer, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglScale, sglScene, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.

Referenced by sglSwitch::cull(), sglScene::cull(), and sglBitMaskSwitch::cull().

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

Reimplemented in sglBillboard, sglBitMaskSwitch, sglCallback, sglDefaultStateNode, sglDiscriminator, sglDistanceSwitch, sglLOD, sglKeyFrameAnimation, sglLayer, sglLOD, sglLODStateNode, sglOrderedGroup, sglOverrideStateNode, sglScale, sglScene, sglSwitch, sglTimedAnimation, sglTransform, sglTranslate, sglUnProject, sglUnScale, and sglUnScaleRange.


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