Changeset 8255 in orxonox.OLD for trunk/src/lib/graphics/effects/fog_effect.cc
- Timestamp:
- Jun 8, 2006, 3:44:12 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/effects/fog_effect.cc
r7810 r8255 20 20 #include "glincl.h" 21 21 22 /*#include "shell_command.h"23 SHELL_COMMAND(activateFog, FogEffect, FogEffect::activate) 24 ->setAlias("aFog");25 SHELL_COMMAND(deactivate Fog, FogEffect, FogEffect::deactivate)26 ->setAlias("dFog");*/ 22 #include "shell_command.h" 23 24 SHELL_COMMAND(activate, FogEffect, activateFog); 25 SHELL_COMMAND(deactivate, FogEffect, deactivateFog); 26 SHELL_COMMAND(startfogging, FogEffect, startFogging); 27 27 28 28 using namespace std; … … 39 39 this->loadParams(root); 40 40 41 this->activate(); 41 if (this->fogActivate) 42 this->activate(); 42 43 } 43 44 … … 57 58 LoadParam(root, "range", this, FogEffect, setFogRange); 58 59 LoadParam(root, "color", this, FogEffect, setFogColor); 60 61 LOAD_PARAM_START_CYCLE(root, element); 62 { 63 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption); 64 } 65 LOAD_PARAM_END_CYCLE(element); 59 66 } 60 67 … … 62 69 { 63 70 //default values 71 this->fogActivate = false; 72 this->fogFadeDuration = 0; 73 this->localTimer = 0; 74 64 75 this->fogMode = GL_EXP2; 65 76 this->fogDensity = 0.001; 66 77 this->fogStart = 0; 67 78 this->fogEnd = 5000; 68 this->colorVector = Vector(0.7, 0.7, 0.7); 79 this->colorVector = Vector(0.7, 0.7, 0.7); 80 69 81 } 70 71 82 72 83 … … 75 86 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); 76 87 88 this->fogActivate = true; 89 90 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 91 glFogi(GL_FOG_MODE, this->fogMode); 92 glFogfv(GL_FOG_COLOR, fogColor); 93 glFogf(GL_FOG_DENSITY, this->fogDensity); 94 glHint(GL_FOG_HINT, GL_DONT_CARE); 95 glFogf(GL_FOG_START, this->fogStart); 96 glFogf(GL_FOG_END, this->fogEnd); 97 77 98 glEnable(GL_FOG); 78 { 79 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 80 81 glFogi(GL_FOG_MODE, this->fogMode); 82 glFogfv(GL_FOG_COLOR, fogColor); 83 glFogf(GL_FOG_DENSITY, this->fogDensity); 84 glHint(GL_FOG_HINT, GL_DONT_CARE); 85 glFogf(GL_FOG_START, this->fogStart); 86 glFogf(GL_FOG_END, this->fogEnd); 87 } 88 glClearColor(0.5, 0.5, 0.5, 1.0); 99 // glClearColor(0.5, 0.5, 0.5, 1.0); 89 100 } 90 101 … … 93 104 { 94 105 PRINTF(0)("Deactivating FogEffect\n"); 106 107 this->fogActivate = false; 108 95 109 glDisable(GL_FOG); 110 } 111 112 void FogEffect::draw() const { 113 114 if (this->fogFadeDuration != 0 && this->localTimer < this->fogFadeDuration) 115 glFogf(GL_FOG_DENSITY, this->fogFadeDensity); 116 //else 117 // glFogf(GL_FOG_DENSITY, this->fogDensity); 118 119 } 120 void FogEffect::tick(float dt) 121 { 122 if (!this->fogActivate) 123 return; 124 125 126 if (this->fogFadeDuration != 0 && this->localTimer < this->fogFadeDuration) { 127 this->localTimer += dt; 128 float progress = this->localTimer / this->fogFadeDuration; 129 this->fogFadeDensity = progress * this->fogDensity; 130 } 131 } 132 133 void FogEffect::startFogging() { 134 135 if (this->fogActivate) 136 this->deactivate(); 137 138 this->fogFadeDuration = 10; 139 this->localTimer = 0; 140 this->activate(); 141 96 142 } 97 143
Note: See TracChangeset
for help on using the changeset viewer.