Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Emitter.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace Engine {
6 
7  class Emitter
8  {
9  public:
10  Emitter();
11  ~Emitter();
12 
14  DELETE_OLDEST = 0,
17  };
18 /*
19  enum class RandomizationType {
20  LINEAR = 0,
21  GAUSSIAN,
22  INVERSE_GAUSSIAN
23  };*/
24 
25  enum class EmitterType {
26  CONTINUOUS = 0,
27  BURST
28  };
29 
30  enum class EmitterShape {
31  SPHERE = 0,
32  SPHERE_OUTLINE,
33  BOX,
34  BOX_OUTLINE,
35  LINE,
36  POINT
37  };
38 
40  CONSTANT = 0,
41  RANDOM
42  };
43 
49  virtual void Compile();
50 
55  virtual void Update(float deltaTime);
56 
61  void SetParticle(eastl::shared_ptr<Particle> particle);
62 
67  eastl::weak_ptr<Particle> GetParticle() const;
68 
73  void SetMaxParticleCount(uint32_t count);
74 
79  uint32_t GetMaxParticleCount() const;
80 
86 
92 
97  void SetEmitterType(EmitterType type);
98 
103  EmitterType GetEmitterType() const;
104 
110  void SetEmitterShape(EmitterShape shape);
111 
117 
124 
130 
137  void SetBurstDuration(float durationMin, float durationMax);
138 
143  eastl::pair<float, float> GetBurstDuration();
144 
151  void SetBurstParticleCount(float particlesMin, float particlesMax);
152 
157  eastl::pair<float, float> GetBurstParticleCount();
158 
163  void SetParticlesPerSecond(float particles);
164 
169  float GetParticlesPerSecond() const;
170 
175  void SetEmitterSphereRadius(float radius);
176 
181  float GetEmitterSphereRadius() const;
182 
187  void SetEmitterSphereCenter(glm::vec3 center);
188 
193  glm::vec3 GetEmitterSphereCenter() const;
194 
200  void SetEmitterBox(glm::vec3 corner1, glm::vec3 corner2);
201 
206  eastl::pair<glm::vec3, glm::vec3> GetEmitterBox();
207 
213  void SetEmitterLine(glm::vec3 start, glm::vec3 end);
214 
219  eastl::pair<glm::vec3, glm::vec3> GetEmitterLine();
220 
225  void SetEmitterPointLocation(glm::vec3 point);
226 
231  glm::vec3 GetEmitterPointLocation() const;
232 
233 
234  protected:
235  eastl::shared_ptr<Particle> particle;
236 
238 
240 
242 
244 
246 
247  bool active;
248 
249  bool compiled;
250 
252 
254 
256 
258 
260 
262 
264 
266 
267  glm::vec3 sphereCenter;
268 
269  glm::vec3 boxCorner1, boxCorner2;
270 
271  glm::vec3 lineStart, lineEnd;
272 
273  glm::vec3 pointLocation;
274 
275  };
276 
277 }
void SetEmitterShape(EmitterShape shape)
Sets the shape of the area the emitter will emit particles in (outline means particles will only be g...
Definition: Emitter.cpp:69
void SetParticlesPerSecond(float particles)
Sets the amount of particles generated by a continuous emitter.
Definition: Emitter.cpp:111
float burstDurationMax
Definition: Emitter.hpp:259
EmitterType GetEmitterType() const
Returns the type of the emitter.
Definition: Emitter.cpp:64
EmitterType emitterType
Definition: Emitter.hpp:241
glm::vec3 GetEmitterPointLocation() const
Returns the location of a point emitter.
Definition: Emitter.cpp:176
eastl::pair< glm::vec3, glm::vec3 > GetEmitterLine()
Returns the start and end of the emitter line.
Definition: Emitter.cpp:166
float GetEmitterSphereRadius() const
Returns the radius of the emitter sphere.
Definition: Emitter.cpp:126
float particlesPerSecond
Definition: Emitter.hpp:251
void SetBurstParticleCount(float particlesMin, float particlesMax)
sets the minimum and maximum amount of particles spawned when the burst is triggered. When activated, a random number will be picked somewhere in between these values.
Definition: Emitter.cpp:100
eastl::pair< float, float > GetBurstParticleCount()
Returns the minimum and maximum amount of particles spawned when the burst is triggered.
Definition: Emitter.cpp:106
uint32_t maxParticleCount
Definition: Emitter.hpp:237
eastl::pair< glm::vec3, glm::vec3 > GetEmitterBox()
Returns the corners of the emitter box.
Definition: Emitter.cpp:155
eastl::weak_ptr< Particle > GetParticle() const
Returns a copy of the particle of the emitter.
Definition: Emitter.cpp:33
virtual void Compile()
Compiles the emitter and associated particle. After this, the particle can&#39;t be changed. Any particle enum values are also no longer changeable. NOTE: This needs to be called before the emitter can be used.
Definition: Emitter.cpp:16
ParticleGenerationStyle particleGenerationStyle
Definition: Emitter.hpp:245
void SetEmitterLine(glm::vec3 start, glm::vec3 end)
Sets the start and end of the emitter line.
Definition: Emitter.cpp:160
EmitterShape GetEmitterShape() const
Returns the shape of emitter.
Definition: Emitter.cpp:74
void SetEmitterSphereCenter(glm::vec3 center)
Sets the center of the emitter sphere.
Definition: Emitter.cpp:131
void SetMaxParticleCount(uint32_t count)
Sets the maximum number of particles this emitter can have alive at the same time.
Definition: Emitter.cpp:38
void SetEmitterBox(glm::vec3 corner1, glm::vec3 corner2)
Sets the corners of the box emitter.
Definition: Emitter.cpp:141
float burstParticlesPerSecond
Definition: Emitter.hpp:257
float burstParticleCountMax
Definition: Emitter.hpp:253
float burstDurationMin
Definition: Emitter.hpp:259
glm::vec3 boxCorner1
Definition: Emitter.hpp:269
glm::vec3 GetEmitterSphereCenter() const
Returns the center of the emitter sphere.
Definition: Emitter.cpp:136
float burstParticles
Definition: Emitter.hpp:255
void SetEmitterPointLocation(glm::vec3 point)
Sets the location of a point emitter.
Definition: Emitter.cpp:171
void SetParticle(eastl::shared_ptr< Particle > particle)
Sets the particle of the emitter.
Definition: Emitter.cpp:27
uint32_t GetMaxParticleCount() const
Returns the maximum number of particles this emitter can have alive at the same time.
Definition: Emitter.cpp:44
eastl::shared_ptr< Particle > particle
Definition: Emitter.hpp:235
glm::vec3 lineStart
Definition: Emitter.hpp:271
EmitterShape emitterShape
Definition: Emitter.hpp:243
void SetBurstDuration(float durationMin, float durationMax)
Sets the minimum and maximum duration a burst can have. When activated, a random duration will be pic...
Definition: Emitter.cpp:89
float burstDuration
Definition: Emitter.hpp:261
float burstActiveTime
Definition: Emitter.hpp:263
void SetMaxParticleCountReachedAction(MaxParticleReachedAction action)
Sets the action that should be used when trying to spawn a new particle while already having the maxi...
Definition: Emitter.cpp:49
eastl::pair< float, float > GetBurstDuration()
Returns the minimum and maximum duration of a burst.
Definition: Emitter.cpp:95
void SetParticleGenerationStyle(ParticleGenerationStyle style)
Sets how the particles are generated. Constant indicates that a new particle is generated every x amo...
Definition: Emitter.cpp:79
float burstParticleCountMin
Definition: Emitter.hpp:253
glm::vec3 lineEnd
Definition: Emitter.hpp:271
void SetEmitterSphereRadius(float radius)
Sets the radius of the emitter sphere.
Definition: Emitter.cpp:121
ParticleGenerationStyle GetParticleGenerationStyle() const
Returns the style in which particles are generated.
Definition: Emitter.cpp:84
glm::vec3 sphereCenter
Definition: Emitter.hpp:267
float sphereRadius
Definition: Emitter.hpp:265
glm::vec3 boxCorner2
Definition: Emitter.hpp:269
MaxParticleReachedAction maxParticleReachedAction
Definition: Emitter.hpp:239
void SetEmitterType(EmitterType type)
Sets the type of the emitter.
Definition: Emitter.cpp:59
MaxParticleReachedAction GetMaxParticleCountReachedAction() const
Returns the action that should be used when trying to spawn a new particle while already having the m...
Definition: Emitter.cpp:54
float GetParticlesPerSecond() const
Returns the amount of particles generated by a continuous emitter.
Definition: Emitter.cpp:116
virtual void Update(float deltaTime)
Update the emitter.
Definition: Emitter.cpp:21
glm::vec3 pointLocation
Definition: Emitter.hpp:273