-
Notifications
You must be signed in to change notification settings - Fork 1
/
particle.h
123 lines (92 loc) · 2.18 KB
/
particle.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef PARTICLE_H
#define PARTICLE_H
class ParticleSystem;
class RibbonEmitter;
#include "model.h"
#include "animated.h"
#include <list>
struct Particle {
Vec3D pos, speed, down, origin;
//Vec3D tpos;
float size, life, maxlife;
int tile;
Vec4D color;
};
typedef std::list<Particle> ParticleList;
class ParticleEmitter {
protected:
ParticleSystem *sys;
public:
ParticleEmitter(ParticleSystem *sys): sys(sys) {}
virtual Particle newParticle(int anim, int time) = 0;
};
class PlaneParticleEmitter: public ParticleEmitter {
public:
PlaneParticleEmitter(ParticleSystem *sys): ParticleEmitter(sys) {}
Particle newParticle(int anim, int time);
};
class SphereParticleEmitter: public ParticleEmitter {
public:
SphereParticleEmitter(ParticleSystem *sys): ParticleEmitter(sys) {}
Particle newParticle(int anim, int time);
};
struct TexCoordSet {
Vec2D tc[4];
};
class ParticleSystem {
Animated<float> speed, variation, spread, lat, gravity, lifespan, rate, areal, areaw, grav2;
Vec4D colors[3];
float sizes[3];
float mid, slowdown, rotation;
Vec3D pos;
GLuint texture;
ParticleEmitter *emitter;
ParticleList particles;
int blend,order,type;
int manim,mtime;
int rows, cols;
std::vector<TexCoordSet> tiles;
void initTile(Vec2D *tc, int num);
bool billboard;
float rem;
//bool transform;
// unknown parameters omitted for now ...
Bone *parent;
public:
Model *model;
float tofs;
ParticleSystem(): emitter(0) {};
~ParticleSystem() { delete emitter; }
void init(MPQFile &f, ModelParticleEmitterDef &mta, int *globals);
void update(float dt);
void setup(int anim, int time);
void draw();
friend class PlaneParticleEmitter;
friend class SphereParticleEmitter;
};
struct RibbonSegment {
Vec3D pos, up, back;
float len,len0;
};
class RibbonEmitter {
Animated<Vec3D> color;
AnimatedShort opacity;
Animated<float> above, below;
Bone *parent;
float f1, f2;
Vec3D pos;
int manim, mtime;
float length, seglen;
int numsegs;
Vec3D tpos;
Vec4D tcolor;
float tabove, tbelow;
GLuint texture;
std::list<RibbonSegment> segs;
public:
Model *model;
void init(MPQFile &f, ModelRibbonEmitterDef &mta, int *globals);
void setup(int anim, int time);
void draw();
};
#endif