Changeset 7810 in orxonox.OLD for trunk/src/lib/graphics/effects/fog_effect.cc
- Timestamp:
- May 24, 2006, 3:57:04 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/effects/fog_effect.cc
r7221 r7810 1 /* 2 orxonox - the future of 3D-vertical-scrollers 1 3 4 Copyright (C) 2004 orx 2 5 3 /* 4 orxonox - the future of 3D-vertical-scrollers 5 6 Copyright (C) 2004 orx 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option) 11 any later version. 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. 12 10 13 11 ### File Specific: 14 main-programmer: Patrick Boenzli 12 main-programmer: hdavid, amaechler 15 13 */ 16 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS18 14 19 15 #include "fog_effect.h" … … 24 20 #include "glincl.h" 25 21 26 22 /*#include "shell_command.h" 23 SHELL_COMMAND(activateFog, FogEffect, FogEffect::activate) 24 ->setAlias("aFog"); 25 SHELL_COMMAND(deactivateFog, FogEffect, FogEffect::deactivate) 26 ->setAlias("dFog");*/ 27 27 28 28 using namespace std; … … 30 30 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT); 31 31 32 FogEffect::FogEffect(const TiXmlElement* root) 33 { 34 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 32 35 33 /** 34 * default constructor 35 * @param root The XML-element to load the FogEffect from 36 */ 37 FogEffect::FogEffect(const TiXmlElement* root) 38 { 39 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 36 this->init(); 40 37 41 this->fogMode = GL_LINEAR; 42 this->fogDensity = 0.001f; 43 this->fogStart = 10.0f; 44 this->fogEnd = 1000.0f; 38 if (root != NULL) 39 this->loadParams(root); 45 40 46 if (root != NULL) 47 this->loadParams(root); 48 49 this->activate(); 41 this->activate(); 50 42 } 51 43 52 44 53 /**54 * destroys a FogEffect55 */56 45 FogEffect::~FogEffect() 57 46 { 58 47 this->deactivate(); 59 48 } 60 49 61 50 62 /**63 * @param root The XML-element to load the FogEffect from64 */65 51 void FogEffect::loadParams(const TiXmlElement* root) 66 52 { 67 GraphicsEffect::loadParams(root);53 WeatherEffect::loadParams(root); 68 54 55 LoadParam(root, "mode", this, FogEffect, setFogMode); 56 LoadParam(root, "density", this, FogEffect, setFogDensity); 57 LoadParam(root, "range", this, FogEffect, setFogRange); 58 LoadParam(root, "color", this, FogEffect, setFogColor); 59 } 69 60 70 LoadParam(root, "fog-mode", this, FogEffect, setFogMode) 71 .describe("sets the the fog mode {GL_LINEAR, GL_EXP, GL_EXP2}"); 72 73 LoadParam(root, "fog-density", this, FogEffect, setFogDensity) 74 .describe("sets the the fog density of the exponentionl functions"); 75 76 LoadParam(root, "fog-color", this, FogEffect, setFogColor) 77 .describe("sets the fog color"); 78 61 bool FogEffect::init() 62 { 63 //default values 64 this->fogMode = GL_EXP2; 65 this->fogDensity = 0.001; 66 this->fogStart = 0; 67 this->fogEnd = 5000; 68 this->colorVector = Vector(0.7, 0.7, 0.7); 79 69 } 80 70 81 71 82 /**83 * initializes the fog effect84 */85 bool FogEffect::init()86 {}87 72 88 89 /**90 * activates the fog effect91 */92 73 bool FogEffect::activate() 93 74 { 94 PRINTF(0)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, 95 this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z); 75 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); 96 76 97 glEnable(GL_FOG); 98 { 99 // GLfloat fogColor[4] = {0.7, 0.6, 0.6, 1.0}; 100 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 77 glEnable(GL_FOG); 78 { 79 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 101 80 102 glFogi(GL_FOG_MODE, this->fogMode); 103 glFogfv(GL_FOG_COLOR, fogColor); 104 glFogf(GL_FOG_DENSITY, this->fogDensity); 105 glHint(GL_FOG_HINT, GL_DONT_CARE); 106 glFogf(GL_FOG_START, this->fogStart); 107 glFogf(GL_FOG_END, this->fogEnd); 108 109 //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE); 110 } 111 glClearColor(0.5, 0.5, 0.5, 1.0); 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); 112 89 } 113 90 114 91 115 /**116 * deactivates the fog effect117 */118 92 bool FogEffect::deactivate() 119 93 { 120 glDisable(GL_FOG); 94 PRINTF(0)("Deactivating FogEffect\n"); 95 glDisable(GL_FOG); 121 96 } 122 97 123 98 124 /**125 * converts a gl mode char to a GLint126 * @param mode the mode character127 */128 99 GLint FogEffect::stringToFogMode(const std::string& mode) 129 100 { 130 131 132 133 134 135 136 137 101 if(mode == "GL_LINEAR") 102 return GL_LINEAR; 103 else if(mode == "GL_EXP") 104 return GL_EXP; 105 else if(mode == "GL_EXP2" ) 106 return GL_EXP2; 107 else 108 return -1; 138 109 } 139 110 111
Note: See TracChangeset
for help on using the changeset viewer.