Showing the changes to interface/src/ParticleSystem.h (1 of 5 files). Show all
Unified · Split
| @@ -11,10 +11,10 @@ · 10 unmodified lines | |||
| 11 | #include <glm/gtc/quaternion.hpp> | 11 | #include <glm/gtc/quaternion.hpp> |
| 12 | 12 | ||
| 13 | const int MAX_PARTICLES = 5000; | 13 | const int MAX_PARTICLES = 5000; |
| 14 | const int MAX_EMITTERS = 20; | 14 | const int MAX_EMITTERS = 20; |
| 15 | const int NUM_PARTICLE_LIFE_STAGES = 4; | 15 | const int NUM_PARTICLE_LIFE_STAGES = 4; |
| 16 | const bool USE_BILLBOARD_RENDERING = false; | 16 | const bool USE_BILLBOARD_RENDERING = false; |
| 17 | const bool SHOW_VELOCITY_TAILS = false; | 17 | const bool SHOW_VELOCITY_TAILS = false; |
| 18 | 18 | ||
| 19 | class ParticleSystem { | 19 | class ParticleSystem { |
| 20 | public: | 20 | public: |
| @@ -38,18 +38,21 @@ public: · 17 unmodified lines | |||
| 38 | ParticleSystem(); | 38 | ParticleSystem(); |
| 39 | 39 | ||
| 40 | int addEmitter(); // add (create new) emitter and get its unique id | 40 | int addEmitter(); // add (create new) emitter and get its unique id |
| 41 | void emitParticlesNow(int emitterIndex, int numParticles, float thrust, float lifespan); | 41 | void emitParticlesNow(int emitterIndex, int numParticles, float thrust); |
| 42 | void simulate(float deltaTime); | 42 | void simulate(float deltaTime); |
| 43 | void killAllParticles(); | ||
| 43 | void render(); | 44 | void render(); |
| 44 | 45 | ||
| 45 | void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up | 46 | void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up |
| 46 | void setEmitterBaseParticle(int emitterIndex, bool showing ); | 47 | void setEmitterBaseParticle (int emitterIndex, bool showing ); |
| 47 | void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color ); | 48 | void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles |
| 48 | void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); | 49 | void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); // set attributes for this life stage of particles |
| 49 | void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); | 50 | void setEmitterBaseParticleColor (int emitterIndex, glm::vec4 color ) {_emitter[emitterIndex].baseParticle.color = color; } |
| 50 | void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter | 51 | void setEmitterBaseParticleRadius(int emitterIndex, float radius ) {_emitter[emitterIndex].baseParticle.radius = radius; } |
| 51 | void setEmitterDirection (int emitterIndex, glm::vec3 direction) { _emitter[emitterIndex].direction = direction; } // set directional axis (normal) | 52 | void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } |
| 52 | void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity | 53 | void setEmitterDirection (int emitterIndex, glm::vec3 direction) {_emitter[emitterIndex].direction = direction; } |
| 54 | void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; } | ||
| 55 | void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; } | ||
| 53 | 56 | ||
| 54 | private: | 57 | private: |
| 55 | 58 | ||
| @@ -68,6 +71,7 @@ private: · 12 unmodified lines | |||
| 68 | glm::vec3 position; | 71 | glm::vec3 position; |
| 69 | glm::vec3 direction; | 72 | glm::vec3 direction; |
| 70 | bool visible; | 73 | bool visible; |
| 74 | float particleLifespan; | ||
| 71 | Particle baseParticle; // a non-physical particle at the emitter position | 75 | Particle baseParticle; // a non-physical particle at the emitter position |
| 72 | ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter | 76 | ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter |
| 73 | }; | 77 | }; |
| @@ -80,7 +84,7 @@ private: · 6 unmodified lines | |||
| 80 | 84 | ||
| 81 | // private methods | 85 | // private methods |
| 82 | void updateParticle(int index, float deltaTime); | 86 | void updateParticle(int index, float deltaTime); |
| 83 | void createParticle(int e, glm::vec3 velocity, float lifespan); | 87 | void createParticle(int e, glm::vec3 velocity); |
| 84 | void killParticle(int p); | 88 | void killParticle(int p); |
| 85 | void renderEmitter(int emitterIndex, float size); | 89 | void renderEmitter(int emitterIndex, float size); |
| 86 | void renderParticle(int p); | 90 | void renderParticle(int p); |