Changeset 8253 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics
- Timestamp:
- Jun 8, 2006, 3:21:15 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src/lib/graphics/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
r8247 r8253 24 24 SHELL_COMMAND(activate, FogEffect, activateFog); 25 25 SHELL_COMMAND(deactivate, FogEffect, deactivateFog); 26 SHELL_COMMAND(startfogging, FogEffect, startFogging); 26 27 27 28 using namespace std; … … 69 70 //default values 70 71 this->fogActivate = false; 72 this->fogFadeDuration = 0; 73 this->localTimer = 0; 74 71 75 this->fogMode = GL_EXP2; 72 76 this->fogDensity = 0.001; … … 74 78 this->fogEnd = 5000; 75 79 this->colorVector = Vector(0.7, 0.7, 0.7); 80 76 81 } 77 82 … … 82 87 83 88 this->fogActivate = true; 84 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 85 98 glEnable(GL_FOG); 86 { 87 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 88 89 glFogi(GL_FOG_MODE, this->fogMode); 90 glFogfv(GL_FOG_COLOR, fogColor); 91 glFogf(GL_FOG_DENSITY, this->fogDensity); 92 glHint(GL_FOG_HINT, GL_DONT_CARE); 93 glFogf(GL_FOG_START, this->fogStart); 94 glFogf(GL_FOG_END, this->fogEnd); 95 } 96 glClearColor(0.5, 0.5, 0.5, 1.0); 99 // glClearColor(0.5, 0.5, 0.5, 1.0); 97 100 } 98 101 … … 105 108 106 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 107 142 } 108 143 -
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h
r8247 r8253 26 26 void deactivateFog() { this->deactivate(); } 27 27 28 virtual void draw() const; 29 virtual void tick(float dt); 30 28 31 inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); } 29 32 inline void setFogDensity(float density) { this->fogDensity = density; } … … 32 35 inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; } 33 36 37 void startFogging(); 38 34 39 private: 35 40 GLint stringToFogMode(const std::string& mode); 36 41 37 42 bool fogActivate; 38 43 GLfloat fogFadeDuration; 44 float localTimer; 45 39 46 GLint fogMode; 40 47 GLfloat fogDensity; 48 GLfloat fogFadeDensity; 49 41 50 GLfloat fogStart; 42 51 GLfloat fogEnd;
Note: See TracChangeset
for help on using the changeset viewer.