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

sglLOD Class Reference

#include <sglLOD.hpp>

Inheritance diagram for sglLOD::

sglGroup sglNode sglObject List of all members.

Public Methods

 sglLOD ()
virtual ~sglLOD ()
unsigned int getNumRanges () const
void setRange (unsigned int index, float range)
float getRange (unsigned int index) const
void setCenter (const sglVec3f &center)
const sglVec3f& getCenter () const
void setLODState (sglLODState *lod_state)
sglLODStategetLODState () 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 sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const
 sglLOD ()
virtual ~sglLOD ()
unsigned int getNumRanges () const
void setRange (unsigned int index, float range)
float getRange (unsigned int index) const
void setCenter (const sglVec3f &center)
const sglVec3f& getCenter () const
void setLODState (sglLODState *lod_state)
sglLODStategetLODState () 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 sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Static Public Methods

void setScaleFactor (float scale)
float getScaleFactor ()
void setScaleFactor (float scale)
float getScaleFactor ()

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 float computeRange (float trav_lod_scale, float trav_lod_offset, const sglMat4f &view_matrix) const
virtual float computeRange (float trav_lod_scale, float trav_lod_offset, const sglMat4d &view_matrix) const
void copyTo (sglLOD *dst, unsigned int mode) const
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 float computeRange (float trav_lod_scale, float trav_lod_offset, const sglMat4f &view_matrix) const
virtual float computeRange (float trav_lod_scale, float trav_lod_offset, const sglMat4d &view_matrix) const
void copyTo (sglLOD *dst, unsigned int mode) const

Protected Attributes

sglVec3f m_center
vector<float> m_ranges
sglLODStatem_lod_state

Static Protected Attributes

float s_range_scale

Detailed Description

This subclass of sglGroup will select all or none of its children to be traversed based on a function of its range from the eye point (the "origin" of the view frustum) and what is defined as the center of this node. This acts like a simplified LOD node where this is a single range threshold.

After the children have been added, the user specifies the range and specifies the center point which is a reference point relative to the origin of the local coordinate system of this node used to compute the range to the viewpoint. This range value can also be scaled and biased to change which child is selected. Unlike LOD, the order that the children are added to the node is NOT significant.

The children are selected for further traversal according to the following table:

  Range Value, x    Child selected:
 -----------------  ---------------
   x <= distance     all children
   x >  distance        none

Scale and Bias

The range value, x, that is computed by this node during traversal can be modified in a number of different ways:

  1. Associate an sglLODState object with this node. This adds an additional scale and offset (bias):
       new_range1 = state_scale*(dist from eyepoint and center) + state_offset
    

  2. Set a static scale factor for the sglDistanceSwitch nodes. This has the following effect on all range calculations:
       new_range2 = static_scale*new_range1
    

  3. Set a scale and offset on the cull or isect traversal state. This has the following effect:
       new_range3 = traversal_scale*new_range2 + traversal_offset
    
    For the cull traversal, the traversal scale and offset are computed in the scene graph's root (sglScene) node before the traversal commences. It does this by making a call to sglScene::computeLODScale with the size of the window in pixels and the field of view. In this function the scale is computed in an attempt select higher resolution children as the window becomes larger or the FOV gets smaller (a zoom in effect). Note: currently the trav_offset is always set to zero.

  4. Add an sglLODStateNode to the scene graph (see its page for an explanation of this node).
Special behaviour for intersect and pick traversals

When using the intersect or pick traversal on a scene graph containing sglLOD nodes a number of different behaviours can be dictated by the user when it encounters an sglLOD node. By default, the intersection will only be performed for the highest resolution child (child[0]). The other behaviours are listed as follows for various sglProbe modes:

  1. ISECT_LOD_ALL - to intersect/pick against all of the children as if an sglGroup node.
  2. ISECT_LOD_NONE - to halt the traversal of this branch.
  3. ISECT_LOD_VIEW - perform intersection/picking against the same node that the view frustum culling would select (user must specify the view matrix).
Example:

   sglLOD *lod_node = new sglLOD;
   lod_node->setLODState(new sglLODState);

   sglGeode *geode1 = new sglGeode;
   sglGeode *geode2 = new sglGeode;
   sglGeode *geode3 = new sglGeode;

   lod_node->addChild(geode1);     // finest resolution
   lod_node->addChild(geode2);
   lod_node->addChild(geode3);     // coarsest resolution

                                   // select nothing less than 1.0
   lod_node->setRange(0, 1.0f);    // select geode1 between 1.0 and 5.0
   lod_node->setRange(1, 5.0f);    // select geode2 between 5.0 and 10.0
   lod_node->setRange(2, 10.0f);   // select geode3 between 10.0 and 50.0
   lod_node->setRange(3, 50.0f);   // select nothing greater than 50.0

   // double computed range for all LODs: has effect of selecting coarser
   // resolution children.
   sglLOD::setScaleFactor(2.0f);

   // halve the computed range and add a bias for this LOD only: has effect
   // of selecting finer resolution children
   sglLODState *lod_state = lod_node->getLODState();
   if (lod_state)
   {
      lod_state->setRangeScale(0.5f);
      lod_state->setRangeOffset(-2.0f);
   }

