VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Public Attributes | 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. 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.

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

Classes

struct  SequenceDescriptor
 

Public Types

typedef std::list< DtStringStateNameList
 
typedef std::list< DtStringValueNameList
 
typedef boost::unordered_map
< DtString, int
ValueChildMap
 
- Public Types inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState >
typedef boost::function< void(DynamicTerrain::NodePathHash)> NodeReferenceFunction
 

Public Member Functions

 DtDynamicTerrainSwitchNode ()
 
 DtDynamicTerrainSwitchNode (const DtDynamicTerrainSwitchNode &, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 
virtual ~DtDynamicTerrainSwitchNode ()
 
virtual const charclassName () const
 
virtual void setState (DynamicTerrain::NodePathHash hashIndex, int state)
 
virtual void setState (DynamicTerrain::NodePathHash hashIndex, const std::string &valueName)
 
virtual void setState (int state)
 
virtual void setState (const std::string &valueName)
 
virtual int numStates () const
 
virtual void setStateNames (const StateNameList &stateNames)
 
virtual void setPositionInModelCoordinates (osg::Vec3d pos)
 
virtual osg::Vec3d positionInModelCoordinates () const
 
virtual const StateNameListstateNames () const
 
virtual void addValues (int state, const ValueNameList &valueNames)
 
virtual void addSequence (DtDynamicTerrainSequenceNode *sequence, DynamicTerrain::NodePathHash seqIndex, DynamicTerrain::NodePathHash switchIndex, int childCount)
 
virtual const ValueChildMapvalueToChildMap () const
 
virtual const osg::BoundingSphere & originalBounds () const
 
virtual void setOriginalBounds (const osg::BoundingSphere &bounds)
 
- Public Member Functions inherited from makVrv::DtMultiReferencedNodeContainer< DtSwitchInstanceState >
 DtMultiReferencedNodeContainer ()
 
 DtMultiReferencedNodeContainer (const DtMultiReferencedNodeContainer &orig)
 
virtual ~DtMultiReferencedNodeContainer ()
 
virtual
DynamicTerrain::NodePathHash 
addNodeInstance (const osg::NodePath &nodePath)
 
virtual void setDefaultState (const DtSwitchInstanceState &state)
 
virtual const
DtSwitchInstanceState
defaultState () const
 
virtual void setState (DynamicTerrain::NodePathHash hashIndex, const DtSwitchInstanceState &state)
 
virtual void setState (const DtSwitchInstanceState &state)
 
virtual bool getState (DynamicTerrain::NodePathHash hashIndex, DtSwitchInstanceState &state)
 
virtual
DynamicTerrain::NodePathHash 
calcNodePathHashValue (const osg::NodePath &nodePath)
 
virtual void forEachNodeReference (NodeReferenceFunction &perNodeFunction)
 

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< intmyNodePathDepths
 
DtSwitchInstanceState myDefaultState
 
boost::mutex myMapMutex
 

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 const char* makVrv::DtDynamicTerrainSwitchNode::className ( ) const
inlinevirtual

Return the className to OSG.

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 void makVrv::DtDynamicTerrainSwitchNode::setPositionInModelCoordinates ( osg::Vec3d  pos)
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 osg::Vec3d makVrv::DtDynamicTerrainSwitchNode::positionInModelCoordinates ( ) const
virtual

Get the position of this switch in model coordinates.

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 const osg::BoundingSphere& makVrv::DtDynamicTerrainSwitchNode::originalBounds ( ) const
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 void makVrv::DtDynamicTerrainSwitchNode::setOriginalBounds ( const osg::BoundingSphere &  bounds)
virtual

setter for the original bounds.

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

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

SwitchToSequenceMap makVrv::DtDynamicTerrainSwitchNode::mySwitchToSequenceMap
protected
StateNameList makVrv::DtDynamicTerrainSwitchNode::myStateNames
protected
ValueChildMap makVrv::DtDynamicTerrainSwitchNode::myValueToChildMap
protected
osg::BoundingSphere makVrv::DtDynamicTerrainSwitchNode::myOriginalbounds
protected
osg::Vec3d makVrv::DtDynamicTerrainSwitchNode::myPosInModelCoords
protected

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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)