Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4017 in orxonox.OLD for orxonox/trunk/src/lib/graphics/particles


Ignore:
Timestamp:
May 2, 2005, 10:49:05 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged particleSystem back into the Trunk
merged with command:
svn merge particleEngine/ ../trunk/ -r 3966:HEAD
U ../trunk/src/lib/graphics/particles/particle_emitter.cc
U ../trunk/src/lib/graphics/particles/particle_system.cc
U ../trunk/src/lib/graphics/particles/particle_system.h

as you can see, no conflicts

Location:
orxonox/trunk/src/lib/graphics/particles
Files:
3 edited

Legend:

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

    r3966 r4017  
    124124    // saving the time
    125125    float count = (dt+this->saveTime) * this->emissionRate;
    126     this->saveTime = modff(count, &count);
    127     this->saveTime /= this->emissionRate;
     126    this->saveTime = modff(count, &count) / this->emissionRate;
    128127    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime);
    129128   
    130     for (int i = 0; i < count; i++)
    131       // emmits from EMITTER_DOT,
     129    if (likely(count > 0))
    132130      {
    133         Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
    134         randDir.normalize();
    135         randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
    136         randDir = randDir.getNormalized()*velocity + (this->getVelocity() * system->inheritSpeed);
    137 
    138         system->addParticle(this->getAbsCoor(), randDir);
     131        Vector inheritVelocity = this->getVelocity() * system->inheritSpeed;
     132        for (int i = 0; i < count; i++)
     133          // emmits from EMITTER_DOT,
     134          {
     135            Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
     136            randDir.normalize();
     137            randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
     138            Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
     139           
     140            system->addParticle(this->getAbsCoor(), velocityV);
     141          }
    139142      }
    140143  }
  • orxonox/trunk/src/lib/graphics/particles/particle_system.cc

    r3966 r4017  
    229229  glMatrixMode(GL_MODELVIEW);
    230230  //  glDisable(GL_LIGHTING);
    231   material->select();
    232 
    233   Particle* drawPart = particles;
     231  material->select(); 
     232  glDisable(GL_DEPTH_TEST);
     233 Particle* drawPart = particles;
    234234  if (likely(drawPart != NULL))
    235235    {
    236       glBegin(GL_POINTS);
     236      //draw in DOT mode
     237      //      glBegin(GL_POINTS);
    237238      while (likely(drawPart != NULL))
    238239        {
    239           // draw in DOT mode
    240240          glPushMatrix();
    241241          glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     
    243243          glCallList(*this->glID);
    244244         
    245           //              glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     245          //glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    246246          drawPart = drawPart->next;
    247247          glPopMatrix();
    248248        }
    249       glEnd();
     249      //      glEnd();
    250250    }
     251  //  glEnable(GL_LIGHTING);
     252  glEnable(GL_DEPTH_TEST);
    251253}
    252254
     
    275277        }
    276278     
    277       particles->timeToLive = this->lifeSpan + (float)(random()/RAND_MAX)* this->randomLifeSpan;
     279      particles->timeToLive = this->lifeSpan + (float)(rand()/RAND_MAX)* this->randomLifeSpan;
    278280      particles->position = position;
    279281      particles->velocity = velocity;
    280282
    281283      //  particle->rotation = ; //! \todo rotation is once again something to be done.
    282       particles->mass = this->initialMass + (random()/RAND_MAX -.5)* this->randomInitialMass;
    283       particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->randomStartRadius;
     284      particles->mass = this->initialMass + (rand()/RAND_MAX -.5)* this->randomInitialMass;
     285      particles->radius = this->startRadius + (rand()/RAND_MAX-.5)*this->randomStartRadius;
    284286     
    285       particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->randomEndRadius - particles->radius) / particles->timeToLive;
     287      particles->radiusIt = (this->endRadius + (rand()/RAND_MAX-.5)*this->randomEndRadius - particles->radius) / particles->timeToLive;
    286288
    287289      ++this->count;
    288290    }
    289291  else
    290     PRINTF(4)("maximum count of particles reached not adding any more\n");
     292    PRINTF(5)("maximum count of particles reached not adding any more\n");
    291293}
    292294
  • orxonox/trunk/src/lib/graphics/particles/particle_system.h

    r3966 r4017  
    1010#include "vector.h"
    1111
    12 #define PARTICLE_DOT_MASK           0x00001
    13 #define PARTICLE_SPRITE_MASK        0x00010
    14 #define PARTICLE_MODEL_MASK         0x00100
    15 #define PARTICLE_WORDL_ENTITY_MASK  0x01000
    16 #define PARTICLE_MULTI_MASK         0x10000
     12#define PARTICLE_DOT_MASK           0x000001
     13#define PARTICLE_SPARK_MASK         0x000010
     14#define PARTICLE_SPRITE_MASK        0x000100
     15#define PARTICLE_MODEL_MASK         0x001000
     16#define PARTICLE_WORDL_ENTITY_MASK  0x010000
     17#define PARTICLE_MULTI_MASK         0x100000
    1718
    1819//! An enumerator for the different types of particles.
    1920typedef enum PARTICLE_TYPE {PARTICLE_DOT = PARTICLE_DOT_MASK,
     21                            PARTICLE_SPARK = PARTICLE_SPARK_MASK,
    2022                            PARTICLE_SPRITE = PARTICLE_SPRITE_MASK,
    2123                            PARTICLE_MULTI_SPRITE = PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
     
    4143  float radius;               //!< The current size of this particle.
    4244  float radiusIt;             //!< The difference of the Size per second.
     45
     46  PARTICLE_TYPE type;
    4347
    4448  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
Note: See TracChangeset for help on using the changeset viewer.