VR-Forces Development_Version 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 
18 #include <osg/Group>
19 
20 class diguyScenario;
21 namespace makArchives
22 {
23  class DtDiGuySettings;
24 }
25 
26 namespace makVrv
27 {
28  class DtDe;
29  class DtWindow;
30 
31  static const int numDiGuyTypeMapFields = 9;
32 
49  {
50  public:
53 
55  void addType(const DtString &type);
57  void addAppearance(const DtString &appearance);
58 
62  void addWildCardNode();
65 
67  // indicates the current level.
68  void getAppearances(std::vector<DtString> &choiceValues, int depth, std::vector<DtString> &retAppearances);
70  void getFieldValues(std::list<DtString> &retList);
71 
74  void deep_merge(DiGuyTypeMapFieldNode *source);
75 
77  int fieldNum;
78  // the name of this option
80  // for quick lookup
81  std::map<DtString, DiGuyTypeMapFieldNode *> nextFieldNodesMap;
82  // If this is the last node in the chain, these will contain the type and appearance
83  // names that the full chain leads to.
84  std::list<DtString> typeNameList;
85  std::list<DtString> appearanceNameList;
86  };
87 
91  {
92  public:
93 
94  // Static accessor: creates a new instance or, if one is already associated
95  // with DtDe instance, return the existing instance. The visual component
96  // (needed for graphical applications) can be initialized now or later.
97  static DtDiGuyScenario& instance(DtDe& de, bool initVisualComponent = true);
98 
99  // For graphical applications, this must be called, but it can be called at
100  // the last possible moment. It calls, or enables the calling of, functions
101  // that are somewhat more time-consuming.
102  void initializeVisualComponent();
103 
104  // This returns an instance of DtDiGuyScenario in which the visual component
105  // has not been initialized. If this is not a graphical application, it will
106  // not be possible to initialize the visual component.
107  static DtDiGuyScenario *lightweight_instance();
108 
110  virtual ~DtDiGuyScenario();
111 
113  diguyScenario& scenario();
114 
115  void clearScene();
116 
118  virtual osg::Node* characterRoot();
119 
120  int getUseGuides(){return myUseGuides;}
121  float getGuideSyncGain(){return myGuideSyncGain;}
122  int getUseInstancing(){return myUseInstancing;}
123 
124  const char * mapEffect(const char * diguy_effect_name);
125 
127  std::string findCharacterName(DtElementID parentSceneObjectID);
128 
130  bool evalScript(const std::string & script);
131 
133  int getNumCharacterTypes();
135  const char * getCharacterTypeAtIndex(int index);
137  int getCharacterTypeNumAppearances(const char *typeName);
139  const char *getCharacterTypeAppearanceAtIndex(const char *typeName, int index);
140 
143  const char *getHandItemClass(const char *typeName);
144  int getNumHandItemsInClass(const char *className);
146  const char *getHandItemFromClass(const char *className, int index);
147 
149  int getCharacterTypeNumHeads(const char *typeName, const char *appearanceName);
151  const char *getCharacterTypeHeadAtIndex(const char *typeName, const char *appearanceName, int index);
152 
154  int getCharacterTypeNumActions(const char *typeName);
156  const char *getCharacterTypeActionAtIndex(const char *typeName, int index);
157 
159  float getCharacterTypeActionDuration(const char *typeName, const char *actionName);
161  float getCharacterTypeActionSpeed(const char *typeName, const char *actionName);
164  const char *getCharacterTypeActionPosture(const char *typeName, const char *actionName);
168  const char *getCharacterTypeActionDirection(const char *typeName, const char *actionName);
173  const char *getCharacterTypeActionPrimaryVariant(const char *typeName, const char *actionName);
174 
185 
188  int getNumTypeMapEntries();
189 
191  const char *getTypeMapCharacterType(int index);
192 
194  const char *getTypeMapCharacterAppearance(int index);
195 
197  const char *getTypeMapFieldValue(int index, const char *fieldName);
198  const char *getTypeMapFieldValue(int index, int fieldIndex);
199 
200  // For finding out the total number of possible values for the first field of a character's type map
201  // Class is something like: animal, effect, human, human_on_vehicle, object, vehicle
202  int getNumTypeMapCharacterClasses();
203  const char* getTypeMapCharacterClassAtIndex(int index);
204 
205  // For finding out the total number of possible values for the second field of a character's type map
206  // Category depends on class (above)
207  int getNumTypeMapCategories(const char* character_class);
208  const char* getTypeMapCategoryAtIndex(const char* character_class, int index);
209 
210  // For finding out the total number of possible values for the third field of a character's type map
211  int getNumTypeMapSubcategories(const char* character_class,
212  const char* category);
213  const char* getTypeMapSubcategoryAtIndex(const char* character_class,
214  const char* category,
215  int index);
216 
219  virtual void getAppearancesMatchingDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &fields, std::vector<DtString> &retAppearances);
222  virtual void getAppearancesMatchingPartialDiGuyTypeMap(const DtString &characterType, std::vector<DtString> &partialFields,
223  std::vector<int> &fieldIndices, std::vector<DtString> &retAppearances);
227  virtual void getTypeMapFieldOptions(const DtString &characterType, std::vector<DtString> &fields, std::vector<std::list<DtString>> &retValues);
229  virtual void getTypeMapPartialFieldOptions(const DtString &characterType, std::vector<DtString> &partialFields, std::vector<int> &fieldIndices,
230  std::vector<std::list<DtString>> &retValues);
231 
232  virtual void initTypeMapNodes();
233 
234  protected:
236  virtual void slot_windowDestroyed(DtWindow* window);
237 
239  virtual void slot_windowCreated(DtWindow* window);
240 
242  virtual void slot_reloadShader();
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_diGuyMaxDrawDistanceChanged( float distance );
267 
269  virtual void slot_diGuyMultiThreadUpdateChanged( bool enabled );
270 
271  protected:
272 
273  // Helper function called by other instance functions. If this is a graphical application,
274  // de must be set.
275  static DtDiGuyScenario *createInstance(DtDe *de = NULL, bool initVisualComponent = true);
276 
277  void updateScenario(double simTime);
278  void setComponentVisualizationMode(int mode);
279 
280  DtDiGuyScenario(DtDe& de);
281  DtDiGuyScenario();
282 
283  void createDiGuyScenario();
284 
285  void reloadConfigInfo();
286 
288  // True if myDe refers to a valid DtDe object, created by a graphical application, this will be true
289  // It might not be true if this instance was created by lightweight_instance()
291  diguyScenario* myScenario;
292 
293  osg::ref_ptr<osg::Group> myDiguyRoot;
294  osg::ref_ptr<osg::Group> myCharacterRoot;
295  osg::ref_ptr<osg::Group> myInstancingRoot;
300 
302 
303  // True if initializeVisualComponent() has been called
306 
309  };
310 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)