Definition at line 145 of file sglDistanceSwitch.hpp~.


Constructor & Destructor Documentation

sglLOD::sglLOD ( )
 

default constructor.

sglLOD::~sglLOD ( ) [virtual]
 

virtual destructor.

sglLOD::sglLOD ( )
 

default constructor.

sglLOD::~sglLOD ( ) [virtual]
 

virtual destructor.


Member Function Documentation

unsigned int sglLOD::getNumRanges ( ) const [inline]
 

Get the number of elements in the range vector.

Returns:
size of the range vector.

Definition at line 156 of file sglDistanceSwitch.hpp~.

void sglLOD::setRange ( unsigned int index,
float range )
 

Set a range value.

Parameters:
index   The index into the range vector.
range   The index-th range value. It should be positive and greater than the range value in the index-1 position.

float sglLOD::getRange ( unsigned int index ) const
 

Get a range value.

Parameters:
index   The index in the range vector.
Returns:
range value at the position specified by index. If index is out of range then -1.0 is returned (note: -1 is returned for unspecified range values as well).

void sglLOD::setCenter ( const sglVec3f & center ) [inline]
 

Set the reference position for computing a range to. This defaults to the origin of this node's local coordinate system.

Parameters:
center   The reference position.

Definition at line 177 of file sglDistanceSwitch.hpp~.

const sglVec3f & sglLOD::getCenter ( ) const [inline]
 

Get the current reference position.

Returns:
The current reference position.

Definition at line 182 of file sglDistanceSwitch.hpp~.

void sglLOD::setScaleFactor ( float scale ) [inline, static]
 

Set a global scale factor used to affect transitions of groups of ALL LOD nodes.

Parameters:
scale   The scale factor (should be positive).

Definition at line 188 of file sglDistanceSwitch.hpp~.

float sglLOD::getScaleFactor ( ) [inline, static]
 

Get the current global scale factor.

Returns:
The current scale factor.

Definition at line 193 of file sglDistanceSwitch.hpp~.

void sglLOD::setLODState ( sglLODState * lod_state )
 

Specify a scale and bias to affect transitions of this LOD node. By using the same sglLODState object for more than one sglLOD node, a group of sglLOD's range calculation can be affected simultaneously. These objects are reference counted with this function. New objects are ref()-ed while previous objects are deref()-ed. If an sglLODState object's reference count goes to zero when it is replaced by this function, it will be deleted.

Parameters:
lod_scale   The new sglLODState object.
See also:
sglLODState

sglLODState * sglLOD::getLODState ( ) const [inline]
 

Get a pointer to the current sglLODState object.

Returns:
Pointer to the current sglLODState object. NULL if no object has be assigned.

Definition at line 211 of file sglDistanceSwitch.hpp~.

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

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

unsigned int sglLOD::getNumRanges ( ) const [inline]
 

Get the number of elements in the range vector.

Returns:
size of the range vector.

Definition at line 174 of file sglLOD.hpp.

void sglLOD::setRange ( unsigned int index,
float range )
 

Set a range value.

Parameters:
index   The index into the range vector.
range   The index-th range value. It should be positive and greater than the range value in the index-1 position.

float sglLOD::getRange ( unsigned int index ) const
 

Get a range value.

Parameters:
index   The index in the range vector.
Returns:
range value at the position specified by index. If index is out of range then -1.0 is returned (note: -1 is returned for unspecified range values as well).

void sglLOD::setCenter ( const sglVec3f & center ) [inline]
 

Set the reference position for computing a range to. This defaults to the origin of this node's local coordinate system.

Parameters:
center   The reference position.

Definition at line 195 of file sglLOD.hpp.

const sglVec3f & sglLOD::getCenter ( ) const [inline]
 

Get the current reference position.

Returns:
The current reference position.

Definition at line 200 of file sglLOD.hpp.

void sglLOD::setScaleFactor ( float scale ) [inline, static]
 

Set a global scale factor used to affect transitions of groups of ALL LOD nodes.

Parameters:
scale   The scale factor (should be positive).

Definition at line 206 of file sglLOD.hpp.

float sglLOD::getScaleFactor ( ) [inline, static]
 

Get the current global scale factor.

Returns:
The current scale factor.

Definition at line 211 of file sglLOD.hpp.

void sglLOD::setLODState ( sglLODState * lod_state )
 

Specify a scale and bias to affect transitions of this LOD node. By using the same sglLODState object for more than one sglLOD node, a group of sglLOD's range calculation can be affected simultaneously. These objects are reference counted with this function. New objects are ref()-ed while previous objects are deref()-ed. If an sglLODState object's reference count goes to zero when it is replaced by this function, it will be deleted.

Parameters:
lod_scale   The new sglLODState object.
See also:
sglLODState

sglLODState * sglLOD::getLODState ( ) const [inline]
 

Get a pointer to the current sglLODState object.

Returns:
Pointer to the current sglLODState object. NULL if no object has be assigned.

Definition at line 229 of file sglLOD.hpp.

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

virtual void sglLOD::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 sglLOD::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 files:
Generated at Mon Jul 1 18:00:08 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001