Repository navigation
Expand file tree
/
Copy pathParticleSystem.hpp
More file actions
169 lines (119 loc) · 4.09 KB
/
Copy pathParticleSystem.hpp
File metadata and controls
169 lines (119 loc) · 4.09 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* @file ParticleSystem.hpp
* @author Chris Compton <christopher_compton@student.uml.edu>
* @date 2013-02-24
* @brief TODO: Documentation from CC/NVV
* @details TODO: Documentation from CC/NVV
*/
#ifndef __PARTICLESYSTEM_H
#define __PARTICLESYSTEM_H
#include <string>
#include <vector>
#include "mat.hpp"
#include "Object.hpp"
#include "Particle.hpp"
#include "Camera.hpp"
#include "Engine.hpp"
#include "vec.hpp"
#include "TransCache.hpp"
#include "ParticleFieldFunctions.hpp"
#include "UserVectorField.hpp"
using Angel::vec2;
using Angel::vec3;
using Angel::vec4;
using Angel::mat4;
using std::string;
using std::vector;
typedef Particle* ParticleP;
typedef enum { PS_NONE, PS_LINE, PS_CIRCLE, PS_SPHERE, PS_HEMI_D, PS_HEMI_U, PS_CUBE, PS_EXTERNAL } PS_SHAPE;
class ParticleSystem : public Object {
public:
// constructor/destructor
ParticleSystem( int particleAmt, const std::string &name, GLuint shader );
~ParticleSystem( void );
// this will fill the system with newborn particles
void fillSystemWithParticles(void);
// Getters and Setters
float getLifespan( void ) const ;
float getMaxLife( void ) const ;
float getMinLife( void ) const ;
int getNumParticles( void ) const ;
int getNumParticlesActual( void ) const ;
int getNumParticlesVisible( void ) const ;
void setNumParticles( int newNumParticles );
void setSlaughterHeight( float );
void setLifespan( float minLifespan, float maxLifespan );
void setEmitterRadius(float);
virtual void draw( bool doDraw = true );
void setVectorField(vec3 (*vectorFieldFunc)(vec4, Parameters* ) );
void setColorFunc(vec4 (*colorFunc)(float, vec4) );
static float rangeRandom( float min, float max );
// methods to pause/unpause the system
void pauseTheSystem(void);
void unpauseTheSystem(void);
void togglePause(void);
void setPause(bool);
void setEnableTheSystem( bool );
bool getEnableTheSystem( void );
//overrides for Engine functionality
virtual void buffer( GLenum usage = GL_DYNAMIC_DRAW );
virtual void sceneToRaytracer( RayTracer &rt );
virtual void bufferToRaytracer( RayTracer &rt );
//TransCache _emitterTrans ; // this transcache represnts the position of the emitter
PS_SHAPE getEmitterShape(void) const ;
PS_SHAPE getSystemShape(void) const ;
void setEmitterShape(PS_SHAPE);
void setSystemShape(PS_SHAPE);
void setFuncParams(Parameters*);
void setRespawnFlag( bool flag );
Parameters* getFuncParams();
void setNumToAddEachFrame(unsigned);
void switchUVF( UserVectorField *newUVF );
UserVectorField* uvf();
private:
/* private methods*/
/* The Do-All function. Will do everything needed in order
to have the particles behave according to our specification
on each call to Draw(). That's the idea, anyway. */
void update();
void updateNumParticles( int );
float generateLifespan();
vec4 getSpawnPos(PS_SHAPE);
vec4 getRandomCircularSpawnPoint(void);
vec4 getRandomCubeSpawnPoint(void);
vec4 getRandomSphericalSpawnPoint(void);
vec4 getRandomHemisphericalSpawnPoint(void);
vec4 getRandomLinearSpawnPoint(void);
vec4 getRandomSphericalSpawnPointHelper(float);
void respawnParticle(Particle &p);
Particle *newRandomParticle(void);
void addParticle(void);
void addSomeParticles( int );
void addOneParticleAtOrigin( void );
void removeParticle( void );
/* member variables */
/* particle control variables */
vector<ParticleP> _particles;
unsigned _numParticles;
float _minLife;
float _maxLife;
/* system control variables */
bool _pauseTheSystem;
bool _enableTheSystem;
float _slaughterHeight;
unsigned _fillSpeedLimit;
/* emitter control */
float _emitterRadius;
PS_SHAPE _emitterShape ;
PS_SHAPE _systemShape ;
public:
TransCache _emitterLoc ;
private:
Parameters* _funcParams;
UserVectorField* _uvf;
Angel::vec3 (*_vecFieldFunc)(Angel::vec4 posIn, Parameters* functionParams);
Angel::vec4 (*_colorFunc)(float lifePct, Angel::vec4 posIn);
unsigned _numToAddEachFrame;
int _cachedVisibleCount;
};
#endif