TDME2  1.9.200
TerrainEditorTabView.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <unordered_map>
6 #include <unordered_set>
7 #include <vector>
8 
9 #include <tdme/tdme.h>
10 #include <tdme/engine/fwd-tdme.h>
14 #include <tdme/math/Vector3.h>
23 
24 using std::string;
25 using std::unique_ptr;
26 using std::unordered_map;
27 using std::unordered_set;
28 using std::vector;
29 
42 
43 /**
44  * Terrain editor tab view
45  * @author Andreas Drewke
46  */
48  : public TabView
49 {
50 protected:
51  unique_ptr<Engine> engine;
52 
53 private:
54  EditorView* editorView { nullptr };
55  string tabId;
56  PopUps* popUps { nullptr };
57  unique_ptr<TerrainEditorTabController> terrainEditorTabController;
59 
60  unique_ptr<CameraInputHandler> cameraInputHandler;
61 
62  unique_ptr<Prototype> prototype;
63 
65  vector<Model*> terrainModels;
66 
67  struct Water {
69  vector<Model*> waterModels;
70  };
71  unordered_map<int, Water> waters;
72 
73  vector<int> partitionFoliageIdx;
74  unordered_set<int> temporaryPartitionIdxs;
75 
76  bool brushingEnabled { false };
77  bool brushMoved { false };
79  Texture* brushTexture { nullptr };
80  float brushScale { 1.0f };
81  float brushDensityStrength { 1.0f };
82  int rampMode { -1 };
83  array<Vector3, 2> rampVertices;
84  array<float, 2> rampHeight;
85 
86 public:
87  // forbid class copy
89 
90  /**
91  * Public constructor
92  * @param editorView editor view
93  * @param tabId tab id
94  * @param prototype prototype
95  */
97 
98  /**
99  * Destructor
100  */
102 
103  /**
104  * @return editor view
105  */
107  return editorView;
108  }
109 
110  /**
111  * @return associated tab controller
112  */
113  inline TabController* getTabController() override {
114  return terrainEditorTabController.get();
115  }
116 
117  /**
118  * @return pop up views
119  */
120  inline PopUps* getPopUps() {
121  return popUps;
122  }
123 
124  /**
125  * @return prototype
126  */
128  return prototype.get();
129  }
130 
131  // overridden methods
132  void handleInputEvents() override;
133  void display() override;
134  inline const string& getTabId() override {
135  return tabId;
136  }
137  void initialize() override;
138  void dispose() override;
139  Engine* getEngine() override;
140  void activate() override;
141  void deactivate() override;
142  void reloadOutliner() override;
143  inline bool hasFixedSize() override{ return false; };
144  void updateRendering() override;
145 
146  /**
147  * Saving prototype as tmodel prototype
148  * @param pathName path name
149  * @param fileName file name
150  */
151  void saveFile(const string& pathName, const string& fileName);
152 
153  /**
154  * Reset engine
155  */
156  void reset();
157 
158  /**
159  * Initialize terrain
160  */
161  void initializeTerrain();
162 
163  /**
164  * Unset terrain
165  */
166  void unsetTerrain();
167 
168  /**
169  * Set terrain models
170  * @param terrainBoundingBox terrain bounding box
171  * @param terrainModels terrain models
172  */
174 
175  /**
176  * Set brush
177  * @param texture brush texture
178  * @param scale scale
179  * @param densityStrength density strength
180  */
181  void setBrush(Texture* texture, float scale, float densityStrength);
182 
183  /**
184  * Set brush scale
185  * @param scale scale
186  */
187  void setBrushScale(float scale);
188 
189  /**
190  * Set brush density/strength
191  * @param densityStrength density/strength
192  */
193  void setBrushDensityStrength(float densityStrength);
194 
195  /**
196  * Unset brush
197  */
198  void unsetBrush();
199 
200  /**
201  * Unset water
202  */
203  void unsetWater();
204 
205  /**
206  * Remove water
207  * @param waterIdx water index
208  */
209  void removeWater(int waterIdx);
210 
211  /**
212  * Add water
213  * @param waterIdx water index
214  * @param waterModels water models
215  * @param waterReflectionEnvironmentMappingPosition water reflection environment mapping position
216  */
217  void addWater(int waterIdx, vector<Model*> waterModels, const Vector3& waterReflectionEnvironmentMappingPosition);
218 
219  /**
220  * Add foliage using render groups at given partition indices
221  */
222  void addFoliage();
223 
224  /**
225  * Add temporary foliage
226  * @param newFoliageMaps new foliage maps
227  */
228  void addTemporaryFoliage(const vector<unordered_map<int, vector<Transform>>>& newFoliageMaps);
229 
230  /**
231  * Update temporary foliage
232  */
233  void updateTemporaryFoliage(const unordered_set<int>& partitionIdxSet);
234 
235  /**
236  * Recreate temporary foliage at given partition indices
237  * @param partitionIdxSet partition indices set
238  */
239  inline void recreateTemporaryFoliage(const unordered_set<int>& partitionIdxSet) {
240  for (auto partitionIdx: partitionIdxSet) recreateTemporaryFoliage(partitionIdx);
241  }
242 
243  /**
244  * Recreate temporary foliage at given partition index
245  * @param partitionIdx partition index
246  */
247  void recreateTemporaryFoliage(int partitionIdx);
248 
249  /**
250  * Recreate foliage using render groups at given partition indices that has been transformed to temporary foliage
251  * @param partitionIdxSet partition index set
252  */
253  void recreateFoliage(const unordered_set<int>& partitionIdxSet);
254 
255 };
Engine main class.
Definition: Engine.h:131
Frame buffer class.
Definition: FrameBuffer.h:22
Texture entity.
Definition: Texture.h:24
Representation of a 3D model.
Definition: Model.h:35
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
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 recreateFoliage(const unordered_set< int > &partitionIdxSet)
Recreate foliage using render groups at given partition indices that has been transformed to temporar...
void addTemporaryFoliage(const vector< unordered_map< int, vector< Transform >>> &newFoliageMaps)
Add temporary foliage.
bool hasFixedSize() override
If this viewport framebuffer has a fixed size.
void addWater(int waterIdx, vector< Model * > waterModels, const Vector3 &waterReflectionEnvironmentMappingPosition)
Add water.
void updateTemporaryFoliage(const unordered_set< int > &partitionIdxSet)
Update temporary foliage.
void addFoliage()
Add foliage using render groups at given partition indices.
TerrainEditorTabView(EditorView *editorView, const string &tabId, Prototype *prototype)
Public constructor.
void setBrushDensityStrength(float densityStrength)
Set brush density/strength.
void handleInputEvents() override
Handle input events that have not yet been processed.
void recreateTemporaryFoliage(const unordered_set< int > &partitionIdxSet)
Recreate temporary foliage at given partition indices.
unique_ptr< TerrainEditorTabController > terrainEditorTabController
void setBrush(Texture *texture, float scale, float densityStrength)
Set brush.
void setTerrain(BoundingBox &terrainBoundingBox, vector< Model * > terrainModels)
Set terrain models.
Tab controller, which connects UI with logic.
Definition: TabController.h:34
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6