History

added sphere resolution to emitter attributes

Jeffrey Ventrella committed 13 years ago

Commit 13e6f2e1 parent ad0ca743 files · +59 −49Browse files

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

Unified · Split

interface/src/ParticleSystem.h+35−32
@@ -10,31 +10,32 @@ · 9 unmodified lines
10 10
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 = 20;
15const int NUM_PARTICLE_LIFE_STAGES = 4;15const int NUM_PARTICLE_LIFE_STAGES = 4;
16const bool USE_BILLBOARD_RENDERING = false;16const bool USE_BILLBOARD_RENDERING = false;
17const bool SHOW_VELOCITY_TAILS = false;17const bool SHOW_VELOCITY_TAILS = false;
18 18
19class ParticleSystem {19class ParticleSystem {
20public:20public:
21 21
22 struct ParticleAttributes {22 struct ParticleAttributes {
23 float radius;23 float radius; // radius of the particle
24 glm::vec4 color;24 glm::vec4 color; // color (rgba) of the particle
25 float bounce;25 float bounce; // how much reflection when the particle collides with floor/ground
26 float gravity;26 float gravity; // force opposite of up direction
27 float airFriction;27 float airFriction; // continual dampening of velocity
28 float jitter;28 float jitter; // random forces on velocity
29 float emitterAttraction;29 float emitterAttraction; // an attraction to the emitter position
30 float tornadoForce;30 float tornadoForce; // force perpendicular to direction axis
31 float neighborAttraction;31 float neighborAttraction; // causes particle to be pulled towards next particle in list
32 float neighborRepulsion;32 float neighborRepulsion; // causes particle to be repelled by previous particle in list
33 bool usingCollisionSphere;33 bool usingCollisionSphere; // set to true to allow collision with a sphere
34 glm::vec3 collisionSpherePosition;34 glm::vec3 collisionSpherePosition; // position of the collision sphere
35 float collisionSphereRadius;35 float collisionSphereRadius; // radius of the collision sphere
36 }; 36 };
37 37
38 // public methods...
38 ParticleSystem();39 ParticleSystem();
39 40
40 int addEmitter(); // add (create new) emitter and get its unique id41 int addEmitter(); // add (create new) emitter and get its unique id
@@ -47,14 +48,15 @@ public: · 6 unmodified lines
47 void setShowingEmitterBaseParticle(int emitterIndex, bool showing );48 void setShowingEmitterBaseParticle(int emitterIndex, bool showing );
48 void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles49 void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles
49 void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); // set attributes for this life stage of particles50 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 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 setEmitterBaseParticleRadius (int emitterIndex, float radius ) {_emitter[emitterIndex].baseParticle.radius = radius; }
52 void setEmitterPosition (int emitterIndex, glm::vec3 position ) {_emitter[emitterIndex].position = position; } 53 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 setEmitterParticleResolution (int emitterIndex, int resolution) {_emitter[emitterIndex].particleResolution = resolution; }
54 void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; } 55 void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; }
55 void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; }56 void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; }
56 void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; }57 void setEmitterParticleLifespan (int emitterIndex, float lifespan ) {_emitter[emitterIndex].particleLifespan = lifespan; }
57 void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; }58 void setEmitterThrust (int emitterIndex, float thrust ) {_emitter[emitterIndex].thrust = thrust; }
59 void setEmitterRate (int emitterIndex, float rate ) {_emitter[emitterIndex].rate = rate; }
58 60
59private:61private:
60 62
@@ -69,13 +71,14 @@ private: · 8 unmodified lines
69 }; 71 };
70 72
71 struct Emitter {73 struct Emitter {
72 glm::vec3 position;74 glm::vec3 position; // teh position of the emitter in world coordinates
73 glm::vec3 direction;75 glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects
74 bool visible;76 bool visible; // whether or not a line is shown indicating the emitter (indicating its direction)
75 float particleLifespan;77 float particleLifespan; // how long the particle shall live, in seconds
76 float thrust;78 int particleResolution; // for sphere-based particles
77 float rate;79 float thrust; // the initial velocity upon emitting along the emitter direction
78 Particle baseParticle; // a non-physical particle at the emitter position80 float rate; // currently, how many particles emitted during a simulation time step
81 Particle baseParticle; // a non-physical particle at the emitter position
79 ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter82 ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter
80 }; 83 };
81 84

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t