#include <sglSwitch.hpp>
Inheritance diagram for sglSwitch::
Public Types | |
enum | { eOFF = -2, eON = -1 } |
Public Methods | |
sglSwitch () | |
virtual | ~sglSwitch () |
void | setVal (int val) |
int | getVal () 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 sglNode* | clone (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 |
void | cull (sglCull< float > &trav_state, unsigned int cull_flags, int switch_val) const |
void | cull (sglCull< double > &trav_state, unsigned int cull_flags, int switch_val) const |
void | copyTo (sglSwitch *dst, unsigned int mode) const |
Protected Attributes | |
int | m_switch_val |
Switch Value Traversal Behaviour --------------- ---------------------------------------------- sglSwitch::eOFF do not traversal any children. sglSwitch::eON traversal all the children (as if an sglGroup) 0 .. MAX_INT traverse only one child whose index equals the switch value
The switch value is a signed integer (because the eOFF and eON tokens are negative values). That means it can be used to select one of up to MAX_INT children. If the switch value is out of range of the number of children currently referenced by this node, then the traversal stops at this point in the branch, a warning message is printed, and the traversal function returns.
Special behaviour for cull traversals
The protected cull functions have been rewritten as thin wrappers around reentrant cull functions that take the switch value as parameter. The default implementation in this class is to pass the switch value directly to these reentrant functions. This node can be subclassed, however, and the cull functions can pass different values in as the switch value parameter to create more complex behaviours.
Special behaviour for intersect and pick traversals
In addition to this behaviour, the intersect and pick traversal behaviour for this node can be changed by adding sglProbe::eSWITCH_ALL or sglProbe::eSWITCH_NONE to its mode. The former behaves as if sglSwitch::eON has been set on this node (all nodes are traversed), and the latter corresponds to sglSwitch::eOFF (no nodes traversed).
Example
sglGeode *geode1 = new sglGeode; sglGeode *geode2 = new sglGeode; sglSwitch *switch_node = new sglSwitch; switch_node->addChild(geode1); switch_node->addChild(geode2); switch_node->setVal(sglSwitch::eOFF); // select neither switch_node->setVal(sglSwitch::eON); // select both (the default) switch_node->setVal(0); // select geode1 switch_node->setVal(1); // select geode2 switch_node->setVal(2); // ERROR: will select neither
Definition at line 96 of file sglSwitch.hpp.
|
Some useful switch value constants scoped to this class.
Definition at line 100 of file sglSwitch.hpp. |
|
default constructor.
|
|
virtual destructor.
|
|
Set the switch value (defaults to eON).
Definition at line 118 of file sglSwitch.hpp. |
|
Get the current switch value.
Definition at line 123 of file sglSwitch.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 from sglGroup. |
|
The double precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.
Reimplemented from sglGroup. |
|
The single precision pick traversal function which returns all objects that fall within the pick frustum.
Reimplemented from sglGroup. |
|
The double precision pick traversal function which returns all objects that fall within the pick frustum.
Reimplemented from sglGroup. |
|
Make a copy of the scenegraph rooted at this node.
Reimplemented from sglGroup. |
|
Output the state of this node to the specified ostream.
Reimplemented from sglGroup. |
|
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 from sglGroup. Definition at line 147 of file sglSwitch.hpp. |
|
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 from sglGroup. Definition at line 154 of file sglSwitch.hpp. |