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/fog_effect.cc

    r8373 r8434  
    123123void FogEffect::draw() const {
    124124
     125        // If Fog Fade In
    125126        if (this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration)
    126                 glFogf(GL_FOG_DENSITY, this->fogFadeDensity);
    127         //else
    128         //      glFogf(GL_FOG_DENSITY, this->fogDensity);
     127                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
     128
     129        // If Fog Fade Out
     130        else if (this->fogFadeOutDuration > 0 && this->localTimer < this->fogFadeOutDuration)
     131                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
     132
     133        // Normal Fog activate
     134        else
     135                glFogf(GL_FOG_DENSITY, this->fogDensity);
    129136
    130137}
     
    134141                return;
    135142               
    136         if (this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration) {
     143        if ( this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration ) {
    137144                this->localTimer += dt;
    138145                float progress = this->localTimer / this->fogFadeInDuration;
    139                 this->fogFadeDensity = progress * this->fogDensity;
     146                this->fogFadeInDensity = progress * this->fogDensity;
    140147        }
    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;
     148        else if ( this->fogFadeOutDuration > 0 ) {
     149                if ( this->localTimer < this->fogFadeOutDuration ) {
     150                        this->localTimer += dt;
     151                        float progress = this->localTimer / this->fogFadeInDuration;
     152                        this->fogFadeOutDensity = 1 - progress * this->fogDensity;
     153                }
     154                else
     155                        this->deactivate();
    145156        }
    146157}
     
    148159void FogEffect::fadeInFog() {
    149160
     161        // If Fog is already on, turn it off first
    150162        if (this->fogActivate)
    151163                this->deactivate();
    152164
     165        // If no manual FadeIn value was set, set a default value
    153166        if (!this->fogFadeInDuration > 0)
    154167                this->fogFadeInDuration = 20;
    155168
     169        // Reset local timer
    156170        this->localTimer = 0;
     171
     172        // Activate Fog
    157173        this->activate();
    158174
     
    162178void FogEffect::fadeOutFog() {
    163179
    164         if (this->fogActivate)
    165                 this->deactivate();
    166 
     180        // If Fog is off, turn it on first
     181        if (!this->fogActivate)
     182                this->activate();
     183
     184        // If no manual FadeOut value was set, set a default value
    167185        if (!this->fogFadeOutDuration > 0)
    168186                this->fogFadeOutDuration = 20;
    169187
     188        // Reset local timer
    170189        this->localTimer = 0;
    171         this->activate();
     190
    172191}
    173192
Note: See TracChangeset for help on using the changeset viewer.