Changeset 4493 in orxonox.OLD for orxonox/trunk/src/lib/particles
- Timestamp:
- Jun 3, 2005, 2:10:47 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/particles
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/particles/particle_emitter.cc
r4478 r4493 37 37 this->emitterSize = 1.0; 38 38 this->direction = direction; 39 this->setInheritSpeed(0); 39 40 this->setSpread(angle); 40 41 this->setEmissionRate(emissionRate); … … 157 158 else 158 159 this->emissionRate = 0.0; 160 } 161 162 /** 163 \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem 164 \param value a Value between zero and one 165 166 if you want to change the value of this variable during emission time (to make it more dynamic) 167 you may want to use the animation class 168 */ 169 void ParticleEmitter::setInheritSpeed(float value) 170 { 171 if (unlikely(value > 1.0)) 172 this->inheritSpeed = 1; 173 else if (unlikely(value < 0.0)) 174 this->inheritSpeed = 0; 175 else 176 this->inheritSpeed = value; 159 177 } 160 178 … … 207 225 if (likely(count > 0)) 208 226 { 209 Vector inheritVelocity = this->getVelocity() * system->inheritSpeed;227 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; 210 228 for (int i = 0; i < count; i++) 211 229 // emmits from EMITTER_DOT, … … 242 260 void ParticleEmitter::debug(void) 243 261 { 244 245 } 262 PRINT(0)(" Emitter %s\n", this->getName()); 263 } -
orxonox/trunk/src/lib/particles/particle_emitter.h
r4478 r4493 40 40 void setSize(float emitterSize); 41 41 void setEmissionRate(float emissionRate); 42 void setInheritSpeed(float value); 42 43 void setSpread(float angle, float randomAngle = 0.0); 43 44 void setEmissionVelocity(float velocity, float randomVelocity = 0.0); … … 49 50 /** \returns the emissionRate */ 50 51 inline float getEmissionRate(void) const { return this->emissionRate; }; 52 /** \returns the inherit-speed-factor */ 53 inline float getInheritSpeed(void) const { return this->inheritSpeed; }; 51 54 /** \returns the SpreadAngle of the emitter */ 52 55 inline float getSpread(void) { return this->angle; }; … … 60 63 EMITTER_TYPE type; //!< The type of emitter this is 61 64 float emitterSize; //!< The size of the emitter (not for EMITTER_DOT) 65 float inheritSpeed; //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter 62 66 Vector direction; //!< emition direction 63 67 float angle; //!< max angle from the direction of the emitter -
orxonox/trunk/src/lib/particles/particle_system.cc
r4478 r4493 42 42 this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem"); 43 43 this->material = NULL; 44 this->name = NULL;45 44 this->maxCount = maxCount; 46 45 this->count = 0; … … 49 48 this->setConserve(1); 50 49 this->setLifeSpan(1); 51 this->setInheritSpeed(0);52 50 this->glID = NULL; 53 51 this->setType(type, 1); … … 123 121 { 124 122 this->material = material; 125 }126 127 /**128 \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem129 \param value a Value between zero and one130 131 if you want to change the value of this variable during emission time (to make it more dynamic)132 you may want to use the animation class133 */134 void ParticleSystem::setInheritSpeed(float value)135 {136 if (unlikely(value > 1.0))137 this->inheritSpeed = 1;138 else if (unlikely(value < 0.0))139 this->inheritSpeed = 0;140 else141 this->inheritSpeed = value;142 123 } 143 124 … … 453 434 void ParticleSystem::debug(void) 454 435 { 455 PRINT(0)(" ParticleSystem %s\n", this-> name);436 PRINT(0)(" ParticleSystem %s\n", this->getName()); 456 437 PRINT(0)(" ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount); 457 438 if (deadList) -
orxonox/trunk/src/lib/particles/particle_system.h
r4478 r4493 7 7 #define _PARTICLE_SYSTEM_H 8 8 9 #include " base_object.h"9 #include "world_entity.h" 10 10 #include "physics_interface.h" 11 11 … … 41 41 typedef struct Particle 42 42 { 43 float lifeTime;//!< The time this particle has to live.44 float lifeCycle;//!< The fraction of time passed. (in percentage of its lifeTime)43 float lifeTime; //!< The time this particle has to live. 44 float lifeCycle; //!< The fraction of time passed. (in percentage of its lifeTime) 45 45 46 Vector position; //!< The current position of this particle. 47 Vector velocity; //!< The current velocity of this particle. 48 Vector extForce; //!< The external Force that influences this Particle. 49 Quaternion rotation; //!< The current rotation of this particle. 50 float mass; //!< The mass of this particle. 51 float massRand; //!< A random mass 52 float radius; //!< The current size of this particle. 53 float radiusRand; //!< a random Radius 46 Vector position; //!< The current position of this particle. 47 Vector velocity; //!< The current velocity of this particle. 48 Vector extForce; //!< The external Force that influences this Particle. 49 Quaternion rotation; //!< The current rotation of this particle. 50 float mass; //!< The mass of this particle. 51 float massRand; //!< A random mass 52 float radius; //!< The current size of this particle. 53 float radiusRand; //!< a random Radius 54 GLfloat color [4]; //!< A Color for the particles. 54 55 55 GLfloat color [4]; //!< A Color for the particles. 56 57 Particle* next; //!< pointer to the next particle in the List. (NULL if no preceding one) 56 Particle* next; //!< pointer to the next particle in the List. (NULL if no preceding one) 58 57 }; 59 58 60 59 //! A class to handle ParticleSystems 61 class ParticleSystem : public PhysicsInterface { 62 friend class ParticleEmitter; 60 class ParticleSystem : public WorldEntity, public PhysicsInterface { 63 61 64 62 public: … … 69 67 void setType(PARTICLE_TYPE particleType, int count = 0); 70 68 void setMaterial(Material* material); 71 void setInheritSpeed(float value);72 69 void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0); 73 70 void setConserve(float conserve); … … 82 79 /** \returns the Material that lies on this particles */ 83 80 inline const Material* getMaterial(void) const { return this->material; }; 84 /** \returns the inherit-speed-factor */85 inline float getInheritSpeed(void) const { return this->inheritSpeed; };86 81 /** \returns the lifespan of the particles */ 87 82 inline float getLifeSpan(void) const { return this->lifeSpan; }; … … 101 96 void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0); 102 97 103 v oid tick(float dt);104 v oid draw(void) const;98 virtual void tick(float dt); 99 virtual void draw(void) const; 105 100 106 101 void debug(void); 107 102 108 103 private: 109 char* name; //!< the Name of the Particle System110 111 104 float conserve; //!< How much energy gets conserved to the next Tick. 112 105 float lifeSpan; //!< Initial lifetime of a Particle. … … 114 107 float initialMass; //!< The initial Mass of the Particle 115 108 float randomInitialMass; //!< The random initial Mass of the Particle 116 float inheritSpeed; //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter117 109 118 // particles119 110 int maxCount; //!< The maximum count of Particles. 120 111 int count; //!< The current count of Particles. … … 128 119 129 120 // per particle attributes 130 QuickAnimation radiusAnim;//!< Animation of the radius131 QuickAnimation randRadiusAnim;//!< Animation of the random Value of the radius132 QuickAnimation massAnim;//!< Animation of the mass133 QuickAnimation randMassAnim;//!< Animation of the random Mass134 QuickAnimation colorAnim[4];//!< Animation of the 4 colors (r,g,b,a)121 QuickAnimation radiusAnim; //!< Animation of the radius 122 QuickAnimation randRadiusAnim; //!< Animation of the random Value of the radius 123 QuickAnimation massAnim; //!< Animation of the mass 124 QuickAnimation randMassAnim; //!< Animation of the random Mass 125 QuickAnimation colorAnim[4]; //!< Animation of the 4 colors (r,g,b,a) 135 126 }; 136 127
Note: See TracChangeset
for help on using the changeset viewer.