Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 24, 2005, 1:44:38 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Particles now have a momentum and an orientation

File:
1 edited

Legend:

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

    r4677 r4687  
    273273
    274274      // rendering new position.
    275       tickPart->position = tickPart->position + tickPart->velocity * dt;
     275      tickPart->position += tickPart->velocity * dt;
     276      tickPart->orientation += tickPart->momentum *dt;
     277
    276278      tickPart->radius = radiusAnim.getValue(tickPart->lifeCycle)
    277279        + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand;
     
    439441
    440442    case PARTICLE_MODEL:
    441       if (likely(this->model != NULL))
    442         while (likely(drawPart != NULL))
    443443      {
    444         glPushMatrix();
    445         glMatrixMode(GL_MODELVIEW);
    446 
    447         glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    448         glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
    449 
    450         this->model->draw();
    451 
    452         glPopMatrix();
    453         drawPart = drawPart->next;
     444        GLfloat matrix[4][4];
     445
     446        if (likely(this->model != NULL))
     447          while (likely(drawPart != NULL))
     448        {
     449          glPushMatrix();
     450          glMatrixMode(GL_MODELVIEW);
     451          /* move */
     452          glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     453          /* scale */
     454          glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
     455          /* rotate */
     456          drawPart->orientation.matrix (matrix);
     457          glMultMatrixf((float*)matrix);
     458
     459          this->model->draw();
     460
     461          glPopMatrix();
     462          drawPart = drawPart->next;
     463        }
    454464      }
    455465      break;
     
    515525          this->particles = tmpPart;
    516526        }
    517 
    518527      particles->lifeTime = this->lifeSpan + (float)(rand()/RAND_MAX)* this->randomLifeSpan;
    519528      particles->lifeCycle = 0.0;
    520529      particles->position = position;
    521530      particles->velocity = velocity;
     531
     532      particles->orientation = Quaternion(.4, velocity.getNormalized());
     533      particles->momentum = Quaternion(.4, velocity.getNormalized());
    522534
    523535      //  particle->rotation = ; //! \todo rotation is once again something to be done.
Note: See TracChangeset for help on using the changeset viewer.