Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2006, 9:36:31 AM (19 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: more rain and sound fadein hacking

File:
1 edited

Legend:

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

    r8180 r8181  
    167167void RainEffect::tick (float dt)
    168168{
    169         if (this->rainMove) {
    170                 this->rainCoord = State::getCameraNode()->getAbsCoor();
    171                 this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
    172         }
    173 
    174         if (this->rainStartDuration != 0 && this->localTimer < this->rainStartDuration) {
    175                 this->localTimer += dt;
    176                 float progress = this->localTimer / this->rainStartDuration;
    177 
    178                 // use alpha in color to fade in
    179                 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
    180                 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
    181                 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey
    182 
    183                 // increase radius for more "heavy" rain
    184                 RainEffect::rainParticles->setRadius(0, 0.03 * progress);
    185                 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
    186                 RainEffect::rainParticles->setRadius(1, 0.01 * progress);
    187 
    188                 // increase sound volume
    189                 this->soundSource.loop(this->rainBuffer, this->soundRainVolume * progress);
    190 
     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                }
     174       
     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                }
    191194        }
    192195}
    193196
    194197void RainEffect::startRaining() {
     198
     199        if (RainEffect::rainParticles != NULL)
     200                this->deactivate();
     201
    195202        this->rainStartDuration = 10;
    196         // this->activate;
    197 }
     203        this->localTimer = 0;
     204        this->activate();
     205
     206}
Note: See TracChangeset for help on using the changeset viewer.