-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleSystem.h
More file actions
65 lines (50 loc) · 1.32 KB
/
ParticleSystem.h
File metadata and controls
65 lines (50 loc) · 1.32 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include "objects.h"
#include <vector>
class Particle :
public Object
{
public:
Particle(GameEngine *engine, GLuint texture, GLfloat lifetime);
const char* getType();
bool isAlive();
GLuint getTexture() { return m_texture; }
GLdouble* getStartColor() { return m_startColor; }
GLdouble* getEndColor() { return m_endColor; }
GLfloat getElapsedPerc() { return m_elapsed / m_lifetime; }
bool collides() {return false;}
void onPrepare(GLfloat dt);
~Particle();
private:
GLuint m_texture;
GLdouble m_startColor[4];
GLdouble m_endColor[4];
GLfloat m_lifetime;
GLfloat m_elapsed;
};
class Emitter :
public Object
{
public:
Emitter(GameEngine *engine,
int maxParticles,
GLfloat lifetimeMean,
GLfloat lifetimeSpread,
GLfloat velocitySpread,
const char* textureFilename);
const char* getType();
GLfloat getRandomValue(GLfloat mean, GLfloat spread);
void generateParticles();
void onPrepare(GLfloat dt);
void onRender();
~Emitter(void);
private:
std::vector<Particle*> m_particles;
std::vector<GLfloat> m_lerpValues;
int m_maxParticles;
GLfloat m_lifetimeMean;
GLfloat m_lifetimeSpread;
GLfloat m_velocitySpread;
GLuint m_texture, m_vertexBuffer, m_colorBufferA, m_colorBufferB, m_lerpValueBuffer;
bool m_firstRun;
};