TDME2  1.9.200
SceneConnector.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/audio/fwd-tdme.h>
9 #include <tdme/engine/fwd-tdme.h>
16 #include <tdme/math/fwd-tdme.h>
17 #include <tdme/math/Vector3.h>
19 
20 using std::string;
21 using std::vector;
22 
23 using tdme::audio::Audio;
40 
41 /**
42  * Scene engine/physics connector
43  * @author Andreas Drewke
44  */
46 {
47 
48 public:
49  static constexpr uint16_t BODY_TYPEID_STATIC { 1 };
50  static constexpr uint16_t BODY_TYPEID_DYNAMIC { 2 };
51  static constexpr uint16_t BODY_TYPEID_COLLISION { 4 };
52  static constexpr uint16_t BODY_TYPEID_TRIGGER { 8 };
53 
54  static constexpr int BODY_TYPEID_STANDARD { 0 };
55  static constexpr int BOUNDINGVOLUME_INDEX_NONE { -1 };
56 
66 
67  /**
68  * @return render groups partition size / width
69  */
70  inline static float getRenderGroupsPartitionWidth() {
72  }
73 
74  /**
75  * Set render groups partition size / width
76  * @param renderNodesPartitionDepth render groups partition size / width
77  */
78  inline static void setRenderGroupsPartitionWidth(float renderNodesPartitionWidth) {
79  SceneConnector::renderGroupsPartitionWidth = renderNodesPartitionWidth;
80  }
81 
82  /**
83  * @return render groups partition size / height
84  */
85  inline static float getRenderGroupsPartitionHeight() {
87  }
88 
89  /**
90  * Set render groups partition size / height
91  * @param renderNodesPartitionDepth render groups partition size / height
92  */
93  inline static void setRenderGroupsPartitionHeight(float renderNodesPartitionHeight) {
94  SceneConnector::renderGroupsPartitionHeight = renderNodesPartitionHeight;
95  }
96 
97  /**
98  * @return render groups partition size / depth
99  */
100  inline static float getRenderGroupsPartitionDepth() {
102  }
103 
104  /**
105  * Set render groups partition size / depth
106  * @param renderNodesPartitionDepth render groups partition size / depth
107  */
108  inline static void setRenderGroupsPartitionDepth(float renderNodesPartitionDepth) {
109  SceneConnector::renderGroupsPartitionDepth = renderNodesPartitionDepth;
110  }
111 
112  /**
113  * Set render groups reduce objects by a given factor
114  * @param reduceBy render groups objects reduce by factor
115  */
116  inline static void setRenderGroupsReduceBy(int reduceBy) {
118  }
119 
120  /**
121  * @return render groups objects reduce by factor
122  */
123  inline static int getRenderGroupsReduceBy() {
124  return renderGroupsReduceBy;
125  }
126 
127  /**
128  * @return render groups LOD levels
129  */
130  inline static int getRenderGroupsLodLevels() {
131  return renderGroupsLODLevels;
132  }
133 
134  /**
135  * Set render groups LOD levels
136  * @param lodLevels render groups LOD levels
137  */
138  inline static void setRenderGroupsLodLevels(int lodLevels) {
139  renderGroupsLODLevels = lodLevels;
140  }
141 
142  /**
143  * @return render groups LOD2 minumum distance
144  */
145  inline static float getRenderGroupsLod2MinDistance() {
147  }
148 
149  /**
150  * Set render groups LOD2 minumum distance
151  * @param minDistance render groups LOD2 minumum distance
152  */
153  inline static void setRenderGroupsLod2MinDistance(float minDistance) {
154  renderGroupsLOD2MinDistance = minDistance;
155  }
156 
157  /**
158  * @return render groups LOD3 minumum distance
159  */
160  inline static float getRenderGroupsLod3MinDistance() {
162  }
163 
164  /**
165  * Set render groups LOD3 minumum distance
166  * @param minDistance render groups LOD3 minumum distance
167  */
168  inline static void setRenderGroupsLod3MinDistance(float minDistance) {
169  renderGroupsLOD3MinDistance = minDistance;
170  }
171 
172  /**
173  * @return render groups LOD2 reduce by factor
174  */
175  inline static int getRenderGroupsLod2ReduceBy() {
177  }
178 
179  /**
180  * Set render groups LOD2 reduce by factor
181  * @param reduceBy render groups LOD2 reduce by factor
182  */
183  inline static void setRenderGroupsLod2ReduceBy(int reduceBy) {
184  renderGroupsLOD2ReduceBy = reduceBy;
185  }
186 
187  /**
188  * @return render groups LOD3 reduce by factor
189  */
190  inline static int getRenderGroupsLod3ReduceBy() {
192  }
193 
194  /**
195  * Set render groups LOD3 reduce by factor
196  * @param reduceBy render groups LOD3 reduce by factor
197  */
198  inline static void setRenderGroupsLod3ReduceBy(int reduceBy) {
199  renderGroupsLOD3ReduceBy = reduceBy;
200  }
201 
202  /**
203  * Set sun/moon lights
204  * @param engine engine
205  * @param t time, while 0.0 <= t <= 1.0
206  */
207  static void setNaturalLights(Engine* engine, float t = 0.15f);
208 
209  /**
210  * Set lights from scene
211  * @param engine engine
212  * @param scene scene
213  * @param t time, while 0.0 <= t <= 1.0
214  * @param translation translation
215  */
216  static void setLights(Engine* engine, Scene* scene, float t = 0.15f, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
217 
218  /**
219  * Create particle system
220  * @param particleSystem prototype particle system
221  * @param id id
222  * @param enableDynamicShadows enable dynamic shadows
223  * @return engine particle system entity
224  */
225  static Entity* createParticleSystem(PrototypeParticleSystem* particleSystem, const string& id, bool enableDynamicShadows = true);
226 
227  /**
228  * Create engine entity
229  * @param id id
230  * @param transform transform
231  * @return entity
232  */
233  static Entity* createEmpty(const string& id, const Transform& transform);
234 
235  /**
236  * Create editor decal engine entity
237  * @param prototype prototype
238  * @param id id
239  * @param transform transform
240  * @param instances instances which applies only for skinned objects
241  * @return entity
242  */
243  static Entity* createEditorDecalEntity(Prototype* prototype, const string& id, const Transform& transform, int instances = 1);
244 
245  /**
246  * Create engine entity
247  * @param prototype prototype
248  * @param id id
249  * @param transform transform
250  * @param instances instances which applies only for skinned objects
251  * @param noEntityHierarchy do not create a entity hierarchy
252  * @return entity
253  */
254  static Entity* createEntity(Prototype* prototype, const string& id, const Transform& transform, int instances = 1, bool noEntityHierarchy = false);
255 
256  /**
257  * Create editor decal engine entity
258  * @param sceneEntity scene object
259  * @param translation translation
260  * @param instances instances which applies only for skinned objects
261  * @return entity
262  */
263  static Entity* createEditorDecalEntity(SceneEntity* sceneEntity, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), int instances = 1);
264 
265  /**
266  * Create engine entity
267  * @param sceneEntity scene object
268  * @param translation translation
269  * @param instances instances which applies only for skinned objects
270  * @param noEntityHierarchy do not create a entity hierarchy
271  * @return entity
272  */
273  static Entity* createEntity(SceneEntity* sceneEntity, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), int instances = 1, bool noEntityHierarchy = false);
274 
275  /**
276  * Add scene to engine
277  * @param engine engine
278  * @param scene scene
279  * @param addEmpties add empties
280  * @param addTrigger add trigger
281  * @param addEnvironmentMapping add environment mapping
282  * @param useEditorDecals use editor decals
283  * @param pickable pickable
284  * @param enable enable
285  * @param translation translation
286  * @param progressCallback progress callback
287  */
288  static void addScene(Engine* engine, Scene* scene, bool addEmpties, bool addTrigger, bool addEnvironmentMapping, bool useEditorDecals, bool pickable, bool enable = true, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), ProgressCallback* progressCallback = nullptr);
289 
290  /**
291  * Create body
292  * @param world world
293  * @param prototype prototype
294  * @param id id
295  * @param transform transform
296  * @param collisionTypeId collision type id or 0 for default
297  * @param hierarchy hierarchy
298  * @param index use a optional index or all bounding volumes
299  * @param overrideType override physics type if required
300  * @return body
301  */
302  static Body* createBody(World* world, Prototype* prototype, const string& id, const Transform& transform, uint16_t collisionTypeId = BODY_TYPEID_STANDARD, bool hierarchy = false, int index = BOUNDINGVOLUME_INDEX_NONE, PrototypePhysics_BodyType* overrideType = nullptr);
303 
304  /**
305  * Create body
306  * @param world world
307  * @param sceneEntity scene entity
308  * @param translation translation
309  * @param collisionTypeId collision type id or 0 for default
310  * @param hierarchy hierarchy
311  * @param index use a optional index or all bounding volumes
312  * @param overrideType override physics type if required
313  * @return body
314  */
315  static Body* createBody(World* world, SceneEntity* sceneEntity, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), uint16_t collisionTypeId = BODY_TYPEID_STANDARD, bool hierarchy = false, int index = BOUNDINGVOLUME_INDEX_NONE, PrototypePhysics_BodyType* overrideType = nullptr);
316 
317  /**
318  * Create sub body in body hierarchy
319  * @param world world
320  * @param prototype prototype
321  * @param id id
322  * @param transform transform
323  * @param bodyHierarchyId body hierarchy id
324  * @param bodyHierarchyParentId body hierarchy parent id
325  * @return body hierarchy
326  */
327  static BodyHierarchy* createSubBody(World* world, Prototype* prototype, const string& id, const Transform& transform, const string& bodyHierarchyId, const string& bodyHierarchyParentId);
328 
329  /**
330  * Add scene to physics world
331  * @param world world
332  * @param scene scene
333  * @param enable enable
334  * @param translation translation
335  * @param progressCallback progress callback
336  */
337  static void addScene(World* world, Scene* scene, bool enable = true, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), ProgressCallback* progressCallback = nullptr);
338 
339  /**
340  * Disable scene in engine
341  * @param engine engine
342  * @param scene scene
343  */
344  static void disableScene(Engine* engine, Scene* scene);
345 
346  /**
347  * Disable scene in physics world
348  * @param world world
349  * @param scene scene
350  */
351  static void disableScene(World* world, Scene* scene);
352 
353  /**
354  * Enable disabled scene in engine
355  * @param engine engine
356  * @param scene scene
357  * @param translation translation
358  */
359  static void enableScene(Engine* engine, Scene* scene, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
360 
361  /**
362  * Enable disabled scene in physics world
363  * @param world world
364  * @param scene scene
365  * @param translation translation
366  */
367  static void enableScene(World* world, Scene* scene, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
368 
369  /**
370  * Reset engine regarding given scene
371  * @param engine engine
372  * @param scene scene
373  */
374  static void resetEngine(Engine* engine, Scene* scene);
375 
376  /**
377  * Add scene entity sounds into given audio instance associated with given id
378  * @param audio audio instance to load sounds into
379  * @param prototype scene entity
380  * @param id audio entity id
381  * @param poolSize pool size, which is optional if you want to use a pool for each sound
382  */
383  static void addSounds(Audio* audio, Prototype* prototype, const string& id, int poolSize = 1);
384 
385 private:
387 };
Interface to audio module.
Definition: Audio.h:29
Engine main class.
Definition: Engine.h:131
Engine entity.
Definition: Entity.h:30
Scene engine/physics connector.
static float getRenderGroupsPartitionHeight()
static STATIC_DLL_IMPEXT int renderGroupsLODLevels
static float getRenderGroupsPartitionDepth()
static Entity * createEditorDecalEntity(Prototype *prototype, const string &id, const Transform &transform, int instances=1)
Create editor decal engine entity.
static BodyHierarchy * createSubBody(World *world, Prototype *prototype, const string &id, const Transform &transform, const string &bodyHierarchyId, const string &bodyHierarchyParentId)
Create sub body in body hierarchy.
static constexpr uint16_t BODY_TYPEID_DYNAMIC
static void setRenderGroupsPartitionWidth(float renderNodesPartitionWidth)
Set render groups partition size / width.
static Entity * createEmpty(const string &id, const Transform &transform)
Create engine entity.
static void setRenderGroupsLod2MinDistance(float minDistance)
Set render groups LOD2 minumum distance.
static void setRenderGroupsLod2ReduceBy(int reduceBy)
Set render groups LOD2 reduce by factor.
static constexpr int BOUNDINGVOLUME_INDEX_NONE
static STATIC_DLL_IMPEXT int renderGroupsReduceBy
static constexpr uint16_t BODY_TYPEID_TRIGGER
static STATIC_DLL_IMPEXT Model * emptyModel
static STATIC_DLL_IMPEXT float renderGroupsPartitionHeight
static void setRenderGroupsPartitionDepth(float renderNodesPartitionDepth)
Set render groups partition size / depth.
static void enableScene(Engine *engine, Scene *scene, const Vector3 &translation=Vector3(0.0f, 0.0f, 0.0f))
Enable disabled scene in engine.
static constexpr int BODY_TYPEID_STANDARD
static STATIC_DLL_IMPEXT int renderGroupsLOD3ReduceBy
static constexpr uint16_t BODY_TYPEID_COLLISION
static STATIC_DLL_IMPEXT int renderGroupsLOD2ReduceBy
static void setNaturalLights(Engine *engine, float t=0.15f)
Set sun/moon lights.
static int getRenderGroupsLod3ReduceBy()
static void disableScene(Engine *engine, Scene *scene)
Disable scene in engine.
static int getRenderGroupsLod2ReduceBy()
static Entity * createEntity(Prototype *prototype, const string &id, const Transform &transform, int instances=1, bool noEntityHierarchy=false)
Create engine entity.
static constexpr uint16_t BODY_TYPEID_STATIC
static void setRenderGroupsPartitionHeight(float renderNodesPartitionHeight)
Set render groups partition size / height.
static void addScene(Engine *engine, Scene *scene, bool addEmpties, bool addTrigger, bool addEnvironmentMapping, bool useEditorDecals, bool pickable, bool enable=true, const Vector3 &translation=Vector3(0.0f, 0.0f, 0.0f), ProgressCallback *progressCallback=nullptr)
Add scene to engine.
static STATIC_DLL_IMPEXT float renderGroupsPartitionDepth
static Entity * createParticleSystem(PrototypeParticleSystem *particleSystem, const string &id, bool enableDynamicShadows=true)
Create particle system.
static float getRenderGroupsLod3MinDistance()
static void setRenderGroupsLod3MinDistance(float minDistance)
Set render groups LOD3 minumum distance.
static float getRenderGroupsLod2MinDistance()
static float getRenderGroupsPartitionWidth()
static void setRenderGroupsReduceBy(int reduceBy)
Set render groups reduce objects by a given factor.
static void resetEngine(Engine *engine, Scene *scene)
Reset engine regarding given scene.
static void setRenderGroupsLod3ReduceBy(int reduceBy)
Set render groups LOD3 reduce by factor.
static STATIC_DLL_IMPEXT float renderGroupsPartitionWidth
static STATIC_DLL_IMPEXT float renderGroupsLOD3MinDistance
static void setLights(Engine *engine, Scene *scene, float t=0.15f, const Vector3 &translation=Vector3(0.0f, 0.0f, 0.0f))
Set lights from scene.
static STATIC_DLL_IMPEXT float renderGroupsLOD2MinDistance
static Body * createBody(World *world, Prototype *prototype, const string &id, const Transform &transform, uint16_t collisionTypeId=BODY_TYPEID_STANDARD, bool hierarchy=false, int index=BOUNDINGVOLUME_INDEX_NONE, PrototypePhysics_BodyType *overrideType=nullptr)
Create body.
static void addSounds(Audio *audio, Prototype *prototype, const string &id, int poolSize=1)
Add scene entity sounds into given audio instance associated with given id.
static void setRenderGroupsLodLevels(int lodLevels)
Set render groups LOD levels.
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
Representation of a 3D model.
Definition: Model.h:35
Rigid body class.
Definition: Body.h:41
Dynamic physics world class.
Definition: World.h:38
Prototype definition.
Definition: Prototype.h:55
Scene entity definition.
Definition: SceneEntity.h:23
Scene definition.
Definition: Scene.h:50
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
Mutable utf8 aware string class.
Definition: MutableString.h:23
#define STATIC_DLL_IMPEXT
Definition: tdme.h:15