Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

branches/atmospheric_engine: fadeins generalized

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
4 edited

Legend:

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

    r8327 r8356  
    2424SHELL_COMMAND(activate, FogEffect, activateFog);
    2525SHELL_COMMAND(deactivate, FogEffect, deactivateFog);
    26 SHELL_COMMAND(startfogging, FogEffect, startFogging);
     26SHELL_COMMAND(fadein, FogEffect, fadeInFog);
     27SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
     28
    2729
    2830using namespace std;
     
    137139                this->fogFadeDensity = progress * this->fogDensity;
    138140        }
     141        else if (this->fogFadeOutDuration > 0 && this->localTimer < this->fogFadeOutDuration) {
     142                this->localTimer += dt;
     143                float progress = this->localTimer / this->fogFadeInDuration;
     144                this->fogFadeDensity = 1 - progress * this->fogDensity;
     145        }
    139146}
    140147
    141 void FogEffect::startFogging() {
     148void FogEffect::fadeInFog() {
    142149
    143150        if (this->fogActivate)
     
    150157        this->activate();
    151158
     159}
     160
     161
     162void FogEffect::fadeOutFog() {
     163
     164        if (this->fogActivate)
     165                this->deactivate();
     166
     167        if (!this->fogFadeOutDuration > 0)
     168                this->fogFadeOutDuration = 20;
     169
     170        this->localTimer = 0;
     171        this->activate();
    152172}
    153173
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r8267 r8356  
    3838                inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; }
    3939
    40                 void startFogging();
     40                void fadeInFog();
     41                void fadeOutFog();
     42
    4143
    4244        private:
  • 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}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8267 r8356  
    3535                virtual bool deactivate();
    3636
     37                inline void activateRain() { this->activate(); }
     38                inline void deactivateRain() { this->deactivate(); }
     39
    3740                virtual void tick(float dt);
    3841
    39                 inline void activateRain() { this->activate(); }
    40                 inline void deactivateRain() { this->deactivate(); }
    4142                void startRaining();
     43                void stopRaining();
    4244
    4345                inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
     
    4749                inline void setRainLife(float life) { this->rainLife = life; }
    4850                inline void setRainWind(int force) { this->rainWindForce = force; }
    49                 inline void setRainStart(float duration) { this->rainFadeInDuration = duration; }
    5051
    5152                inline void setRainFadeIn(float fadein) { this->rainFadeInDuration = fadein; }
    5253                inline void setRainFadeOut(float fadeout) { this->rainFadeOutDuration = fadeout; }
    53 
    5454
    5555                inline void setRainOption(const std::string& option) {
Note: See TracChangeset for help on using the changeset viewer.