Showing the changes to interface/src/ParticleSystem.h (1 of 3 files). Show all
Unified · Split
| @@ -10,31 +10,32 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #include <glm/gtc/quaternion.hpp> |
| 12 | 12 | |
| 13 | −const int MAX_PARTICLES = 5000; | |
| 14 | −const int MAX_EMITTERS = 20; | |
| 13 | +const int MAX_PARTICLES = 5000; | |
| 14 | +const int MAX_EMITTERS = 20; | |
| 15 | 15 | const int NUM_PARTICLE_LIFE_STAGES = 4; |
| 16 | −const bool USE_BILLBOARD_RENDERING = false; | |
| 17 | −const bool SHOW_VELOCITY_TAILS = false; | |
| 16 | +const bool USE_BILLBOARD_RENDERING = false; | |
| 17 | +const bool SHOW_VELOCITY_TAILS = false; | |
| 18 | 18 | |
| 19 | 19 | class ParticleSystem { |
| 20 | 20 | public: |
| 21 | 21 | |
| 22 | 22 | struct ParticleAttributes { |
| 23 | − float radius; | |
| 24 | − glm::vec4 color; | |
| 25 | − float bounce; | |
| 26 | − float gravity; | |
| 27 | − float airFriction; | |
| 28 | − float jitter; | |
| 29 | − float emitterAttraction; | |
| 30 | − float tornadoForce; | |
| 31 | − float neighborAttraction; | |
| 32 | − float neighborRepulsion; | |
| 33 | − bool usingCollisionSphere; | |
| 34 | − glm::vec3 collisionSpherePosition; | |
| 35 | − float collisionSphereRadius; | |
| 23 | + float radius; // radius of the particle | |
| 24 | + glm::vec4 color; // color (rgba) of the particle | |
| 25 | + float bounce; // how much reflection when the particle collides with floor/ground | |
| 26 | + float gravity; // force opposite of up direction | |
| 27 | + float airFriction; // continual dampening of velocity | |
| 28 | + float jitter; // random forces on velocity | |
| 29 | + float emitterAttraction; // an attraction to the emitter position | |
| 30 | + float tornadoForce; // force perpendicular to direction axis | |
| 31 | + float neighborAttraction; // causes particle to be pulled towards next particle in list | |
| 32 | + float neighborRepulsion; // causes particle to be repelled by previous particle in list | |
| 33 | + bool usingCollisionSphere; // set to true to allow collision with a sphere | |
| 34 | + glm::vec3 collisionSpherePosition; // position of the collision sphere | |
| 35 | + float collisionSphereRadius; // radius of the collision sphere | |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | + // public methods... | |
| 38 | 39 | ParticleSystem(); |
| 39 | 40 | |
| 40 | 41 | int addEmitter(); // add (create new) emitter and get its unique id |
| @@ -47,14 +48,15 @@ public: · 6 unmodified lines | ||
| 47 | 48 | void setShowingEmitterBaseParticle(int emitterIndex, bool showing ); |
| 48 | 49 | void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles |
| 49 | 50 | void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); // set attributes for this life stage of particles |
| 50 | − void setEmitterBaseParticleColor (int emitterIndex, glm::vec4 color ) {_emitter[emitterIndex].baseParticle.color = color; } | |
| 51 | − void setEmitterBaseParticleRadius (int emitterIndex, float radius ) {_emitter[emitterIndex].baseParticle.radius = radius; } | |
| 52 | − void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } | |
| 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; } | |
| 56 | − void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; } | |
| 57 | − void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; } | |
| 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; } | |
| 58 | 60 | |
| 59 | 61 | private: |
| 60 | 62 | |
| @@ -69,13 +71,14 @@ private: · 8 unmodified lines | ||
| 69 | 71 | }; |
| 70 | 72 | |
| 71 | 73 | struct Emitter { |
| 72 | − glm::vec3 position; | |
| 73 | − glm::vec3 direction; | |
| 74 | − bool visible; | |
| 75 | − float particleLifespan; | |
| 76 | − float thrust; | |
| 77 | − float rate; | |
| 78 | − Particle baseParticle; // a non-physical particle at the emitter position | |
| 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 | |
| 79 | 82 | ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter |
| 80 | 83 | }; |
| 81 | 84 | |