Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 8, 2006, 2:04:37 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: general activate, cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8181 r8242  
    125125        PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" );
    126126
     127        this->rainActivate = true;
     128
    127129        if (unlikely(RainEffect::rainParticles == NULL))
    128130        {
     
    134136                RainEffect::rainParticles->setRadius(0.2, 0.02);
    135137                RainEffect::rainParticles->setRadius(1, 0.01);
    136                 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2); // grey blue 1
    137                 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2); // grey blue 2
    138                 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2); // light grey
     138                RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2);     // grey blue 1
     139                RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2);   // grey blue 2
     140                RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2);     // light grey
    139141        }
    140142
     
    158160{
    159161        PRINTF(0)("Deactivating RainEffect\n");
     162       
     163        this->rainActivate = false;
    160164        this->emitter->setSystem(NULL);
    161 
    162165        this->soundSource.stop();
    163166
     
    167170void RainEffect::tick (float dt)
    168171{
    169         if (RainEffect::rainParticles != NULL) {
    170                 if (this->rainMove) {
    171                         this->rainCoord = State::getCameraNode()->getAbsCoor();
    172                         this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
    173                 }
     172        if (!this->rainActivate)
     173                return;
     174               
     175        if (this->rainMove) {
     176                this->rainCoord = State::getCameraNode()->getAbsCoor();
     177                this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
     178        }
     179
     180        if (this->rainStartDuration != 0 && this->localTimer < this->rainStartDuration) {
     181                this->localTimer += dt;
     182                float progress = this->localTimer / this->rainStartDuration;
     183
     184                // PRINTF(0)("Progress %f: \n", progress);
     185
     186                // use alpha in color to fade in
     187                RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     188                RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     189                RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     190
     191                // increase radius for more "heavy" rain
     192                RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     193                RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     194                RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     195
     196                // increase sound volume
     197                // this->soundSource.fadein(this->rainBuffer, 10);
     198        }
    174199       
    175                 if (this->rainStartDuration != 0 && this->localTimer < this->rainStartDuration) {
    176                         this->localTimer += dt;
    177                         float progress = this->localTimer / this->rainStartDuration;
    178        
    179                         // PRINTF(0)("Progress %f: \n", progress);
    180        
    181                         // use alpha in color to fade in
    182                         RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
    183                         RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
    184                         RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
    185        
    186                         // increase radius for more "heavy" rain
    187                         RainEffect::rainParticles->setRadius(0, 0.03 * progress);
    188                         RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
    189                         RainEffect::rainParticles->setRadius(1, 0.01 * progress);
    190        
    191                         // increase sound volume
    192                         // this->soundSource.fadein(this->rainBuffer, 10);
    193                 }
    194         }
    195200}
    196201
    197202void RainEffect::startRaining() {
    198203
    199         if (RainEffect::rainParticles != NULL)
     204        if (this->rainActivate)
    200205                this->deactivate();
    201206
Note: See TracChangeset for help on using the changeset viewer.