/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: hdavid, amaechler */ #include "volfog_effect.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "glincl.h" #include "shell_command.h" /*SHELL_COMMAND(activateVolFog, VolFogEffect, VolFogEffect::activate) ->setAlias("aVolFog"); SHELL_COMMAND(deactivateVolFog, VolFogEffect, VolFogEffect::deactivate) ->setAlias("dVolFog");*/ using namespace std; CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT); VolFogEffect::VolFogEffect(const TiXmlElement* root) { this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect"); this->volfogMode = GL_LINEAR; this->volfogDensity = 0.001f; this->volfogStart = 10.0f; this->volfogEnd = 1000.0f; if (root != NULL) this->loadParams(root); this->activate(); } VolFogEffect::~VolFogEffect() { this->deactivate(); } void VolFogEffect::loadParams(const TiXmlElement* root) { WeatherEffect::loadParams(root); LoadParam(root, "volfog-mode", this, VolFogEffect, setVolFogMode); LoadParam(root, "volfog-density", this, VolFogEffect, setVolFogDensity); LoadParam(root, "volfog-color", this, VolFogEffect, setVolFogColor); } bool VolFogEffect::init() {} bool VolFogEffect::activate() { PRINTF(0)( "Enabling VolFog Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->volfogMode, this->volfogDensity, this->volfogStart, this->volfogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z); glEnable(GL_FOG); { //GLfloat volfogColor[4] = {0.7, 0.6, 0.6, 1.0}; GLfloat volfogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; glFogi(GL_FOG_MODE, this->volfogMode); glFogfv(GL_FOG_COLOR, volfogColor); glFogf(GL_FOG_DENSITY, this->volfogDensity); glHint(GL_FOG_HINT, GL_DONT_CARE); glFogf(GL_FOG_START, this->volfogStart); glFogf(GL_FOG_END, this->volfogEnd); //glVolFogi(GL_VOLFOG_COORDINATE_SOURCE, GL_VOLFOG_COORDINATE); } glClearColor(0.5, 0.5, 0.5, 1.0); } bool VolFogEffect::deactivate() { PRINTF(0)("Deactivating VolFog Effect"); glDisable(GL_FOG); } GLint VolFogEffect::stringToVolFogMode(const std::string& mode) { if(mode == "GL_LINEAR") return GL_LINEAR; else if(mode == "GL_EXP") return GL_EXP; else if(mode == "GL_EXP2" ) return GL_EXP2; else return -1; }