Changeset 7810 in orxonox.OLD for trunk/src/lib/graphics/effects
- Timestamp:
- May 24, 2006, 3:57:04 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/effects
- Files:
-
- 4 edited
- 16 copied
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 -
trunk/src/lib/graphics/effects/fog_effect.h
r7221 r7810 1 1 /** 2 * @file fog_effect.h 3 * atmospheric fog 4 */ 2 * @file fog_effect.h 3 */ 5 4 6 5 #ifndef _FOG_EFFECT … … 8 7 9 8 #include "vector.h" 10 #include "graphics_effect.h"11 9 12 class TiXmlElement; 10 #include "weather_effect.h" 13 11 14 //! A class that handles FogEffects. The FogEffectManager operates on this. 15 class FogEffect : public GraphicsEffect 12 class FogEffect : public WeatherEffect 16 13 { 17 18 19 14 public: 15 FogEffect(const TiXmlElement* root = NULL); 16 virtual ~FogEffect(); 20 17 21 18 virtual void loadParams(const TiXmlElement* root); 22 19 23 20 virtual bool init(); 24 21 25 26 22 virtual bool activate(); 23 virtual bool deactivate(); 27 24 28 29 30 31 25 inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); } 26 inline void setFogDensity(float density) { this->fogDensity = density; } 27 inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; } 28 inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); } 32 29 30 private: 31 GLint stringToFogMode(const std::string& mode); 33 32 34 private: 35 GLint stringToFogMode(const std::string& mode); 36 37 38 private: 39 GLint fogMode; 40 GLfloat fogDensity; 41 GLfloat fogStart; 42 GLfloat fogEnd; 43 Vector colorVector; 33 private: 34 GLint fogMode; 35 GLfloat fogDensity; 36 GLfloat fogStart; 37 GLfloat fogEnd; 38 Vector colorVector; 44 39 }; 45 40 46 41 47 #endif /* _FOG_EFFECT */42 #endif /* _FOG_EFFECT */ -
trunk/src/lib/graphics/effects/lense_flare.cc
r7316 r7810 28 28 #include "state.h" 29 29 30 #include "render2D/ billboard.h"30 #include "render2D/image_plane.h" 31 31 32 32 #include "light.h" … … 80 80 LenseFlare::~LenseFlare() 81 81 { 82 std::vector< Billboard*>::iterator it;82 std::vector<ImagePlane*>::iterator it; 83 83 for( it = flares.begin(); it != flares.end(); it++) 84 84 delete (*it); … … 155 155 } 156 156 157 Billboard* bb = new Billboard(NULL);157 ImagePlane* bb = new ImagePlane(NULL); 158 158 bb->setTexture(textureName); 159 159 bb->setSize(50, 50); 160 160 this->flares.push_back(bb); 161 PRINTF(4)("Added a Lenseflare Billboardwith texture %s\n", textureName.c_str());161 PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str()); 162 162 163 163 // the first flare belongs to the light source … … 178 178 float dist = this->frustumPlane.distancePoint(this->lightSource->getAbsCoor()); 179 179 PRINTF(0)("dist: %f\n", dist); 180 std::vector< Billboard*>::const_iterator it;180 std::vector<ImagePlane*>::const_iterator it; 181 181 for(it = flares.begin(); it != flares.end(); it++) 182 182 (*it)->setVisibility(visibility); … … 220 220 221 221 // now calculate the new coordinates of the billboards 222 std::vector< Billboard*>::iterator it;222 std::vector<ImagePlane*>::iterator it; 223 223 int i; 224 224 for( it = flares.begin(), i = 0; it != flares.end(); it++, i++) -
trunk/src/lib/graphics/effects/lense_flare.h
r7316 r7810 20 20 class TiXmlElement; 21 21 class Light; 22 class Billboard;22 class ImagePlane; 23 23 24 24 //! A class that handles LenseFlares. The LenseFlareManager operates on this. … … 50 50 float isVisible; //!< Checks visibility 51 51 Light* lightSource; //!< reference to the sun (or primary light source) 52 std::vector< Billboard*> flares; //!< the flares array52 std::vector<ImagePlane*> flares; //!< the flares array 53 53 54 54 Vector2D flareVector; //!< the axis to draw the flares on -
trunk/src/lib/graphics/effects/rain_effect.cc
r7808 r7810 47 47 if (this->rainBuffer != NULL) 48 48 ResourceManager::getInstance()->unload(this->rainBuffer); 49 this->rainBuffer = ( SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);49 this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV); 50 50 51 51 //load wind sound … … 53 53 if (this->windBuffer != NULL) 54 54 ResourceManager::getInstance()->unload(this->windBuffer); 55 this->windBuffer = ( SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);55 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV); 56 56 } 57 57 -
trunk/src/lib/graphics/effects/rain_effect.h
r7808 r7810 61 61 bool rainMove; 62 62 63 SoundSourcesoundSource;64 SoundBuffer*rainBuffer;65 SoundBuffer*windBuffer;63 OrxSound::SoundSource soundSource; 64 OrxSound::SoundBuffer* rainBuffer; 65 OrxSound::SoundBuffer* windBuffer; 66 66 }; 67 67 -
trunk/src/lib/graphics/effects/snow_effect.cc
r7808 r7810 50 50 if (this->windBuffer != NULL) 51 51 ResourceManager::getInstance()->unload(this->windBuffer); 52 this->windBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);52 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV); 53 53 } 54 54 -
trunk/src/lib/graphics/effects/snow_effect.h
r7808 r7810 17 17 class PNode; 18 18 19 #include "sound_source.h" 19 20 #include "sound_buffer.h" 20 #include "sound_source.h"21 21 22 22 class SnowEffect : public WeatherEffect … … 70 70 71 71 static SpriteParticles* snowParticles; 72 OrxSound::SoundSource soundSource; 73 OrxSound::SoundBuffer* windBuffer; 72 74 73 SoundSource soundSource;74 SoundBuffer* windBuffer;75 75 }; 76 76
Note: See TracChangeset
for help on using the changeset viewer.