Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4173 in orxonox.OLD


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

orxonox/branches/particleEngine: implemented sparks

Location:
orxonox/branches/particleEngine/src
Files:
6 edited

Legend:

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

    r4129 r4173  
    140140            // this should spread the Particles evenly. if the Emitter is moved around quickly
    141141            Vector equalSpread = this->getVelocity() * random()/RAND_MAX * dt;
    142             equalSpread.debug();
    143142
    144143            system->addParticle(this->getAbsCoor() - equalSpread, velocityV);
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_engine.cc

    r4129 r4173  
    251251/**
    252252   \brief draws all the systems and their Particles.
    253 */
    254 void ParticleEngine::draw(void)
     253   \param dt the time passed in seconds (since the last Frame)
     254*/
     255void ParticleEngine::draw(float dt)
    255256{
    256257  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
     
    258259  while(tmpSys)
    259260    {
    260       tmpSys->draw();
     261      tmpSys->draw(dt);
    261262      tmpSys = tmpIt->nextElement();
    262263    }
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_engine.h

    r4128 r4173  
    3030
    3131  void tick(float dt);
    32   void draw(void);
     32  void draw(float dt);
    3333
    3434  void addSystem(ParticleSystem* system);
  • 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
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.h

    r4128 r4173  
    7070
    7171  void tick(float dt);
    72   void draw(void);
     72  void draw(float dt);
    7373
    7474  void debug(void);
  • orxonox/branches/particleEngine/src/story_entities/world.cc

    r4129 r4173  
    493493
    494494
    495   ParticleSystem* system = new ParticleSystem(1000);
    496   system->setLifeSpan(1);
     495  ParticleSystem* system = new ParticleSystem(1000, PARTICLE_SPARK);
     496  system->setLifeSpan(.5);
    497497  system->setRadius(2, 0, 2, 0);
    498   ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), 0, 1000, 0);
     498
     499  ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 1000, .05);
    499500  emitter->setParent(this->localPlayer);
    500501 
     
    962963
    963964  TextEngine::getInstance()->draw();
    964   particleEngine->draw();
     965  particleEngine->draw((float)dt/1000.0); //!< \todo should be dts like in the Trunk;
    965966
    966967  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
Note: See TracChangeset for help on using the changeset viewer.