VR-Forces 4.10 Class Documentation
 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 
78  {
79  public:
80 
81  typedef std::set<DtString> StringSet;
82  typedef std::vector<StringSet> StringSetVec;
83  typedef std::vector<DtDiguyLightConfig> LightConfigDataArray;
84 
85  public:
86 
87  // Static accessor: creates a new instance or, if one is already associated
88  // with DtDe instance, return the existing instance. The visual component
89  // (needed for graphical applications) can be initialized now or later.
90  static DtDiGuyScenario& instance( DtDe& de, bool initVisualComponent = true );
91 
92  // This returns an instance of DtDiGuyScenario in which the visual component
93  // has not been initialized. If this is not a graphical application, it will
94  // not be possible to initialize the visual component.
95  static DtDiGuyScenario* lightweight_instance( const std::string& dataPath );
96 
97  protected:
98 
99  DtDiGuyScenario( DtDe& de );
100  DtDiGuyScenario( const std::string& dataPth );
101 
102  public:
103 
105  DtDiGuyScenario( const DtDiGuyScenario& rhs ) = delete;
106 
108  DtDiGuyScenario& operator = ( const DtDiGuyScenario& rhs ) = delete;
109 
110  public:
111 
113  virtual ~DtDiGuyScenario();
114 
115  // For graphical applications, this must be called, but it can be called at
116  // the last possible moment. It calls, or enables the calling of, functions
117  // that are somewhat more time-consuming.
118  void initializeVisualComponent();
119 
121  diguyScenario& scenario();
122 
123  virtual void clearScene();
124 
126  virtual osg::Node* characterRoot();
127 
129  virtual bool useGuides() const;
131  virtual float guideSyncGain() const;
132 
134  virtual bool useInstancing() const;
135 
137  virtual bool useTextureVariations() const;
138 
140  virtual bool useMultithreadedCull() const;
141 
143  virtual bool useOctree() const;
144 
146  std::string findCharacterName( DtElementID parentSceneObjectID );
147 
149  int getSupportsWeightVariations( DtElementID parentSceneObjectID );
150 
152  bool evalScript( const std::string& script );
153 
155  static osg::Group* getDiGuyAttachGroup();
156 
158  static osg::Group* getDiGuyInstancingAttachGroup();
159 
161  virtual bool isGeocentric() const;
162 
165 
167  virtual void createOctreeNode( DtDiGuyOsgRootNode* pChar );
168 
170  virtual void destroyOctreeNode( DtDiGuyOsgRootNode* pChar );
171 
173  virtual void characterOctreeNodeUpdated( DtDiGuyOsgRootNode* pChar );
174 
176  virtual Octree_64* octree() { return myOctree; }
177 
179 
181  virtual DtDe& getDe() { return myDe; }
182 
183  // runs octree cull and finished instancing group generation
184  virtual void cullAndUpdate( const Frustum_64& frustum, const DtDiGuyCullData& cullData );
185 
187  virtual DtDiGuyInstanceDrawable* instancedDrawable() { return myInstancedDrawable; }
188 
190  virtual void updateStats( int mask, double duration );
191 
193  virtual DtLightPointNode* lightPointNode();
194 
196  virtual const LightConfigDataArray& lightDataArray();
197 
199  virtual void drawDebugLines( osg::RenderInfo& renderInfo, const osg::Vec3d& eyePoint,
200  DtOsgGizmoRenderer* renderer );
201 
202  protected:
203 
206 
208  virtual void slot_terrainLoaded( const DtUnicode& terrain, bool reload );
209 
211  virtual void slot_windowCreated( DtWindow* window );
212 
214  virtual void slot_windowDestroyed( DtWindow* window );
215 
217  virtual void slot_ProfilingChanged( bool active );
218 
220  virtual void slot_reloadShader();
221 
223  virtual void slot_displayConfigurationRealized();
224 
226  virtual void slot_preDraw();
227 
229  virtual void slot_postDraw();
230 
232  virtual void slot_postUpdate();
233 
235  virtual void syncToSharedDiGuySettings();
236 
238  virtual void slot_diGuyInstancingEnabledChanged( bool enabled );
239 
241  virtual void slot_diGuyInstancedLodChanged( int lod );
242 
244  virtual void slot_diGuyVisualizeInstancingChanged( bool enabled );
245 
247  virtual void slot_diGuyTextureVariationsEnabledChanged( bool enabled );
248 
250  virtual void slot_diGuyMaxDrawDistanceChanged( float distance );
251 
253  virtual void slot_diGuyMaxMotionUpdateDistanceChanged( float distance );
254 
256  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
257 
259 
260  // Internal helper function to get pointer to specific DI-Guy character
261  diguyCharacter* getCharacter( DtElementID parentSceneObjectID );
262 
263  void updateScenario( double simTime );
264  void setComponentVisualizationMode( int mode );
265 
266  void createDiGuyScenario();
267 
268  void reloadConfigInfo();
269 
270  // Helper function called by other instance functions.
271  // If this is a graphical application, de must be set.
272  static DtDiGuyScenario* createInstance( DtDe& de, bool initVisualComponent = true );
273  static DtDiGuyScenario* createNonVisualInstance( const std::string& dataPath );
274 
275  static void slot_displayToBeDestroyed( const std::string& displayName, DtDe* de );
276 
277  public:
278 
280  static tbb::atomic<int> theStatNumCharInstanced;
281 
282  protected:
283 
285 
286  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
287  // It might not be true if this instance was created by lightweight_instance()
289 
290  diguyScenario* myScenario;
291 
298 
302 
303  // settings
313 
314  // True if initializeVisualComponent() has been called
317 
318  std::string myAlternateDataPath; // use this when the De is not valid
320 
321  tbb::mutex myOctreeMutex;
324 
325  // temp object, don't realloc every frame
326  tbb::concurrent_vector<DtDiGuyOsgRootNode*> myNoninstancedNodeArray;
327 
328  // stats
333 
335 
336  // A dirty flag indicating that this must be reattached after RDE reconnection
338 
339  };
340 
341 
342  DtCoordTransform getTopoToGeoc( const DtVector& location );
343 
344 }
virtual DtDe & getDe()
returns de
Definition: DtDiGuyScenario.h:181
std::set< DtString > StringSet
Definition: DtDiGuyScenario.h:81
bool myVisualComponentInitialized
Definition: DtDiGuyScenario.h:315
data that&#39;s passed around for culling
Definition: DtDiGuyOctreeCullGroup.h:35
Abstract Base class.
Definition: DtWindow.h:25
tbb::mutex myOctreeMutex
Definition: DtDiGuyScenario.h:321
Virtual base class.
Definition: DtVirtualBaseClass.h:19
osg::ref_ptr< DtDiGuyInstanceDrawable > myInstancedDrawable
Definition: DtDiGuyScenario.h:297
osg::ref_ptr< osg::Group > myCharacterRoot
Definition: DtDiGuyScenario.h:293
A unicode string.
Definition: DtUnicode.h:33
bool myDrawSkeletons
Definition: DtDiGuyScenario.h:309
helper struct for data loaded from light config file
Definition: DtDiGuyScenario.h:68
LightConfigDataArray myLightDataArray
Definition: DtDiGuyScenario.h:334
bool myUseInstancing
Definition: DtDiGuyScenario.h:304
int myLightType
Definition: DtDiGuyScenario.h:71
osg::ref_ptr< osg::Group > myDiguyRoot
Definition: DtDiGuyScenario.h:292
diguyScenario * myScenario
Definition: DtDiGuyScenario.h:290
bool myDeIsValid
Definition: DtDiGuyScenario.h:288
Custom per character root node that does custom traversals and short circuits osg lod picking...
Definition: DtDiGuyOsgGraphicsLink.h:99
virtual Instance * createInstance()
Definition: bdiQPropTree_subclasses.h:693
bool myUseMultithreadedCull
Definition: DtDiGuyScenario.h:308
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.
Definition: DtOsgGizmoRenderer.h:136
bool myUseTextureVariations
Definition: DtDiGuyScenario.h:306
bool myLightweightInstance
Definition: DtDiGuyScenario.h:316
double myFirstUpdateT
Definition: DtDiGuyScenario.h:300
osg::ref_ptr< osg::MatrixTransform > myInstancingRoot
Definition: DtDiGuyScenario.h:296
tbb::concurrent_vector< DtDiGuyOsgRootNode * > myNoninstancedNodeArray
Definition: DtDiGuyScenario.h:326
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
osg::ref_ptr< DtLightPointNode > myLightPointNode
Definition: DtDiGuyScenario.h:294
int myStatOctreeUpdate
Definition: DtDiGuyScenario.h:329
float myGuideSyncGain
Definition: DtDiGuyScenario.h:312
bool myDrawIKVisuals
Definition: DtDiGuyScenario.h:310
bool myReAddNodeToSceneGraph
Definition: DtDiGuyScenario.h:337
virtual Octree_64 * octree()
returns octree
Definition: DtDiGuyScenario.h:176
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.
DtCoordTransform getTopoToGeoc(const DtVector &location)
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
Octree datastructure for managing scene nodes.
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:301
int myDriver
Definition: DtDiGuyScenario.h:72
static int theStatNumCharDrawn
Definition: DtDiGuyScenario.h:279
Octree_64::NodeVector myVisibleOctreeNodes
Definition: DtDiGuyScenario.h:323
osg::ref_ptr< osg::MatrixTransform > myLightPointRoot
Definition: DtDiGuyScenario.h:295
Base class to provide boost signal/slot management.
DtDe & myDe
Definition: DtDiGuyScenario.h:284
DtSignalConnectionManager myConnections
Definition: DtDiGuyScenario.h:319
const char int mode
Definition: ioapi.h:38
std::vector< DtDiguyLightConfig > LightConfigDataArray
Definition: DtDiGuyScenario.h:83
Contains makVrv::DtUniqueID type.
float myMaxMotionUpdateDistance
Definition: DtDiGuyScenario.h:311
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.
Definition: DtDe.h:69
#define DT_DLL_VRVDIGUY
Definition: vrvDiGuy.h:21
Octree_64 * myOctree
Definition: DtDiGuyScenario.h:322
bool myIsGeocentric
Definition: DtDiGuyScenario.h:299
std::string myAlternateDataPath
Definition: DtDiGuyScenario.h:318
float myStatOctreeUpdateTime
Definition: DtDiGuyScenario.h:330
float myStatPreviousOctreeUpdateTime
Definition: DtDiGuyScenario.h:331
bool myUseGuides
Definition: DtDiGuyScenario.h:305
bool myUseOctree
Definition: DtDiGuyScenario.h:307
static tbb::atomic< int > theStatNumCharInstanced
Definition: DtDiGuyScenario.h:280
std::vector< StringSet > StringSetVec
Definition: DtDiGuyScenario.h:82
float myStatCulltime
Definition: DtDiGuyScenario.h:332
Owns a DiGuy scenario for the application.
Definition: DtDiGuyScenario.h:77
Contains the makVrv::DtDiGuyTypeMapFieldNode class declaration.
std::string myLinkName
Definition: DtDiGuyScenario.h:70
virtual DtDiGuyInstanceDrawable * instancedDrawable()
returns instance drawable singleton
Definition: DtDiGuyScenario.h:187

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)