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
1111 #include <glm/gtc/quaternion.hpp>
1212
1313 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
1716 const bool SHOW_VELOCITY_TAILS = false;
1817
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+
1926 class ParticleSystem {
2027 public:
2128
@@ -45,42 +52,44 @@ public: · 23 unmodified lines
4552 void render();
4653
4754 void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
48− void setShowingEmitterBaseParticle(int emitterIndex, bool showing );
4955 void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles
5056 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+
6167 private:
6268
6369 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;
7178 };
7279
7380 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
8290 ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter
83− };
91+ ParticleRenderStyle particleRenderStyle;
92+ };
8493
8594 glm::vec3 _upDirection;
8695 Emitter _emitter[MAX_EMITTERS];