VR-Forces Developer's Guide
 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. 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).

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

Public Types

Output structures
typedef std::vector< osg::Vec3d > StateLocationList
 
typedef std::vector
< DynamicTerrain::NodePathHash
StateIndexList
 
typedef std::vector
< osg::ref_ptr
< DtDynamicTerrainSwitchNode > > 
TerrainSwitchList
 
- Public Types inherited from makVrv::DtArticulatedModelParser
enum  TrackSide { TS_LEFT = 0, TS_RIGHT, TS_UKNOWN }
 
typedef std::vector
< osg::ref_ptr
< osgSim::DOFTransform > > 
PartTransformList
 
typedef std::unordered_map
< int, PartTransformList
PartMap
 
typedef std::vector
< osg::ref_ptr
< osgSim::MultiSwitch > > 
MultiSwitchList
 
typedef std::unordered_map
< int, MultiSwitchList
MapStateNumberToMultiSwitchList
 
typedef std::vector
< osg::ref_ptr< osg::Sequence > > 
AnimationList
 
typedef std::unordered_map
< std::string, AnimationList
AnimationMap
 
typedef std::map< int, intMapStateNumberToStateValue
 
typedef std::vector< boolStateExistenceList
 
typedef std::unordered_map
< int, StateExistenceList
MapStateNumberToStateExistenceList
 
typedef std::vector
< osg::ref_ptr< osg::Group > > 
GroupList
 
typedef std::unordered_map
< std::string, GroupList
AnnotationMap
 
typedef std::vector< boolValueList
 
typedef std::vector< ValueListSwitchSetList
 
typedef std::map
< osgSim::MultiSwitch
*, SwitchSetList
MapMultiSwitchToSwitchSetList
 
typedef std::vector
< SequenceAndParams
VectorSequenceAndMultipliers
 
typedef std::unordered_map
< std::string,
VectorSequenceAndMultipliers
FlipBookAnimationMap
 
typedef std::vector
< ScrollableTextureGroupAndParams
VectorScrollableTextureGroupAndParams
 
typedef std::map< std::string,
VectorScrollableTextureGroupAndParams
ScrollableTextureGroupMap
 

Public Member Functions

 DtDynamicTerrainParser (DtDe &de, bool addInstances=true)
 
 DtDynamicTerrainParser (DtDe &de, DtDynamicTerrainWorld &world, DtModelSemanticsMapper &modelSematicsMapper, bool addInstances=true)
 
virtual ~DtDynamicTerrainParser ()
 
virtual
DtDynamicTerrainWorld::FeatureHandle 
parse (makVrv::DtDynamicTerrainStateManipulatorFactory &manipulatorFactory, osg::Node &node, const osg::Matrix &matrix=osg::Matrix::identity())
 
virtual
DtDynamicTerrainWorld::FeatureHandle 
parse (osg::Node &node, const osg::Matrix &matrix=osg::Matrix::identity())
 
DtDynamicTerrainWorld::FeatureHandle featureHandle () const
 
virtual void apply (osg::Group &group)
 
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 StateLocationListstateLocations () const
 
void addStateLocation (const osg::Vec3d &vec)
 
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)
 
virtual ~DtArticulatedModelParser ()
 
virtual void apply (osgSim::DOFTransform &transform)
 
virtual void apply (osg::Transform &transform)
 
- Public Member Functions inherited from makVrv::DtModelParser
 DtModelParser ()
 
virtual ~DtModelParser ()
 

Static Public Member Functions

static std::string parserFormat ()
 
- Static Public Member Functions inherited from makVrv::DtArticulatedModelParser
static std::string parserFormat ()
 

Protected Types

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

Protected Member Functions

virtual void runVisitor (osg::Node &, const osg::Matrix &)
 
virtual bool parseSwitchNames (const std::string &desc, osgSim::MultiSwitch &multiswitch, std::list< DtString > &stateNames)
 
virtual bool parseSwitchPosition (const std::string &desc, osgSim::MultiSwitch &multiswitch, DtString &positionStr)
 
virtual void parseSwitchValues (const osg::Node &node, std::list< DtString > &valueNames)
 
virtual void parseValueListString (const std::string &valueList, std::list< DtString > &valueNames)
 
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)
 
virtual bool parseDefaultMultiSwitchValues (osgSim::MultiSwitch &multiswitch)
 
const
DtModelSemanticsMapper::States::Id
createCustomStateId (const std::string &stateName)
 
virtual bool parseStateDeclaration (const std::string &desc, osg::Group &group)
 
virtual bool parseAnnotationDeclaration (const std::string &desc, osg::Group &group)
 
virtual bool parseScrollableTextureDeclaration (const std::string &desc, osg::Group &group)
 
virtual bool parsePartDeclaration (const std::string &desc, osgSim::DOFTransform &transform)
 
virtual bool parseAnimationDeclaration (const std::string &desc, osg::Sequence &sequence)
 
virtual bool parseFlipBookAnimationDeclaration (const std::string &desc, osg::Sequence &sequence)
 
std::vector< intparseValueList (const std::string &valueList)
 
void pushStateId (int idNumber, osgSim::MultiSwitch *lastStateId)
 
void popStateId ()
 
osgSim::MultiSwitch * lastStateId () const
 
int lastStateIdNumber () const
 
void getParts (DtArticulatedModel::PartList &parts) const
 
const PartMapparts () const
 
const
MapStateNumberToMultiSwitchList
states () const
 
const AnimationMapanimations () const
 
const FlipBookAnimationMapflipBookAnimations (void) const
 
const FlipBookAnimationMapflipBookAnimationsWithVelocityControl (void) 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 addScrollableTextureGroup (osg::Group *group)
 
void setDepthMask (osg::Group &parent)
 

Protected Attributes

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

Static Protected Attributes

static boost::mutex theParserMutex
 

Private Member Functions

 DtDynamicTerrainParser ()
 

Additional Inherited Members

- Public Attributes inherited from makVrv::DtArticulatedModelParser
PartMap myPartMap
 
AnimationMap myAnimationMap
 
FlipBookAnimationMap myFlipBookAnimationMap
 
FlipBookAnimationMap myFlipBookAnimationMapWithVelocityControl
 
AnnotationMap myAnnotationMap
 
ScrollableTextureGroupMap myScrollableTextureGroupMap
 
MapStateNumberToStateExistenceList myMapStateNumberToStateExistenceList
 
MapStateNumberToStateValue myMapStateNumberToStateValue
 
MapStateNumberToMultiSwitchList myMapStateNumberToMultiSwitchList
 
MapMultiSwitchToSwitchSetList myDefaultActiveSwitchState
 
DtModelSemanticsMappermyModelSematicsMapper
 

Member Typedef Documentation

typedef std::vector< osg::Vec3d > makVrv::DtDynamicTerrainParser::StateLocationList

StateLocationList 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

apply overrides so this visitor can find switch nodes.

Reimplemented from makVrv::DtArticulatedModelParser.

virtual void makVrv::DtDynamicTerrainParser::apply ( DtDynamicTerrainSwitchNode terrainSwitch)
virtual

apply overrides so this visitor can find switch nodes.

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

apply overrides so this visitor can find switch nodes.

Reimplemented from makVrv::DtArticulatedModelParser.

virtual void makVrv::DtDynamicTerrainParser::apply ( DtDynamicTerrainSequenceNode terrainSequence)
virtual

apply overrides so this visitor can find switch nodes.

const StateLocationList& makVrv::DtDynamicTerrainParser::stateLocations ( ) const
void makVrv::DtDynamicTerrainParser::addStateLocation ( const osg::Vec3d &  vec)
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 bool makVrv::DtDynamicTerrainParser::parseSwitchPosition ( const std::string &  desc,
osgSim::MultiSwitch &  multiswitch,
DtString positionStr 
)
protectedvirtual

Parse a switch declaration and find the position of the switch if it has been tagged (with switchposition x,y,z).

Return values
trueif a position was found.
falseif a position was not found.
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
StateLocationList makVrv::DtDynamicTerrainParser::myStateLocationList
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
std::string makVrv::DtDynamicTerrainParser::mySwitchPosTag
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 Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)