TDME2  1.9.200
ModelEditorTabController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <memory>
5 #include <string>
6 #include <unordered_map>
7 #include <vector>
8 
9 #include <tdme/tdme.h>
20 #include <tdme/math/fwd-tdme.h>
26 
27 using std::array;
28 using std::string;
29 using std::unique_ptr;
30 using std::unordered_map;
31 using std::vector;
32 
61 
62 /**
63  * Model editor tab controller
64  * @author Andreas Drewke
65  */
67  : public TabController
68 {
69 
70 private:
71  unique_ptr<BasePropertiesSubController> basePropertiesSubController;
72  unique_ptr<PrototypeDisplaySubController> prototypeDisplaySubController;
73  unique_ptr<PrototypePhysicsSubController> prototypePhysicsSubController;
74  unique_ptr<PrototypeSoundsSubController> prototypeSoundsSubController;
75  unique_ptr<PrototypeScriptSubController> prototypeScriptSubController;
76  ModelEditorTabView* view { nullptr };
77  GUIScreenNode* screenNode { nullptr };
78  PopUps* popUps { nullptr };
79 
80  array<string, 5> applyAnimationNodes = {
81  "animation_startframe",
82  "animation_endframe",
83  "animation_speed",
84  "animation_loop",
85  "animation_overlaybone"
86  };
87 
88  array<string, 3> applyMaterialBaseNodes = {
89  "material_specular_embedtextures_enabled",
90  "material_pbr_embedtextures_enabled",
91  "material_lightningmodel"
92  };
93 
94  array<string, 3> applySpecularMaterialNodes = {
95  "specularmaterial_shininess",
96  "specularmaterial_reflection",
97  "specularmaterial_maskedtransparency"
98  };
99 
100  array<string, 6> applyPBRMaterialNodes = {
101  "pbrmaterial_metallic_factor",
102  "pbrmaterial_roughness_factor",
103  "pbrmaterial_normal_scale",
104  "pbrmaterial_exposure",
105  "pbrmaterial_maskedtransparency"
106  };
107 
108  array<string, 5> applyAnimationPreviewNodes = {
109  "animationpreview_base",
110  "animationpreview_overlay1",
111  "animationpreview_overlay2",
112  "animationpreview_overlay3",
113  "animationpreview_attachment1_bone"
114  };
115 
116  array<string, 4> applyLODNodes = {
117  "lod_min_distance",
118  };
119 
121  int renameAnimationLOD { -1 };
122 
124 
125  /**
126  * Get LOD level
127  * @return created or existing LOD level with given level
128  */
129  PrototypeLODLevel* getLODLevel(int level);
130 
131  /**
132  * @return prototype lod level or nullptr
133  */
134  Model* getLODLevelModel(int level);
135 
136  /**
137  * @return current selected model
138  */
140 
141  /**
142  * @return current selected material
143  */
145 
146  /**
147  * @return current selected animation setup
148  */
150 
151  /**
152  * Create outliner model nodes xml
153  * @param prefix prefix
154  * @param subNodes sub nodes
155  * @param xml xml
156  */
157  void createOutlinerModelNodesXML(const string& prefix, const unordered_map<string, Node*>& subNodes, string& xml);
158 
159 public:
160  // forbid class copy
162 
163  /**
164  * Public constructor
165  * @param view view
166  */
168 
169  /**
170  * Destructor
171  */
172  virtual ~ModelEditorTabController();
173 
174  /**
175  * Get view
176  * @return view
177  */
179  return view;
180  }
181 
182  /**
183  * @return prototype display sub screen controller
184  */
186  return prototypeDisplaySubController.get();
187  }
188 
189  /**
190  * @return prototype bounding volume sub screen controller
191  */
193  return prototypePhysicsSubController.get();
194  }
195 
196  /**
197  * @return prototype sounds sub screen controller
198  */
200  return prototypeSoundsSubController.get();
201  }
202 
203  // overridden method
204  inline GUIScreenNode* getScreenNode() override {
205  return screenNode;
206  }
207 
208  // overridden methods
209  void initialize(GUIScreenNode* screenNode) override;
210  void dispose() override;
211 
212  /**
213  * Set outliner content
214  */
215  void setOutlinerContent();
216 
217  /**
218  * Set outliner add drop down content
219  */
221 
222  /**
223  * Set details content
224  */
225  void setDetailsContent();
226 
227  /**
228  * @return current material
229  */
231 
232  /**
233  * Set up model statistics
234  * @param statsOpaqueFaces stats opaque faces
235  * @param statsTransparentFaces stats transparent faces
236  * @param statsMaterialCount stats material count
237  */
238  void setStatistics(int statsOpaqueFaces, int statsTransparentFaces, int statsMaterialCount);
239 
240  /**
241  * Unset statistics
242  */
243  void unsetStatistics();
244 
245  /**
246  * On model reload
247  */
248  void onModelReload();
249 
250  /**
251  * On model load
252  */
253  void onModelLoad();
254 
255  /**
256  * On model reload
257  */
258  void onModelReimport();
259 
260  /**
261  * On LOD load
262  */
263  void onLODLoad(int lodLevel);
264 
265  /**
266  * On tools compute normals
267  */
268  void onToolsComputeNormal();
269 
270  /**
271  * On tools optimize model
272  */
273  void onToolsOptimizeModel();
274 
275  /**
276  * Save file
277  * @param pathName path name
278  * @param fileName file name
279  */
280  void saveFile(const string& pathName, const string& fileName);
281 
282  /**
283  * Load file
284  * @param pathName path name
285  * @param fileName file name
286  */
287  void loadFile(const string& pathName, const string& fileName);
288 
289  /**
290  * Set material base details
291  */
292  void setMaterialBaseDetails();
293 
294  /**
295  * Update material base details
296  */
298 
299  /**
300  * Apply material base details
301  */
303 
304  /**
305  * Set material details
306  */
307  void setMaterialDetails();
308 
309  /**
310  * Update material details
311  */
312  void updateMaterialDetails();
313 
314  /**
315  * Update material color details
316  */
318 
319  /**
320  * Apply specular material details
321  */
323 
324  /**
325  * Apply PBR material details
326  */
328 
329  /**
330  * Set animation details
331  */
332  void setAnimationDetails();
333 
334  /**
335  * Apply animation details
336  */
337  void applyAnimationDetails();
338 
339  /**
340  * Set animation preview details
341  */
343 
344  /**
345  * Apply animation preview details
346  */
348 
349  /**
350  * Update details panel
351  * @param outlinerNode outliner node
352  */
353  void updateDetails(const string& outlinerNode);
354 
355  /**
356  * Set material diffuse texture
357  * @param fileName file name
358  */
359  void setMaterialDiffuseTexture(const string& fileName);
360 
361  /**
362  * On material load diffuse texture
363  */
365 
366  /**
367  * On material clear diffuse texture
368  */
370 
371  /**
372  * On material browse to diffuse texture
373  */
375 
376  /**
377  * Set material diffuse transparency texture
378  * @param fileName file name
379  */
380  void setMaterialDiffuseTransparencyTexture(const string& fileName);
381 
382  /**
383  * On material load diffuse transparency texture
384  */
386 
387  /**
388  * On material clear diffuse transparency texture
389  */
391 
392  /**
393  * On material browse to diffuse transparency texture
394  */
396 
397  /**
398  * Set material normal texture
399  * @param fileName file name
400  */
401  void setMaterialNormalTexture(const string& fileName);
402 
403  /**
404  * On material load normal texture
405  */
407 
408  /**
409  * On material clear normal texture
410  */
412 
413  /**
414  * On material browse to normal texture
415  */
417 
418  /**
419  * Set material specular texture
420  * @param fileName file name
421  */
422  void setMaterialSpecularTexture(const string& fileName);
423 
424  /**
425  * On material load specular texture
426  */
428 
429  /**
430  * On material clear specular texture
431  */
433 
434  /**
435  * On material browse to specular texture
436  */
438 
439  /**
440  * Set material PBR base color texture
441  * @param fileName file name
442  */
443  void setMaterialPBRBaseColorTexture(const string& fileName);
444 
445  /**
446  * On material load PBR base color texture
447  */
449 
450  /**
451  * On material clear PBR base color texture
452  */
454 
455  /**
456  * On material browse to PBR base color texture
457  */
459 
460  /**
461  * Set material PBR metallic roughness texture
462  * @param fileName file name
463  */
464  void setMaterialPBRMetallicRoughnessTexture(const string& fileName);
465 
466  /**
467  * On material load PBR metallic roughness texture
468  */
470 
471  /**
472  * On material clear PBR metallic roughness texture
473  */
475 
476  /**
477  * On material browse to PBR metallic roughness texture
478  */
480 
481  /**
482  * Set material PBR normal texture
483  * @param fileName file name
484  */
485  void setMaterialPBRNormalTexture(const string& fileName);
486 
487  /**
488  * On material load PBR normal texture
489  */
491 
492  /**
493  * On material load PBR normal texture
494  */
496 
497  /**
498  * On material browse to PBR normal texture
499  */
501 
502  /**
503  * Set material PBR emissive texture
504  * @param fileName file name
505  */
506  void setMaterialPBREmissiveTexture(const string& fileName);
507 
508  /**
509  * On material load PBR emissive texture
510  */
512 
513  /**
514  * On material load PBR emissive texture
515  */
517 
518  /**
519  * On material browse to PBR emissive texture
520  */
522 
523  /**
524  * Set preview animations attachment 1 model
525  * @param fileName file name
526  */
527  void setPreviewAnimationsAttachment1Model(const string& fileName);
528 
529  /**
530  * On preview animations attachment 1 model load
531  */
533 
534  /**
535  * On preview animations attachment 1 model clear
536  */
538 
539  /**
540  * On preview animations attachment 1 model browse to
541  */
543 
544  /**
545  * Start rename animation
546  * @param lodLevel lod level
547  * @param animationId animation id
548  */
549  void startRenameAnimation(int lodLevel, const string& animationId);
550 
551  /**
552  * Rename animation
553  */
554  void renameAnimation();
555 
556  /**
557  * Create animation setup
558  * @param lodLevel lod level
559  */
560  void createAnimationSetup(int lodLevel);
561 
562  /**
563  * Create LOD
564  */
565  void createLOD();
566 
567  /**
568  * Create LOD none
569  */
570  void createLODNone();
571 
572  /**
573  * Set LOD details
574  * @param lodLevel lod level
575  */
576  void setLODDetails(int lodLevel);
577 
578  /**
579  * Set LOD color details
580  * @param lodLevel lod level
581  */
582  void updateLODColorDetails(int lodLevel);
583 
584  /**
585  * Apply LOD details
586  * @param lodLevel LOD level
587  */
588  void applyLODDetails(int lodLevel);
589 
590  /**
591  * Get outliner node within model or LOD models
592  * @param outlinerNode outliner node
593  * @param modelOutlinerNode model outliner node
594  * @param model model
595  * @param lodLevel lod level
596  * @return success
597  */
598  bool getOutlinerNodeLOD(const string& outlinerNode, string& modelOutlinerNode, Model** model = nullptr, int* lodLevel = nullptr);
599 
600  // overridden methods
601  void onChange(GUIElementNode* node) override;
602  void onAction(GUIActionListenerType type, GUIElementNode* node) override;
603  void onFocus(GUIElementNode* node) override;
604  void onUnfocus(GUIElementNode* node) override;
605  void onContextMenuRequest(GUIElementNode* node, int mouseX, int mouseY) override;
606  void onTooltipShowRequest(GUINode* node, int mouseX, int mouseY) override;
607  void onTooltipCloseRequest() override;
608  void onCommand(TabControllerCommand command) override;
609  void onDrop(const string& payload, int mouseX, int mouseY) override;
610 
611  /**
612  * Update info text line
613  * @param text text
614  */
615  void updateInfoText(const MutableString& text);
616 
617  /**
618  * Show the information pop up / modal
619  * @param caption caption
620  * @param message message
621  */
622  void showInfoPopUp(const string& caption, const string& message);
623 
624 };
Shader parameter model class.
Represents a material.
Definition: Material.h:23
Representation of a 3D model.
Definition: Model.h:35
Model node.
Definition: Node.h:32
Prototype LOD level definition.
Prototype definition.
Definition: Prototype.h:55
GUI node base class.
Definition: GUINode.h:64
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
Pop ups controller accessor class.
Definition: PopUps.h:29
void onMaterialClearPBRBaseColorTexture()
On material clear PBR base color texture.
void saveFile(const string &pathName, const string &fileName)
Save file.
void onContextMenuRequest(GUIElementNode *node, int mouseX, int mouseY) override
On context menu request.
void onDrop(const string &payload, int mouseX, int mouseY) override
On drop.
void setMaterialSpecularTexture(const string &fileName)
Set material specular texture.
unique_ptr< PrototypeSoundsSubController > prototypeSoundsSubController
void updateInfoText(const MutableString &text)
Update info text line.
void setOutlinerAddDropDownContent()
Set outliner add drop down content.
void setMaterialDiffuseTexture(const string &fileName)
Set material diffuse texture.
void onMaterialBrowseToDiffuseTexture()
On material browse to diffuse texture.
void onMaterialLoadPBRNormalTexture()
On material load PBR normal texture.
void onPreviewAnimationsAttachment1ModelBrowseTo()
On preview animations attachment 1 model browse to.
void onMaterialClearPBREmissiveTexture()
On material load PBR emissive texture.
void onMaterialClearPBRMetallicRoughnessTexture()
On material clear PBR metallic roughness texture.
void onMaterialClearSpecularTexture()
On material clear specular texture.
void onMaterialBrowseToDiffuseTransparencyTexture()
On material browse to diffuse transparency texture.
void setMaterialPBRNormalTexture(const string &fileName)
Set material PBR normal texture.
void onCommand(TabControllerCommand command) override
On command.
void onPreviewAnimationsAttachment1ModelLoad()
On preview animations attachment 1 model load.
void setStatistics(int statsOpaqueFaces, int statsTransparentFaces, int statsMaterialCount)
Set up model statistics.
void onMaterialClearPBRNormalTexture()
On material load PBR normal texture.
void startRenameAnimation(int lodLevel, const string &animationId)
Start rename animation.
void onMaterialLoadPBREmissiveTexture()
On material load PBR emissive texture.
ModelEditorTabController(ModelEditorTabView *view)
Public constructor.
void onMaterialLoadPBRMetallicRoughnessTexture()
On material load PBR metallic roughness texture.
void onMaterialLoadPBRBaseColorTexture()
On material load PBR base color texture.
void updateDetails(const string &outlinerNode)
Update details panel.
void setPreviewAnimationsAttachment1Model(const string &fileName)
Set preview animations attachment 1 model.
void onMaterialLoadDiffuseTransparencyTexture()
On material load diffuse transparency texture.
void createOutlinerModelNodesXML(const string &prefix, const unordered_map< string, Node * > &subNodes, string &xml)
Create outliner model nodes xml.
void onMaterialBrowseToPBRBaseColorTexture()
On material browse to PBR base color texture.
void onPreviewAnimationsAttachment1ModelClear()
On preview animations attachment 1 model clear.
unique_ptr< PrototypeScriptSubController > prototypeScriptSubController
void onMaterialBrowseToPBRMetallicRoughnessTexture()
On material browse to PBR metallic roughness texture.
void onMaterialBrowseToPBRNormalTexture()
On material browse to PBR normal texture.
void setMaterialPBRMetallicRoughnessTexture(const string &fileName)
Set material PBR metallic roughness texture.
unique_ptr< PrototypePhysicsSubController > prototypePhysicsSubController
void setMaterialPBREmissiveTexture(const string &fileName)
Set material PBR emissive texture.
unique_ptr< PrototypeDisplaySubController > prototypeDisplaySubController
void loadFile(const string &pathName, const string &fileName)
Load file.
void showInfoPopUp(const string &caption, const string &message)
Show the information pop up / modal.
void onAction(GUIActionListenerType type, GUIElementNode *node) override
void onMaterialBrowseToNormalTexture()
On material browse to normal texture.
void onMaterialBrowseToSpecularTexture()
On material browse to specular texture.
void setMaterialNormalTexture(const string &fileName)
Set material normal texture.
void setMaterialPBRBaseColorTexture(const string &fileName)
Set material PBR base color texture.
unique_ptr< BasePropertiesSubController > basePropertiesSubController
bool getOutlinerNodeLOD(const string &outlinerNode, string &modelOutlinerNode, Model **model=nullptr, int *lodLevel=nullptr)
Get outliner node within model or LOD models.
void onTooltipShowRequest(GUINode *node, int mouseX, int mouseY) override
On tooltip show request.
void setMaterialDiffuseTransparencyTexture(const string &fileName)
Set material diffuse transparency texture.
void onMaterialBrowseToPBREmissiveTexture()
On material browse to PBR emissive texture.
void onMaterialClearDiffuseTransparencyTexture()
On material clear diffuse transparency texture.
Mutable utf8 aware string class.
Definition: MutableString.h:23
GUI action listener interface.
GUI change listener interface.
GUI focus listener interface.
Tab controller, which connects UI with logic.
Definition: TabController.h:34
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6