TDME2  1.9.200
ModelEditorTabView.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/audio/fwd-tdme.h>
8 #include <tdme/engine/fwd-tdme.h>
12 #include <tdme/math/fwd-tdme.h>
13 #include <tdme/math/Vector3.h>
20 
21 using std::string;
22 using std::unique_ptr;
23 
24 using tdme::audio::Audio;
42 
43 /**
44  * Model editor tab view
45  * @author Andreas Drewke
46  */
48  : public TabView
49  , public PlayableSoundView
51 {
52 protected:
53  unique_ptr<Engine> engine { nullptr };
54  Audio* audio { nullptr };
55 
56 private:
57  EditorView* editorView { nullptr };
58  string tabId;
59  PopUps* popUps { nullptr };
60  unique_ptr<ModelEditorTabController> modelEditorTabController;
64  unique_ptr<Prototype> prototype { nullptr };
66  int lodLevel;
67  unique_ptr<CameraRotationInputHandler> cameraRotationInputHandler;
68  int64_t audioStarted;
69  int64_t audioOffset;
72  unique_ptr<Model> attachment1Model;
74 
75  /**
76  * Init model
77  * @param resetup resetup flag which would mean to leave camera and lighting as is
78  */
79  void initModel(bool resetup);
80 
81  /**
82  * Load settings
83  */
84  void loadSettings();
85 
86  /**
87  * Store settings
88  */
89  void storeSettings();
90 
91  /**
92  * Load a model
93  */
94  void loadModel();
95 
96  /**
97  * Load model prototype
98  * @param name name
99  * @param description description
100  * @param pathName path name
101  * @param fileName file name
102  * @return prototype
103  * @throws tdme::utilities::Exception
104  */
105  virtual Prototype* loadModelPrototype(const string& name, const string& description, const string& pathName, const string& fileName);
106 
107  // overridden methods
108  void onCameraRotation() override;
109  void onCameraScale() override;
110 
111 public:
112  // forbid class copy
114 
115  /**
116  * Public constructor
117  * @param editorView editor view
118  * @param tabId tab id
119  * @param prototype prototype
120  */
122 
123  /**
124  * Destructor
125  */
127 
128  /**
129  * @return editor view
130  */
132  return editorView;
133  }
134 
135  /**
136  * @return pop up views
137  */
138  inline PopUps* getPopUps() {
139  return popUps;
140  }
141 
142  /**
143  * @return prototype
144  */
146  return prototype.get();
147  }
148 
149  /**
150  * Set prototype
151  * @param prototype prototype
152  */
154 
155  /**
156  * Reset prototype
157  */
158  void resetPrototype();
159 
160  /**
161  * Reload prototype
162  */
163  void reloadPrototype();
164 
165  /**
166  * Reimport prototype
167  */
168  void reimportPrototype();
169 
170  /**
171  * @return current model file name
172  */
173  const string& getFileName();
174 
175  /**
176  * @return LOD level
177  */
178  int getLODLevel() const;
179 
180  /**
181  * Set LOD level to display
182  * @param lodLevel lod level
183  */
184  void setLODLevel(int lodLevel);
185 
186  /**
187  * Update LOD level
188  */
189  void updateLODLevel();
190 
191  /**
192  * Issue file loading
193  * @param pathName path name
194  * @param fileName file name
195  */
196  void loadModel(const string& pathName, const string& fileName);
197 
198  /**
199  * Issue reimport model file
200  * @param pathName path name
201  * @param fileName file name
202  */
203  void reimportModel(const string& pathName, const string& fileName);
204 
205  /**
206  * Saving prototype as tmodel prototype
207  * @param pathName path name
208  * @param fileName file name
209  */
210  void saveFile(const string& pathName, const string& fileName);
211 
212  /**
213  * Issue file reloading
214  */
215  void reloadFile();
216 
217  /**
218  * Compute normals
219  */
220  void computeNormals();
221 
222  /**
223  * Optimize model
224  */
225  void optimizeModel();
226 
227  // overridden methods
228  void handleInputEvents() override;
229  void display() override;
230  inline const string& getTabId() override {
231  return tabId;
232  }
233  void initialize() override;
234  void dispose() override;
235  void activate() override;
236  void deactivate() override;
237  Engine* getEngine() override;
238  TabController* getTabController() override;
239  void reloadOutliner() override;
240  void playSound(const string& soundId) override;
241  void stopSound() override;
242  void updateRendering() override;
243  inline bool hasFixedSize() override { return false; };
244 
245  /**
246  * Play animation
247  * @param baseAnimationId base animation id
248  * @param overlay1AnimationId overlay 1 animation id
249  * @param overlay2AnimationId overlay 2 animation id
250  * @param overlay3AnimationId overlay 3 animation id
251  */
252  void playAnimation(const string& baseAnimationId, const string& overlay1AnimationId = string(), const string& overlay2AnimationId = string(), const string& overlay3AnimationId = string());
253 
254  /**
255  * Add attachment 1
256  * @param nodeId node id to attach model to
257  * @param attachmentModelFile attachment model mile
258  */
259  void addAttachment1(const string& nodeId, const string& attachmentModelFile);
260 
261  /**
262  * Set attachment 1 node id
263  * @param nodeId node id to attach model to
264  */
265  void setAttachment1NodeId(const string& nodeId);
266 
267  /**
268  * Update shader parameters
269  */
270  void updateShaderParemeters();
271 
272 };
Interface to audio module.
Definition: Audio.h:29
Engine main class.
Definition: Engine.h:131
Frame buffer class.
Definition: FrameBuffer.h:22
Representation of a 3D model.
Definition: Model.h:35
Prototype definition.
Definition: Prototype.h:55
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 saveFile(const string &pathName, const string &fileName)
Saving prototype as tmodel prototype.
void playSound(const string &soundId) override
Play sound.
unique_ptr< ModelEditorTabController > modelEditorTabController
bool hasFixedSize() override
If this viewport framebuffer has a fixed size.
void onCameraRotation() override
On rotation event to be overloaded.
ModelEditorTabView(EditorView *editorView, const string &tabId, Prototype *prototype)
Public constructor.
void addAttachment1(const string &nodeId, const string &attachmentModelFile)
Add attachment 1.
void handleInputEvents() override
Handle input events that have not yet been processed.
void setLODLevel(int lodLevel)
Set LOD level to display.
virtual Prototype * loadModelPrototype(const string &name, const string &description, const string &pathName, const string &fileName)
Load model prototype.
void playAnimation(const string &baseAnimationId, const string &overlay1AnimationId=string(), const string &overlay2AnimationId=string(), const string &overlay3AnimationId=string())
Play animation.
unique_ptr< CameraRotationInputHandler > cameraRotationInputHandler
void setPrototype(Prototype *prototype)
Set prototype.
void updateShaderParemeters()
Update shader parameters.
void reimportModel(const string &pathName, const string &fileName)
Issue reimport model file.
void onCameraScale() override
On scale event to be overloaded.
void setAttachment1NodeId(const string &nodeId)
Set attachment 1 node id.
GUI input event handler interface.
Tab controller, which connects UI with logic.
Definition: TabController.h:34
Playable sound view interface, which represents a view that supports playing sounds additionally.
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6