#include <sglNode.hpp>
Inheritance diagram for sglNode::
Public Methods | |
sglNode () | |
virtual | ~sglNode () |
unsigned int | getNumParents () const |
sglGroup* | getParent (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 |
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.
|
default constructor.
|
|
destructor.
|
|
Get the number of nodes (parents) that reference this one.
Definition at line 135 of file sglNode.hpp. |
|
Get a pointer to the i-th parent.
|
|
Set the bounding sphere and its update behaviour.
|
|
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
|
|
Get the current bound recomputation mode.
Definition at line 168 of file sglNode.hpp. |
|
Returns the bounding volume as it was last computed.
Definition at line 171 of file sglNode.hpp. |
|
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.
Reimplemented in sglGeode, sglGroup, sglKeyFrameAnimation, sglScene, and sglTimedAnimation. |
|
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.
Reimplemented in sglScale, sglTransform, and sglTranslate. Definition at line 200 of file sglNode.hpp. |
|
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.
Reimplemented in sglScale, sglTransform, and sglTranslate. Definition at line 210 of file sglNode.hpp. |
|
The single precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.
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. |
|
The double precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.
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. |
|
The single precision pick traversal function which returns all objects that fall within the pick frustum.
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. |
|
The double precision pick traversal function which returns all objects that fall within the pick frustum.
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. |
|
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.
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. |
|
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.
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. |
|
Make a copy of the scenegraph rooted at this node.
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. |
|
Output the state of this node to the specified ostream.
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. |