History

added extra mode and started prototyping "ribbon" effect

Jeffrey Ventrella committed 13 years ago

Commit 062ee651 parent 90bc3e94 files · +341 −204Browse files

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

Unified · Split

interface/src/ParticleSystem.h+39−30
@@ -11,11 +11,18 @@ · 10 unmodified lines
11#include <glm/gtc/quaternion.hpp>11#include <glm/gtc/quaternion.hpp>
12 12
13const int MAX_PARTICLES = 5000;13const int MAX_PARTICLES = 5000;
14const int MAX_EMITTERS = 20;14const int MAX_EMITTERS = 1000;
15const int NUM_PARTICLE_LIFE_STAGES = 4;15const int NUM_PARTICLE_LIFE_STAGES = 4; // each equal time-division of the particle's life can have different attributes
16const bool USE_BILLBOARD_RENDERING = false;
17const bool SHOW_VELOCITY_TAILS = false;16const bool SHOW_VELOCITY_TAILS = false;
18 17
18enum 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
19class ParticleSystem {26class ParticleSystem {
20public:27public:
21 28
@@ -45,42 +52,44 @@ public: · 23 unmodified lines
45 void render();52 void render();
46 53
47 void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up54 void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
48 void setShowingEmitterBaseParticle(int emitterIndex, bool showing );
49 void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles55 void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles
50 void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); // set attributes for this life stage of particles56 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; }57 void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; }
52 void setEmitterBaseParticleRadius (int emitterIndex, float radius ) {_emitter[emitterIndex].baseParticle.radius = radius; }58 void setEmitterParticleResolution (int emitterIndex, int resolution ) {_emitter[emitterIndex].particleResolution = resolution; }
53 void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } 59 void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; }
54 void setEmitterParticleResolution (int emitterIndex, int resolution) {_emitter[emitterIndex].particleResolution = resolution; } 60 void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; }
55 void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; } 61 void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; }
56 void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; } 62 void setParticleRenderStyle (int emitterIndex, ParticleRenderStyle renderStyle ) {_emitter[emitterIndex].particleRenderStyle = renderStyle; }
57 void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; }63 void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; }
58 void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; }64 void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; }
59 void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; }65 void setShowingEmitterBaseParticle(int emitterIndex, bool showing ) {_emitter[emitterIndex].showingBaseParticle = showing; }
60 66
61private:67private:
62 68
63 struct Particle {69 struct Particle {
64 bool alive; // is the particle active?70 bool alive; // is the particle active?
65 glm::vec3 position; // position71 glm::vec3 position; // position
66 glm::vec3 velocity; // velocity72 glm::vec3 velocity; // velocity
67 glm::vec4 color; // color (rgba)73 glm::vec4 color; // color (rgba)
68 float age; // age in seconds74 float age; // age in seconds
69 float radius; // radius75 float radius; // radius
70 int emitterIndex; // which emitter created this particle?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 struct Emitter {80 struct Emitter {
74 glm::vec3 position; // teh position of the emitter in world coordinates81 glm::vec3 position; // the position of the emitter in world coordinates
75 glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects82 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)83 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 seconds84 float particleLifespan; // how long the particle shall live, in seconds
78 int particleResolution; // for sphere-based particles85 int particleResolution; // for sphere-based particles
79 float thrust; // the initial velocity upon emitting along the emitter direction 86 float thrust; // the initial velocity upon emitting along the emitter direction
80 float rate; // currently, how many particles emitted during a simulation time step87 float rate; // currently, how many particles emitted during a simulation time step
81 Particle baseParticle; // a non-physical particle at the emitter position88 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 ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter90 ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter
83 }; 91 ParticleRenderStyle particleRenderStyle;
92 };
84 93
85 glm::vec3 _upDirection;94 glm::vec3 _upDirection;
86 Emitter _emitter[MAX_EMITTERS];95 Emitter _emitter[MAX_EMITTERS];