VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtDynamicTerrainSwitchNode.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
16 #include <vlutil/vlString.h>
17 
18 #include <osg/Group>
19 #include <osg/Sequence>
20 
21 #include <boost/unordered_map.hpp>
22 #include <vrvUtil/signalslib.h>
23 #include <list>
24 
25 // Add to VRL eventually
26 #ifdef __rhentws8__
27 namespace MAKBoost_1_63 {} namespace boost = MAKBoost_1_63; namespace MAKBoost_1_63
28 #else
29 namespace boost
30 #endif
31 {
32  template <> struct hash<DtString> {
33  size_t operator()(DtString const& v) const {
34  boost::hash<std::string> string_hash;
35  return string_hash(std::string(v.c_str()));
36  }
37  };
38 }
39 
40 namespace osg
41 {
42  class NodeVisitor;
43 }
44 
45 namespace makVrv
46 {
47  class DtDynamicTerrainSequenceNode;
48 
51  {
52  public:
54  unsigned int mySwitchState;
55  };
56 
75  : public osg::Group
76  , public DtMultiReferencedNodeContainer<DtSwitchInstanceState>
77  {
78  public:
79 
83  typedef std::list<DtString> StateNameList;
84 
87  typedef std::list<DtString> ValueNameList;
88 
91  typedef boost::unordered_map<DtString, int> ValueChildMap;
92 
93  public:
94 
97 
100  const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
101 
103  virtual ~DtDynamicTerrainSwitchNode();
104 
106  virtual const char* className() const { return "DtDynamicTerrainSwitchNode"; }
107 
114  virtual void setState( DynamicTerrain::NodePathHash hashIndex, int state );
115 
120  virtual void setState( DynamicTerrain::NodePathHash hashIndex, const std::string& valueName );
121 
124  virtual void setState( int state );
125 
128  virtual void setState( const std::string& valueName );
129 
132  virtual int numStates() const;
133 
136  virtual void setStateNames(const StateNameList& stateNames );
137 
141  virtual void setPositionInModelCoordinates(osg::Vec3d pos);
142 
144  virtual osg::Vec3d positionInModelCoordinates() const;
145 
148  virtual const StateNameList& stateNames() const;
149 
153  virtual void addValues( int state, const ValueNameList& valueNames );
154 
156  virtual void addSequence( DtDynamicTerrainSequenceNode* sequence,
157  DynamicTerrain::NodePathHash seqIndex, DynamicTerrain::NodePathHash switchIndex, int childCount );
158 
160  virtual const ValueChildMap& valueToChildMap() const;
161 
163  boost::signalslib::signal<void(DtDynamicTerrainSwitchNode*, DynamicTerrain::NodePathHash, int)> signal_setSwitch;
164 
170  virtual const osg::BoundingSphere& originalBounds() const;
171 
173  virtual void setOriginalBounds(const osg::BoundingSphere& bounds);
174 
175  protected:
176 
181  virtual void traverse(osg::NodeVisitor& nv);
182 
188  virtual void setStateBindable( DynamicTerrain::NodePathHash hashIndex, int state );
189 
190  protected:
191 
192  // Each instance of a sequence has a hash index and the switch child it
193  // is associated with
195  {
199  };
200 
201  // This is a list of SequenceDescriptors, since a switch might have multiples attached
202  typedef std::list<SequenceDescriptor> SequenceInstanceList;
203 
204  // SwitchToSequenceMap defines a map from switch reference to a sequence instance list for sequence
205  // references associated with that switch reference
206  typedef boost::unordered_map< DynamicTerrain::NodePathHash, SequenceInstanceList> SwitchToSequenceMap;
207 
208  // The map from switch reference to sequence references
210 
211  // All the names discovered for this switch when parsed. Only the first is currently used
213 
214  // The map from value names to the states/children they correspond to
216 
217  osg::BoundingSphere myOriginalbounds;
218 
219  osg::Vec3d myPosInModelCoords;
220  };
221 }
virtual const char * className() const
Return the className to OSG.
Definition: DtDynamicTerrainSwitchNode.h:106
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: DtIndirectSwitchInfo.h:23
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Definition: featureContext.h:37
StateNameList myStateNames
Definition: DtDynamicTerrainSwitchNode.h:212
int mySwitchChild
Definition: DtDynamicTerrainSwitchNode.h:198
std::list< SequenceDescriptor > SequenceInstanceList
Definition: DtDynamicTerrainSwitchNode.h:202
boost::signalslib::signal< void(DtDynamicTerrainSwitchNode *, DynamicTerrain::NodePathHash, int)> signal_setSwitch
signal for things to listen to so they can find out when a switch changes
Definition: DtDynamicTerrainSwitchNode.h:163
osg::BoundingSphere myOriginalbounds
Definition: DtDynamicTerrainSwitchNode.h:217
ValueChildMap myValueToChildMap
Definition: DtDynamicTerrainSwitchNode.h:215
unsigned int mySwitchState
Definition: DtDynamicTerrainSwitchNode.h:54
SwitchToSequenceMap mySwitchToSequenceMap
Definition: DtDynamicTerrainSwitchNode.h:209
boost::unordered_map< DynamicTerrain::NodePathHash, SequenceInstanceList > SwitchToSequenceMap
Definition: DtDynamicTerrainSwitchNode.h:206
This is everything we track for each switch reference.
Definition: DtDynamicTerrainSwitchNode.h:50
size_t operator()(DtString const &v) const
Definition: DtDynamicTerrainSwitchNode.h:33
boost::unordered_map< DtString, int > ValueChildMap
ValueChildMap defines an unordered map of value names to the child indices to which they correspond...
Definition: DtDynamicTerrainSwitchNode.h:91
Contains makVrv::DtMultiReferencedNodeContainer class.
DtDynamicTerrainSequenceNode replaces an osg::Sequence in a terrain patch (or page) that is tagged wi...
Definition: DtDynamicTerrainSequenceNode.h:62
osg::ref_ptr< DtDynamicTerrainSequenceNode > mySequence
Definition: DtDynamicTerrainSwitchNode.h:196
Contains DLL export macros.
osg::Vec3d myPosInModelCoords
Definition: DtDynamicTerrainSwitchNode.h:219
std::list< DtString > ValueNameList
ValueNameList defines a list of the names of state values (like &#39;on&#39;, or &#39;off&#39;, or &#39;damaged&#39; etc...
Definition: DtDynamicTerrainSwitchNode.h:87
DtMultiReferencedNodeContainer is a class template that it used to provide support for dynamic nodes ...
Definition: DtMultiReferencedNodeContainer.h:42
std::list< DtString > StateNameList
StateNameList defines a list of the names this switch can be referred to by, as discovered with WRM &#39;...
Definition: DtDynamicTerrainSwitchNode.h:83
DynamicTerrain::NodePathHash mySeqIndex
Definition: DtDynamicTerrainSwitchNode.h:197
Definition: DtDynamicTerrainSwitchNode.h:194

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)