![]() |
VR-Forces 5.0.2 Developer's Guide
|
DtDynamicTerrainSwitchNode replaces an osgSim::multiswitch in a terrain patch (or page) that is tagged with a WRM ' switch' comment if that patch/page is parsed by the dynamic terrain parser. It supports multiple references to itself by extending DtMultiReferencedNodeContainer, with DtSwitchInstanceState as its template parameter. During a traversal of this node, a node path hash is requested and used to look up the state of the switch for that particular reference. the accept method is only called for those children associated with the current state.
To support transition animations between states, the DtDynamicTerrainSwitchNode also maintains information about osg::Sequences found under the switch. Those osg::Sequences will be replaced in the scene graph with DtDynamicTerrainSequenceNodes; so it tracks their node path hashes (since they will be referenced as many times as the switch is); which state of the switch the DtDynamicTerrainSequenceNode(s) corresponds to; and osg::ref_ptrs to the DtDynamicTerrainSequenceNode(s) themselves. When a switch is set to a new state, it checks for a DtDynamicTerrainSequenceNode related to it; if any exist, it will invoke each sequence's reset() method (which includes node path hash to specify a reference to that sequence), so the sequence referense can be set to its START state.

Classes | |
| struct | SequenceDescriptor |
Public Types | |
| typedef std::list< DtString > | StateNameList |
| typedef std::list< DtString > | ValueNameList |
| typedef boost::unordered_map < DtString, int > | ValueChildMap |
Public Types inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState > | |
| typedef boost::function< void(DynamicTerrain::NodePathHash)> | NodeReferenceFunction |
Public Attributes | |
| boost::signalslib::signal < void(DtDynamicTerrainSwitchNode *, DynamicTerrain::NodePathHash, int)> | signal_setSwitch |
Protected Types | |
| typedef std::list < SequenceDescriptor > | SequenceInstanceList |
| typedef boost::unordered_map < DynamicTerrain::NodePathHash, SequenceInstanceList > | SwitchToSequenceMap |
Protected Types inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState > | |
| typedef boost::unordered_map < DynamicTerrain::NodePathHash, DtSwitchInstanceState > | NodeInstanceMap |
Protected Member Functions | |
| virtual void | traverse (osg::NodeVisitor &nv) |
| virtual void | setStateBindable (DynamicTerrain::NodePathHash hashIndex, int state) |
Protected Attributes | |
| SwitchToSequenceMap | mySwitchToSequenceMap |
| StateNameList | myStateNames |
| ValueChildMap | myValueToChildMap |
| osg::BoundingSphere | myOriginalbounds |
| osg::Vec3d | myPosInModelCoords |
Protected Attributes inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState > | |
| NodeInstanceMap | myNodeInstanceMap |
| std::set< int > | myNodePathDepths |
| DtSwitchInstanceState | myDefaultState |
| boost::mutex | myMapMutex |
| typedef std::list<DtString> makVrv::DtDynamicTerrainSwitchNode::StateNameList |
StateNameList defines a list of the names this switch can be referred to by, as discovered with WRM ' switch' comments. Currently, only the first found will be used as the key to dynamic terrain state changes.
| typedef std::list<DtString> makVrv::DtDynamicTerrainSwitchNode::ValueNameList |
ValueNameList defines a list of the names of state values (like 'on', or 'off', or 'damaged' etc. discovered on the osg::multiswitch as ' state' WRM comments.
| typedef boost::unordered_map<DtString, int> makVrv::DtDynamicTerrainSwitchNode::ValueChildMap |
ValueChildMap defines an unordered map of value names to the child indices to which they correspond.
|
protected |
|
protected |
| makVrv::DtDynamicTerrainSwitchNode::DtDynamicTerrainSwitchNode | ( | ) |
CTOR.
| makVrv::DtDynamicTerrainSwitchNode::DtDynamicTerrainSwitchNode | ( | const DtDynamicTerrainSwitchNode & | , |
| const osg::CopyOp & | copyop = osg::CopyOp::SHALLOW_COPY |
||
| ) |
Copy CTOR.
|
virtual |
DTOR.
|
inlinevirtual |
Return the className to OSG.
|
virtual |
Set the active state for a switch node reference. In addition to saving the state for the reference, this checks for and activates any sequences that are under this state. Note that there is a one-to-one correspondence between the state and the child node in the osg::Group param[in] hashIndex node path hash for the referenced switch param[in] state state / child to make active.
|
virtual |
Set the active state for a switch node reference using a value specified with an ' state' WRM comment on the child. This looks up the child in the valueToChildMap param[in] hashIndex node path hash for the referenced switch param[in] valueName name of the state to make active.
|
virtual |
Set the active state for ALL switch references in this container param[in] state state/child to make the active state.
|
virtual |
Set the active state for ALL switch references using a state value name param[in] valueName ' state' name for the state.
|
virtual |
Get the number of states this switch has.
|
virtual |
Set the names found for this switch param[in] stateNames the list of names found for this switch.
|
virtual |
Set the position of this switch in model coordinates. This may come to us via an comment. If not, it is computed by OSG as the center of the bounding sphere that encompasses ALL the geometry under the multiswitch.
|
virtual |
Get the position of this switch in model coordinates.
|
virtual |
Get the names found for this switch.
|
virtual |
Associate a list of value names with a state/child param[in] state the state/child associated with this list of names param[in] valueNames the list of names this state/child is known by.
|
virtual |
Add a sequence which is under this switch.
|
virtual |
Get the map that converts values (by name) to states/children.
|
virtual |
getter for the originalBounds of this switch. This is the bounds that is used for calculating the location of this switch node so that it matches the location that the VRF Backend is using. The node::_boundingSphere changes if there are any light points under this switch so we have to save off the original bounds when this node is created.
|
virtual |
setter for the original bounds.
|
protectedvirtual |
Traverse the node. The path that the node visitor used to traverse to this node is used the calculate a node path hash, which in turn is used to find the state of the reference to this node. Only the active state/child is 'accept'ed. param[in] nv the node visitor performing the traversal.
|
protectedvirtual |
This method is a workaround to get boost::bind to use the actual setState (which this calls). I suspect this is related to the fact that this class is derived from a templated base class; boost::bind doesn't want to work with any method that is an override of that base class' methods param[in] hashIndex node path hash for the referenced switch param[in] state state / child to make active.
| boost::signalslib::signal<void(DtDynamicTerrainSwitchNode*, DynamicTerrain::NodePathHash, int)> makVrv::DtDynamicTerrainSwitchNode::signal_setSwitch |
signal for things to listen to so they can find out when a switch changes
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |