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

Implementation of the model parser for Dynamic Terrain The DtDynamicTerrainParser visits all the nodes in a terrain patch or page and looks for osg::multiswitches with WRM switch ( switch) comments. More...

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

Public Types

Output structures
typedef std::vector< osg::Matrixd > StateTransformList
 StateTransformList defines a vector of the world locations of each dynamic terrain switch reference discovered. More...
 
typedef std::vector
< DynamicTerrain::NodePathHash
StateIndexList
 StateIndexList defines a vector of a NodePathHash values associated with each switch reference discovered. More...
 
typedef std::vector
< osg::ref_ptr
< DtDynamicTerrainSwitchNode > > 
TerrainSwitchList
 TerrainSwitchList defines a vector of all the dynamic terrain switches discovered. More...
 
- Public Types inherited from makVrv::DtArticulatedModelParser
typedef std::vector
< osg::ref_ptr
< osgSim::DOFTransform > > 
PartTransformList
 
typedef boost::unordered_map
< int, PartTransformList
PartMap
 
typedef std::vector
< osg::ref_ptr
< osgSim::MultiSwitch > > 
StateList
 
typedef boost::unordered_map
< int, StateList
StateMap
 
typedef std::vector
< osg::ref_ptr< osg::Sequence > > 
AnimationList
 
typedef boost::unordered_map
< std::string, AnimationList
AnimationMap
 
typedef std::map< int, intStateValueMap
 
typedef std::vector< intStateExistenceList
 
typedef boost::unordered_map
< int, StateExistenceList
StateExistenceMap
 
typedef std::vector
< osg::ref_ptr< osg::Group > > 
GroupList
 
typedef boost::unordered_map
< std::string, GroupList
AnnotationMap
 
typedef std::vector< boolValueList
 
typedef std::vector< ValueListSwitchSetList
 
typedef std::map
< osgSim::MultiSwitch
*, SwitchSetList
SwitchSetMap
 

Public Member Functions

 DtDynamicTerrainParser (DtDe &de, bool addInstances=true)
 CTOR. More...
 
 DtDynamicTerrainParser (DtDe &de, DtDynamicTerrainWorld &world, DtModelSemanticsMapper &modelSematicsMapper, bool addInstances=true)
 CTOR. More...
 
virtual ~DtDynamicTerrainParser ()
 DTOR. More...
 
virtual
DtDynamicTerrainWorld::FeatureHandle 
parse (makVrv::DtDynamicTerrainStateManipulatorFactory &manipulatorFactory, osg::Node &node, const osg::Matrix &matrix=osg::Matrix::identity())
 Run the entire parsing algorithm. More...
 
virtual
DtDynamicTerrainWorld::FeatureHandle 
parse (osg::Node &node, const osg::Matrix &matrix=osg::Matrix::identity())
 Run the entire parsing algorithm with defaults Calls the main parse function with the default terrain state manipulator factory. More...
 
DtDynamicTerrainWorld::FeatureHandle featureHandle () const
 Accessor the handle to the features which have been paged in by calls to parse. More...
 
virtual void apply (osg::Group &group)
 apply overrides so this visitor can find switch nodes. More...
 
virtual void apply (osgSim::MultiSwitch &multiswitch)
 
virtual void apply (DtDynamicTerrainSwitchNode &terrainSwitch)
 
virtual void apply (osg::Sequence &sequence)
 
virtual void apply (DtDynamicTerrainSequenceNode &terrainSequence)
 
get/set parsed data interface
const StateTransformListstateTransforms () const
 
void addStateTransform (const osg::Matrixd &mat)
 
const TerrainSwitchListterrainSwitches () const
 
void addTerrainSwitch (DtDynamicTerrainSwitchNode *tSwitch)
 
const StateIndexListstateIndices () const
 
void addStateIndex (DynamicTerrain::NodePathHash index)
 
- Public Member Functions inherited from makVrv::DtArticulatedModelParser
 DtArticulatedModelParser (DtDe &de, DtModelSemanticsMapper &modelSematicsMapper)
 CTOR. More...
 
virtual ~DtArticulatedModelParser ()
 DTOR. More...
 
virtual void apply (osgSim::DOFTransform &transform)
 
virtual void apply (osg::Transform &transform)
 
- Public Member Functions inherited from makVrv::DtModelParser
 DtModelParser ()
 CTOR. More...
 
virtual ~DtModelParser ()
 DTOR. More...
 

Static Public Member Functions

static std::string parserFormat ()
 Get the string to indicate the parser format this parser supports. More...
 
- Static Public Member Functions inherited from makVrv::DtArticulatedModelParser
static std::string parserFormat ()
 Get the string to indicate the parser format this parser supports. More...
 

Protected Types

typedef boost::unordered_map
< DynamicTerrain::NodePathHash,
DynamicTerrain::NodePathHash
ParentHashMap
 

Protected Member Functions

virtual void runVisitor (osg::Node &, const osg::Matrix &)
 Calls node.accept(*this). More...
 
virtual bool parseSwitchNames (const std::string &desc, osgSim::MultiSwitch &multiswitch, std::list< DtString > &stateNames)
 Parse a switch declaration and add a state to the model if it is able to parse the description. More...
 
virtual void parseSwitchValues (const osg::Node &node, std::list< DtString > &valueNames)
 Parse a state node. More...
 
virtual void parseValueListString (const std::string &valueList, std::list< DtString > &valueNames)
 Parse a value list string into a list of strings. More...
 
virtual void pushSwitch (DtDynamicTerrainSwitchNode *switchNode)
 
virtual void popSwitch ()
 
virtual
DtDynamicTerrainSwitchNode
findCurrentSwitch () const
 
virtual void pushSwitchIndex (DynamicTerrain::NodePathHash index)
 
virtual void popSwitchIndex ()
 
virtual
DynamicTerrain::NodePathHash 
findCurrentSwitchIndex () const
 
virtual void pushSwitchChildCount (int child)
 
virtual void popSwitchChildCount ()
 
virtual int findCurrentSwitchChildCount () const
 
virtual void incrementSwitchChildCount ()
 
virtual void decrementSwitchChildCount ()
 
- Protected Member Functions inherited from makVrv::DtArticulatedModelParser
virtual bool parseSwitchDeclaration (const std::string &desc, osgSim::MultiSwitch &multiswitch)
 Parse a switch declaration and add a state to the model if it is able to parse the description. More...
 
virtual bool parseDefaultMultiSwitchValues (osgSim::MultiSwitch &multiswitch)
 Parse a switch to save the default values to be re-used when use by a simple model (props) More...
 
const
DtModelSemanticsMapper::States::Id
createCustomStateId (const std::string &stateName, DtModelSemanticsMapper &mapper)
 Creates a custom state id if possible. More...
 
virtual bool parseStateDeclaration (const std::string &desc, osg::Group &group)
 Parse a state node. More...
 
virtual bool parseAnnotationDeclaration (const std::string &desc, osg::Group &group)
 Parse a annotation node. More...
 
virtual bool parsePartDeclaration (const std::string &desc, osgSim::DOFTransform &transform)
 Parse a part declaration and add a part if the parse was successful. More...
 
virtual bool parseAnimationDeclaration (const std::string &desc, osg::Sequence &sequence)
 Parse an animation declaration and add an animation if the part was successful. More...
 
std::vector< intparseValueList (const std::string &valueList)
 Parse a value list string into a list of integers. More...
 
void pushStateId (int idNumber, osgSim::MultiSwitch *lastStateId)
 Push a state id onto a local stack. More...
 
void popStateId ()
 Pop a state id onto a local stack. More...
 
osgSim::MultiSwitch * lastStateId () const
 
int lastStateIdNumber () const
 
void getParts (DtArticulatedModel::PartList &parts) const
 
const PartMapparts () const
 
const StateMapstates () const
 
const AnimationMapanimations () const
 
void addPart (int partNumber, osgSim::DOFTransform *node)
 
void addState (int stateNumber, osgSim::MultiSwitch *node)
 
void addAnimation (const std::string &animationName, osg::Sequence *node)
 
void setStateValueExists (int stateNumber, int stateValue)
 
void addAnnotationGroup (const std::string &annotation, osg::Group *group)
 
void setDepthMask (osg::Group &parent)
 

Protected Attributes

DtDynamicTerrainWorldmyWorld
 
StateTransformList myStateTransformList
 
StateIndexList myStateIndexList
 
TerrainSwitchList myTerrainSwitchList
 
std::stack< std::string > myStateNames
 
std::stack< osg::ref_ptr
< DtDynamicTerrainSwitchNode > > 
myCurrentSwitchStack
 
std::stack
< DynamicTerrain::NodePathHash
myCurrentSwitchIndexStack
 
std::stack< intmyCurrentSwitchChildCountStack
 
ParentHashMap myParentHashMap
 
DtDynamicTerrainWorld::FeatureHandle myFeatureHandles
 
bool myAddInstances
 
- Protected Attributes inherited from makVrv::DtArticulatedModelParser
std::string mySwitchTag
 
std::string myStateTag
 
std::string myPartTag
 
std::string myAnimationTag
 
std::string mySkipTag
 
std::string myNoSkipTag
 
std::string myAnnotationTag
 
std::string myLoopCountTag
 
std::string myLastFrameTimeTag
 
std::stack< osg::ref_ptr
< osgSim::MultiSwitch > > 
myStateIds
 
std::stack< intmyStateIdNumbers
 
DtDemyDe
 

Static Protected Attributes

static boost::mutex theParserMutex
 

Private Member Functions

 DtDynamicTerrainParser ()
 Intentionally unimplemented default CTOR. More...
 

Additional Inherited Members

- Public Attributes inherited from makVrv::DtArticulatedModelParser
PartMap myPartMap
 
StateMap myStateMap
 
AnimationMap myAnimationMap
 
AnnotationMap myAnnotationMap
 
StateExistenceMap myStateExistenceMap
 
StateValueMap myStateValueMap
 
SwitchSetMap myDefaultActiveSwitchState
 
DtModelSemanticsMappermyModelSematicsMapper
 

Detailed Description

Implementation of the model parser for Dynamic Terrain The DtDynamicTerrainParser visits all the nodes in a terrain patch or page and looks for osg::multiswitches with WRM switch ( switch) comments.

It is derived from DtArticulatedModelParser, which it can use to help with parsing of the WRM comments. Since it is common for terrain to use external references to objects, there may be multiple references to the same switch; to support different states for these external references, it replaces the osg::multiswitch with a DtDynamicTerrainSwitchNode, which can support switch state for each node path reference to that switch. In addition, the parser will also look for osg::Sequences with animation comments that are found under switches. These are assumed to be animated transitions between the states associated with the switches. Since this may also be externally referenced, these osg::Sequences are replaced with DtDynamicTerrainSequenceNodes, which provide the same type of reference support. These sequences are not part of the parser output directly, but are fed to their associated switches as discovered. As with the DtArticulatedModelParser, instances of the new switches, and related state information, as well as the world location of each reference, is stored in lists which remain available as long as the parser itself exists. The multiswitches and sequences replaced by the parser can still be found in the base class lists, but are no longer in the scene graph (and will go away unless you keep an osg::ref_ptr to them).

Member Typedef Documentation

typedef std::vector< osg::Matrixd > makVrv::DtDynamicTerrainParser::StateTransformList

StateTransformList defines a vector of the world locations of each dynamic terrain switch reference discovered.

StateIndexList defines a vector of a NodePathHash values associated with each switch reference discovered.

TerrainSwitchList defines a vector of all the dynamic terrain switches discovered.

Note that there are many duplicates here. The transforms, nodePath hashes and terrain switches in these lists correspond one to one. So a hundred references to the same switch would result in a hundred different transforms in the transform list; a hundred different node path hashes, one for each reference; and then a hundred osg::ref_ptrs to the same underlying switch node used to manage those one hundred references

Constructor & Destructor Documentation

makVrv::DtDynamicTerrainParser::DtDynamicTerrainParser ( DtDe de,
bool  addInstances = true 
)

CTOR.

Parameters
[in]de
makVrv::DtDynamicTerrainParser::DtDynamicTerrainParser ( DtDe de,
DtDynamicTerrainWorld world,
DtModelSemanticsMapper modelSematicsMapper,
bool  addInstances = true 
)

CTOR.

Parameters
[in]de
[in]world
makVrv::DtDynamicTerrainParser::DtDynamicTerrainParser ( )
private

Intentionally unimplemented default CTOR.

virtual makVrv::DtDynamicTerrainParser::~DtDynamicTerrainParser ( )
virtual

DTOR.

Member Function Documentation

virtual DtDynamicTerrainWorld::FeatureHandle makVrv::DtDynamicTerrainParser::parse ( makVrv::DtDynamicTerrainStateManipulatorFactory manipulatorFactory,
osg::Node &  node,
const osg::Matrix &  matrix = osg::Matrix::identity() 
)
virtual

Run the entire parsing algorithm.

Run the visitor on the node (by calling runVisitor) and then add the dynamic features created to the terrain world. The handle to the paged in features are available through featureHandle.

virtual DtDynamicTerrainWorld::FeatureHandle makVrv::DtDynamicTerrainParser::parse ( osg::Node &  node,
const osg::Matrix &  matrix = osg::Matrix::identity() 
)
virtual

Run the entire parsing algorithm with defaults Calls the main parse function with the default terrain state manipulator factory.

DtDynamicTerrainWorld::FeatureHandle makVrv::DtDynamicTerrainParser::featureHandle ( ) const
inline

Accessor the handle to the features which have been paged in by calls to parse.

static std::string makVrv::DtDynamicTerrainParser::parserFormat ( )
static

Get the string to indicate the parser format this parser supports.

virtual void makVrv::DtDynamicTerrainParser::apply ( osg::Group &  group)
virtual

apply overrides so this visitor can find switch nodes.

Reimplemented from makVrv::DtArticulatedModelParser.

