Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4687 in orxonox.OLD for orxonox/trunk/src/lib/particles


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

Location:
orxonox/trunk/src/lib/particles
Files:
2 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.
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4680 r4687  
    5151
    5252  Vector        position;            //!< The current position of this particle.
    53   Vector        velocity;            //!< The current velocity of this particle.
     53  Vector        velocity;            //!< The current velocity of this Particle.
    5454  Vector        extForce;            //!< The external Force that influences this Particle.
    55   Quaternion    rotation;            //!< The current rotation of this particle.
    56   float         mass;                //!< The mass of this particle.
     55  Quaternion    orientation;         //!< The current orientation of this Particle.
     56  Quaternion    momentum;            //!< The current angular momentum (spin) of this Particle.
     57  float         mass;                //!< The mass of this Particle.
    5758  float         massRand;            //!< A random mass
    58   float         radius;              //!< The current size of this particle.
     59  float         radius;              //!< The current size of this Particle.
    5960  float         radiusRand;          //!< a random Radius
    6061  GLfloat       color [4];           //!< A Color for the particles.
Note: See TracChangeset for help on using the changeset viewer.