Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 22, 2006, 1:57:16 PM (19 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: FogFade finally fixed

File:
1 edited

Legend:

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

    r8704 r8716  
    7878    this->fogFadeOutDuration = 0;
    7979    this->fogFadeDensity = 0;
     80    this->fogFadeEnd = 0;
     81
    8082    this->localTimer = 0;
    8183    this->fogActivate = false;
     
    123125    // If Fog Fade
    124126    if ( this->fogFadeInActivate || this->fogFadeOutActivate ) {
    125       glDisable(GL_FOG);
    126 
    127       GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
    128       glFogi(GL_FOG_MODE, this->fogMode);
    129       glFogfv(GL_FOG_COLOR, fogColor);
    130       glHint(GL_FOG_HINT, GL_DONT_CARE);
    131       glFogf(GL_FOG_DENSITY, this->fogFadeDensity);
    132       glFogf(GL_FOG_START, this->fogStart);
    133       glFogf(GL_FOG_END, this->fogEnd);
    134 
    135       glEnable(GL_FOG);
     127        if ( this->fogMode == GL_LINEAR)
     128            glFogf(GL_FOG_END, this->fogFadeEnd);
     129        else
     130            glFogf(GL_FOG_DENSITY, this->fogFadeDensity);
    136131    }
    137132}
     
    144139    if ( this->fogFadeInActivate ) {
    145140        this->localTimer += dt;
    146         this->fogFadeDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity;
    147 
    148         if ( this->localTimer >= this->fogFadeOutDuration )
     141
     142        if ( this->fogMode == GL_LINEAR)
     143          this->fogFadeEnd = 2000 * (1 - ( this->localTimer / this->fogFadeInDuration )) + this->fogEnd;
     144        else
     145            this->fogFadeDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity;
     146
     147        if ( this->localTimer >= this->fogFadeInDuration )
    149148            this->fogFadeInActivate = false;
    150149    }
     
    152151    if ( this->fogFadeOutActivate ) {
    153152        this->localTimer += dt;
    154         this->fogFadeDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
     153
     154        if ( this->fogMode == GL_LINEAR)
     155          this->fogFadeEnd = 2000 * ( this->localTimer / this->fogFadeInDuration ) + this->fogEnd;
     156        else
     157            this->fogFadeDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
    155158
    156159        if ( this->localTimer >= this->fogFadeOutDuration )
     
    175178    this->localTimer = 0;
    176179
     180    // Activate Fog
     181    this->activate();
     182
    177183    // set FogFadeIn activate
    178184    this->fogFadeInActivate = true;
    179 
    180     // Activate Fog
    181     this->activate();
    182185
    183186}
Note: See TracChangeset for help on using the changeset viewer.