Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 15, 2006, 1:12:24 PM (19 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: fog & changed init & activate fcts from bool to void

File:
1 edited

Legend:

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

    r8445 r8455  
    7171}
    7272
    73 bool FogEffect::init()
    74 {
    75         //default values
    76         this->fogActivate = false;
     73void FogEffect::init()
     74{
     75        // default values
     76        this->fogMode = GL_LINEAR;
     77        this->fogDensity = 0.03;
     78        this->fogStart = 0;
     79        this->fogEnd = 50;
     80        this->colorVector = Vector(0.3, 0.3, 0.3);
     81
     82        // init variables
    7783        this->fogFadeInDuration = 0;
    7884        this->fogFadeOutDuration = 0;
     85        this->fogFadeInDensity = 0;
     86        this->fogFadeOutDensity = 0;
    7987        this->localTimer = 0;
    80        
    81         this->fogMode = GL_LINEAR;
    82         this->fogDensity = 0.05;
    83         this->fogStart = 0;
    84         this->fogEnd = 500;
    85         this->colorVector = Vector(0.3, 0.3, 0.3);
    86 
    87         return 0;
    88 }
    89 
    90 
    91 bool FogEffect::activate()
     88        this->fogActivate = false;
     89        this->fogFadeInActivate = false;
     90        this->fogFadeOutActivate = false;
     91
     92}
     93
     94
     95void FogEffect::activate()
    9296{
    9397        PRINTF(0)( "Enabling FogEffect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
     
    102106        glFogf(GL_FOG_END, this->fogEnd);
    103107
    104         // glFogf(GL_FOG_DENSITY, this->fogDensity);
    105 
     108        if ( this->fogFadeInActivate )
     109                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
     110        else if ( this->fogFadeOutActivate )
     111                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
     112        else
     113                glFogf(GL_FOG_DENSITY, this->fogDensity);
     114               
    106115        glEnable(GL_FOG);
    107116
    108         return 0;
    109 }
    110 
    111 
    112 bool FogEffect::deactivate()
     117}
     118
     119
     120void FogEffect::deactivate()
    113121{
    114122        PRINTF(0)("Deactivating FogEffect\n");
     
    120128        glDisable(GL_FOG);
    121129
    122         return 0;
    123130}
    124131
    125132void FogEffect::draw() const {
    126133
     134        if (!this->fogActivate)
     135                return;
     136
    127137        // If Fog Fade In
    128         if ( this->fogFadeInActivate ) {
     138        if ( this->fogFadeInActivate )
    129139                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
    130                 // PRINTF(0)( "this->fogFadeInDensity: %f\n", this->fogFadeInDensity);
    131         }
     140
    132141        // If Fog Fade Out
    133         else if ( this->fogFadeOutActivate )
     142        if ( this->fogFadeOutActivate )
    134143                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
    135 
    136         // Normal Fog activate
    137         else
    138                 glFogf(GL_FOG_DENSITY, this->fogDensity);
    139144
    140145}
     
    147152        if ( this->fogFadeInActivate ) {
    148153                this->localTimer += dt;
    149                 float progress = this->localTimer / this->fogFadeInDuration;
    150                 this->fogFadeInDensity = progress * this->fogDensity;
     154                this->fogFadeInDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity;
    151155
    152156                if ( this->localTimer >= this->fogFadeOutDuration )
    153157                        this->fogFadeInActivate = false;
    154158        }
    155         else if ( this->fogFadeOutActivate ) {
     159
     160        if ( this->fogFadeOutActivate ) {
    156161                this->localTimer += dt;
    157                 float progress = this->localTimer / this->fogFadeInDuration;
    158                 this->fogFadeOutDensity = 1 - progress * this->fogDensity;
     162                this->fogFadeOutDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
    159163
    160164                if ( this->localTimer >= this->fogFadeOutDuration )
Note: See TracChangeset for help on using the changeset viewer.