-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaterFall.cpp
More file actions
50 lines (48 loc) · 2.44 KB
/
Copy pathWaterFall.cpp
File metadata and controls
50 lines (48 loc) · 2.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
43
44
45
46
47
48
49
//--------------------------------------------------------------------------------------------------------------------
/// @file WaterFall.h
/// @brief This makes a waterfall emitter,
/// updates only when it is alive and checks if it touches the ground if it does it will make splatter effect
/// if the particld is dead it will reset it values to a "water particle"
//--------------------------------------------------------------------------------------------------------------------
#include "WaterFall.h"
Waterfall::Waterfall(int _numberOfParticles, glm::vec3 _position) : Emitter(_numberOfParticles, _position)
{
for(int i=0; i<m_numberOfParticles; ++i)
{
m_listOfParticles.push_back(Particle());
}
m_numberOfParticles = _numberOfParticles;
m_positionEmitter = _position;
}
//--------------------------------------------------------------------------------------------------------------------
void Waterfall::update(float _deltaTime)
{
for(int i=0; i<m_numberOfParticles; ++i)
{
if(m_listOfParticles[i].isDead()==0)
{
m_listOfParticles[i].update(_deltaTime);
// if the particle hits the ground make splash effect
if(m_listOfParticles[i].getYPosition()<-99)
{
m_listOfParticles[i].setVelocity((glm::vec3((float)rand()/(float)RAND_MAX*3.0f-1.5f,(float)rand()/(float)RAND_MAX*3.0+1.5f,(float)rand()/(float)RAND_MAX*3.0f-1.5f)));
}
}
else
{
// reset the values to the default waterfall particle
m_listOfParticles[i].setPosition(glm::vec3((float)rand()/(float)RAND_MAX*50.0f-25.0f,(float)rand()/(float)RAND_MAX*50-10.0f,(float)rand()/(float)RAND_MAX*25.0f-10.0f)+m_positionEmitter);
m_listOfParticles[i].setAcceleration(glm::vec3(0,-0.6,0));
m_listOfParticles[i].setVelocity(glm::vec3(0,-((float)rand()/(float)RAND_MAX*2.0f+1.0f),0));
m_listOfParticles[i].setColour(glm::vec3(0,0.35,1));
m_listOfParticles[i].setDeltaColour(glm::vec3(-0.02,-0.02,0));
m_listOfParticles[i].setSize((float)rand()/(float)RAND_MAX*2.0f+1.0f);
m_listOfParticles[i].setDeltaSize(0.002);
m_listOfParticles[i].setLifeSpan(0);
m_listOfParticles[i].setDeltaLifeSpan(0.02);
m_listOfParticles[i].setLifeLimit(2);
m_listOfParticles[i].setTransparency(2);
m_listOfParticles[i].setDeltaTransparency(0.05);
}
}
}