virtual void makVrv::DtDynamicTerrainParser::apply ( osgSim::MultiSwitch &  multiswitch)
virtual

Reimplemented from makVrv::DtArticulatedModelParser.

virtual void makVrv::DtDynamicTerrainParser::apply ( DtDynamicTerrainSwitchNode terrainSwitch)
virtual
virtual void makVrv::DtDynamicTerrainParser::apply ( osg::Sequence &  sequence)
virtual

Reimplemented from makVrv::DtArticulatedModelParser.

virtual void makVrv::DtDynamicTerrainParser::apply ( DtDynamicTerrainSequenceNode terrainSequence)
virtual
const StateTransformList& makVrv::DtDynamicTerrainParser::stateTransforms ( ) const
void makVrv::DtDynamicTerrainParser::addStateTransform ( const osg::Matrixd &  mat)
const TerrainSwitchList& makVrv::DtDynamicTerrainParser::terrainSwitches ( ) const
void makVrv::DtDynamicTerrainParser::addTerrainSwitch ( DtDynamicTerrainSwitchNode tSwitch)
const StateIndexList& makVrv::DtDynamicTerrainParser::stateIndices ( ) const
void makVrv::DtDynamicTerrainParser::addStateIndex ( DynamicTerrain::NodePathHash  index)
virtual void makVrv::DtDynamicTerrainParser::runVisitor ( osg::Node &  ,
const osg::Matrix &   
)
protectedvirtual

Calls node.accept(*this).

Thus function exists so that subclasses can override the visitation step to run custom code (i.e. VRF has another parsing pass which needs to be run before the algorithm continues).

virtual bool makVrv::DtDynamicTerrainParser::parseSwitchNames ( const std::string &  desc,
osgSim::MultiSwitch &  multiswitch,
std::list< DtString > &  stateNames 
)
protectedvirtual

Parse a switch declaration and add a state to the model if it is able to parse the description.

Return values
trueif a state was added.
falseif a state was not added.
virtual void makVrv::DtDynamicTerrainParser::parseSwitchValues ( const osg::Node &  node,
std::list< DtString > &  valueNames 
)
protectedvirtual

Parse a state node.

A state is added if a declaration was parsed.

Return values
trueif a state was added.
falseif a state was not added.
virtual void makVrv::DtDynamicTerrainParser::parseValueListString ( const std::string &  valueList,
std::list< DtString > &  valueNames 
)
protectedvirtual

Parse a value list string into a list of strings.

For example, "0,1,damage" becomes "0", "1", "damage"

virtual void makVrv::DtDynamicTerrainParser::pushSwitch ( DtDynamicTerrainSwitchNode switchNode)
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::popSwitch ( )
protectedvirtual
virtual DtDynamicTerrainSwitchNode* makVrv::DtDynamicTerrainParser::findCurrentSwitch ( ) const
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::pushSwitchIndex ( DynamicTerrain::NodePathHash  index)
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::popSwitchIndex ( )
protectedvirtual
virtual DynamicTerrain::NodePathHash makVrv::DtDynamicTerrainParser::findCurrentSwitchIndex ( ) const
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::pushSwitchChildCount ( int  child)
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::popSwitchChildCount ( )
protectedvirtual
virtual int makVrv::DtDynamicTerrainParser::findCurrentSwitchChildCount ( ) const
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::incrementSwitchChildCount ( )
protectedvirtual
virtual void makVrv::DtDynamicTerrainParser::decrementSwitchChildCount ( )
protectedvirtual

Member Data Documentation

DtDynamicTerrainWorld& makVrv::DtDynamicTerrainParser::myWorld
protected
StateTransformList makVrv::DtDynamicTerrainParser::myStateTransformList
protected
StateIndexList makVrv::DtDynamicTerrainParser::myStateIndexList
protected
TerrainSwitchList makVrv::DtDynamicTerrainParser::myTerrainSwitchList
protected
std::stack<std::string> makVrv::DtDynamicTerrainParser::myStateNames
protected
std::stack<osg::ref_ptr<DtDynamicTerrainSwitchNode> > makVrv::DtDynamicTerrainParser::myCurrentSwitchStack
protected
std::stack<DynamicTerrain::NodePathHash> makVrv::DtDynamicTerrainParser::myCurrentSwitchIndexStack
protected
std::stack<int> makVrv::DtDynamicTerrainParser::myCurrentSwitchChildCountStack
protected
ParentHashMap makVrv::DtDynamicTerrainParser::myParentHashMap
protected
DtDynamicTerrainWorld::FeatureHandle makVrv::DtDynamicTerrainParser::myFeatureHandles
protected
boost::mutex makVrv::DtDynamicTerrainParser::theParserMutex
staticprotected
bool makVrv::DtDynamicTerrainParser::myAddInstances
protected

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

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)