Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

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

Legend:

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

    r4496 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3131   \brief standard constructor
    3232*/
    33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
    34                   float velocity)
    35 {
     33ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
     34                  float velocity)
     35{
     36  this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter");
    3637  this->type = EMITTER_DOT;
    3738  this->emitterSize = 1.0;
     
    6465   removes the EmitterSystem from the ParticleEngine
    6566*/
    66 ParticleEmitter::~ParticleEmitter () 
     67ParticleEmitter::~ParticleEmitter ()
    6768{
    6869  ParticleEngine::getInstance()->removeEmitter(this);
     
    9192  LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity)
    9293    .describe("How fast the particles are emittet (their initial speed)");
    93  
     94
    9495  LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread)
    9596    .describe("The angle the particles are emitted from (angle, deviation)");
     
    224225    float count = (dt+this->saveTime) * this->emissionRate;
    225226    this->saveTime = modff(count, &count) / this->emissionRate;
    226     PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 
    227    
     227    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime);
     228
    228229    if (likely(count > 0))
    229230      {
    230         Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    231         for (int i = 0; i < count; i++)
    232           // emmits from EMITTER_DOT,
    233           {
    234             Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    235             randDir.normalize();
    236             randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
    237             Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    238 
    239             // this should spread the Particles evenly. if the Emitter is moved around quickly
    240             Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt;
    241             Vector extension; // the Vector for different fields.
    242 
    243             if (this->type & 2)
    244               {
    245                 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5));
    246                 extension = this->getAbsDir().apply(extension);
    247               }
    248             else if (this->type & 8)
    249               {
    250                 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize;
    251               }
    252 
    253             system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV);
    254            
    255           }
     231        Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
     232        for (int i = 0; i < count; i++)
     233          // emmits from EMITTER_DOT,
     234          {
     235            Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
     236            randDir.normalize();
     237            randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
     238            Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
     239
     240            // this should spread the Particles evenly. if the Emitter is moved around quickly
     241            Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt;
     242            Vector extension; // the Vector for different fields.
     243
     244            if (this->type & 2)
     245              {
     246                extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5));
     247                extension = this->getAbsDir().apply(extension);
     248              }
     249            else if (this->type & 8)
     250              {
     251                extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize;
     252              }
     253
     254            system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV);
     255
     256          }
    256257      }
    257258  }
  • orxonox/trunk/src/lib/particles/particle_emitter.h

    r4493 r4597  
    1 /*! 
     1/*!
    22    \file particle_emitter.h
    33    \brief Definition of a ParticleEmitter
     
    99#include "p_node.h"
    1010
    11 // FORWARD DEFINITION 
     11// FORWARD DEFINITION
    1212class ParticleSystem;
    1313class TiXmlElement;
    1414
    1515//! The form of the Emitter to emit from
    16 typedef enum EMITTER_TYPE { EMITTER_DOT   = 1,
    17                             EMITTER_PLANE = 2,
    18                             EMITTER_SPHERE= 4,
    19                             EMITTER_CUBE  = 8 };
     16  typedef enum EMITTER_TYPE
     17{
     18  EMITTER_DOT     = 1,
     19  EMITTER_PLANE   = 2,
     20  EMITTER_SPHERE  = 4,
     21  EMITTER_CUBE    = 8
     22};
    2023
    2124//! A class to handle an Emitter.
     
    2427 public:
    2528  ParticleEmitter(const Vector& direction, float angle = .5,
    26                   float emissionRate = 1.0, float velocity = 1.0);
     29                  float emissionRate = 1.0, float velocity = 1.0);
    2730  ParticleEmitter(const TiXmlElement* root);
    2831  virtual ~ParticleEmitter(void);
    29  
     32
    3033  void loadParams(const TiXmlElement* root);
    3134
  • orxonox/trunk/src/lib/particles/particle_engine.cc

    r4519 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3030   \brief standard constructor
    3131*/
    32 ParticleEngine::ParticleEngine () 
     32ParticleEngine::ParticleEngine ()
    3333{
    3434   this->setClassID(CL_PARTICLE_ENGINE, "ParticleEngine");
     35   this->setName("ParticleEngine");
    3536
    3637   this->systemList = new tList<ParticleSystem>;
     
    4748   \brief deletes all the system, emitters, connections and Lists
    4849*/
    49 ParticleEngine::~ParticleEngine () 
     50ParticleEngine::~ParticleEngine ()
    5051{
    5152  // delete all remaining systems
     
    113114    {
    114115      if (tmpConnection->emitter == emitter && tmpConnection->system == system)
    115         {
    116           PRINTF(2)("Connection between Emitter and System already added\n");
    117           delete tmpConIt;
    118           return;
    119         }
    120      
     116        {
     117          PRINTF(2)("Connection between Emitter and System already added\n");
     118          delete tmpConIt;
     119          return;
     120        }
     121
    121122      tmpConnection = tmpConIt->nextElement();
    122123    }
    123124  delete tmpConIt;
    124  
     125
    125126
    126127
     
    144145    {
    145146      if (tmpConnection->system == system)
    146         this->breakConnection(tmpConnection);
     147        this->breakConnection(tmpConnection);
    147148      tmpConnection = tmpConIt->nextElement();
    148149    }
     
    165166    {
    166167      if (tmpConnection->emitter == emitter)
    167         this->breakConnection(tmpConnection);
     168        this->breakConnection(tmpConnection);
    168169      tmpConnection = tmpConIt->nextElement();
    169170    }
     
    191192    if (tmpConnection->emitter == emitter && tmpConnection->system == system)
    192193      {
    193         this->breakConnection(tmpConnection);
    194         delete tmpConIt;
    195         return true;
     194        this->breakConnection(tmpConnection);
     195        delete tmpConIt;
     196        return true;
    196197      }
    197198    tmpConnection = tmpConIt->nextElement();
     
    268269    {
    269270      if (!strcmp(systemName, tmpSys->getName()))
    270         {
    271           delete tmpIt;
    272           return tmpSys;
    273         }
     271        {
     272          delete tmpIt;
     273          return tmpSys;
     274        }
    274275      tmpSys = tmpIt->nextElement();
    275276    }
     
    291292      count++;
    292293      if ( count == number)
    293         {
    294           delete tmpIt;
    295           return tmpSys;
    296         }
     294        {
     295          delete tmpIt;
     296          return tmpSys;
     297        }
    297298      tmpSys = tmpIt->nextElement();
    298299    }
     
    312313    {
    313314      if (!strcmp(emitterName, tmpEmit->getName()))
    314         {
    315           delete tmpIt;
    316           return tmpEmit;
    317         }
     315        {
     316          delete tmpIt;
     317          return tmpEmit;
     318        }
    318319      tmpEmit = tmpIt->nextElement();
    319320    }
     
    336337      count++;
    337338      if ( count == number)
    338         {
    339           delete tmpIt;
    340           return tmpEmit;
    341         }
     339        {
     340          delete tmpIt;
     341          return tmpEmit;
     342        }
    342343      tmpEmit = tmpIt->nextElement();
    343344    }
     
    356357  PRINT(0)(" Reference: %p\n", ParticleEngine::singletonRef);
    357358  PRINT(0)(" Count: Emitters: %d; Systems: %d, Connections: %d\n",
    358             this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize());
     359            this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize());
    359360  if (this->connectionList->getSize() > 0)
    360361    {
     
    365366      ParticleConnection* tmpConnection = tmpConIt->nextElement();
    366367      while(tmpConnection)
    367         {
    368           PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName());
    369           tmpConnection = tmpConIt->nextElement();
    370         }
     368        {
     369          PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName());
     370          tmpConnection = tmpConIt->nextElement();
     371        }
    371372      delete tmpConIt;
    372373    }
     
    376377      ParticleSystem* tmpSys = tmpIt->nextElement();
    377378      while(tmpSys)
    378         {
    379           tmpSys->debug();
    380           tmpSys = tmpIt->nextElement();
    381         }
     379        {
     380          tmpSys->debug();
     381          tmpSys = tmpIt->nextElement();
     382        }
    382383      delete tmpIt;
    383384    }
  • orxonox/trunk/src/lib/particles/particle_system.cc

    r4515 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    4141{
    4242  this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem");
     43
    4344  this->material = NULL;
    4445  this->maxCount = maxCount;
     
    125126/**
    126127   \brief Sets the lifespan of newly created particles
    127 */   
     128*/
    128129void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan)
    129130{
     
    197198{
    198199  Particle* tickPart = particles;  // the particle to Tick
    199   Particle* prevPart = NULL;       // 
     200  Particle* prevPart = NULL;       //
    200201  while (likely(tickPart != NULL))
    201202    {
    202203      // applying force to the System.
    203204      if (likely (tickPart->mass > 0.0))
    204         tickPart->velocity += tickPart->extForce / tickPart->mass * dt;
     205        tickPart->velocity += tickPart->extForce / tickPart->mass * dt;
    205206
    206207      // rendering new position.
    207208      tickPart->position = tickPart->position + tickPart->velocity * dt;
    208209      tickPart->radius = radiusAnim.getValue(tickPart->lifeCycle)
    209         + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand;
     210        + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand;
    210211
    211212      tickPart->mass = massAnim.getValue(tickPart->lifeCycle)
    212         + randMassAnim.getValue(tickPart->lifeCycle) * tickPart->massRand;
    213      
     213        + randMassAnim.getValue(tickPart->lifeCycle) * tickPart->massRand;
     214
    214215      tickPart->extForce = Vector(0,0,0);
    215216
     
    223224
    224225      if (this->conserve < 1.0)
    225         tickPart->velocity = tickPart->velocity * this->conserve;
     226        tickPart->velocity = tickPart->velocity * this->conserve;
    226227      // find out if we have to delete tickPart
    227228      if (unlikely((tickPart->lifeCycle += dt/tickPart->lifeTime) >= 1.0))
    228         {
    229           // remove the particle from the list
    230           if (likely(prevPart != NULL))
    231             {
    232               prevPart->next = tickPart->next;
    233               tickPart->next = this->deadList;
    234               this->deadList = tickPart;
    235               tickPart = prevPart->next;
    236             }
    237           else
    238             {
    239               prevPart = NULL;
    240               this->particles = tickPart->next;
    241               tickPart->next = this->deadList;
    242               this->deadList = tickPart;
    243               tickPart = this->particles;
    244             }
    245           --this->count;
    246         }
     229        {
     230          // remove the particle from the list
     231          if (likely(prevPart != NULL))
     232            {
     233              prevPart->next = tickPart->next;
     234              tickPart->next = this->deadList;
     235              this->deadList = tickPart;
     236              tickPart = prevPart->next;
     237            }
     238          else
     239            {
     240              prevPart = NULL;
     241              this->particles = tickPart->next;
     242              tickPart->next = this->deadList;
     243              this->deadList = tickPart;
     244              tickPart = this->particles;
     245            }
     246          --this->count;
     247        }
    247248      else
    248         {     
    249           prevPart = tickPart;
    250           tickPart = tickPart->next;
    251         }
    252     }
    253 }
    254 
    255 /** 
     249        {
     250          prevPart = tickPart;
     251          tickPart = tickPart->next;
     252        }
     253    }
     254}
     255
     256/**
    256257    \brief applies some force to a Particle.
    257258    \param field the Field to apply.
     
    281282
    282283  Particle* drawPart = particles;
    283      
     284
    284285  switch (this->particleType)
    285286    {
     
    289290      glDepthMask(GL_FALSE);
    290291
    291       material->select(); 
     292      material->select();
    292293      //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    293      
     294
    294295
    295296      while (likely(drawPart != NULL))
    296         {
    297           glColor4fv(drawPart->color);
    298           //! \todo implement a faster code for the look-at Camera algorithm.
    299 
    300           const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
    301           Vector cameraPos = camera->getAbsCoor();
    302           Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
    303           Vector view = cameraTargetPos - cameraPos;
    304           Vector up = Vector(0, 1, 0);
    305           up = camera->getAbsDir().apply(up);
    306           Vector h = up.cross(view);
    307           Vector v = h.cross(view);
    308           h.normalize();
    309           v.normalize();
    310           v *= .5 * drawPart->radius;
    311           h *= .5 * drawPart->radius;
    312 
    313           glBegin(GL_TRIANGLE_STRIP);
    314           glTexCoord2i(1, 1);
    315           glVertex3f(drawPart->position.x - h.x - v.x,
    316                      drawPart->position.y - h.y - v.y,
    317                      drawPart->position.z - h.z - v.z);
    318           glTexCoord2i(0, 1);
    319           glVertex3f(drawPart->position.x - h.x + v.x,
    320                      drawPart->position.y - h.y + v.y,
    321                      drawPart->position.z - h.z + v.z);
    322           glTexCoord2i(1, 0);
    323           glVertex3f(drawPart->position.x + h.x - v.x,
    324                      drawPart->position.y + h.y - v.y,
    325                      drawPart->position.z + h.z - v.z);
    326           glTexCoord2i(0, 0);
    327           glVertex3f(drawPart->position.x + h.x + v.x,
    328                      drawPart->position.y + h.y + v.y,
    329                      drawPart->position.z + h.z + v.z);
    330 
    331           glEnd();
    332  
    333           drawPart = drawPart->next;
    334         }
     297        {
     298          glColor4fv(drawPart->color);
     299          //! \todo implement a faster code for the look-at Camera algorithm.
     300
     301          const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
     302          Vector cameraPos = camera->getAbsCoor();
     303          Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
     304          Vector view = cameraTargetPos - cameraPos;
     305          Vector up = Vector(0, 1, 0);
     306          up = camera->getAbsDir().apply(up);
     307          Vector h = up.cross(view);
     308          Vector v = h.cross(view);
     309          h.normalize();
     310          v.normalize();
     311          v *= .5 * drawPart->radius;
     312          h *= .5 * drawPart->radius;
     313
     314          glBegin(GL_TRIANGLE_STRIP);
     315          glTexCoord2i(1, 1);
     316          glVertex3f(drawPart->position.x - h.x - v.x,
     317                     drawPart->position.y - h.y - v.y,
     318                     drawPart->position.z - h.z - v.z);
     319          glTexCoord2i(0, 1);
     320          glVertex3f(drawPart->position.x - h.x + v.x,
     321                     drawPart->position.y - h.y + v.y,
     322                     drawPart->position.z - h.z + v.z);
     323          glTexCoord2i(1, 0);
     324          glVertex3f(drawPart->position.x + h.x - v.x,
     325                     drawPart->position.y + h.y - v.y,
     326                     drawPart->position.z + h.z - v.z);
     327          glTexCoord2i(0, 0);
     328          glVertex3f(drawPart->position.x + h.x + v.x,
     329                     drawPart->position.y + h.y + v.y,
     330                     drawPart->position.z + h.z + v.z);
     331
     332          glEnd();
     333
     334          drawPart = drawPart->next;
     335        }
    335336      glDepthMask(GL_TRUE);
    336337      break;
     
    340341      glBegin(GL_LINES);
    341342      while (likely(drawPart != NULL))
    342         {
    343           glColor4fv(drawPart->color);
    344           glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    345           glVertex3f(drawPart->position.x - drawPart->velocity.x,
    346                      drawPart->position.y - drawPart->velocity.y,
    347                      drawPart->position.z - drawPart->velocity.z);
    348           drawPart = drawPart->next;
    349         }
     343        {
     344          glColor4fv(drawPart->color);
     345          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     346          glVertex3f(drawPart->position.x - drawPart->velocity.x,
     347                     drawPart->position.y - drawPart->velocity.y,
     348                     drawPart->position.z - drawPart->velocity.z);
     349          drawPart = drawPart->next;
     350        }
    350351      glEnd();
    351352      break;
    352      
     353
    353354    case PARTICLE_DOT:
    354355      glBegin(GL_POINTS);
    355356      while (likely(drawPart != NULL))
    356         {
    357           glColor4fv(drawPart->color);
    358 
    359           glLineWidth(drawPart->radius);
    360 
    361           glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    362           drawPart = drawPart->next;
    363         }
     357        {
     358          glColor4fv(drawPart->color);
     359
     360          glLineWidth(drawPart->radius);
     361
     362          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     363          drawPart = drawPart->next;
     364        }
    364365      glEnd();
    365366      break;
     
    380381      // if it is the first Particle
    381382      if (unlikely(particles == NULL))
    382         {
    383           if (likely(deadList != NULL))
    384             {
    385               this->particles = this->deadList;
    386               deadList = deadList->next;
    387             }
    388           else
    389             {
    390               PRINTF(5)("Generating new Particle\n");
    391               this->particles = new Particle;
    392             }
    393           this->particles->next = NULL;
    394         }
     383        {
     384          if (likely(deadList != NULL))
     385            {
     386              this->particles = this->deadList;
     387              deadList = deadList->next;
     388            }
     389          else
     390            {
     391              PRINTF(5)("Generating new Particle\n");
     392              this->particles = new Particle;
     393            }
     394          this->particles->next = NULL;
     395        }
    395396      // filling the List from the beginning
    396397      else
    397         {
    398           Particle* tmpPart;
    399           if (likely(deadList != NULL))
    400             {
    401               tmpPart = this->deadList;
    402               deadList = deadList->next;
    403             }
    404           else
    405             {
    406               PRINTF(5)("Generating new Particle\n");
    407               tmpPart = new Particle;
    408             }
    409           tmpPart->next = this->particles;
    410           this->particles = tmpPart;
    411         }
    412      
     398        {
     399          Particle* tmpPart;
     400          if (likely(deadList != NULL))
     401            {
     402              tmpPart = this->deadList;
     403              deadList = deadList->next;
     404            }
     405          else
     406            {
     407              PRINTF(5)("Generating new Particle\n");
     408              tmpPart = new Particle;
     409            }
     410          tmpPart->next = this->particles;
     411          this->particles = tmpPart;
     412        }
     413
    413414      particles->lifeTime = this->lifeSpan + (float)(rand()/RAND_MAX)* this->randomLifeSpan;
    414415      particles->lifeCycle = 0.0;
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4493 r4597  
    1 /*! 
     1/*!
    22    \file particle_system.h
    33
     
    2323
    2424//! An enumerator for the different types of particles.
    25 typedef enum PARTICLE_TYPE { PARTICLE_DOT           =  PARTICLE_DOT_MASK,
    26                              PARTICLE_SPARK         =  PARTICLE_SPARK_MASK,
    27                              PARTICLE_SPRITE        =  PARTICLE_SPRITE_MASK,
    28                              PARTICLE_MULTI_SPRITE  =  PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
    29                              PARTICLE_MODEL         =  PARTICLE_MODEL_MASK,
    30                              PARTICLE_MULTI_MODE    =  PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK };
     25typedef enum PARTICLE_TYPE
     26{
     27  PARTICLE_DOT           =  PARTICLE_DOT_MASK,
     28  PARTICLE_SPARK         =  PARTICLE_SPARK_MASK,
     29  PARTICLE_SPRITE        =  PARTICLE_SPRITE_MASK,
     30  PARTICLE_MULTI_SPRITE  =  PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
     31  PARTICLE_MODEL         =  PARTICLE_MODEL_MASK,
     32  PARTICLE_MULTI_MODE    =  PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK
     33};
    3134
    3235#define PARTICLE_DEFAULT_MAX_COUNT    200               //!< A default count of particles in the system.
     
    5962//! A class to handle ParticleSystems
    6063class ParticleSystem : public WorldEntity, public PhysicsInterface {
    61  
     64
    6265 public:
    6366  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT,
    64                 PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
     67                PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
    6568  virtual ~ParticleSystem();
    6669
     
    116119
    117120  GLuint*           glID;                //!< A List of different gl-List-ID's
    118   GLuint            dialectCount;        //!< How many different types of particles are there in the Particle System 
     121  GLuint            dialectCount;        //!< How many different types of particles are there in the Particle System
    119122
    120123  // per particle attributes
  • orxonox/trunk/src/lib/particles/quick_animation.cc

    r4479 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2727using namespace std;
    2828
    29 
    3029/**
    3130   \brief standard constructor
     
    3332QuickAnimation::QuickAnimation (void)
    3433{
    35    this->setClassName("QuickAnimation");
     34   this->setClassID(CL_QUICK_ANIMATION, "QuickAnimation");
    3635
    3736   this->first = this->current = NULL;
     
    4746  this->current = this->first;
    4847  QuickKeyFrame delKF;
    49  
     48
    5049  while (this->current != NULL)
    5150    {
     
    5453      this->current = this->first;
    5554    }
    56 
    5755}
    5856
     
    7068      // if it is between some keyframes
    7169      if ((!this->current->next && this->current->position < position)
    72           || (this->current->position < position && this->current->next->position > position))
    73         break;
     70          || (this->current->position < position && this->current->next->position > position))
     71        break;
    7472      // if it is the same as an already existing keyframe
    7573      else if (this->current->position == position)
    76         return false;
     74        return false;
    7775      this->current = this->current->next;
    7876    }
     
    9290  newKey->value = value;
    9391  newKey->position = position;
    94  
     92
    9593  this->current = this->first;
    9694
     
    110108    {
    111109      if (this->current->position < position+region && this->current->position > position-region)
    112         {
    113           this->current->value = value;
    114           return true;
    115         }
    116       this->current = this->current->next; 
     110        {
     111          this->current->value = value;
     112          return true;
     113        }
     114      this->current = this->current->next;
    117115    }
    118116  this->current = this->first;
     
    122120/*
    123121  \param position The position where to find the Node to kill
    124  
     122
    125123  bool QuickAnimation::removeEntry(float position)
    126124  {
    127125  this->current = this->first;
    128   QuickKeyFrame* last = 
    129  
     126  QuickKeyFrame* last =
     127
    130128  while (this->current)
    131129  {
    132130  if (this->current->position == position)
    133131  {
    134  
    135  
     132
     133
    136134  }
    137   this->current = this->current->next; 
     135  this->current = this->current->next;
    138136  }
    139137  this->current = this->first;
     
    145143   \param position the position to get the value from :)
    146144*/
    147 float QuickAnimation::getValue(float position) 
     145float QuickAnimation::getValue(float position)
    148146{
    149147  if (unlikely(this->first == NULL))
     
    154152    {
    155153      if (unlikely(position < this->current->position))
    156         {
    157           if (position <= this->first->position)
    158             return this->first->value;
    159           this->current = this->first;
    160         }
     154        {
     155          if (position <= this->first->position)
     156            return this->first->value;
     157          this->current = this->first;
     158        }
    161159      while (likely(this->current->next != NULL && position > this->current->next->position))
    162         this->current = this->current->next;
     160        this->current = this->current->next;
    163161      if (this->current->next == NULL)
    164         return this->current->value;
    165                
     162        return this->current->value;
     163
    166164      return this->current->value + (this->current->next->value - this->current->value)
    167         * ((position-this->current->position) / (this->current->next->position -this->current->position));
     165        * ((position-this->current->position) / (this->current->next->position -this->current->position));
    168166    }
    169167}
  • orxonox/trunk/src/lib/particles/quick_animation.h

    r4479 r4597  
    1 /*! 
     1/*!
    22    \file quick_animation.h
    33    \brief Definition of the QuickAnimation-class
     
    2121   this class is optimized for a raising value. eg. 100 particles sorted
    2222   by age.
     23  \todo speedUP this stuff (especially getValue)
    2324*/
    2425class QuickAnimation : public BaseObject {
Note: See TracChangeset for help on using the changeset viewer.