Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2006, 2:15:03 AM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: fadeins generalized

File:
1 edited

Legend:

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

    r8327 r8356  
    3131SHELL_COMMAND(activate, RainEffect, activateRain);
    3232SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
    33 
    34 SHELL_COMMAND(startRaining, RainEffect, startRaining);
     33SHELL_COMMAND(startraining, RainEffect, startRaining);
     34SHELL_COMMAND(stopraining, RainEffect, stopRaining);
    3535
    3636using namespace std;
     
    210210                // this->soundSource.fadein(this->rainBuffer, 10);
    211211        }
     212        else if (this->rainFadeOutDuration != 0 && this->localTimer < this->rainFadeOutDuration) {
     213                this->localTimer += dt;
     214                float progress = 1 - (this->localTimer / this->rainFadeOutDuration);
     215
     216                // Dim Light
     217                lightMan->setAmbientColor(1.1 - progress, 1.1 - progress, 1.1 - progress);
     218
     219                // use alpha in color to fade in
     220                RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     221                RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     222                RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     223
     224                // increase radius for more "heavy" rain
     225                RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     226                RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     227                RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     228
     229                // increase sound volume
     230                // this->soundSource.fadein(this->rainBuffer, 10);
     231        }
    212232       
    213233}
     
    225245
    226246}
     247
     248void RainEffect::stopRaining() {
     249
     250        if (this->rainActivate)
     251                this->deactivate();
     252
     253        if (!this->rainFadeOutDuration > 0)
     254                this->rainFadeOutDuration = 20;
     255
     256        this->localTimer = 0;
     257        this->activate();
     258
     259}
Note: See TracChangeset for help on using the changeset viewer.