VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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();
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);
158 
161  const char *getHandItemClass(const char *typeName);
162  int getNumHandItemsInClass(const char *className);
164  const char *getHandItemFromClass(const char *className, int index);
165 
167  int getCharacterTypeNumHeads(const char *typeName, const char *appearanceName);
169  const char *getCharacterTypeHeadAtIndex(const char *typeName, const char *appearanceName, int index);
170 
172  int getCharacterTypeNumActions(const char *typeName);
174  const char *getCharacterTypeActionAtIndex(const char *typeName, int index);
175 
177  float getCharacterTypeActionDuration(const char *typeName, const char *actionName);
179  float getCharacterTypeActionSpeed(const char *typeName, const char *actionName);
182  const char *getCharacterTypeActionPosture(const char *typeName, const char *actionName);
186  const char *getCharacterTypeActionDirection(const char *typeName, const char *actionName);
191  const char *getCharacterTypeActionPrimaryVariant(const char *typeName, const char *actionName);
192 
205 
208  int getNumTypeMapEntries();
209 
211  const char *getTypeMapCharacterType(int index);
212 
214  const char *getTypeMapCharacterAppearance(int index);
215 
217  const char *getTypeMapFieldValue(int index, const char *fieldName);
218  const char *getTypeMapFieldValue(int index, int fieldIndex);
219 
220  // For finding out the total number of possible values for the first field of a character's type map
221  // Class is something like: animal, effect, human, human_on_vehicle, object, vehicle
222  int getNumTypeMapCharacterClasses();
223  const char* getTypeMapCharacterClassAtIndex(int index);
224 
225  // For finding out the total number of possible values for the second field of a character's type map
226  // Category depends on class (above)
227  int getNumTypeMapCategories(const char* character_class);
228  const char* getTypeMapCategoryAtIndex(const char* character_class, int index);
229 
230  // For finding out the total number of possible values for the third field of a character's type map
231  int getNumTypeMapSubcategories(const char* character_class,
232  const char* category);
233  const char* getTypeMapSubcategoryAtIndex(const char* character_class,
234  const char* category,
235  int index);
236 
239  virtual void getAppearancesMatchingDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &fields, std::vector<DtString> &retAppearances);
242  virtual void getAppearancesMatchingPartialDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &partialFields,
243  std::vector<int> &fieldIndices, std::vector<DtString> &retAppearances);
247  virtual void getTypeMapFieldOptions(const DtString &characterType, std::vector<DtString> &fields, StringListVec &retValues);
249  virtual void getTypeMapPartialFieldOptions(const DtString &characterType, std::vector<DtString> &partialFields, std::vector<int> &fieldIndices,
250  StringListVec &retValues);
251 
252  virtual void initTypeMapNodes();
253 
254  protected:
256  virtual void slot_windowDestroyed(DtWindow* window);
257 
259  virtual void slot_windowCreated(DtWindow* window);
260 
262  virtual void slot_reloadShader();
263 
265  virtual void slot_preDraw();
266 
268  virtual void slot_postDraw();
269 
271  virtual void slot_postUpdate();
272 
274  virtual void syncToSharedDiGuySettings();
275 
277  virtual void slot_diGuyInstancingEnabledChanged( bool enabled );
278 
280  virtual void slot_diGuyInstancedLodChanged( int lod );
281 
283  virtual void slot_diGuyVisualizeInstancingChanged( bool enabled );
284 
286  virtual void slot_diGuyMaxDrawDistanceChanged( float distance );
287 
289  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
290 
291  protected:
292 
293  // Internal helper function to get pointer to specific DI-Guy character
294  diguyCharacter *getCharacter(DtElementID parentSceneObjectID);
295 
296  // Helper function called by other instance functions. If this is a graphical application,
297  // de must be set.
298  static DtDiGuyScenario *createInstance(DtDe *de = NULL, bool initVisualComponent = true);
299 
300  static void slot_displayToBeDestroyed(const std::string& displayName, DtDe *de);
301 
302 
303  void updateScenario(double simTime);
304  void setComponentVisualizationMode(int mode);
305 
306  DtDiGuyScenario(DtDe& de);
307  DtDiGuyScenario();
308 
309  void createDiGuyScenario();
310 
311  void reloadConfigInfo();
312 
314  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
315  // It might not be true if this instance was created by lightweight_instance()
317  diguyScenario* myScenario;
318 
319  osg::ref_ptr<osg::Group> myDiguyRoot;
320  osg::ref_ptr<osg::Group> myCharacterRoot;
321  osg::ref_ptr<osg::Group> myInstancingRoot;
326 
328 
329  // True if initializeVisualComponent() has been called
332 
335 
337  };
338 
339  DtCoordTransform getTopoToGeoc(const DtVector& location);
340 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)