forked from graphitemaster/neothyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
r_particles.h
71 lines (56 loc) · 1.27 KB
/
r_particles.h
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
66
67
68
69
70
71
#ifndef R_PARTICLES_HDR
#define R_PARTICLES_HDR
#include "r_geom.h"
#include "r_method.h"
#include "r_texture.h"
#include "m_vec.h"
namespace m {
struct mat4;
}
namespace r {
struct pipeline;
struct particle {
m::vec3 origin;
m::vec3 velocity;
float size;
float startSize;
m::vec3 color;
float alpha;
float startAlpha;
float lifeTime;
float totalLifeTime;
bool respawn;
};
struct particleSystemMethod : method {
particleSystemMethod();
bool init();
void setVP(const m::mat4 &vp);
void setColorTextureUnit(int unit);
private:
GLint m_VPLocation;
GLint m_colorTextureUnitLocation;
};
struct particleSystem : geom {
particleSystem();
virtual ~particleSystem();
bool load(const u::string &file);
bool upload();
void render(const pipeline &p);
virtual void update(const pipeline &p);
void addParticle(particle &&p);
protected:
virtual void initParticle(particle &p, const m::vec3 &ownerPosition) = 0;
virtual float getGravity() { return 25.0f; };
u::vector<particle> m_particles;
private:
struct vertex {
m::vec3 p;
float u, v;
float r, g, b, a;
};
u::vector<vertex> m_vertices;
particleSystemMethod m_method;
texture2D m_texture;
};
}
#endif