History

adding rave glove modes and changing API of particle system to accommodate

Jeffrey Ventrella committed 13 years ago

Commit 05039b41 parent ed278005 files · +203 −65Browse files

Showing the changes to interface/src/ParticleSystem.cpp (1 of 5 files). Show all

Unified · Split

interface/src/ParticleSystem.cpp+11−9
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 const float DEFAULT_PARTICLE_RADIUS = 0.01f;
1515 const float DEFAULT_PARTICLE_BOUNCE = 1.0f;
1616 const float DEFAULT_PARTICLE_AIR_FRICTION = 2.0f;
17+const float DEFAULT_PARTICLE_LIFESPAN = 1.0f;
1718
1819 ParticleSystem::ParticleSystem() {
1920
@@ -26,6 +27,7 @@ ParticleSystem::ParticleSystem() { · 6 unmodified lines
2627 _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f);
2728 _emitter[emitterIndex].direction = glm::vec3(0.0f, 1.0f, 0.0f);
2829 _emitter[emitterIndex].visible = false;
30+ _emitter[emitterIndex].particleLifespan = DEFAULT_PARTICLE_LIFESPAN;
2931 _emitter[emitterIndex].baseParticle.alive = false;
3032 _emitter[emitterIndex].baseParticle.age = 0.0f;
3133 _emitter[emitterIndex].baseParticle.lifespan = 0.0f;
@@ -91,23 +93,23 @@ void ParticleSystem::simulate(float deltaTime) { · 59 unmodified lines
9193 }
9294 }
9395
94−void ParticleSystem::emitParticlesNow(int e, int num, float thrust, float lifespan) {
96+void ParticleSystem::emitParticlesNow(int e, int num, float thrust) {
9597
9698 for (unsigned int p = 0; p < num; p++) {
97− createParticle(e, _emitter[e].direction * thrust, lifespan);
99+ createParticle(e, _emitter[e].direction * thrust);
98100 }
99101 }
100102
101−void ParticleSystem::createParticle(int e, glm::vec3 velocity, float lifespan) {
103+void ParticleSystem::createParticle(int e, glm::vec3 velocity) {
102104
103105 for (unsigned int p = 0; p < MAX_PARTICLES; p++) {
104106 if (!_particle[p].alive) {
105107
106108 _particle[p].emitterIndex = e;
107− _particle[p].lifespan = lifespan;
108109 _particle[p].alive = true;
109110 _particle[p].age = 0.0f;
110111 _particle[p].velocity = velocity;
112+ _particle[p].lifespan = _emitter[e].particleLifespan;
111113 _particle[p].position = _emitter[e].position;
112114 _particle[p].radius = _emitter[e].particleAttributes[0].radius;
113115 _particle[p].color = _emitter[e].particleAttributes[0].color;
@@ -261,15 +263,15 @@ void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) { · 147 unmodified lines
261263 _emitter[emitterIndex].baseParticle.emitterIndex = emitterIndex;
262264 }
263265
264−void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color ) {
266+void ParticleSystem::killAllParticles() {
265267
266− _emitter[emitterIndex].baseParticle.alive = true;
267− _emitter[emitterIndex].baseParticle.emitterIndex = emitterIndex;
268− _emitter[emitterIndex].baseParticle.radius = radius;
269− _emitter[emitterIndex].baseParticle.color = color;
268+ for (unsigned int p = 0; p < _numParticles; p++) {
269+ killParticle(p);
270+ }
270271 }
271272
272273
274+
273275 void ParticleSystem::render() {
274276
275277 // render the emitters