VR-Forces 4.6.1 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) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
9 #pragma once
10 #include <string>
11 #include <list>
12 
13 #include <vrvDiGuy/vrvDiGuy.h>
15 #include <vrvCore/DtUniqueID.h>
16 #include <vlutil/vlString.h>
17 #include <matrix/vlVector.h>
18 
19 #include <osg/Group>
21 
22 #define ENABLE_DIGUY_PARTICLE_RENDERING 0
23 
24 class diguyScenario;
25 class diguyCharacter;
26 class DtCoordTransform;
27 
28 namespace makArchives
29 {
30  class DtDiGuySettings;
31 }
32 
33 namespace makVrv
34 {
35  class DtDe;
36  class DtWindow;
37 
38  static const int numDiGuyTypeMapFields = 9;
39 
56  {
57  public:
60 
62  void addType(const DtString &type);
64  void addAppearance(const DtString &appearance);
65 
69  void addWildCardNode();
72 
74  // indicates the current level.
75  void getAppearances(std::vector<DtString> &choiceValues, int depth, std::vector<DtString> &retAppearances);
77  void getFieldValues(std::list<DtString> &retList);
78 
81  void deep_merge(DiGuyTypeMapFieldNode *source);
82 
84  int fieldNum;
85  // the name of this option
87  // for quick lookup
88  std::map<DtString, DiGuyTypeMapFieldNode *> nextFieldNodesMap;
89  // If this is the last node in the chain, these will contain the type and appearance
90  // names that the full chain leads to.
91  std::list<DtString> typeNameList;
92  std::list<DtString> appearanceNameList;
93  };
94 
98  {
99  public:
100 
101  typedef std::list<DtString> StringList;
102  typedef std::vector<StringList> StringListVec;
103 
104  // Static accessor: creates a new instance or, if one is already associated
105  // with DtDe instance, return the existing instance. The visual component
106  // (needed for graphical applications) can be initialized now or later.
107  static DtDiGuyScenario& instance(DtDe& de, bool initVisualComponent = true);
108 
109  // For graphical applications, this must be called, but it can be called at
110  // the last possible moment. It calls, or enables the calling of, functions
111  // that are somewhat more time-consuming.
112  void initializeVisualComponent();
113 
114  // This returns an instance of DtDiGuyScenario in which the visual component
115  // has not been initialized. If this is not a graphical application, it will
116  // not be possible to initialize the visual component.
117  static DtDiGuyScenario *lightweight_instance( const std::string& dataPath );
118 
120  virtual ~DtDiGuyScenario();
121 
123  diguyScenario& scenario();
124 
125  void clearScene();
126 
128  virtual osg::Node* characterRoot();
129 
130  int getUseGuides(){return myUseGuides;}
131  float getGuideSyncGain(){return myGuideSyncGain;}
132  int getUseInstancing(){return myUseInstancing;}
133 
134  const char * mapEffect(const char * diguy_effect_name);
135 
137  std::string findCharacterName(DtElementID parentSceneObjectID);
138 
140  int getSupportsWeightVariations(DtElementID parentSceneObjectID);
141 
143  bool evalScript(const std::string & script);
144 
149 
151  int getNumCharacterTypes();
153  const char * getCharacterTypeAtIndex(int index);
155  int getCharacterTypeNumAppearances(const char *typeName);
157  const char *getCharacterTypeAppearanceAtIndex(const char *typeName, int index);
159  int getCharacterTypeNumGestures(const char *typeName);
161  const char *getCharacterTypeGestureAtIndex(const char *typeName, int index);
162 
165  const char *getHandItemClass(const char *typeName);
166  int getNumHandItemsInClass(const char *className);
168  const char *getHandItemFromClass(const char *className, int index);
169 
171  int getCharacterTypeNumHeads(const char *typeName, const char *appearanceName);
173  const char *getCharacterTypeHeadAtIndex(const char *typeName, const char *appearanceName, int index);
174 
176  int getCharacterTypeNumActions(const char *typeName);
178  const char *getCharacterTypeActionAtIndex(const char *typeName, int index);
179 
181  float getCharacterTypeActionDuration(const char *typeName, const char *actionName);
183  float getCharacterTypeActionSpeed(const char *typeName, const char *actionName);
186  const char *getCharacterTypeActionPosture(const char *typeName, const char *actionName);
190  const char *getCharacterTypeActionDirection(const char *typeName, const char *actionName);
195  const char *getCharacterTypeActionPrimaryVariant(const char *typeName, const char *actionName);
196 
209 
212  int getNumTypeMapEntries();
213 
215  const char *getTypeMapCharacterType(int index);
216 
218  const char *getTypeMapCharacterAppearance(int index);
219 
221  const char *getTypeMapFieldValue(int index, const char *fieldName);
222  const char *getTypeMapFieldValue(int index, int fieldIndex);
223 
224  // For finding out the total number of possible values for the first field of a character's type map
225  // Class is something like: animal, effect, human, human_on_vehicle, object, vehicle
226  int getNumTypeMapCharacterClasses();
227  const char* getTypeMapCharacterClassAtIndex(int index);
228 
229  // For finding out the total number of possible values for the second field of a character's type map
230  // Category depends on class (above)
231  int getNumTypeMapCategories(const char* character_class);
232  const char* getTypeMapCategoryAtIndex(const char* character_class, int index);
233 
234  // For finding out the total number of possible values for the third field of a character's type map
235  int getNumTypeMapSubcategories(const char* character_class,
236  const char* category);
237  const char* getTypeMapSubcategoryAtIndex(const char* character_class,
238  const char* category,
239  int index);
240 
243  virtual void getAppearancesMatchingDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &fields, std::vector<DtString> &retAppearances);
246  virtual void getAppearancesMatchingPartialDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &partialFields,
247  std::vector<int> &fieldIndices, std::vector<DtString> &retAppearances);
251  virtual void getTypeMapFieldOptions(const DtString &characterType, std::vector<DtString> &fields, StringListVec &retValues);
253  virtual void getTypeMapPartialFieldOptions(const DtString &characterType, std::vector<DtString> &partialFields, std::vector<int> &fieldIndices,
254  StringListVec &retValues);
255 
256  virtual void initTypeMapNodes();
257 
258  protected:
260  virtual void slot_windowDestroyed(DtWindow* window);
261 
263  virtual void slot_windowCreated(DtWindow* window);
264 
266  virtual void slot_reloadShader();
267 
269  virtual void slot_preDraw();
270 
272  virtual void slot_postDraw();
273 
275  virtual void slot_postUpdate();
276 
278  virtual void syncToSharedDiGuySettings();
279 
281  virtual void slot_diGuyInstancingEnabledChanged( bool enabled );
282 
284  virtual void slot_diGuyInstancedLodChanged( int lod );
285 
287  virtual void slot_diGuyVisualizeInstancingChanged( bool enabled );
288 
290  virtual void slot_diGuyMaxDrawDistanceChanged( float distance );
291 
293  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
294 
295  protected:
296 
297  // Internal helper function to get pointer to specific DI-Guy character
298  diguyCharacter *getCharacter(DtElementID parentSceneObjectID);
299 
300  // Helper function called by other instance functions. If this is a graphical application,
301  // de must be set.
302  static DtDiGuyScenario *createInstance(DtDe& de, bool initVisualComponent = true);
303  static DtDiGuyScenario *createNonVisualInstance(const std::string& dataPath);
304 
305  static void slot_displayToBeDestroyed(const std::string& displayName, DtDe *de);
306 
307 
308  void updateScenario(double simTime);
309  void setComponentVisualizationMode(int mode);
310 
311  DtDiGuyScenario(DtDe& de);
312  DtDiGuyScenario(const std::string& dataPth);
313 
314  void createDiGuyScenario();
315 
316  void reloadConfigInfo();
317 
319  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
320  // It might not be true if this instance was created by lightweight_instance()
322  diguyScenario* myScenario;
323 
324  osg::ref_ptr<osg::Group> myDiguyRoot;
325  osg::ref_ptr<osg::Group> myCharacterRoot;
326  osg::ref_ptr<osg::Group> myInstancingRoot;
331 
333 
334  // True if initializeVisualComponent() has been called
337 
340 
341  std::string myAlternateDataPath; // use this when the De is not valid
342 
344  };
345 
346  DtCoordTransform getTopoToGeoc(const DtVector& location);
347 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)