Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4493 in orxonox.OLD for orxonox/trunk/src/lib/particles


Ignore:
Timestamp:
Jun 3, 2005, 2:10:47 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: inheritSpeed now property of particle_emitter. system not friend emitter anymore

Location:
orxonox/trunk/src/lib/particles
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/particles/particle_emitter.cc

    r4478 r4493  
    3737  this->emitterSize = 1.0;
    3838  this->direction = direction;
     39  this->setInheritSpeed(0);
    3940  this->setSpread(angle);
    4041  this->setEmissionRate(emissionRate);
     
    157158  else
    158159    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*/
     169void 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;
    159177}
    160178
     
    207225    if (likely(count > 0))
    208226      {
    209         Vector inheritVelocity = this->getVelocity() * system->inheritSpeed;
     227        Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    210228        for (int i = 0; i < count; i++)
    211229          // emmits from EMITTER_DOT,
     
    242260void ParticleEmitter::debug(void)
    243261{
    244 
    245 }
     262  PRINT(0)(" Emitter %s\n", this->getName());
     263}
  • orxonox/trunk/src/lib/particles/particle_emitter.h

    r4478 r4493  
    4040  void setSize(float emitterSize);
    4141  void setEmissionRate(float emissionRate);
     42  void setInheritSpeed(float value);
    4243  void setSpread(float angle, float randomAngle = 0.0);
    4344  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
     
    4950  /** \returns the emissionRate */
    5051  inline float getEmissionRate(void) const { return this->emissionRate; };
     52  /** \returns the inherit-speed-factor */
     53  inline float getInheritSpeed(void) const { return this->inheritSpeed; };
    5154  /** \returns the SpreadAngle of the emitter */
    5255  inline float getSpread(void) { return this->angle; };
     
    6063  EMITTER_TYPE    type;              //!< The type of emitter this is
    6164  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
    6266  Vector          direction;         //!< emition direction
    6367  float           angle;             //!< max angle from the direction of the emitter
  • orxonox/trunk/src/lib/particles/particle_system.cc

    r4478 r4493  
    4242  this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem");
    4343  this->material = NULL;
    44   this->name = NULL;
    4544  this->maxCount = maxCount;
    4645  this->count = 0;
     
    4948  this->setConserve(1);
    5049  this->setLifeSpan(1);
    51   this->setInheritSpeed(0);
    5250  this->glID = NULL;
    5351  this->setType(type, 1);
     
    123121{
    124122  this->material = material;
    125 }
    126 
    127 /**
    128    \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem
    129    \param value a Value between zero and one
    130 
    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 class
    133 */
    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   else
    141     this->inheritSpeed = value;
    142123}
    143124
     
    453434void ParticleSystem::debug(void)
    454435{
    455   PRINT(0)("  ParticleSystem %s\n", this->name);
     436  PRINT(0)("  ParticleSystem %s\n", this->getName());
    456437  PRINT(0)("  ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount);
    457438  if (deadList)
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4478 r4493  
    77#define _PARTICLE_SYSTEM_H
    88
    9 #include "base_object.h"
     9#include "world_entity.h"
    1010#include "physics_interface.h"
    1111
     
    4141typedef struct Particle
    4242{
    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)
    4545
    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.
    5455
    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)
    5857};
    5958
    6059//! A class to handle ParticleSystems
    61 class ParticleSystem : public PhysicsInterface {
    62   friend class ParticleEmitter;
     60class ParticleSystem : public WorldEntity, public PhysicsInterface {
    6361 
    6462 public:
     
    6967  void setType(PARTICLE_TYPE particleType, int count = 0);
    7068  void setMaterial(Material* material);
    71   void setInheritSpeed(float value);
    7269  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
    7370  void setConserve(float conserve);
     
    8279  /** \returns the Material that lies on this particles */
    8380  inline const Material* getMaterial(void) const { return this->material; };
    84   /** \returns the inherit-speed-factor */
    85   inline float getInheritSpeed(void) const { return this->inheritSpeed; };
    8681  /** \returns the lifespan of the particles */
    8782  inline float getLifeSpan(void) const { return this->lifeSpan; };
     
    10196  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
    10297
    103   void tick(float dt);
    104   void draw(void) const;
     98  virtual void tick(float dt);
     99  virtual void draw(void) const;
    105100
    106101  void debug(void);
    107102
    108103 private:
    109   char*             name;                //!< the Name of the Particle System
    110 
    111104  float             conserve;            //!< How much energy gets conserved to the next Tick.
    112105  float             lifeSpan;            //!< Initial lifetime of a Particle.
     
    114107  float             initialMass;         //!< The initial Mass of the Particle
    115108  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 emitter
    117109
    118   // particles
    119110  int               maxCount;            //!< The maximum count of Particles.
    120111  int               count;               //!< The current count of Particles.
     
    128119
    129120  // per particle attributes
    130   QuickAnimation radiusAnim;             //!< Animation of the radius
    131   QuickAnimation randRadiusAnim;         //!< Animation of the random Value of the radius
    132   QuickAnimation massAnim;               //!< Animation of the mass
    133   QuickAnimation randMassAnim;           //!< Animation of the random Mass
    134   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)
    135126};
    136127
Note: See TracChangeset for help on using the changeset viewer.