Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8443 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 11:27:47 AM (18 years ago)
Author:
amaechler
Message:

branches/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

    r8434 r8443  
    9898        glFogi(GL_FOG_MODE, this->fogMode);
    9999        glFogfv(GL_FOG_COLOR, fogColor);
    100         glFogf(GL_FOG_DENSITY, this->fogDensity);
    101100        glHint(GL_FOG_HINT, GL_DONT_CARE);
    102101        glFogf(GL_FOG_START, this->fogStart);
    103102        glFogf(GL_FOG_END, this->fogEnd);
    104        
     103
     104        // glFogf(GL_FOG_DENSITY, this->fogDensity);
     105
    105106        glEnable(GL_FOG);
    106         // glClearColor(0.5, 0.5, 0.5, 1.0);
    107107
    108108        return 0;
     
    114114        PRINTF(0)("Deactivating FogEffect\n");
    115115
     116        this->fogFadeInActivate = false;
     117        this->fogFadeOutActivate = false;
    116118        this->fogActivate = false;
    117119       
     
    124126
    125127        // If Fog Fade In
    126         if (this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration)
     128        if ( this->fogFadeInActivate ) {
    127129                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
    128 
     130                PRINTF(0)( "this->fogFadeInDensity: %f", this->fogFadeInDensity);
     131        }
    129132        // If Fog Fade Out
    130         else if (this->fogFadeOutDuration > 0 && this->localTimer < this->fogFadeOutDuration)
     133        else if ( this->fogFadeOutActivate )
    131134                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
    132135
     
    136139
    137140}
     141
    138142void FogEffect::tick(float dt)
    139143{
     
    141145                return;
    142146               
    143         if ( this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration ) {
     147        if ( this->fogFadeInActivate ) {
    144148                this->localTimer += dt;
    145149                float progress = this->localTimer / this->fogFadeInDuration;
    146150                this->fogFadeInDensity = progress * this->fogDensity;
    147         }
    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
     151
     152                if ( this->localTimer >= this->fogFadeOutDuration )
     153                        this->fogFadeInActivate = false;
     154        }
     155        else if ( this->fogFadeOutActivate ) {
     156                this->localTimer += dt;
     157                float progress = this->localTimer / this->fogFadeInDuration;
     158                this->fogFadeOutDensity = 1 - progress * this->fogDensity;
     159
     160                if ( this->localTimer >= this->fogFadeOutDuration )
    155161                        this->deactivate();
    156162        }
     
    158164
    159165void FogEffect::fadeInFog() {
     166
     167        // If Fog is already fading out, stop it
     168        this->fogFadeOutActivate = false;
    160169
    161170        // If Fog is already on, turn it off first
     
    170179        this->localTimer = 0;
    171180
     181        // set FogFadeIn activate
     182        this->fogFadeInActivate = true;
     183
    172184        // Activate Fog
    173185        this->activate();
     
    177189
    178190void FogEffect::fadeOutFog() {
     191
     192        // If Fog is already fading in, stop it
     193        this->fogFadeInActivate = false;
    179194
    180195        // If Fog is off, turn it on first
     
    185200        if (!this->fogFadeOutDuration > 0)
    186201                this->fogFadeOutDuration = 20;
     202
     203        // set FogFadeOut activate
     204        this->fogFadeOutActivate = true;
    187205
    188206        // Reset local timer
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r8434 r8443  
    4646
    4747                bool                            fogActivate;
     48
     49                bool                            fogFadeInActivate;
     50                bool                            fogFadeOutActivate;
     51
    4852                GLfloat                         fogFadeInDuration;
    4953                GLfloat                         fogFadeOutDuration;
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8434 r8443  
    143143                RainEffect::rainParticles = new SparkParticles((int) this->rainMaxParticles);
    144144                RainEffect::rainParticles->setName("RainParticles");
    145                 RainEffect::rainParticles->precache((int)this->rainLife);
     145                RainEffect::rainParticles->precache((int)this->rainLife, 30); // TODO: Why doesnt this work??
    146146                RainEffect::rainParticles->setLifeSpan(this->rainLife, 2);
    147147                RainEffect::rainParticles->setRadius(0, 0.03);
Note: See TracChangeset for help on using the changeset viewer.