Public Types |
| typedef std::list< DtString > | StateNameList |
| | StateNameList defines a list of the names this switch can be referred to by, as discovered with WRM ' switch' comments.
|
| typedef std::list< DtString > | ValueNameList |
| | ValueNameList defines a list of the names of state values (like 'on', or 'off', or 'damaged' etc.
|
typedef boost::unordered_map
< DtString, int > | ValueChildMap |
| | ValueChildMap defines an unordered map of value names to the child indices to which they correspond.
|
| typedef boost::function< void(DynamicTerrain::NodePathHash)> | NodeReferenceFunction |
| | Function type that runs on node reference.
|
Public Member Functions |
| | DtDynamicTerrainSwitchNode () |
| | CTOR.
|
| | DtDynamicTerrainSwitchNode (const DtDynamicTerrainSwitchNode &, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY) |
| | Copy CTOR.
|
| virtual | ~DtDynamicTerrainSwitchNode () |
| | DTOR.
|
| virtual void | setState (DynamicTerrain::NodePathHash hashIndex, int state) |
| | Set the active state for a switch node reference.
|
| virtual void | setState (DynamicTerrain::NodePathHash hashIndex, const std::string &valueName) |
| | Set the active state for a switch node reference using a value specified with an ' state' WRM comment on the child.
|
| virtual void | setState (int state) |
| | Set the active state for ALL switch references in this container param[in] state state/child to make the active state.
|
| virtual void | setState (const std::string &valueName) |
| | Set the active state for ALL switch references using a state value name param[in] valueName ' state' name for the state.
|
| virtual int | numStates () const |
| | Get the number of states this switch has.
|
| virtual void | setStateNames (const StateNameList &stateNames) |
| | Set the names found for this switch param[in] stateNames the list of names found for this switch.
|
| virtual const StateNameList & | stateNames () const |
| | Get the names found for this switch.
|
| virtual void | addValues (int state, const ValueNameList &valueNames) |
| | 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 void | addSequence (DtDynamicTerrainSequenceNode *sequence, DynamicTerrain::NodePathHash seqIndex, DynamicTerrain::NodePathHash switchIndex, int childCount) |
| | Add a sequence which is under this switch.
|
| virtual const ValueChildMap & | valueToChildMap () const |
| | Get the map that converts values (by name) to states/children.
|
| | DtMultiReferencedNodeContainer () |
| | CTOR.
|
| | DtMultiReferencedNodeContainer (const DtMultiReferencedNodeContainer &orig) |
| | Copy CTOR param[in] orig the DtMultiReferencedNodeContainer to copy.
|
| virtual | ~DtMultiReferencedNodeContainer () |
| | DTOR.
|
virtual
DynamicTerrain::NodePathHash | addNodeInstance (const osg::NodePath &nodePath) |
| | Add a reference to a node and return the hash for the passed in node path.
|
| virtual void | setDefaultState (const DtSwitchInstanceState &state) |
| | Specify a default state used to initialize each node reference when added.
|
virtual const
DtSwitchInstanceState & | defaultState () const |
| | Get the default state used for node references.
|
| virtual void | setState (DynamicTerrain::NodePathHash hashIndex, const DtSwitchInstanceState &state) |
| | Set the state of a node reference.
|
| virtual void | setState (const DtSwitchInstanceState &state) |
| | Set the state of all node references.
|
| virtual bool | getState (DynamicTerrain::NodePathHash hashIndex, DtSwitchInstanceState &state) |
| | Get the state of node instance.
|
virtual
DynamicTerrain::NodePathHash | calcNodePathHashValue (const osg::NodePath &nodePath) |
| | Calculate a node hash, checks all known depths that nodes werer added at.
|
| virtual void | forEachNodeReference (NodeReferenceFunction &perNodeFunction) |
| | Execute a function on each node reference in the container.
|
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.