Showing the changes to interface/src/ParticleSystem.h (1 of 4 files). Show all
Unified · Split
| @@ -11,11 +11,18 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <glm/gtc/quaternion.hpp> |
| 12 | 12 | |
| 13 | 13 | const int MAX_PARTICLES = 5000; |
| 14 | −const int MAX_EMITTERS = 20; | |
| 15 | −const int NUM_PARTICLE_LIFE_STAGES = 4; | |
| 16 | −const bool USE_BILLBOARD_RENDERING = false; | |
| 14 | +const int MAX_EMITTERS = 1000; | |
| 15 | +const int NUM_PARTICLE_LIFE_STAGES = 4; // each equal time-division of the particle's life can have different attributes | |
| 17 | 16 | const bool SHOW_VELOCITY_TAILS = false; |
| 18 | 17 | |
| 18 | +enum ParticleRenderStyle | |
| 19 | +{ | |
| 20 | + PARTICLE_RENDER_STYLE_SPHERE = 0, | |
| 21 | + PARTICLE_RENDER_STYLE_BILLBOARD, | |
| 22 | + PARTICLE_RENDER_STYLE_RIBBON, | |
| 23 | + NUM_PARTICLE_RENDER_STYLES | |
| 24 | +}; | |
| 25 | + | |
| 19 | 26 | class ParticleSystem { |
| 20 | 27 | public: |
| 21 | 28 | |
| @@ -45,42 +52,44 @@ public: · 23 unmodified lines | ||
| 45 | 52 | void render(); |
| 46 | 53 | |
| 47 | 54 | void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up |
| 48 | − void setShowingEmitterBaseParticle(int emitterIndex, bool showing ); | |
| 49 | 55 | void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles |
| 50 | 56 | void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); // set attributes for this life stage of particles |
| 51 | − void setEmitterBaseParticleColor (int emitterIndex, glm::vec4 color ) {_emitter[emitterIndex].baseParticle.color = color; } | |
| 52 | − void setEmitterBaseParticleRadius (int emitterIndex, float radius ) {_emitter[emitterIndex].baseParticle.radius = radius; } | |
| 53 | − void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } | |
| 54 | − void setEmitterParticleResolution (int emitterIndex, int resolution) {_emitter[emitterIndex].particleResolution = resolution; } | |
| 55 | − void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; } | |
| 56 | − void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; } | |
| 57 | − void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; } | |
| 58 | − void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; } | |
| 59 | − void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; } | |
| 60 | − | |
| 57 | + void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } | |
| 58 | + void setEmitterParticleResolution (int emitterIndex, int resolution ) {_emitter[emitterIndex].particleResolution = resolution; } | |
| 59 | + void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; } | |
| 60 | + void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; } | |
| 61 | + void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; } | |
| 62 | + void setParticleRenderStyle (int emitterIndex, ParticleRenderStyle renderStyle ) {_emitter[emitterIndex].particleRenderStyle = renderStyle; } | |
| 63 | + void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; } | |
| 64 | + void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; } | |
| 65 | + void setShowingEmitterBaseParticle(int emitterIndex, bool showing ) {_emitter[emitterIndex].showingBaseParticle = showing; } | |
| 66 | + | |
| 61 | 67 | private: |
| 62 | 68 | |
| 63 | 69 | struct Particle { |
| 64 | − bool alive; // is the particle active? | |
| 65 | − glm::vec3 position; // position | |
| 66 | − glm::vec3 velocity; // velocity | |
| 67 | − glm::vec4 color; // color (rgba) | |
| 68 | − float age; // age in seconds | |
| 69 | − float radius; // radius | |
| 70 | − int emitterIndex; // which emitter created this particle? | |
| 70 | + bool alive; // is the particle active? | |
| 71 | + glm::vec3 position; // position | |
| 72 | + glm::vec3 velocity; // velocity | |
| 73 | + glm::vec4 color; // color (rgba) | |
| 74 | + float age; // age in seconds | |
| 75 | + float radius; // radius | |
| 76 | + int emitterIndex; // which emitter created this particle? | |
| 77 | + int previousParticle; // the last particle that this particle's emitter emitted; | |
| 71 | 78 | }; |
| 72 | 79 | |
| 73 | 80 | struct Emitter { |
| 74 | − glm::vec3 position; // teh position of the emitter in world coordinates | |
| 75 | − glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects | |
| 76 | − bool visible; // whether or not a line is shown indicating the emitter (indicating its direction) | |
| 77 | − float particleLifespan; // how long the particle shall live, in seconds | |
| 78 | − int particleResolution; // for sphere-based particles | |
| 79 | − float thrust; // the initial velocity upon emitting along the emitter direction | |
| 80 | − float rate; // currently, how many particles emitted during a simulation time step | |
| 81 | − Particle baseParticle; // a non-physical particle at the emitter position | |
| 81 | + glm::vec3 position; // the position of the emitter in world coordinates | |
| 82 | + glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects | |
| 83 | + bool visible; // whether or not a line is shown indicating the emitter (indicating its direction) | |
| 84 | + float particleLifespan; // how long the particle shall live, in seconds | |
| 85 | + int particleResolution; // for sphere-based particles | |
| 86 | + float thrust; // the initial velocity upon emitting along the emitter direction | |
| 87 | + float rate; // currently, how many particles emitted during a simulation time step | |
| 88 | + bool showingBaseParticle; // if true, a copy of particle 0 is shown on the emitter position | |
| 89 | + int currentParticle; // the index of the most recently-emitted particle | |
| 82 | 90 | ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter |
| 83 | − }; | |
| 91 | + ParticleRenderStyle particleRenderStyle; | |
| 92 | + }; | |
| 84 | 93 | |
| 85 | 94 | glm::vec3 _upDirection; |
| 86 | 95 | Emitter _emitter[MAX_EMITTERS]; |