Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 15, 2006, 1:01:31 AM (18 years ago)
Author:
amaechler
Message:

atmospheric_engine: fade work

File:
1 edited

Legend:

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

    r8356 r8434  
    3838CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT);
    3939
    40 // TODO: Dim Light with Rain, Finish preCaching, check out if multiple rain emitters work,  Think about what happens with building poss. to hang movewithcam off, benchmark, possible to activate lightening, turn off visibility when in a building, variable emitter size depending on playable, also rain velocity
     40/* TODO:
     41        - preCaching
     42        - test multiple rain emitters
     43        - Think about what happens with building poss. to hang movewithcam off
     44        - Possible to activate lightening
     45        - turn off visibility when in a building
     46        - variable emitter size depending on playable
     47*/
    4148
    4249RainEffect::RainEffect(const TiXmlElement* root)
     
    158165        if (this->rainWindForce != 0) this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce);
    159166
    160         lightMan->setAmbientColor(.1,.1,.1);
     167        if (this->rainFadeInDuration == 0)
     168                lightMan->setAmbientColor(.1,.1,.1);
    161169
    162170        return 0;
     
    195203
    196204                // Dim Light
    197                 lightMan->setAmbientColor(1.1 - progress, 1.1 - progress, 1.1 - progress);
     205                lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
    198206
    199207                // use alpha in color to fade in
     
    210218                // this->soundSource.fadein(this->rainBuffer, 10);
    211219        }
    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);
     220        else if ( this->rainFadeOutDuration != 0 ) {
     221                if ( this->localTimer < this->rainFadeOutDuration ) {
     222                        this->localTimer += dt;
     223                        float progress = 1 - (this->localTimer / this->rainFadeOutDuration);
     224       
     225                        // Fade In Light
     226                        lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
     227
     228                        // use alpha in color to fade out
     229                        RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     230                        RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     231                        RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     232       
     233                        // decrease radius
     234                        RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     235                        RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     236                        RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     237       
     238                        // decrease sound volume
     239                        // this->soundSource.fadeout(this->rainBuffer, 10);
     240                }
     241                else
     242                        this->deactivate();
    231243        }
    232244       
     
    242254
    243255        this->localTimer = 0;
     256
    244257        this->activate();
    245258
     
    248261void RainEffect::stopRaining() {
    249262
    250         if (this->rainActivate)
    251                 this->deactivate();
     263        if (!this->rainActivate)
     264                this->activate();
    252265
    253266        if (!this->rainFadeOutDuration > 0)
     
    255268
    256269        this->localTimer = 0;
    257         this->activate();
    258 
    259 }
     270
     271}
Note: See TracChangeset for help on using the changeset viewer.