Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8434 in orxonox.OLD for branches/atmospheric_engine


Ignore:
Timestamp:
Jun 15, 2006, 1:01:31 AM (18 years ago)
Author:
amaechler
Message:

atmospheric_engine: fade work

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
3 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
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r8356 r8434  
    5353                GLint                           fogMode;
    5454                GLfloat                         fogDensity;
    55                 GLfloat                         fogFadeDensity;
     55                GLfloat                         fogFadeInDensity;
     56                GLfloat                         fogFadeOutDensity;
    5657
    5758                GLfloat                         fogStart;
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8356 r8434  
    3838CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT);
    3939
    40 // TODO: Dim Light with Rain, Finish preCaching, check out if multiple rain emitters work,  Think about what happens with building poss. to hang movewithcam off, benchmark, possible to activate lightening, turn off visibility when in a building, variable emitter size depending on playable, also rain velocity
     40/* TODO:
     41        - preCaching
     42        - test multiple rain emitters
     43        - Think about what happens with building poss. to hang movewithcam off
     44        - Possible to activate lightening
     45        - turn off visibility when in a building
     46        - variable emitter size depending on playable
     47*/
    4148
    4249RainEffect::RainEffect(const TiXmlElement* root)
     
    158165        if (this->rainWindForce != 0) this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce);
    159166
    160         lightMan->setAmbientColor(.1,.1,.1);
     167        if (this->rainFadeInDuration == 0)
     168                lightMan->setAmbientColor(.1,.1,.1);
    161169
    162170        return 0;
     
    195203
    196204                // Dim Light
    197                 lightMan->setAmbientColor(1.1 - progress, 1.1 - progress, 1.1 - progress);
     205                lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
    198206
    199207                // use alpha in color to fade in
     
    210218                // this->soundSource.fadein(this->rainBuffer, 10);
    211219        }
    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);
     220        else if ( this->rainFadeOutDuration != 0 ) {
     221                if ( this->localTimer < this->rainFadeOutDuration ) {
     222                        this->localTimer += dt;
     223                        float progress = 1 - (this->localTimer / this->rainFadeOutDuration);
     224       
     225                        // Fade In Light
     226                        lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
     227
     228                        // use alpha in color to fade out
     229                        RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     230                        RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     231                        RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     232       
     233                        // decrease radius
     234                        RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     235                        RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     236                        RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     237       
     238                        // decrease sound volume
     239                        // this->soundSource.fadeout(this->rainBuffer, 10);
     240                }
     241                else
     242                        this->deactivate();
    231243        }
    232244       
     
    242254
    243255        this->localTimer = 0;
     256
    244257        this->activate();
    245258
     
    248261void RainEffect::stopRaining() {
    249262
    250         if (this->rainActivate)
    251                 this->deactivate();
     263        if (!this->rainActivate)
     264                this->activate();
    252265
    253266        if (!this->rainFadeOutDuration > 0)
     
    255268
    256269        this->localTimer = 0;
    257         this->activate();
    258 
    259 }
     270
     271}
Note: See TracChangeset for help on using the changeset viewer.