![]() |
VR-Forces 5.0.2 Developer's Guide
|
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).

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, int > | MapStateNumberToStateValue |
| typedef std::vector< bool > | StateExistenceList |
| 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< bool > | ValueList |
| typedef std::vector< ValueList > | SwitchSetList |
| 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 StateLocationList & | stateLocations () const |
| void | addStateLocation (const osg::Vec3d &vec) |
| const TerrainSwitchList & | terrainSwitches () const |
| void | addTerrainSwitch (DtDynamicTerrainSwitchNode *tSwitch) |
| const StateIndexList & | stateIndices () 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 boost::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< int > | parseValueList (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 PartMap & | parts () const |
| const MapStateNumberToMultiSwitchList & | states () const |
| const AnimationMap & | animations () const |
| const FlipBookAnimationMap & | flipBookAnimations (void) const |
| const FlipBookAnimationMap & | flipBookAnimationsWithVelocityControl (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) |
Static Protected Attributes | |
| static boost::mutex | theParserMutex |
Private Member Functions | |
| DtDynamicTerrainParser () | |
| typedef std::vector< osg::Vec3d > makVrv::DtDynamicTerrainParser::StateLocationList |
StateLocationList defines a vector of the world locations of each dynamic terrain switch reference discovered.
| typedef std::vector< DynamicTerrain::NodePathHash > makVrv::DtDynamicTerrainParser::StateIndexList |
StateIndexList defines a vector of a NodePathHash values associated with each switch reference discovered.
| typedef std::vector<osg::ref_ptr< DtDynamicTerrainSwitchNode> > makVrv::DtDynamicTerrainParser::TerrainSwitchList |
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.
|
protected |
CTOR.
| [in] | de |
| makVrv::DtDynamicTerrainParser::DtDynamicTerrainParser | ( | DtDe & | de, |
| DtDynamicTerrainWorld & | world, | ||
| DtModelSemanticsMapper & | modelSematicsMapper, | ||
| bool | addInstances = true |
||
| ) |
CTOR.
| [in] | de | |
| [in] | world |
|
private |
Intentionally unimplemented default CTOR.
|
virtual |
DTOR.
|
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 |
Run the entire parsing algorithm with defaults Calls the main parse function with the default terrain state manipulator factory.
|
inline |
Accessor the handle to the features which have been paged in by calls to parse.
|
static |
Get the string to indicate the parser format this parser supports.
|
virtual |
apply overrides so this visitor can find switch nodes.
Reimplemented from makVrv::DtArticulatedModelParser.
|
virtual |
apply overrides so this visitor can find switch nodes.
Reimplemented from makVrv::DtArticulatedModelParser.
|
virtual |
apply overrides so this visitor can find switch nodes.
|
virtual |
apply overrides so this visitor can find switch nodes.
Reimplemented from makVrv::DtArticulatedModelParser.
|
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 | ) |
|
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).
|
protectedvirtual |
Parse a switch declaration and add a state to the model if it is able to parse the description.
| true | if a state was added. |
| false | if a state was not added. |
|
protectedvirtual |
Parse a switch declaration and find the position of the switch if it has been tagged (with switchposition x,y,z).
| true | if a position was found. |
| false | if a position was not found. |
|
protectedvirtual |
Parse a state node. A state is added if a declaration was parsed.
| true | if a state was added. |
| false | if a state was not added. |
|
protectedvirtual |
Parse a value list string into a list of strings. For example, "0,1,damage" becomes "0", "1", "damage".
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |