-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmitter.cpp
More file actions
42 lines (40 loc) · 1.44 KB
/
Copy pathEmitter.cpp
File metadata and controls
42 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//--------------------------------------------------------------------------------------------------------------------
/// @file Emitter.h
/// @brief Creates the constructor, the update, draw, run and applyforce function.
//--------------------------------------------------------------------------------------------------------------------
#include "Emitter.h"
Emitter::Emitter(int _numberOfParticles, glm::vec3 _positionE)
{
for(int i=0; i<_numberOfParticles; ++i)
{
m_listOfParticles.push_back(Particle());
}
m_numberOfParticles = _numberOfParticles;
m_positionEmitter = _positionE;
}
//--------------------------------------------------------------------------------------------------------------------
void Emitter::draw()
{
for(int i=0; i<m_numberOfParticles; ++i)
{
// only draw if the particle is alive
if(m_listOfParticles[i].isDead() == 0)
{
m_listOfParticles[i].draw();
}
}
}
//--------------------------------------------------------------------------------------------------------------------
void Emitter::run(float _deltaTime)
{
update(_deltaTime);
draw();
}
//--------------------------------------------------------------------------------------------------------------------
void Emitter::applyWind()
{
for(int i=0; i<m_numberOfParticles; ++i)
{
m_listOfParticles[i].setAcceleration(glm::vec3(0,0,(float)rand()/(float)RAND_MAX*0.005));
}
}