Changeset 8771 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
- Timestamp:
- Jun 24, 2006, 3:35:07 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
r8734 r8771 20 20 #include "shell_command.h" 21 21 22 // Define shell commands 22 23 SHELL_COMMAND(activate, FogEffect, activateFog); 23 24 SHELL_COMMAND(deactivate, FogEffect, deactivateFog); … … 25 26 SHELL_COMMAND(fadeout, FogEffect, fadeOutFog); 26 27 27 // TODO: Fix fades28 29 28 using namespace std; 30 29 31 30 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT); 32 31 32 /** 33 * @brief standard constructor 34 */ 33 35 FogEffect::FogEffect(const TiXmlElement* root) { 34 36 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 35 37 38 // Initialize values 36 39 this->init(); 37 40 41 // Load XML params 38 42 if (root != NULL) 39 43 this->loadParams(root); 40 44 45 // Activate fog, if chosen to be activated by default 41 46 if (this->fogActivate) 42 47 this->activate(); 43 48 } 44 49 45 50 /** 51 * @brief standard destructor 52 */ 46 53 FogEffect::~FogEffect() { 47 54 this->deactivate(); 48 55 } 49 56 50 57 /** 58 * @brief initalizes the fog effect with default values 59 */ 60 void FogEffect::init() { 61 // default values 62 this->fogMode = GL_LINEAR; 63 this->fogDensity = 0.005; 64 this->fogStart = 0; 65 this->fogEnd = 300; 66 this->colorVector = Vector(0.6, 0.0, 0.0); 67 68 // init variables 69 this->fogFadeInDuration = 0; 70 this->fogFadeOutDuration = 0; 71 this->fogFadeDensity = 0; 72 this->fogFadeEnd = 0; 73 74 this->localTimer = 0; 75 this->fogActivate = false; 76 this->fogFadeInActivate = false; 77 this->fogFadeOutActivate = false; 78 } 79 80 /** 81 * @brief loads the fog effect parameters. 82 * @param root: the XML-Element to load the data from 83 */ 51 84 void FogEffect::loadParams(const TiXmlElement* root) { 52 85 WeatherEffect::loadParams(root); 53 86 54 LoadParam(root, "mode", this, FogEffect, setFogMode) ;55 LoadParam(root, "density", this, FogEffect, setFogDensity) ;56 LoadParam(root, "range", this, FogEffect, setFogRange) ;57 LoadParam(root, "color", this, FogEffect, setFogColor) ;58 LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn) ;59 LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut) ;87 LoadParam(root, "mode", this, FogEffect, setFogMode).describe("fog mode (linear, exponential)");; 88 LoadParam(root, "density", this, FogEffect, setFogDensity).describe("fog density if exp. fog");; 89 LoadParam(root, "range", this, FogEffect, setFogRange).describe("fog range: start, end");; 90 LoadParam(root, "color", this, FogEffect, setFogColor).describe("fog color: r,g,b");; 91 LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn).describe("duration of the fade in");; 92 LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut).describe("duration of the fade out");; 60 93 61 94 LOAD_PARAM_START_CYCLE(root, element); 62 95 { 63 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption);96 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption).describe("sets a fog option: activate");; 64 97 } 65 98 LOAD_PARAM_END_CYCLE(element); 66 99 } 67 100 68 void FogEffect::init() { 69 // default values 70 this->fogMode = GL_LINEAR; 71 this->fogDensity = 0.005; 72 this->fogStart = 0; 73 this->fogEnd = 300; 74 this->colorVector = Vector(0.6, 0.0, 0.0); 75 76 // init variables 77 this->fogFadeInDuration = 0; 78 this->fogFadeOutDuration = 0; 79 this->fogFadeDensity = 0; 80 this->fogFadeEnd = 0; 81 82 this->localTimer = 0; 83 this->fogActivate = false; 84 this->fogFadeInActivate = false; 85 this->fogFadeOutActivate = false; 86 87 } 88 89 101 /** 102 * @brief activates the fog effect 103 */ 90 104 void FogEffect::activate() { 91 105 PRINTF(0)( "Activating FogEffect\n"); … … 103 117 104 118 glEnable(GL_FOG); 105 106 } 107 108 119 } 120 121 /** 122 * @brief deactivates the fog effect 123 */ 109 124 void FogEffect::deactivate() { 110 125 PRINTF(0)("Deactivating FogEffect\n"); … … 115 130 116 131 glDisable(GL_FOG); 117 118 } 119 132 } 133 134 /** 135 * @brief draws the fog effect 136 */ 120 137 void FogEffect::draw() const { 121 138 … … 123 140 return; 124 141 125 // If Fog Fade142 // If fog is fading 126 143 if ( this->fogFadeInActivate || this->fogFadeOutActivate ) { 127 144 if ( this->fogMode == GL_LINEAR) … … 132 149 } 133 150 151 /** 152 * @brief ticks the fog effect 153 * @param dt: tick float 154 */ 134 155 void FogEffect::tick(float dt) { 135 156 … … 137 158 return; 138 159 160 // If fog is fading in 139 161 if ( this->fogFadeInActivate ) { 140 162 this->localTimer += dt; … … 149 171 } 150 172 173 // If fog is fading out 151 174 if ( this->fogFadeOutActivate ) { 152 175 this->localTimer += dt; … … 162 185 } 163 186 187 /** 188 * @brief fades the fog in 189 */ 164 190 void FogEffect::fadeInFog() { 165 191 … … 183 209 // set FogFadeIn activate 184 210 this->fogFadeInActivate = true; 185 186 } 187 188 211 } 212 213 /** 214 * @brief fades the fog out 215 */ 189 216 void FogEffect::fadeOutFog() { 190 217 … … 205 232 // Reset local timer 206 233 this->localTimer = 0; 207 208 } 209 234 } 235
Note: See TracChangeset
for help on using the changeset viewer.