VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
makVrv::DtDynamicTerrainSwitchNode Class Reference

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. More...

Inheritance diagram for makVrv::DtDynamicTerrainSwitchNode:
Inheritance graph
[legend]

Classes

struct  SequenceDescriptor

Public Types

typedef std::list< DtStringStateNameList
 StateNameList defines a list of the names this switch can be referred to by, as discovered with WRM ' switch' comments.
typedef std::list< DtStringValueNameList
 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.
- Public Types inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState >
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 &copyop=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 StateNameListstateNames () 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 ValueChildMapvalueToChildMap () const
 Get the map that converts values (by name) to states/children.
- Public Member Functions inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState >
 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.

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)
 Traverse the node.
virtual void setStateBindable (DynamicTerrain::NodePathHash hashIndex, int state)
 This method is a workaround to get boost::bind to use the actual setState (which this calls).

Protected Attributes

SwitchToSequenceMap mySwitchToSequenceMap
StateNameList myStateNames
ValueChildMap myValueToChildMap
- Protected Attributes inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState >
NodeInstanceMap myNodeInstanceMap
std::set< intmyNodePathDepths
DtSwitchInstanceState myDefaultState

Detailed Description

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.

Member Typedef Documentation

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

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

ValueChildMap defines an unordered map of value names to the child indices to which they correspond.

Constructor & Destructor Documentation

makVrv::DtDynamicTerrainSwitchNode::DtDynamicTerrainSwitchNode ( )

CTOR.

makVrv::DtDynamicTerrainSwitchNode::DtDynamicTerrainSwitchNode ( const DtDynamicTerrainSwitchNode ,
const osg::CopyOp &  copyop = osg::CopyOp::SHALLOW_COPY 
)

Copy CTOR.

virtual makVrv::DtDynamicTerrainSwitchNode::~DtDynamicTerrainSwitchNode ( )
virtual

DTOR.

Member Function Documentation

virtual void makVrv::DtDynamicTerrainSwitchNode::setState ( DynamicTerrain::NodePathHash  hashIndex,
int  state 
)
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 void makVrv::DtDynamicTerrainSwitchNode::setState ( DynamicTerrain::NodePathHash  hashIndex,
const std::string &  valueName 
)
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 void makVrv::DtDynamicTerrainSwitchNode::setState ( int  state)
virtual

Set the active state for ALL switch references in this container param[in] state state/child to make the active state.

virtual void makVrv::DtDynamicTerrainSwitchNode::setState ( const std::string &  valueName)
virtual

Set the active state for ALL switch references using a state value name param[in] valueName ' state' name for the state.

virtual int makVrv::DtDynamicTerrainSwitchNode::numStates ( ) const
virtual

Get the number of states this switch has.

Returns
the number of states/children in the switch
virtual void makVrv::DtDynamicTerrainSwitchNode::setStateNames ( const StateNameList stateNames)
virtual

Set the names found for this switch param[in] stateNames the list of names found for this switch.

virtual const StateNameList& makVrv::DtDynamicTerrainSwitchNode::stateNames ( ) const
virtual

Get the names found for this switch.

Returns
the list of names for this switch
virtual void makVrv::DtDynamicTerrainSwitchNode::addValues ( int  state,
const ValueNameList valueNames 
)
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 void makVrv::DtDynamicTerrainSwitchNode::addSequence ( DtDynamicTerrainSequenceNode sequence,
DynamicTerrain::NodePathHash  seqIndex,
DynamicTerrain::NodePathHash  switchIndex,
int  childCount 
)
virtual

Add a sequence which is under this switch.

virtual const ValueChildMap& makVrv::DtDynamicTerrainSwitchNode::valueToChildMap ( ) const
virtual

Get the map that converts values (by name) to states/children.

virtual void makVrv::DtDynamicTerrainSwitchNode::traverse ( osg::NodeVisitor &  nv)
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

virtual void makVrv::DtDynamicTerrainSwitchNode::setStateBindable ( DynamicTerrain::NodePathHash  hashIndex,
int  state 
)
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

Member Data Documentation

SwitchToSequenceMap makVrv::DtDynamicTerrainSwitchNode::mySwitchToSequenceMap
protected
StateNameList makVrv::DtDynamicTerrainSwitchNode::myStateNames
protected
ValueChildMap makVrv::DtDynamicTerrainSwitchNode::myValueToChildMap
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)