Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2005, 12:42:09 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: the first particles are being drawn :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc

    r3931 r3932  
    2020#include "particle_emitter.h"
    2121#include "particle_engine.h"
     22#include "compiler.h"
    2223
    2324using namespace std;
     
    3637
    3738   this->particleType = type;
     39   this->particles = NULL;
     40   this->conserve = 1.0;
     41   this->setLifeSpan(5.0);
     42
     43   ParticleEngine::getInstance()->addSystem(this);
    3844}
    3945
     
    4349
    4450*/
    45 ParticleSystem::~ParticleSystem ()
     51ParticleSystem::~ParticleSystem()
    4652{
    4753  // delete what has to be deleted here
    4854}
    4955
     56// setting properties
     57void ParticleSystem::setMaterial(Material* material)
     58{
     59 
     60}
     61
     62void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan)
     63{
     64
     65}
     66
     67void ParticleSystem::setRadius(float startRadius, float endRadius, float randomRadius)
     68{
     69
     70}
     71
     72void ParticleSystem::setConserve(float conserve)
     73{
     74  this->conserve = conserve;
     75}
     76
     77
    5078
    5179void ParticleSystem::tick(float dt)
    5280{
     81  Particle* tmpPart = particles;
     82  while (likely(tmpPart != NULL))
     83    {
     84      tmpPart->position = tmpPart->position + tmpPart->velocity;
     85
     86      // many more to come
     87
     88      tmpPart = tmpPart->next;
     89    }
     90}
     91
     92void ParticleSystem::draw(void)
     93{
     94  Particle* tmpPart = particles;
     95  if (likely(tmpPart != NULL))
     96    {
     97      glBegin(GL_POINTS);
     98      while (likely(tmpPart != NULL))
     99        {
     100          // draw in DOT mode
     101          glVertex3f(tmpPart->position.x, tmpPart->position.y, tmpPart->position.z);
     102         
     103         
     104          tmpPart = tmpPart->next;
     105        }
     106      glEnd();
     107    }
     108}
     109
     110
     111void ParticleSystem::addParticle(Vector position, Vector velocity, unsigned int data)
     112{
     113  // if it is the first Particle
     114  if (unlikely(particles == NULL))
     115    {
     116      this->particles = new Particle;
     117      this->particles->next = NULL;
     118    }
     119  // filling the List from the beginning
     120  else
     121    {
     122      Particle* tmpPart = new Particle;
     123      tmpPart->next = this->particles;
     124      this->particles = tmpPart;
     125    }
    53126 
     127  particles->timeToLive = this->lifeSpan + (float)(random()/RAND_MAX)* this->randomLifeSpan;
     128  particles->position = position;
     129  particles->velocity = velocity;
     130  //  particle->rotation = ; //! \todo rotation is once again something to be done.
     131  particles->mass = this->initialMass + (random()/RAND_MAX)* this->randomInitialMass;
     132  particles->radius = this->startRadius + (random()/RAND_MAX)*this->randomRadius;
     133}
    54134
    55 }
Note: See TracChangeset for help on using the changeset viewer.