TDME2  1.9.200
FogParticleSystem.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
8 #include <tdme/engine/Engine.h>
10 #include <tdme/engine/Transform.h>
11 
12 using std::string;
13 
20 
21 FogParticleSystem::FogParticleSystem(const string& id, ParticleEmitter* emitter, int32_t maxPoints, float pointSize, Texture* texture, int32_t textureHorizontalSprites, int32_t textureVerticalSprites, float fps):
22  FogParticleSystemInternal(id, emitter, maxPoints, pointSize, texture, textureHorizontalSprites, textureVerticalSprites, fps)
23 {
24 }
25 
27 {
28  FogParticleSystemInternal::initialize();
29 }
30 
32 {
33  FogParticleSystemInternal::setTransform(transform);
34  if (parentEntity == nullptr && frustumCulling == true && engine != nullptr && enabled == true) engine->partition->updateEntity(this);
35 }
36 
38 {
39  FogParticleSystemInternal::update();
40  if (parentEntity == nullptr && frustumCulling == true && engine != nullptr && enabled == true) engine->partition->updateEntity(this);
41 }
42 
44 {
45  // return if enable state has not changed
46  if (this->enabled == enabled) return;
47  // frustum if root entity
48  if (parentEntity == nullptr) {
49  // frustum culling enabled?
50  if (frustumCulling == true) {
51  // yeo, add or remove from partition
52  if (enabled == true) {
53  if (engine != nullptr) engine->partition->addEntity(this);
54  } else {
55  if (engine != nullptr) engine->partition->removeEntity(this);
56  }
57  }
58  }
59  // call parent class::setEnabled()
60  FogParticleSystemInternal::setEnabled(enabled);
61 }
62 
64 {
65  FogParticleSystemInternal::updateParticles();
66  if (parentEntity == nullptr && frustumCulling == true && engine != nullptr && enabled == true) engine->partition->updateEntity(this);
67 }
68 
70  return frustumCulling;
71 }
72 
73 void FogParticleSystem::setFrustumCulling(bool frustumCulling) {
74  // check if enabled and engine attached
75  if (enabled == true && engine != nullptr) {
76  // had frustum culling
77  if (this->frustumCulling == true) {
78  // yep, remove if set to false now
79  if (frustumCulling == false) engine->partition->removeEntity(this);
80  } else {
81  // yep, add if set to true now
82  if (frustumCulling == true) engine->partition->addEntity(this);
83  }
84  }
85  this->frustumCulling = frustumCulling;
86  // delegate change to engine
87  if (engine != nullptr) engine->updateEntityRegistration(this);
88 }
89 
90 void FogParticleSystem::setAutoEmit(bool autoEmit) {
91  if (this->isAutoEmit() == autoEmit) return;
92  // delegate to base class
93  FogParticleSystemInternal::setAutoEmit(autoEmit);
94  // delegate change to engine
95  if (engine != nullptr) engine->updateEntityRegistration(this);
96 }
97 
99 {
100  FogParticleSystemInternal::dispose();
101 }
102 
104 {
105  if (this->engine != nullptr) this->engine->deregisterEntity(this);
106  this->engine = engine;
107  if (engine != nullptr) engine->registerEntity(this);
108  FogParticleSystemInternal::setEngine(engine);
109 }
110 
112 {
113  FogParticleSystemInternal::setRenderer(renderer);
114 }
115 
Engine main class.
Definition: Engine.h:131
unique_ptr< Partition > partition
Definition: Engine.h:289
void updateEntityRegistration(Entity *entity)
Updates registration of engine by performing deregisterEntity() and registerEntity()
Definition: Engine.h:1489
void deregisterEntity(Entity *entity)
Removes a entity from internal lists, those entities can also be sub entities from entity hierarchy o...
Definition: Engine.cpp:382
void registerEntity(Entity *entity)
Adds a entity to internal lists, those entities can also be sub entities from entity hierarchy or par...
Definition: Engine.cpp:437
Entity * parentEntity
Definition: Entity.h:39
Fog particle system entity to be used with engine class.
void updateParticles() override
Updates the particle entity.
void dispose() override
Dispose this entity.
void initialize() override
Initiates this entity.
void update() override
Update transform.
void setTransform(const Transform &transform) override
Set transform.
void setFrustumCulling(bool frustumCulling) override
Set frustum culling.
void setAutoEmit(bool autoEmit) override
Set auto emit.
void setEngine(Engine *engine) override
Set up engine.
void setEnabled(bool enabled) override
Enable/disable rendering.
void setRenderer(Renderer *renderer) override
Set up renderer.
Texture entity.
Definition: Texture.h:24
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
Partition interface.
Definition: Partition.h:18