VR-Forces Developer's Guide
 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) 2025 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 #if defined(__rhentws8__) || defined(__rhentws9__)
27 namespace MAKBoost_1_84 {} namespace boost = MAKBoost_1_84; namespace MAKBoost_1_84
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  // Healthy (default) child metadata captured at parse time.
176  // The parser will determine the first active child (or other heuristic)
177  // when transforming an osgSim::MultiSwitch and record its child index
178  // and that child's local-space center so later passes can compute an
179  // accurate world-space center without recomputing or relying on the
180  // potentially inflated union bound center.
181  void setHealthyChildInfo(int idx, const osg::Vec3d& localCenter);
182  int healthyChildIndex() const;
183  const osg::Vec3d& healthyChildLocalCenter() const;
184 
185  protected:
186 
191  virtual void traverse(osg::NodeVisitor& nv);
192 
198  virtual void setStateBindable( DynamicTerrain::NodePathHash hashIndex, int state );
199 
200  protected:
201 
202  // Each instance of a sequence has a hash index and the switch child it
203  // is associated with
205  {
209  };
210 
211  // This is a list of SequenceDescriptors, since a switch might have multiples attached
212  typedef std::list<SequenceDescriptor> SequenceInstanceList;
213 
214  // SwitchToSequenceMap defines a map from switch reference to a sequence instance list for sequence
215  // references associated with that switch reference
216  typedef boost::unordered_map< DynamicTerrain::NodePathHash, SequenceInstanceList> SwitchToSequenceMap;
217 
218  // The map from switch reference to sequence references
220 
221  // All the names discovered for this switch when parsed. Only the first is currently used
223 
224  // The map from value names to the states/children they correspond to
226 
227  osg::BoundingSphere myOriginalbounds;
228 
229  osg::Vec3d myPosInModelCoords;
230 
233  };
234 }
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: DtMultiReferencedNodeContainer.h:26
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Definition: featureContext.h:36
StateNameList myStateNames
Definition: DtDynamicTerrainSwitchNode.h:222
int mySwitchChild
Definition: DtDynamicTerrainSwitchNode.h:208
std::list< SequenceDescriptor > SequenceInstanceList
Definition: DtDynamicTerrainSwitchNode.h:212
osg::Vec3d myHealthyChildLocalCenter
Definition: DtDynamicTerrainSwitchNode.h:232
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:227
ValueChildMap myValueToChildMap
Definition: DtDynamicTerrainSwitchNode.h:225
int myHealthyChildIndex
Definition: DtDynamicTerrainSwitchNode.h:231
unsigned int mySwitchState
Definition: DtDynamicTerrainSwitchNode.h:54
SwitchToSequenceMap mySwitchToSequenceMap
Definition: DtDynamicTerrainSwitchNode.h:219
boost::unordered_map< DynamicTerrain::NodePathHash, SequenceInstanceList > SwitchToSequenceMap
Definition: DtDynamicTerrainSwitchNode.h:216
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:206
Contains DLL export macros.
osg::Vec3d myPosInModelCoords
Definition: DtDynamicTerrainSwitchNode.h:229
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:43
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:207
Definition: DtDynamicTerrainSwitchNode.h:204

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)