VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtDynamicTerrainParser.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
17 
19 
20 #include <vlutil/vlString.h>
21 
22 #include <osg/Matrixd>
23 #include <osg/Group>
24 #include <unordered_map>
25 
26 #include <vector>
27 #include <stack>
28 #include <boost/thread/mutex.hpp>
29 
30 namespace osgSim
31 {
32  class MultiSwitch;
33 }
34 
35 namespace osg
36 {
37  class sequence;
38 }
39 
40 namespace makVrv
41 {
42  class DtDe;
43  class DtDynamicTerrainSequenceNode;
44 
66  {
67  public:
70 
73  typedef std::vector< osg::Vec3d > StateLocationList;
74 
77  typedef std::vector< DynamicTerrain::NodePathHash > StateIndexList;
78 
84  typedef std::vector<osg::ref_ptr< DtDynamicTerrainSwitchNode> > TerrainSwitchList;
86 
89  DtDynamicTerrainParser(DtDe& de, bool addInstances = true);
90 
94  DtDynamicTerrainParser(DtDe& de, DtDynamicTerrainWorld& world, DtModelSemanticsMapper& modelSematicsMapper, bool addInstances = true);
95 
96  private:
99 
100  public:
102  virtual ~DtDynamicTerrainParser();
103 
110  osg::Node& node,
111  const osg::Matrix& matrix = osg::Matrix::identity());
112 
116  osg::Node& node,
117  const osg::Matrix& matrix = osg::Matrix::identity());
118 
120  DtDynamicTerrainWorld::FeatureHandle featureHandle() const { return myFeatureHandles; }
121 
124  static std::string parserFormat();
125 
128  virtual void apply( osg::Group& group );
129  virtual void apply( osgSim::MultiSwitch& multiswitch );
130  virtual void apply( DtDynamicTerrainSwitchNode& terrainSwitch );
131  virtual void apply( osg::Sequence& sequence );
132  virtual void apply( DtDynamicTerrainSequenceNode& terrainSequence );
134 
137  const StateLocationList& stateLocations() const;
138  void addStateLocation(const osg::Vec3d& vec);
139 
140  const TerrainSwitchList& terrainSwitches() const;
141  void addTerrainSwitch( DtDynamicTerrainSwitchNode* tSwitch );
142 
143  const StateIndexList& stateIndices() const;
144  void addStateIndex( DynamicTerrain::NodePathHash index );
146 
147  protected:
152  virtual void runVisitor(osg::Node&, const osg::Matrix&);
153 
158  virtual bool parseSwitchNames( const std::string& desc,
159  osgSim::MultiSwitch& multiswitch, std::list<DtString>& stateNames );
160 
165  virtual bool parseSwitchPosition(const std::string& desc,
166  osgSim::MultiSwitch& multiswitch, DtString& positionStr);
167 
172  virtual void parseSwitchValues( const osg::Node& node, std::list<DtString>& valueNames );
173 
176  virtual void parseValueListString( const std::string& valueList, std::list<DtString>& valueNames );
177 
178  virtual void pushSwitch( DtDynamicTerrainSwitchNode* switchNode );
179  virtual void popSwitch();
180  virtual DtDynamicTerrainSwitchNode* findCurrentSwitch() const;
181 
182  virtual void pushSwitchIndex( DynamicTerrain::NodePathHash index );
183  virtual void popSwitchIndex();
184  virtual DynamicTerrain::NodePathHash findCurrentSwitchIndex() const;
185 
186  virtual void pushSwitchChildCount( int child );
187  virtual void popSwitchChildCount();
188  virtual int findCurrentSwitchChildCount() const;
189  virtual void incrementSwitchChildCount();
190  virtual void decrementSwitchChildCount();
191 
192  protected:
193 
195 
199  std::stack<std::string> myStateNames;
200  std::stack<osg::ref_ptr<DtDynamicTerrainSwitchNode> > myCurrentSwitchStack;
201  std::stack<DynamicTerrain::NodePathHash> myCurrentSwitchIndexStack;
203 
204  std::string mySwitchPosTag;
205 
206  // maps node's hash to it's parents hash
207  typedef std::unordered_map<DynamicTerrain::NodePathHash, DynamicTerrain::NodePathHash> ParentHashMap;
209 
211 
212  static boost::mutex theParserMutex;
213 
215  };
216 
220  {
221  public:
222 
225  static void registerCreator(DtDe& de);
226 
229 
232 
234  virtual DtModelParser* create(DtDe& de);
235  };
236 
237 }
DtDynamicTerrainWorld & myWorld
Definition: DtDynamicTerrainParser.h:194
Implementation of the model parser for Dynamic Terrain The DtDynamicTerrainParser visits all the node...
Definition: DtDynamicTerrainParser.h:65
std::stack< std::string > myStateNames
Definition: DtDynamicTerrainParser.h:199
StateIndexList myStateIndexList
Definition: DtDynamicTerrainParser.h:197
std::vector< osg::ref_ptr< DtDynamicTerrainSwitchNode > > 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.
Definition: DtDynamicTerrainParser.h:84
DtDynamicTerrainSwitchNode replaces an osgSim::multiswitch in a terrain patch (or page) that is tagge...
Definition: DtDynamicTerrainSwitchNode.h:74
size_t NodePathHash
Typedef used to represent a hash of an OSG Node path to a referenced node.
Definition: DtMultiReferencedNodeContainer.h:26
DtDynamicTerrainWorld::FeatureHandle myFeatureHandles
Definition: DtDynamicTerrainParser.h:210
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Abstract base class used to parse a model.
Definition: DtModelParser.h:22
std::vector< DynamicTerrain::NodePathHash > StateIndexList
StateIndexList defines a vector of a NodePathHash values associated with each switch reference discov...
Definition: DtDynamicTerrainParser.h:77
static boost::mutex theParserMutex
Definition: DtDynamicTerrainParser.h:212
std::vector< osg::Vec3d > StateLocationList
StateLocationList defines a vector of the world locations of each dynamic terrain switch reference di...
Definition: DtDynamicTerrainParser.h:73
std::stack< osg::ref_ptr< DtDynamicTerrainSwitchNode > > myCurrentSwitchStack
Definition: DtDynamicTerrainParser.h:200
std::unordered_map< DynamicTerrain::NodePathHash, DynamicTerrain::NodePathHash > ParentHashMap
Definition: DtDynamicTerrainParser.h:207
Contains makVrv::DtDynamicTerrainStateManipulatorFactory class.
StateLocationList myStateLocationList
Definition: DtDynamicTerrainParser.h:196
Create an articulated model parser.
Definition: DtDynamicTerrainParser.h:219
Factory for creating objects which implement some kind of manipulation of the state of dynamically ch...
Definition: DtDynamicTerrainStateManipulatorFactory.h:64
std::stack< int > myCurrentSwitchChildCountStack
Definition: DtDynamicTerrainParser.h:202
ParentHashMap myParentHashMap
Definition: DtDynamicTerrainParser.h:208
bool myAddInstances
Definition: DtDynamicTerrainParser.h:214
DtDynamicTerrainWorld::FeatureHandle featureHandle() const
Accessor the handle to the features which have been paged in by calls to parse.
Definition: DtDynamicTerrainParser.h:120
Contains makVrv::DtArticulatedModelParser class.
DtDynamicTerrainSequenceNode replaces an osg::Sequence in a terrain patch (or page) that is tagged wi...
Definition: DtDynamicTerrainSequenceNode.h:62
Contains makVrv::DtDynamicTerrainWorld class.
Contains DLL export macros.
Feature Insertion/Removal/Paging Features represent parts of the terrain which are individually ident...
Definition: DtDynamicTerrainWorld.h:97
Contains makVrv::DtDynamicTerrainSwitchNode class.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
TerrainSwitchList myTerrainSwitchList
Definition: DtDynamicTerrainParser.h:198
An abstract creator class for the model parser.
Definition: DtModelParser.h:35
std::string mySwitchPosTag
Definition: DtDynamicTerrainParser.h:204
Container for dynamic terrain features, change requests, and queries.
Definition: DtDynamicTerrainWorld.h:69
The DtModelSemanticsMapper object is responsible for mapping Names of model semantics declarations (f...
Definition: DtModelSemanticsMapper.h:27
std::stack< DynamicTerrain::NodePathHash > myCurrentSwitchIndexStack
Definition: DtDynamicTerrainParser.h:201
Default implementation of the model parser for Articulated models.
Definition: DtArticulatedModelParser.h:38

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)