Changeset 8455 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
- Timestamp:
- Jun 15, 2006, 1:12:24 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
r8445 r8455 71 71 } 72 72 73 bool FogEffect::init() 74 { 75 //default values 76 this->fogActivate = false; 73 void 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 77 83 this->fogFadeInDuration = 0; 78 84 this->fogFadeOutDuration = 0; 85 this->fogFadeInDensity = 0; 86 this->fogFadeOutDensity = 0; 79 87 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 95 void FogEffect::activate() 92 96 { 93 97 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); … … 102 106 glFogf(GL_FOG_END, this->fogEnd); 103 107 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 106 115 glEnable(GL_FOG); 107 116 108 return 0; 109 } 110 111 112 bool FogEffect::deactivate() 117 } 118 119 120 void FogEffect::deactivate() 113 121 { 114 122 PRINTF(0)("Deactivating FogEffect\n"); … … 120 128 glDisable(GL_FOG); 121 129 122 return 0;123 130 } 124 131 125 132 void FogEffect::draw() const { 126 133 134 if (!this->fogActivate) 135 return; 136 127 137 // If Fog Fade In 128 if ( this->fogFadeInActivate ) {138 if ( this->fogFadeInActivate ) 129 139 glFogf(GL_FOG_DENSITY, this->fogFadeInDensity); 130 // PRINTF(0)( "this->fogFadeInDensity: %f\n", this->fogFadeInDensity); 131 } 140 132 141 // If Fog Fade Out 133 elseif ( this->fogFadeOutActivate )142 if ( this->fogFadeOutActivate ) 134 143 glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity); 135 136 // Normal Fog activate137 else138 glFogf(GL_FOG_DENSITY, this->fogDensity);139 144 140 145 } … … 147 152 if ( this->fogFadeInActivate ) { 148 153 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; 151 155 152 156 if ( this->localTimer >= this->fogFadeOutDuration ) 153 157 this->fogFadeInActivate = false; 154 158 } 155 else if ( this->fogFadeOutActivate ) { 159 160 if ( this->fogFadeOutActivate ) { 156 161 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); 159 163 160 164 if ( this->localTimer >= this->fogFadeOutDuration )
Note: See TracChangeset
for help on using the changeset viewer.