-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParticleSystem.h
55 lines (46 loc) · 1.14 KB
/
ParticleSystem.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
#pragma once
// Kevin M. Smith - CS 134 SJSU
#include "ofMain.h"
#include "Particle.h"
// Pure Virtual Function Class - must be subclassed to create new forces.
//
class ParticleForce {
protected:
public:
bool applyOnce = false;
bool applied = false;
virtual void updateForce(Particle *) = 0;
};
class ParticleSystem {
public:
void add(const Particle &);
void addForce(ParticleForce *);
void remove(int);
void update();
void setLifespan(float);
void reset();
int removeNear(const ofVec3f & point, float dist);
void draw();
vector<Particle> particles;
vector<ParticleForce *> forces;
};
// Some convenient built-in forces
//
class GravityForce: public ParticleForce {
ofVec3f gravity;
public:
GravityForce(const ofVec3f & gravity);
void updateForce(Particle *);
};
class TurbulenceForce : public ParticleForce {
ofVec3f tmin, tmax;
public:
TurbulenceForce(const ofVec3f & min, const ofVec3f &max);
void updateForce(Particle *);
};
class ImpulseRadialForce : public ParticleForce {
float magnitude;
public:
ImpulseRadialForce(float magnitude);
void updateForce(Particle *);
};