Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Emitter.cpp
Go to the documentation of this file.
2 
3 namespace Engine {
4 
6  {
7  compiled = false;
8  active = false;
9  }
10 
11 
13  {
14  }
15 
17  {
18  compiled = true;
19  }
20 
21  void Emitter::Update(float deltaTime)
22  {
23  if (!compiled)
24  return;
25  }
26 
27  void Emitter::SetParticle(eastl::shared_ptr<Particle> particle)
28  {
29  if (!compiled)
30  particle = particle;
31  }
32 
33  eastl::weak_ptr<Particle> Emitter::GetParticle() const
34  {
35  return particle;
36  }
37 
38  void Emitter::SetMaxParticleCount(uint32_t count)
39  {
40  if (!compiled)
41  maxParticleCount = count;
42  }
43 
45  {
46  return maxParticleCount;
47  }
48 
50  {
51  maxParticleReachedAction = action;
52  }
53 
55  {
57  }
58 
60  {
61  emitterType = type;
62  }
63 
65  {
66  return emitterType;
67  }
68 
70  {
71  emitterShape = shape;
72  }
73 
75  {
76  return emitterShape;
77  }
78 
80  {
82  }
83 
85  {
87  }
88 
89  void Emitter::SetBurstDuration(float durationMin, float durationMax)
90  {
91  burstDurationMin = durationMin;
92  burstDurationMax = durationMax;
93  }
94 
95  eastl::pair<float, float> Emitter::GetBurstDuration()
96  {
97  return eastl::pair<float, float>(burstDurationMin, burstDurationMax);
98  }
99 
100  void Emitter::SetBurstParticleCount(float particlesMin, float particlesMax)
101  {
102  burstParticleCountMin = particlesMin;
103  burstParticleCountMax = particlesMax;
104  }
105 
106  eastl::pair<float, float> Emitter::GetBurstParticleCount()
107  {
108  return eastl::pair<float, float>(burstParticleCountMin, burstParticleCountMax);
109  }
110 
111  void Emitter::SetParticlesPerSecond(float particles)
112  {
113  particlesPerSecond = particles;
114  }
115 
117  {
118  return particlesPerSecond;
119  }
120 
122  {
123  sphereRadius = radius;
124  }
125 
127  {
128  return sphereRadius;
129  }
130 
131  void Emitter::SetEmitterSphereCenter(glm::vec3 center)
132  {
133  sphereCenter = center;
134  }
135 
137  {
138  return sphereCenter;
139  }
140 
141  void Emitter::SetEmitterBox(glm::vec3 corner1, glm::vec3 corner2)
142  {
143  boxCorner1.x = corner1.x <= corner2.x ? corner1.x : corner2.x;
144  boxCorner2.x = corner1.x > corner2.x ? corner1.x : corner2.x;
145 
146  boxCorner1.y = corner1.y <= corner2.y ? corner1.y : corner2.y;
147  boxCorner2.y = corner1.y > corner2.y ? corner1.y : corner2.y;
148 
149  boxCorner1.z = corner1.z <= corner2.z ? corner1.z : corner2.z;
150  boxCorner2.z = corner1.z > corner2.z ? corner1.z : corner2.z;
151 
152 
153  }
154 
155  eastl::pair<glm::vec3, glm::vec3> Emitter::GetEmitterBox()
156  {
157  return eastl::pair<glm::vec3, glm::vec3>(boxCorner1, boxCorner2);
158  }
159 
160  void Emitter::SetEmitterLine(glm::vec3 start, glm::vec3 end)
161  {
162  lineStart = start;
163  lineEnd = end;
164  }
165 
166  eastl::pair<glm::vec3, glm::vec3> Emitter::GetEmitterLine()
167  {
168  return eastl::pair<glm::vec3, glm::vec3>(lineStart, lineEnd);
169  }
170 
171  void Emitter::SetEmitterPointLocation(glm::vec3 point)
172  {
173  pointLocation = point;
174  }
175 
177  {
178  return pointLocation;
179  }
180 
181 }
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
eastl::pair< glm::vec3, glm::vec3 > GetEmitterBox()
Returns the corners of the emitter box.
Definition: Emitter.cpp:155
uint32_t maxParticleCount
Definition: Emitter.hpp:237
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 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
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
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