Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 13, 2005, 9:04:50 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: implemented sparks

File:
1 edited

Legend:

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

    r4129 r4173  
    3838   this->maxCount = maxCount;
    3939   this->count = 0;
    40    this->particleType = type;
    4140   this->particles = NULL;
    4241   this->deadList = NULL;
    43    this->setConserve(.8);
    44    this->setLifeSpan(.1);
     42   this->setConserve(1);
     43   this->setLifeSpan(1);
    4544   this->setInheritSpeed(0);
    4645   this->glID = NULL;
    4746   this->setRadius(1.0, 1.0, 0.0);
    48    this->setType(PARTICLE_SPRITE, 1);
     47   this->setType(type, 1);
    4948   ParticleEngine::getInstance()->addSystem(this);
    5049}
     
    5453   \brief standard deconstructor
    5554*/
    56 ParticleSystem::~ParticleSystem() 
     55ParticleSystem::~ParticleSystem()
    5756{
    5857  // delete what has to be deleted here
     
    240239/**
    241240   \brief draws all the Particles of this System
    242 */
    243 void ParticleSystem::draw(void)
    244 {
     241   \param the time passed in seconds (since the last draw)
     242*/
     243void ParticleSystem::draw(float dt)
     244{
     245  glPushAttrib(GL_ENABLE_BIT);
    245246  //  material->select();
    246 
    247 
    248   glMatrixMode(GL_MODELVIEW);
    249   //  glDisable(GL_LIGHTING);
    250   material->select();
    251   glDisable(GL_DEPTH_TEST);
    252  Particle* drawPart = particles;
    253   if (likely(drawPart != NULL))
     247  Particle* drawPart = particles;
     248
     249  switch (this->particleType)
    254250    {
    255       //draw in DOT mode
    256       //      glBegin(GL_POINTS);
     251    case PARTICLE_SPRITE:
     252      glMatrixMode(GL_MODELVIEW);
     253      //  glDisable(GL_LIGHTING);
     254      material->select();
     255      glDisable(GL_DEPTH_TEST);
    257256      while (likely(drawPart != NULL))
    258257        {
     
    267266        }
    268267      //      glEnd();
     268     
     269      //  glEnable(GL_LIGHTING);
     270     
     271      glEnable(GL_DEPTH_TEST);
     272      break;
     273    default:
     274
     275    case PARTICLE_SPARK:
     276      glEnable(GL_LINE_SMOOTH);
     277      glBegin(GL_LINES);
     278      while (likely(drawPart != NULL))
     279        {
     280          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     281          glVertex3f(drawPart->position.x - drawPart->velocity.x,
     282                     drawPart->position.y - drawPart->velocity.y,
     283                     drawPart->position.z - drawPart->velocity.z);
     284          drawPart = drawPart->next;
     285        }
     286      glEnd();
     287      break;
     288     
     289    case PARTICLE_DOT:
     290      glBegin(GL_POINTS);
     291      while (likely(drawPart != NULL))
     292        {
     293          glLineWidth(drawPart->radius);
     294
     295          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     296          drawPart = drawPart->next;
     297        }
     298      glEnd();
     299      break;
    269300    }
    270   //  glEnable(GL_LIGHTING);
    271   glEnable(GL_DEPTH_TEST);
     301  glPopAttrib();
    272302}
    273303
Note: See TracChangeset for help on using the changeset viewer.