TDME2 1.9.121
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ObjectParticleSystemInternal.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include <tdme/tdme.h>
20#include <tdme/math/Matrix4x4.h>
21#include <tdme/math/Vector3.h>
23
24using std::string;
25using std::vector;
26
42
43/**
44 * Particle system which displays objects as particles
45 * @author Andreas Drewke
46 * @version $Id$
47 */
49 : public Transformations
50 , public virtual ParticleSystemEntityInternal
51{
52protected:
53 Engine* engine { nullptr };
54 Renderer* renderer { nullptr };
55 string id;
56 bool enabled;
57 Model* model { nullptr };
62 vector<Particle> particles;
63 vector<Object3D*> objects;
64 vector<Object3D*> enabledObjects;
74
75 /**
76 * Update internal
77 */
78 inline void updateInternal() {
83 for (auto object: objects) {
84 object->setScale(scale);
85 object->update();
86 }
89 }
90
91public:
92 /**
93 * Public constructor
94 * @param id id
95 * @param model model
96 * @param scale scale
97 * @param autoEmit auto emit
98 * @param contributesShadows enable contributes shadows
99 * @param receivesShadows enable receives shadows
100 * @param maxCount maxCount
101 * @param emitter emitter
102 */
103 ObjectParticleSystemInternal(const string& id, Model* model, const Vector3& scale, bool autoEmit, bool contributesShadows, bool receivesShadows, int32_t maxCount, ParticleEmitter* emitter);
104
105 /**
106 * Destructor
107 */
109
110 // overridden methods
111 inline ParticleEmitter* getEmitter() override {
112 return emitter;
113 }
114
115 const string& getId() override;
116 void setEngine(Engine* engine);
118 inline bool isEnabled() override {
119 return enabled;
120 }
121 inline bool isActive() override {
122 return enabledObjects.size() > 0;
123 }
124 inline void setEnabled(bool enabled) override {
125 this->enabled = enabled;
126 }
127 inline const Color4& getEffectColorMul() const override {
128 return effectColorMul;
129 }
130 inline void setEffectColorMul(const Color4& effectColorMul) override {
131 this->effectColorMul = effectColorMul;
132 }
133 inline const Color4& getEffectColorAdd() const override {
134 return effectColorAdd;
135 }
136 inline void setEffectColorAdd(const Color4& effectColorAdd) override {
137 this->effectColorAdd = effectColorAdd;
138 }
139 inline bool isPickable() override {
140 return pickable;
141 }
142 inline void setPickable(bool pickable) override {
143 this->pickable = pickable;
144 }
145 inline bool isAutoEmit() override {
146 return autoEmit;
147 }
148 inline void setAutoEmit(bool autoEmit) override {
149 this->autoEmit = autoEmit;
150 }
151
152 /**
153 * @return if entity contributes to shadows
154 */
155 inline bool isContributesShadows() {
156 return contributesShadows;
157 }
158
159 /**
160 * Enable/disable contributes shadows
161 * @param contributesShadows contributes shadows
162 */
164 this->contributesShadows = contributesShadows;
165 for (auto i = 0; i < objects.size(); i++) objects[i]->setContributesShadows(contributesShadows);
166 }
167
168 /**
169 * @return if entity receives shadows
170 */
171 inline bool isReceivesShadows() {
172 return receivesShadows;
173 }
174
175 /**
176 * Enable/disable receives shadows
177 * @param receivesShadows receives shadows
178 */
180 this->receivesShadows = receivesShadows;
181 for (auto i = 0; i < objects.size(); i++) objects[i]->setReceivesShadows(receivesShadows);
182 }
183
184 /**
185 * Update transformations
186 */
187 void update() override;
188 void fromTransformations(const Transformations& transformations) override;
189 int32_t emitParticles() override;
190 void updateParticles() override;
191 void dispose();
192
193 inline const Transformations& getLocalTransformations() override {
195 }
196 inline void setLocalTransformations(const Transformations& transformations) override {
197 this->localTransformations = transformations;
199 }
200
201};
Engine main class.
Definition: Engine.h:122
TDME engine entity.
Definition: Entity.h:31
Object 3D to be used with engine class.
Definition: Object3D.h:60
Transformations which contain scale, rotations and translation.
const Matrix4x4 & getTransformationsMatrix() const
virtual void invert()
Invert this transformations.
const Vector3 & getScale() const
virtual void fromTransformations(const Transformations &transformations)
Set up this transformations from given transformations.
Color 4 definition.
Definition: Color4.h:20
Representation of a 3d model.
Definition: Model.h:32
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:25
void setContributesShadows(bool contributesShadows)
Enable/disable contributes shadows.
const Color4 & getEffectColorAdd() const override
The effect color will be added to fragment color.
void setLocalTransformations(const Transformations &transformations) override
Set local transformations.
void setEffectColorMul(const Color4 &effectColorMul) override
Set the effect color that will be multiplied with fragment color.
void fromTransformations(const Transformations &transformations) override
Set up this transformations from given transformations.
const Color4 & getEffectColorMul() const override
The effect color will be multiplied with fragment color.
ObjectParticleSystemInternal(const string &id, Model *model, const Vector3 &scale, bool autoEmit, bool contributesShadows, bool receivesShadows, int32_t maxCount, ParticleEmitter *emitter)
Public constructor.
int32_t emitParticles() override
Adds particles to this particle entity at given position.
void setReceivesShadows(bool receivesShadows)
Enable/disable receives shadows.
void setEffectColorAdd(const Color4 &effectColorAdd) override
Set the effect color that will be added to fragment color.
4x4 3D Matrix class
Definition: Matrix4x4.h:24
void getScale(Vector3 &scale) const
Get scale.
Definition: Matrix4x4.h:282
3D vector 3 class
Definition: Vector3.h:22
Vector3 & scale(float scale)
Scale this vector.
Definition: Vector3.h:349