VR-Forces 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) 2022 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 
21 #include <vrvMath/DtOctree.h>
22 #include <vrvMath/DtOctreeNode.h>
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  protected:
222 
225 
227  virtual void slot_terrainLoaded( const DtUnicode& terrain, bool reload );
228 
230  virtual void slot_windowCreated( DtWindow* window );
231 
233  virtual void slot_windowDestroyed( DtWindow* window );
234 
236  virtual void slot_ProfilingChanged( bool active );
237 
239  virtual void slot_reloadShader();
240 
242  virtual void slot_displayConfigurationRealized();
243 
245  virtual void slot_preDraw();
246 
248  virtual void slot_postDraw();
249 
251  virtual void slot_postUpdate();
252 
254  virtual void syncToSharedDiGuySettings();
255 
257  virtual void slot_diGuyInstancingEnabledChanged( bool enabled );
258 
260  virtual void slot_diGuyInstancedLodChanged( int lod );
261 
263  virtual void slot_diGuyVisualizeInstancingChanged( bool enabled );
264 
266  virtual void slot_diGuyTextureVariationsEnabledChanged( bool enabled );
267 
269  virtual void slot_diGuyMaxDrawDistanceChanged( float distance );
270 
272  virtual void slot_diGuyMaxMotionUpdateDistanceChanged( float distance );
273 
275  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
276 
277  virtual void updateImgui(void);
278 
280 
281 
282  void updateScenario( double simTime );
283  void setComponentVisualizationMode( int mode );
284 
285  void createDiGuyScenario();
286 
287  // Helper function called by other instance functions.
288  // If this is a graphical application, de must be set.
289  static DtDiGuyScenario* createInstance( DtDe& de, bool initVisualComponent = true );
290  static DtDiGuyScenario* createNonVisualInstance( const std::string& dataPath );
291 
292  static void slot_displayToBeDestroyed( const std::string& displayName, DtDe* de );
293 
294  public:
295 
297  static tbb::atomic<int> theStatNumCharInstanced;
298 
299  protected:
300 
302 
303  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
304  // It might not be true if this instance was created by lightweight_instance()
306 
307  diguyScenario* myScenario;
308 
315 
319 
320  // settings
331 
332  // True if initializeVisualComponent() has been called
336  std::string myAlternateDataPath; // use this when the De is not valid
338 
339  tbb::mutex myOctreeMutex;
342 
343  // temp object, don't realloc every frame
344  tbb::concurrent_vector<DtDiGuyOsgRootNode*> myNoninstancedNodeArray;
345 
346  // stats
351 
354 
355  // A dirty flag indicating that this must be reattached after RDE reconnection
357  };
358 
359 
360  DtCoordTransform getTopoToGeoc( const DtVector& location );
361 
362 }
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:333
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:339
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:314
osg::ref_ptr< osg::Group > myCharacterRoot
Definition: DtDiGuyScenario.h:310
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:326
helper struct for data loaded from light config file
Definition: DtDiGuyScenario.h:68
LightConfigDataArray myLightDataArray
Definition: DtDiGuyScenario.h:352
int myEnum
Definition: DtDiGuyScenario.h:82
bool myUseInstancing
Definition: DtDiGuyScenario.h:321
int myLightType
Definition: DtDiGuyScenario.h:71
osg::ref_ptr< osg::Group > myDiguyRoot
Definition: DtDiGuyScenario.h:309
std::string myIkTargetRightArm
Definition: DtDiGuyScenario.h:80
diguyScenario * myScenario
Definition: DtDiGuyScenario.h:307
bool myDeIsValid
Definition: DtDiGuyScenario.h:305
std::string myIkTargetLeftArm
Definition: DtDiGuyScenario.h:81
StationConfigArray myStationDataArray
Definition: DtDiGuyScenario.h:353
Custom per character root node that does custom traversals and short circuits osg lod picking...
Definition: DtDiGuyOsgGraphicsLink.h:101
bool myUseMultithreadedCull
Definition: DtDiGuyScenario.h:325
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:323
bool myLightweightInstance
Definition: DtDiGuyScenario.h:334
double myFirstUpdateT
Definition: DtDiGuyScenario.h:317
osg::ref_ptr< osg::MatrixTransform > myInstancingRoot
Definition: DtDiGuyScenario.h:313
tbb::concurrent_vector< DtDiGuyOsgRootNode * > myNoninstancedNodeArray
Definition: DtDiGuyScenario.h:344
Contains DLL export macros.
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:23
helper struct for data loaded from station config file
Definition: DtDiGuyScenario.h:76
osg::ref_ptr< DtLightPointNode > myLightPointNode
Definition: DtDiGuyScenario.h:311
int myStatOctreeUpdate
Definition: DtDiGuyScenario.h:347
float myGuideSyncGain
Definition: DtDiGuyScenario.h:330
bool myDrawIKVisuals
Definition: DtDiGuyScenario.h:327
bool myDrawMovementInfo
Definition: DtDiGuyScenario.h:328
bool myReAddNodeToSceneGraph
Definition: DtDiGuyScenario.h:356
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:318
int myDriver
Definition: DtDiGuyScenario.h:72
static int theStatNumCharDrawn
Definition: DtDiGuyScenario.h:296
Octree_64::NodeVector myVisibleOctreeNodes
Definition: DtDiGuyScenario.h:341
osg::ref_ptr< osg::MatrixTransform > myLightPointRoot
Definition: DtDiGuyScenario.h:312
Base class to provide boost signal/slot management.
DtDe & myDe
Definition: DtDiGuyScenario.h:301
DtSignalConnectionManager myConnections
Definition: DtDiGuyScenario.h:337
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:329
Class that renders all the diguy instance objects in one osg drawable, major performance improvement...
Definition: DtDiGuyInstanceDrawable.h:27
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:72
#define DT_DLL_VRVDIGUY
Definition: vrvDiGuy.h:21
Octree_64 * myOctree
Definition: DtDiGuyScenario.h:340
bool myIsGeocentric
Definition: DtDiGuyScenario.h:316
bool myDebugUIActive
Definition: DtDiGuyScenario.h:335
std::string myAlternateDataPath
Definition: DtDiGuyScenario.h:336
float myStatOctreeUpdateTime
Definition: DtDiGuyScenario.h:348
float myStatPreviousOctreeUpdateTime
Definition: DtDiGuyScenario.h:349
bool myUseGuides
Definition: DtDiGuyScenario.h:322
std::string myTargetName
Definition: DtDiGuyScenario.h:79
bool myUseOctree
Definition: DtDiGuyScenario.h:324
static tbb::atomic< int > theStatNumCharInstanced
Definition: DtDiGuyScenario.h:297
std::vector< StringSet > StringSetVec
Definition: DtDiGuyScenario.h:92
float myStatCulltime
Definition: DtDiGuyScenario.h:350
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 Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)