Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4431 in orxonox.OLD


Ignore:
Timestamp:
Jun 1, 2005, 10:30:13 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: particles: color is animatable too

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r4430 r4431  
    208208
    209209/**
    210    \brief Tells the ParticleSystem how it should iterate the color over time
    211    \param ....
    212 */
    213 void ParticleSystem::setColor(GLfloat br, GLfloat bg, GLfloat bb, GLfloat ba,
    214                               GLfloat mr, GLfloat mg, GLfloat mb, GLfloat ma,
    215                               GLfloat er, GLfloat eg, GLfloat eb, GLfloat ea)
    216 {
    217   this->startColor[0] = br;
    218   this->startColor[1] = bg;
    219   this->startColor[2] = bb;
    220   this->startColor[3] = ba;
    221 
    222   this->midColor[0] = mr;
    223   this->midColor[1] = mg;
    224   this->midColor[2] = mb;
    225   this->midColor[3] = ma;
    226 
    227   this->endColor[0] = er;
    228   this->endColor[1] = eg;
    229   this->endColor[2] = eb;
    230   this->endColor[3] = ea;
     210   \brief sets a key in the color-animation on a per-particle basis
     211   \param lifeCycleTime the time (partilceLifeTime/particleAge) [0-1]
     212   \param red red
     213   \param green green
     214   \param blue blue
     215*/
     216void ParticleSystem::setColor(float lifeCycleTime, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
     217{
     218  this->colorAnim[0].addEntry(lifeCycleTime, red);
     219  this->colorAnim[1].addEntry(lifeCycleTime, green);
     220  this->colorAnim[2].addEntry(lifeCycleTime, blue);
     221  this->colorAnim[3].addEntry(lifeCycleTime, alpha);
    231222}
    232223
     
    254245
    255246      // applying Color
    256       //! \todo better algorithm to do this \todo also implement the midColor
    257       if (tickPart->lifeCycle < .5)
    258         {
    259           tickPart->color[0] = this->startColor[0] *(1.0-tickPart->lifeCycle*2.0) + this->midColor[0] *(tickPart->lifeCycle*2);
    260           tickPart->color[1] = this->startColor[1] *(1.0-tickPart->lifeCycle*2.0) + this->midColor[1] *(tickPart->lifeCycle*2);
    261           tickPart->color[2] = this->startColor[2] *(1.0-tickPart->lifeCycle*2.0) + this->midColor[2] *(tickPart->lifeCycle*2);
    262           tickPart->color[3] = this->startColor[3] *(1.0-tickPart->lifeCycle*2.0) + this->midColor[3] *(tickPart->lifeCycle*2);
    263         }
    264       else
    265         {
    266           tickPart->color[0] = this->midColor[0] *(2.0-tickPart->lifeCycle*2.0) + this->endColor[0] *(tickPart->lifeCycle*2);
    267           tickPart->color[1] = this->midColor[1] *(2.0-tickPart->lifeCycle*2.0) + this->endColor[1] *(tickPart->lifeCycle*2);
    268           tickPart->color[2] = this->midColor[2] *(2.0-tickPart->lifeCycle*2.0) + this->endColor[2] *(tickPart->lifeCycle*2);
    269           tickPart->color[3] = this->midColor[3] *(2.0-tickPart->lifeCycle*2.0) + this->endColor[3] *(tickPart->lifeCycle*2);
    270         }         
     247      tickPart->color[0] = this->colorAnim[0].getValue(tickPart->lifeCycle);
     248      tickPart->color[1] = this->colorAnim[1].getValue(tickPart->lifeCycle);
     249      tickPart->color[2] = this->colorAnim[2].getValue(tickPart->lifeCycle);
     250      tickPart->color[3] = this->colorAnim[3].getValue(tickPart->lifeCycle);
     251
    271252      // many more to come
    272253
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4430 r4431  
    7979  void setRadius(float lifeCycleTime, float radius, float randRadius = 0.0);
    8080  void setMass(float lifeCycleTime, float mass, float randMass = 0.0);
    81   void setColor(GLfloat br, GLfloat bg, GLfloat bb, GLfloat ba,
    82                 GLfloat mr, GLfloat mg, GLfloat mb, GLfloat ma,
    83                 GLfloat er, GLfloat eg, GLfloat eb, GLfloat ea);
    84 
    85 
     81  void setColor(float lifeCycleTime, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
    8682
    8783  /** \returns the Type of the particles */
     
    126122  float inheritSpeed;        //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter
    127123
    128   GLfloat startColor[4];     //!< Color of the Particle at the beginning
    129   GLfloat midColor[4];       //!< Color of the Particle at the middle of its lifeSpan
    130   GLfloat endColor[4];       //!< Color of the Particle at the end of its lifeSpan
    131 
    132124  // particles
    133125  int maxCount;              //!< The maximum count of Particles.
     
    141133  GLuint dialectCount;       //!< How many different types of particles are there in the Particle System 
    142134
     135  // per particle attributes
    143136  QuickAnimation radiusAnim;
    144137  QuickAnimation randRadiusAnim;
  • orxonox/trunk/src/story_entities/world.cc

    r4430 r4431  
    474474  // Creating a Test Particle System
    475475  ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);
    476   system->setLifeSpan(1);
     476  system->setLifeSpan(.5);
    477477  system->setConserve(.8);
    478478  system->setRadius(0.0, 1.0, .6);
     479  system->setRadius(.2, 3, .2);
    479480  system->setRadius(1.0, 0.0, .0);
    480 
    481   system->setColor(.5,0,0,.5, 1,1,0,1, 0,0,0,0);
     481  system->setMass (0.0, 1.0);
     482
     483  system->setColor(0, .5,0,0,.5);
     484  system->setColor(.5, 1,1,0,1);
     485  system->setColor(1.0, 0,0,0,0);
    482486
    483487  // Creating a Test Particle Emitter
Note: See TracChangeset for help on using the changeset viewer.