Changeset 7652 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
- Timestamp:
- May 17, 2006, 6:41:58 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
r7628 r7652 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2004 orx 5 5 6 7 8 9 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler 13 13 */ 14 14 … … 22 22 /*#include "shell_command.h" 23 23 SHELL_COMMAND(activateFog, FogEffect, FogEffect::activate) 24 24 ->setAlias("aFog"); 25 25 SHELL_COMMAND(deactivateFog, FogEffect, FogEffect::deactivate) 26 26 ->setAlias("dFog");*/ 27 27 28 28 using namespace std; … … 32 32 FogEffect::FogEffect(const TiXmlElement* root) 33 33 { 34 35 36 37 38 39 34 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 35 36 this->fogMode = GL_LINEAR; 37 this->fogDensity = 0.001f; 38 this->fogStart = 10.0f; 39 this->fogEnd = 1000.0f; 40 40 41 42 41 if (root != NULL) 42 this->loadParams(root); 43 43 44 44 this->activate(); 45 45 } 46 46 … … 49 49 FogEffect::~FogEffect() 50 50 { 51 51 this->deactivate(); 52 52 } 53 53 … … 55 55 void FogEffect::loadParams(const TiXmlElement* root) 56 56 { 57 57 WeatherEffect::loadParams(root); 58 58 59 60 61 59 LoadParam(root, "fog-mode", this, FogEffect, setFogMode); 60 LoadParam(root, "fog-density", this, FogEffect, setFogDensity); 61 LoadParam(root, "fog-color", this, FogEffect, setFogColor); 62 62 63 63 … … 71 71 bool FogEffect::activate() 72 72 { 73 73 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); 74 74 75 76 77 78 75 glEnable(GL_FOG); 76 { 77 //GLfloat fogColor[4] = {0.7, 0.6, 0.6, 1.0}; 78 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 79 79 80 81 82 83 84 85 80 glFogi(GL_FOG_MODE, this->fogMode); 81 glFogfv(GL_FOG_COLOR, fogColor); 82 glFogf(GL_FOG_DENSITY, this->fogDensity); 83 glHint(GL_FOG_HINT, GL_DONT_CARE); 84 glFogf(GL_FOG_START, this->fogStart); 85 glFogf(GL_FOG_END, this->fogEnd); 86 86 87 88 89 87 //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE); 88 } 89 glClearColor(0.5, 0.5, 0.5, 1.0); 90 90 } 91 91 … … 93 93 bool FogEffect::deactivate() 94 94 { 95 95 PRINTF(0)("Deactivating FogEffect\n"); 96 96 glDisable(GL_FOG); 97 97 } … … 101 101 GLint FogEffect::stringToFogMode(const std::string& mode) 102 102 { 103 104 105 106 107 108 109 110 103 if(mode == "GL_LINEAR") 104 return GL_LINEAR; 105 else if(mode == "GL_EXP") 106 return GL_EXP; 107 else if(mode == "GL_EXP2" ) 108 return GL_EXP2; 109 else 110 return -1; 111 111 } 112 112
Note: See TracChangeset
for help on using the changeset viewer.