VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtDiGuyScenario.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvDiGuy/vrvDiGuy.h>
14 
15 #include <vrvCore/DtUniqueID.h>
16 
19 #include <vrvUtil/DtUnicode.h>
20 
23 
24 #include <vlutil/vlString.h>
25 #include <matrix/vlVector.h>
26 #include <osg/Group>
27 
28 #include <tbb/tbb.h>
29 #include <tbb/mutex.h>
30 
31 #include <string>
32 #include <set>
33 
34 class diguyScenario;
35 class diguyCharacter;
36 class diguyCharacterTypeMapFieldValues;
37 class diguyGestureMetadata;
38 
39 class DtCoordTransform;
40 
41 namespace makArchives
42 {
43  class DtDiGuySettings;
44 }
45 
46 namespace osg
47 {
48  class RenderInfo;
49 }
50 
51 namespace makVrv
52 {
53 
54  class DtDe;
55  class DtLightPointNode;
56  class DtWindow;
57 
58  class DtDiGuyOsgRootNode;
59  class DtDiGuyInstanceTboUpdaterJob;
60  class DtDiGuyScenario;
61  class DtDiGuyInstanceDrawable;
62 
63  class DtOsgGizmoRenderer;
64 
65  struct DtDiGuyCullData;
66 
69  {
70  std::string myLinkName;
72  int myDriver;
73  };
74 
77  {
78  std::string myName;
79  std::string myTargetName;
80  std::string myIkTargetRightArm;
81  std::string myIkTargetLeftArm;
82  int myEnum;
83  };
84 
88  {
89  public:
90 
91  typedef std::set<DtString> StringSet;
92  typedef std::vector<StringSet> StringSetVec;
93  typedef std::vector<DtDiguyLightConfig> LightConfigDataArray;
94  typedef std::vector<DtDiguyStationConfig> StationConfigArray;
95 
96  public:
97 
98  // Static accessor: creates a new instance or, if one is already associated
99  // with DtDe instance, return the existing instance. The visual component
100  // (needed for graphical applications) can be initialized now or later.
101  static DtDiGuyScenario& instance( DtDe& de, bool initVisualComponent = true );
102 
103  // This returns an instance of DtDiGuyScenario in which the visual component
104  // has not been initialized. If this is not a graphical application, it will
105  // not be possible to initialize the visual component.
106  static DtDiGuyScenario* lightweight_instance( const std::string& dataPath );
107 
108  protected:
109 
110  DtDiGuyScenario( DtDe& de );
111  DtDiGuyScenario( const std::string& dataPth );
112 
113  public:
114 
116  DtDiGuyScenario( const DtDiGuyScenario& rhs ) = delete;
117 
119  DtDiGuyScenario& operator = ( const DtDiGuyScenario& rhs ) = delete;
120 
121  public:
122 
124  virtual ~DtDiGuyScenario();
125 
126  // For graphical applications, this must be called, but it can be called at
127  // the last possible moment. It calls, or enables the calling of, functions
128  // that are somewhat more time-consuming.
129  void initializeVisualComponent();
130 
132  diguyScenario& scenario();
133 
134  virtual void clearScene();
135 
137  virtual osg::Node* characterRoot();
138 
140  virtual bool useGuides() const;
142  virtual float guideSyncGain() const;
143 
145  virtual bool useInstancing() const;
146 
148  virtual bool useTextureVariations() const;
149 
151  virtual bool useMultithreadedCull() const;
152 
154  virtual bool useOctree() const;
155 
157  std::string findCharacterName( DtElementID parentSceneObjectID );
158 
160  diguyCharacter* getCharacter(DtElementID parentSceneObjectID);
161 
163  int getSupportsWeightVariations( DtElementID parentSceneObjectID );
164 
166  bool evalScript( const std::string& script );
167 
169  static osg::Group* getDiGuyAttachGroup();
170 
172  static osg::Group* getDiGuyInstancingAttachGroup();
173 
175  virtual bool isGeocentric() const;
176 
179 
181  virtual void createOctreeNode( DtDiGuyOsgRootNode* pChar );
182 
184  virtual void destroyOctreeNode( DtDiGuyOsgRootNode* pChar );
185 
187  virtual void characterOctreeNodeUpdated( DtDiGuyOsgRootNode* pChar );
188 
190  virtual Octree_64* octree() { return myOctree; }
191 
193 
195  virtual DtDe& getDe() { return myDe; }
196 
197  // runs octree cull and finished instancing group generation
198  virtual void cullAndUpdate( const Frustum_64& frustum, const DtDiGuyCullData& cullData );
199 
201  virtual DtDiGuyInstanceDrawable* instancedDrawable() { return myInstancedDrawable; }
202 
204  virtual void updateStats( int mask, double duration );
205 
207  virtual DtLightPointNode* lightPointNode();
208 
210  virtual const LightConfigDataArray& lightDataArray();
211 
213  virtual const StationConfigArray& stationDataArray();
214 
216  virtual void drawDebugLines( osg::RenderInfo& renderInfo, const osg::Vec3d& eyePoint,
217  DtOsgGizmoRenderer* renderer );
218 
220  virtual bool debugUIActive() { return myDebugUIActive; }
221 
223  virtual void addImguiTextureUI(unsigned int contextID);
224 
225  protected:
226 
229 
231  virtual void slot_terrainLoaded( const DtUnicode& terrain, bool reload );
232 
234  virtual void slot_windowCreated( DtWindow* window );
235 
237  virtual void slot_windowDestroyed( DtWindow* window );
238 
240  virtual void slot_ProfilingChanged( bool active );
241 
243  virtual void slot_reloadShader();
244 
246  virtual void slot_displayConfigurationRealized();
247 
249  virtual void slot_preDraw();
250 
252  virtual void slot_postDraw();
253 
255  virtual void slot_postUpdate();
256 
258  virtual void syncToSharedDiGuySettings();
259 
261  virtual void slot_diGuyInstancingEnabledChanged( bool enabled );
262 
264  virtual void slot_diGuyInstancedLodChanged( int lod );
265 
267  virtual void slot_diGuyVisualizeInstancingChanged( bool enabled );
268 
270  virtual void slot_diGuyTextureVariationsEnabledChanged( bool enabled );
271 
273  virtual void slot_diGuyMaxDrawDistanceChanged( float distance );
274 
276  virtual void slot_diGuyMaxMotionUpdateDistanceChanged( float distance );
277 
279  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
280 
282 
283 
284  void updateScenario( double simTime );
285  void setComponentVisualizationMode( int mode );
286 
287  void createDiGuyScenario();
288 
289  // Helper function called by other instance functions.
290  // If this is a graphical application, de must be set.
291  static DtDiGuyScenario* createInstance( DtDe& de, bool initVisualComponent = true );
292  static DtDiGuyScenario* createNonVisualInstance( const std::string& dataPath );
293 
294  static void slot_displayToBeDestroyed( const std::string& displayName, DtDe* de );
295 
296  public:
297 
299  static tbb::atomic<int> theStatNumCharInstanced;
300 
301  protected:
302 
304 
305  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
306  // It might not be true if this instance was created by lightweight_instance()
308 
309  diguyScenario* myScenario;
310 
317 
321 
322  // settings
333 
334  // True if initializeVisualComponent() has been called
338  std::string myAlternateDataPath; // use this when the De is not valid
340 
341  tbb::mutex myOctreeMutex;
344 
345  // temp object, don't realloc every frame
346  tbb::concurrent_vector<DtDiGuyOsgRootNode*> myNoninstancedNodeArray;
347 
348  // stats
353 
356 
357  // A dirty flag indicating that this must be reattached after RDE reconnection
359  };
360 
361 
362  DtCoordTransform getTopoToGeoc( const DtVector& location );
363 
364 }
virtual DtDe & getDe()
returns de
Definition: DtDiGuyScenario.h:195
std::set< DtString > StringSet
Definition: DtDiGuyScenario.h:91
std::vector< DtDiguyStationConfig > StationConfigArray
Definition: DtDiGuyScenario.h:94
bool myVisualComponentInitialized
Definition: DtDiGuyScenario.h:335
data that&#39;s passed around for culling
Definition: DtDiGuyOctreeCullGroup.h:35
Abstract Base class.
Definition: DtWindow.h:25
virtual bool debugUIActive()
is the lower level debug UI visible
Definition: DtDiGuyScenario.h:220
tbb::mutex myOctreeMutex
Definition: DtDiGuyScenario.h:341
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
osg::ref_ptr< DtDiGuyInstanceDrawable > myInstancedDrawable
Definition: DtDiGuyScenario.h:316
osg::ref_ptr< osg::Group > myCharacterRoot
Definition: DtDiGuyScenario.h:312
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
bool myDrawSkeletons
Definition: DtDiGuyScenario.h:328
helper struct for data loaded from light config file
Definition: DtDiGuyScenario.h:68
LightConfigDataArray myLightDataArray
Definition: DtDiGuyScenario.h:354
int myEnum
Definition: DtDiGuyScenario.h:82
bool myUseInstancing
Definition: DtDiGuyScenario.h:323
int myLightType
Definition: DtDiGuyScenario.h:71
osg::ref_ptr< osg::Group > myDiguyRoot
Definition: DtDiGuyScenario.h:311
std::string myIkTargetRightArm
Definition: DtDiGuyScenario.h:80
diguyScenario * myScenario
Definition: DtDiGuyScenario.h:309
bool myDeIsValid
Definition: DtDiGuyScenario.h:307
std::string myIkTargetLeftArm
Definition: DtDiGuyScenario.h:81
StationConfigArray myStationDataArray
Definition: DtDiGuyScenario.h:355
Custom per character root node that does custom traversals and short circuits osg lod picking...
Definition: DtDiGuyOsgGraphicsLink.h:99
bool myUseMultithreadedCull
Definition: DtDiGuyScenario.h:327
a class to quickly render a bunch of basic primitives as debugging aids basic overview, create an adapter that inherits from DtDebugDrawCallbackInterface then call DtOsgGizmoRenderer::addDebugDrawerCallback() to register it with the system. Your code will then get called while the system is drawing, user should then add various primitives that will get rendered in one big batch after all the callbacks. See DtOsgLightDebugAdapter::drawDebugLines() for an example.
Definition: DtOsgGizmoRenderer.h:44
bool myUseTextureVariations
Definition: DtDiGuyScenario.h:325
bool myLightweightInstance
Definition: DtDiGuyScenario.h:336
double myFirstUpdateT
Definition: DtDiGuyScenario.h:319
osg::ref_ptr< osg::MatrixTransform > myInstancingRoot
Definition: DtDiGuyScenario.h:315
tbb::concurrent_vector< DtDiGuyOsgRootNode * > myNoninstancedNodeArray
Definition: DtDiGuyScenario.h:346
Contains DLL export macros.
helper struct for data loaded from station config file
Definition: DtDiGuyScenario.h:76
osg::ref_ptr< DtLightPointNode > myLightPointNode
Definition: DtDiGuyScenario.h:313
int myStatOctreeUpdate
Definition: DtDiGuyScenario.h:349
float myGuideSyncGain
Definition: DtDiGuyScenario.h:332
bool myDrawIKVisuals
Definition: DtDiGuyScenario.h:329
bool myDrawMovementInfo
Definition: DtDiGuyScenario.h:330
bool myReAddNodeToSceneGraph
Definition: DtDiGuyScenario.h:358
std::string myName
Definition: DtDiGuyScenario.h:78
virtual Octree_64 * octree()
returns octree
Definition: DtDiGuyScenario.h:190
Contains makVrv::DtVirtualBaseClass class.
DtOctree class.
OctreeNode class.
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
DtCoordTransform getTopoToGeoc(const DtVector &location)
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
Octree datastructure for managing scene nodes. This is a loose octree implementation, meaning that each octant child of the octree actually overlaps it&#39;s siblings by a factor of .5. This guarantees that any thing that is half the size of the parent will fit completely into a child, with no splitting necessary.
Definition: DtOctree.h:27
Derived from osg::Node and is a replacement for the osgSim::LightPointNode represents a group of ligh...
Definition: DtLightPointNode.h:37
std::vector< DtOctreeNode< T > * > NodeVector
Definition: DtOctree.h:79
double myPreviousUpdateTime
Definition: DtDiGuyScenario.h:320
int myDriver
Definition: DtDiGuyScenario.h:72
static int theStatNumCharDrawn
Definition: DtDiGuyScenario.h:298
Octree_64::NodeVector myVisibleOctreeNodes
Definition: DtDiGuyScenario.h:343
osg::ref_ptr< osg::MatrixTransform > myLightPointRoot
Definition: DtDiGuyScenario.h:314
Base class to provide boost signal/slot management.
DtDe & myDe
Definition: DtDiGuyScenario.h:303
DtSignalConnectionManager myConnections
Definition: DtDiGuyScenario.h:339
const char int mode
Definition: ioapi.h:38
std::vector< DtDiguyLightConfig > LightConfigDataArray
Definition: DtDiGuyScenario.h:93
Contains makVrv::DtUniqueID type.
float myMaxMotionUpdateDistance
Definition: DtDiGuyScenario.h:331
Class that renders all the diguy instance objects in one osg drawable, major performance improvement...
Definition: DtDiGuyInstanceDrawable.h:26
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:70
#define DT_DLL_VRVDIGUY
Definition: vrvDiGuy.h:21
Octree_64 * myOctree
Definition: DtDiGuyScenario.h:342
bool myIsGeocentric
Definition: DtDiGuyScenario.h:318
bool myDebugUIActive
Definition: DtDiGuyScenario.h:337
std::string myAlternateDataPath
Definition: DtDiGuyScenario.h:338
float myStatOctreeUpdateTime
Definition: DtDiGuyScenario.h:350
float myStatPreviousOctreeUpdateTime
Definition: DtDiGuyScenario.h:351
bool myUseGuides
Definition: DtDiGuyScenario.h:324
std::string myTargetName
Definition: DtDiGuyScenario.h:79
bool myUseOctree
Definition: DtDiGuyScenario.h:326
static tbb::atomic< int > theStatNumCharInstanced
Definition: DtDiGuyScenario.h:299
std::vector< StringSet > StringSetVec
Definition: DtDiGuyScenario.h:92
float myStatCulltime
Definition: DtDiGuyScenario.h:352
Owns a DiGuy scenario for the application.
Definition: DtDiGuyScenario.h:87
Contains the makVrv::DtDiGuyTypeMapFieldNode class declaration.
std::string myLinkName
Definition: DtDiGuyScenario.h:70
virtual DtDiGuyInstanceDrawable * instancedDrawable()
returns instance drawable singleton
Definition: DtDiGuyScenario.h:201

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)