- Timestamp:
- Jun 15, 2006, 1:43:24 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/atmospheric_engine.cc
r8190 r8457 30 30 * @param root The XML-element to load the AtmosphericEngine from 31 31 */ 32 AtmosphericEngine::AtmosphericEngine() 33 { 34 this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine"); 32 AtmosphericEngine::AtmosphericEngine() { 33 this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine"); 35 34 } 36 35 … … 44 43 * destroys a AtmosphericEngine 45 44 */ 46 AtmosphericEngine::~AtmosphericEngine() 47 { 48 AtmosphericEngine::singletonRef = NULL; 45 AtmosphericEngine::~AtmosphericEngine() { 46 AtmosphericEngine::singletonRef = NULL; 49 47 50 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);48 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT); 51 49 52 if (weatherEffects != NULL) 53 { 54 while(!weatherEffects->empty()) 55 delete weatherEffects->front(); 56 } 50 if (weatherEffects != NULL) { 51 while(!weatherEffects->empty()) 52 delete weatherEffects->front(); 53 } 57 54 } 58 55 … … 60 57 * @param root The XML-element to load the AtmosphericEngine from 61 58 */ 62 void AtmosphericEngine::loadParams(const TiXmlElement* root) 63 { 64 LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect); 65 LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect); 59 void AtmosphericEngine::loadParams(const TiXmlElement* root) { 60 LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect); 61 LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect); 66 62 } 67 63 … … 69 65 * @param root The XML-element to load WeatherEffects from 70 66 */ 71 void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) 72 { 73 LOAD_PARAM_START_CYCLE(root, element); 74 { 75 PRINTF(4)("element is: %s\n", element->Value()); 76 // Factory::fabricate(element); 67 void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) { 68 LOAD_PARAM_START_CYCLE(root, element); 69 { 70 PRINTF(4)("element is: %s\n", element->Value()); 71 // Factory::fabricate(element); 77 72 78 BaseObject* bo = Factory::fabricate(element);79 if( bo == NULL)80 PRINTF(0)(" Could not create Element %s\n", element->Value());81 }82 LOAD_PARAM_END_CYCLE(element);73 BaseObject* bo = Factory::fabricate(element); 74 if( bo == NULL) 75 PRINTF(0)(" Could not create Element %s\n", element->Value()); 76 } 77 LOAD_PARAM_END_CYCLE(element); 83 78 } 84 79 … … 86 81 * @param root The XML-element to load SunEffects from 87 82 */ 88 void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) 89 { 90 LOAD_PARAM_START_CYCLE(root, element); 91 { 92 PRINTF(4)("element is: %s\n", element->Value()); 93 } 94 LOAD_PARAM_END_CYCLE(element); 83 void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) { 84 LOAD_PARAM_START_CYCLE(root, element); 85 { 86 PRINTF(4)("element is: %s\n", element->Value()); 87 } 88 LOAD_PARAM_END_CYCLE(element); 95 89 } 96 90 … … 99 93 * draws the effect, if needed 100 94 */ 101 void AtmosphericEngine::draw() const 102 { 103 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT); 95 void AtmosphericEngine::draw() const { 96 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT); 104 97 105 // draw the weather effects 106 if (weatherEffects != NULL) 107 { 108 std::list<BaseObject*>::const_iterator it; 109 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) 110 dynamic_cast<WeatherEffect*>(*it)->draw(); 111 } 98 // draw the weather effects 99 if (weatherEffects != NULL) { 100 std::list<BaseObject*>::const_iterator it; 101 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) 102 dynamic_cast<WeatherEffect*>(*it)->draw(); 103 } 112 104 } 113 105 … … 117 109 * ticks the effect if there is any time dependancy 118 110 */ 119 void AtmosphericEngine::tick(float dt) 120 { 121 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT); 111 void AtmosphericEngine::tick(float dt) { 112 const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT); 122 113 123 // tick the weather effects 124 if (weatherEffects != NULL) 125 { 126 std::list<BaseObject*>::const_iterator it; 127 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) 128 { 129 /* printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/ 130 dynamic_cast<WeatherEffect*>(*it)->tick(dt); 114 // tick the weather effects 115 if (weatherEffects != NULL) { 116 std::list<BaseObject*>::const_iterator it; 117 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) { 118 /* printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/ 119 dynamic_cast<WeatherEffect*>(*it)->tick(dt); 120 } 131 121 } 132 }133 122 } -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
r8455 r8457 20 20 class Vector; 21 21 22 class CloudEffect : public WeatherEffect 23 { 24 public: 25 CloudEffect(const TiXmlElement* root = NULL); 26 virtual ~CloudEffect(); 22 class CloudEffect : public WeatherEffect { 23 public: 24 CloudEffect(const TiXmlElement* root = NULL); 25 virtual ~CloudEffect(); 27 26 28 27 virtual void loadParams(const TiXmlElement* root); 29 28 30 29 virtual void init(); 31 30 32 33 31 virtual void activate(); 32 virtual void deactivate(); 34 33 35 inline void activateCloud() { this->activate(); } 36 inline void deactivateCloud() { this->deactivate(); } 37 38 virtual void draw() const; 39 virtual void tick(float dt); 34 inline void activateCloud() { 35 this->activate(); 36 } 37 inline void deactivateCloud() { 38 this->deactivate(); 39 } 40 40 41 inline void setCloudOption(const std::string& option) { 42 if (option == "activate") this->cloudActivate = true; 43 } 41 virtual void draw() const; 42 virtual void tick(float dt); 43 44 inline void setCloudOption(const std::string& option) { 45 if (option == "activate") 46 this->cloudActivate = true; 47 } 44 48 45 49 46 47 50 private: 51 void initialize(char* fileName); 48 52 49 boolcloudActivate;53 bool cloudActivate; 50 54 51 Material* cloudMaterial;// A Material for the Sphere.55 Material* cloudMaterial; // A Material for the Sphere. 52 56 53 std::stringcloudTexture;57 std::string cloudTexture; 54 58 55 Sglmodel_sglcloudModel;56 Shader*cloudShader;59 Sglmodel_sgl cloudModel; 60 Shader* cloudShader; 57 61 58 GLfloatcloudTint[4];59 GLfloatcloudScroll;62 GLfloat cloudTint[4]; 63 GLfloat cloudScroll; 60 64 61 floattime;65 float time; 62 66 63 67 }; -
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
r8455 r8457 1 1 /* 2 3 4 5 6 7 8 9 2 orxonox - the future of 3D-vertical-scrollers 3 4 Copyright (C) 2004 orx 5 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 … … 33 33 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT); 34 34 35 FogEffect::FogEffect(const TiXmlElement* root) 36 { 37 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 38 39 this->init(); 40 41 if (root != NULL) 42 this->loadParams(root); 43 44 if (this->fogActivate) 45 this->activate(); 46 } 47 48 49 FogEffect::~FogEffect() 50 { 51 this->deactivate(); 52 } 53 54 55 void FogEffect::loadParams(const TiXmlElement* root) 56 { 57 WeatherEffect::loadParams(root); 58 59 LoadParam(root, "mode", this, FogEffect, setFogMode); 60 LoadParam(root, "density", this, FogEffect, setFogDensity); 61 LoadParam(root, "range", this, FogEffect, setFogRange); 62 LoadParam(root, "color", this, FogEffect, setFogColor); 63 LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn); 64 LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut); 65 66 LOAD_PARAM_START_CYCLE(root, element); 67 { 68 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption); 69 } 70 LOAD_PARAM_END_CYCLE(element); 71 } 72 73 void FogEffect::init() 74 { 75 // default values 76 this->fogMode = GL_LINEAR; 77 this->fogDensity = 0.03; 78 this->fogStart = 0; 79 this->fogEnd = 50; 80 this->colorVector = Vector(0.3, 0.3, 0.3); 81 82 // init variables 83 this->fogFadeInDuration = 0; 84 this->fogFadeOutDuration = 0; 85 this->fogFadeInDensity = 0; 86 this->fogFadeOutDensity = 0; 87 this->localTimer = 0; 88 this->fogActivate = false; 89 this->fogFadeInActivate = false; 90 this->fogFadeOutActivate = false; 91 92 } 93 94 95 void FogEffect::activate() 96 { 97 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); 98 99 this->fogActivate = true; 100 101 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 102 glFogi(GL_FOG_MODE, this->fogMode); 103 glFogfv(GL_FOG_COLOR, fogColor); 104 glHint(GL_FOG_HINT, GL_DONT_CARE); 105 glFogf(GL_FOG_START, this->fogStart); 106 glFogf(GL_FOG_END, this->fogEnd); 107 108 if ( this->fogFadeInActivate ) 109 glFogf(GL_FOG_DENSITY, this->fogFadeInDensity); 110 else if ( this->fogFadeOutActivate ) 111 glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity); 112 else 113 glFogf(GL_FOG_DENSITY, this->fogDensity); 114 115 glEnable(GL_FOG); 116 117 } 118 119 120 void FogEffect::deactivate() 121 { 122 PRINTF(0)("Deactivating FogEffect\n"); 123 124 this->fogFadeInActivate = false; 125 this->fogFadeOutActivate = false; 126 this->fogActivate = false; 127 128 glDisable(GL_FOG); 35 FogEffect::FogEffect(const TiXmlElement* root) { 36 this->setClassID(CL_FOG_EFFECT, "FogEffect"); 37 38 this->init(); 39 40 if (root != NULL) 41 this->loadParams(root); 42 43 if (this->fogActivate) 44 this->activate(); 45 } 46 47 48 FogEffect::~FogEffect() { 49 this->deactivate(); 50 } 51 52 53 void FogEffect::loadParams(const TiXmlElement* root) { 54 WeatherEffect::loadParams(root); 55 56 LoadParam(root, "mode", this, FogEffect, setFogMode); 57 LoadParam(root, "density", this, FogEffect, setFogDensity); 58 LoadParam(root, "range", this, FogEffect, setFogRange); 59 LoadParam(root, "color", this, FogEffect, setFogColor); 60 LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn); 61 LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut); 62 63 LOAD_PARAM_START_CYCLE(root, element); 64 { 65 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption); 66 } 67 LOAD_PARAM_END_CYCLE(element); 68 } 69 70 void FogEffect::init() { 71 // default values 72 this->fogMode = GL_LINEAR; 73 this->fogDensity = 0.03; 74 this->fogStart = 0; 75 this->fogEnd = 50; 76 this->colorVector = Vector(0.3, 0.3, 0.3); 77 78 // init variables 79 this->fogFadeInDuration = 0; 80 this->fogFadeOutDuration = 0; 81 this->fogFadeInDensity = 0; 82 this->fogFadeOutDensity = 0; 83 this->localTimer = 0; 84 this->fogActivate = false; 85 this->fogFadeInActivate = false; 86 this->fogFadeOutActivate = false; 87 88 } 89 90 91 void FogEffect::activate() { 92 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); 93 94 this->fogActivate = true; 95 96 GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; 97 glFogi(GL_FOG_MODE, this->fogMode); 98 glFogfv(GL_FOG_COLOR, fogColor); 99 glHint(GL_FOG_HINT, GL_DONT_CARE); 100 glFogf(GL_FOG_START, this->fogStart); 101 glFogf(GL_FOG_END, this->fogEnd); 102 103 if ( this->fogFadeInActivate ) 104 glFogf(GL_FOG_DENSITY, this->fogFadeInDensity); 105 else if ( this->fogFadeOutActivate ) 106 glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity); 107 else 108 glFogf(GL_FOG_DENSITY, this->fogDensity); 109 110 glEnable(GL_FOG); 111 112 } 113 114 115 void FogEffect::deactivate() { 116 PRINTF(0)("Deactivating FogEffect\n"); 117 118 this->fogFadeInActivate = false; 119 this->fogFadeOutActivate = false; 120 this->fogActivate = false; 121 122 glDisable(GL_FOG); 129 123 130 124 } … … 132 126 void FogEffect::draw() const { 133 127 134 if (!this->fogActivate) 135 return; 136 137 // If Fog Fade In 138 if ( this->fogFadeInActivate ) 139 glFogf(GL_FOG_DENSITY, this->fogFadeInDensity); 140 141 // If Fog Fade Out 142 if ( this->fogFadeOutActivate ) 143 glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity); 144 145 } 146 147 void FogEffect::tick(float dt) 148 { 149 if (!this->fogActivate) 150 return; 151 152 if ( this->fogFadeInActivate ) { 153 this->localTimer += dt; 154 this->fogFadeInDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity; 155 156 if ( this->localTimer >= this->fogFadeOutDuration ) 157 this->fogFadeInActivate = false; 158 } 159 160 if ( this->fogFadeOutActivate ) { 161 this->localTimer += dt; 162 this->fogFadeOutDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity); 163 164 if ( this->localTimer >= this->fogFadeOutDuration ) 165 this->deactivate(); 166 } 128 if (!this->fogActivate) 129 return; 130 131 // If Fog Fade In 132 if ( this->fogFadeInActivate ) 133 glFogf(GL_FOG_DENSITY, this->fogFadeInDensity); 134 135 // If Fog Fade Out 136 if ( this->fogFadeOutActivate ) 137 glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity); 138 139 } 140 141 void FogEffect::tick(float dt) { 142 if (!this->fogActivate) 143 return; 144 145 if ( this->fogFadeInActivate ) { 146 this->localTimer += dt; 147 this->fogFadeInDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity; 148 149 if ( this->localTimer >= this->fogFadeOutDuration ) 150 this->fogFadeInActivate = false; 151 } 152 153 if ( this->fogFadeOutActivate ) { 154 this->localTimer += dt; 155 this->fogFadeOutDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity); 156 157 if ( this->localTimer >= this->fogFadeOutDuration ) 158 this->deactivate(); 159 } 167 160 } 168 161 169 162 void FogEffect::fadeInFog() { 170 163 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 164 // If Fog is already fading out, stop it 165 this->fogFadeOutActivate = false; 166 167 // If Fog is already on, turn it off first 168 if (this->fogActivate) 169 this->deactivate(); 170 171 // If no manual FadeIn value was set, set a default value 172 if (!this->fogFadeInDuration > 0) 173 this->fogFadeInDuration = 20; 174 175 // Reset local timer 176 this->localTimer = 0; 177 178 // set FogFadeIn activate 179 this->fogFadeInActivate = true; 180 181 // Activate Fog 182 this->activate(); 190 183 191 184 } … … 194 187 void FogEffect::fadeOutFog() { 195 188 196 // If Fog is already fading in, stop it 197 this->fogFadeInActivate = false; 198 199 // If Fog is off, turn it on first 200 if (!this->fogActivate) 201 this->activate(); 202 203 // If no manual FadeOut value was set, set a default value 204 if (!this->fogFadeOutDuration > 0) 205 this->fogFadeOutDuration = 20; 206 207 // set FogFadeOut activate 208 this->fogFadeOutActivate = true; 209 210 // Reset local timer 211 this->localTimer = 0; 212 213 } 214 215 216 GLint FogEffect::stringToFogMode(const std::string& mode) 217 { 218 if(mode == "GL_LINEAR") 219 return GL_LINEAR; 220 else if(mode == "GL_EXP") 221 return GL_EXP; 222 else if(mode == "GL_EXP2" ) 223 return GL_EXP2; 224 else 225 return -1; 226 } 227 228 189 // If Fog is already fading in, stop it 190 this->fogFadeInActivate = false; 191 192 // If Fog is off, turn it on first 193 if (!this->fogActivate) 194 this->activate(); 195 196 // If no manual FadeOut value was set, set a default value 197 if (!this->fogFadeOutDuration > 0) 198 this->fogFadeOutDuration = 20; 199 200 // set FogFadeOut activate 201 this->fogFadeOutActivate = true; 202 203 // Reset local timer 204 this->localTimer = 0; 205 206 } 207 208 209 GLint FogEffect::stringToFogMode(const std::string& mode) { 210 if(mode == "GL_LINEAR") 211 return GL_LINEAR; 212 else if(mode == "GL_EXP") 213 return GL_EXP; 214 else if(mode == "GL_EXP2" ) 215 return GL_EXP2; 216 else 217 return -1; 218 } 219 220 -
branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h
r8455 r8457 10 10 #include "weather_effect.h" 11 11 12 class FogEffect : public WeatherEffect 13 { 14 public: 15 FogEffect(const TiXmlElement* root = NULL); 16 virtual ~FogEffect(); 12 class FogEffect : public WeatherEffect { 13 public: 14 FogEffect(const TiXmlElement* root = NULL); 15 virtual ~FogEffect(); 17 16 18 17 virtual void loadParams(const TiXmlElement* root); 19 18 20 19 virtual void init(); 21 20 22 23 21 virtual void activate(); 22 virtual void deactivate(); 24 23 25 void activateFog() { this->activate(); } 26 void deactivateFog() { this->deactivate(); } 24 void activateFog() { 25 this->activate(); 26 } 27 void deactivateFog() { 28 this->deactivate(); 29 } 27 30 28 29 31 virtual void draw() const; 32 virtual void tick(float dt); 30 33 31 inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); } 32 inline void setFogDensity(float density) { this->fogDensity = density; } 33 inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; } 34 inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); } 35 inline void setFogFadeIn(float fadein) { this->fogFadeInDuration = fadein; } 36 inline void setFogFadeOut(float fadeout) { this->fogFadeOutDuration = fadeout; } 34 inline void setFogMode(const std::string& mode) { 35 this->fogMode = this->stringToFogMode(mode); 36 } 37 inline void setFogDensity(float density) { 38 this->fogDensity = density; 39 } 40 inline void setFogRange(float start, float end) { 41 this->fogStart = start; 42 this->fogEnd = end; 43 } 44 inline void setFogColor(float r, float g, float b) { 45 this->colorVector = Vector(r, g, b); 46 } 47 inline void setFogFadeIn(float fadein) { 48 this->fogFadeInDuration = fadein; 49 } 50 inline void setFogFadeOut(float fadeout) { 51 this->fogFadeOutDuration = fadeout; 52 } 37 53 38 inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; } 54 inline void setFogOption(const std::string& option) { 55 if (option == "activate") 56 this->fogActivate = true; 57 } 39 58 40 41 59 void fadeInFog(); 60 void fadeOutFog(); 42 61 43 62 44 45 63 private: 64 GLint stringToFogMode(const std::string& mode); 46 65 47 boolfogActivate;66 bool fogActivate; 48 67 49 boolfogFadeInActivate;50 boolfogFadeOutActivate;68 bool fogFadeInActivate; 69 bool fogFadeOutActivate; 51 70 52 GLfloatfogFadeInDuration;53 GLfloatfogFadeOutDuration;71 GLfloat fogFadeInDuration; 72 GLfloat fogFadeOutDuration; 54 73 55 float localTimer; 56 57 GLint fogMode; 58 GLfloat fogDensity; 59 GLfloat fogFadeInDensity; 60 GLfloat fogFadeOutDensity; 74 float localTimer; 61 75 62 GLfloat fogStart; 63 GLfloat fogEnd; 64 Vector colorVector; 76 GLint fogMode; 77 GLfloat fogDensity; 78 GLfloat fogFadeInDensity; 79 GLfloat fogFadeOutDensity; 80 81 GLfloat fogStart; 82 GLfloat fogEnd; 83 Vector colorVector; 65 84 }; 66 85 -
branches/atmospheric_engine/src/lib/graphics/effects/graphics_effect.cc
r7193 r8457 32 32 @todo what to do, if no GraphicsEffect-Slots are open anymore ??? 33 33 */ 34 GraphicsEffect::GraphicsEffect(const TiXmlElement* root) 35 { 36 this->setClassID(CL_GRAPHICS_EFFECT, "GraphicsEffect"); 37 this->bActivated = false; 34 GraphicsEffect::GraphicsEffect(const TiXmlElement* root) { 35 this->setClassID(CL_GRAPHICS_EFFECT, "GraphicsEffect"); 36 this->bActivated = false; 38 37 } 39 38 … … 42 41 * destroys a GraphicsEffect 43 42 */ 44 GraphicsEffect::~GraphicsEffect() 45 { 46 43 GraphicsEffect::~GraphicsEffect() { 47 44 } 48 45 … … 51 48 * @param root The XML-element to load the GraphicsEffect from 52 49 */ 53 void GraphicsEffect::loadParams(const TiXmlElement* root) 54 { 55 BaseObject::loadParams(root); 50 void GraphicsEffect::loadParams(const TiXmlElement* root) { 51 BaseObject::loadParams(root); 56 52 } 57 53 … … 60 56 * initializes the graphics effect 61 57 */ 62 bool GraphicsEffect::init() 63 {} 58 void GraphicsEffect::init() {} 64 59 65 60 … … 68 63 * draws the effect, if needed 69 64 */ 70 void GraphicsEffect::draw() const 71 {} 65 void GraphicsEffect::draw() const {} 72 66 73 67 … … 76 70 * ticks the effect if there is any time dependancy 77 71 */ 78 void GraphicsEffect::tick(float dt) 79 {} 72 void GraphicsEffect::tick(float dt) {} -
branches/atmospheric_engine/src/lib/graphics/effects/graphics_effect.h
r6815 r8457 12 12 13 13 //! A class that handles GraphicsEffects. The GraphicsEffectManager operates on this. 14 class GraphicsEffect : public BaseObject 15 { 16 public: 14 class GraphicsEffect : public BaseObject { 15 public: 17 16 GraphicsEffect(const TiXmlElement* root = NULL); 18 17 virtual ~GraphicsEffect(); … … 20 19 virtual void loadParams(const TiXmlElement* root); 21 20 22 virtual boolinit();21 virtual void init(); 23 22 24 virtual boolactivate() = 0;25 virtual booldeactivate() = 0;23 virtual void activate() = 0; 24 virtual void deactivate() = 0; 26 25 27 26 virtual void draw() const; 28 27 virtual void tick(float dt); 29 28 30 inline bool isActivated() const { return this->bActivated; } 29 inline bool isActivated() const { 30 return this->bActivated; 31 } 31 32 32 33 33 34 protected: 34 35 bool bActivated; 35 36 }; -
branches/atmospheric_engine/src/lib/graphics/effects/lense_flare.cc
r7844 r8457 44 44 * @param root The XML-element to load the LenseFlare from 45 45 */ 46 LenseFlare::LenseFlare(const TiXmlElement* root) 47 { 48 this->setClassID(CL_LENSE_FLARE, "LenseFlare"); 49 50 this->flareMatrix = new float[14]; 51 /* length image scale */ 52 this->flareMatrix[0] = 1.0f; this->flareMatrix[1] = 1.0f; 53 this->flareMatrix[2] = 0.5f; this->flareMatrix[3] = 0.5f; 54 this->flareMatrix[4] = 0.33f; this->flareMatrix[5] = 0.25f; 55 this->flareMatrix[6] = 0.125f; this->flareMatrix[7] = 1.0f; 56 this->flareMatrix[8] = -0.5f; this->flareMatrix[9] = 0.5f; 57 this->flareMatrix[10] = -0.25f; this->flareMatrix[11] = 0.15f; 58 this->flareMatrix[12] = -1.82f; this->flareMatrix[13] = 0.25f; 59 60 this->lightSource = (LightManager::getInstance())->getLight(0); 61 PRINTF(0)("light is: %p\n", this->lightSource); 62 63 if (root != NULL) 64 { 65 this->loadParams(root); 66 this->activate(); 67 } 68 69 this->bVisible = true; 70 this->setSourceVisibility(false); 46 LenseFlare::LenseFlare(const TiXmlElement* root) { 47 this->setClassID(CL_LENSE_FLARE, "LenseFlare"); 48 49 this->flareMatrix = new float[14]; 50 /* length image scale */ 51 this->flareMatrix[0] = 1.0f; 52 this->flareMatrix[1] = 1.0f; 53 this->flareMatrix[2] = 0.5f; 54 this->flareMatrix[3] = 0.5f; 55 this->flareMatrix[4] = 0.33f; 56 this->flareMatrix[5] = 0.25f; 57 this->flareMatrix[6] = 0.125f; 58 this->flareMatrix[7] = 1.0f; 59 this->flareMatrix[8] = -0.5f; 60 this->flareMatrix[9] = 0.5f; 61 this->flareMatrix[10] = -0.25f; 62 this->flareMatrix[11] = 0.15f; 63 this->flareMatrix[12] = -1.82f; 64 this->flareMatrix[13] = 0.25f; 65 66 this->lightSource = (LightManager::getInstance())->getLight(0); 67 PRINTF(0)("light is: %p\n", this->lightSource); 68 69 if (root != NULL) { 70 this->loadParams(root); 71 this->activate(); 72 } 73 74 this->bVisible = true; 75 this->setSourceVisibility(false); 71 76 72 77 } … … 76 81 * destroys a LenseFlare 77 82 */ 78 LenseFlare::~LenseFlare() 79 { 80 std::vector<ImagePlane*>::iterator it; 81 for( it = flares.begin(); it != flares.end(); it++) 82 delete (*it); 83 LenseFlare::~LenseFlare() { 84 std::vector<ImagePlane*>::iterator it; 85 for( it = flares.begin(); it != flares.end(); it++) 86 delete (*it); 83 87 } 84 88 … … 87 91 * @param root The XML-element to load the LenseFlare from 88 92 */ 89 void LenseFlare::loadParams(const TiXmlElement* root) 90 { 91 GraphicsEffect::loadParams(root); 92 93 LOAD_PARAM_START_CYCLE(root, element); 94 { 95 LoadParam_CYCLE(element, "add-flare-texture", this, LenseFlare, addFlare) 93 void LenseFlare::loadParams(const TiXmlElement* root) { 94 GraphicsEffect::loadParams(root); 95 96 LOAD_PARAM_START_CYCLE(root, element); 97 { 98 LoadParam_CYCLE(element, "add-flare-texture", this, LenseFlare, addFlare) 96 99 .describe("adds a lensflare texture to the engine"); 97 }98 LOAD_PARAM_END_CYCLE(element);100 } 101 LOAD_PARAM_END_CYCLE(element); 99 102 } 100 103 … … 103 106 * initializes the fog effect 104 107 */ 105 bool LenseFlare::init() 106 {} 108 void LenseFlare::init() {} 107 109 108 110 … … 110 112 * activates the fog effect 111 113 */ 112 bool LenseFlare::activate() 113 { 114 this->bActivated = true; 114 void LenseFlare::activate() { 115 this->bActivated = true; 115 116 } 116 117 … … 119 120 * deactivates the fog effect 120 121 */ 121 bool LenseFlare::deactivate() 122 { 123 this->bActivated = false; 122 void LenseFlare::deactivate() { 123 this->bActivated = false; 124 124 } 125 125 … … 129 129 * @param mode the mode character 130 130 */ 131 GLint LenseFlare::stringToFogMode(const std::string& mode) 132 {} 131 GLint LenseFlare::stringToFogMode(const std::string& mode) { 132 return 0; 133 } 133 134 134 135 … … 145 146 * 7th: Texture of the third burst 146 147 */ 147 void LenseFlare::addFlare(const std::string& textureName) 148 { 149 if( this->flares.size() > LF_MAX_FLARES) 150 { 151 PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES); 152 return; 153 } 154 155 ImagePlane* bb = new ImagePlane(NULL); 156 if (this->flares.empty()) 157 bb->setLayer(E2D_LAYER_BELOW_ALL); 158 bb->setTexture(textureName); 159 bb->setSize(50, 50); 160 this->flares.push_back(bb); 161 bb->setVisibility(true); 162 163 PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str()); 164 165 // the first flare belongs to the light source 166 if( this->flares.size() == 1 && this->lightSource != NULL) 167 { 168 bb->setBindNode(static_cast<PNode*>(this->lightSource)); 169 } 170 171 PRINTF(4)("Finished adding\n"); 172 } 173 174 175 void LenseFlare::setSourceVisibility(bool visibility) 176 { 177 if (this->bVisible == visibility) 178 return; 179 180 std::vector<ImagePlane*>::const_iterator it; 148 void LenseFlare::addFlare(const std::string& textureName) { 149 if( this->flares.size() > LF_MAX_FLARES) { 150 PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES); 151 return; 152 } 153 154 ImagePlane* bb = new ImagePlane(NULL); 155 if (this->flares.empty()) 156 bb->setLayer(E2D_LAYER_BELOW_ALL); 157 bb->setTexture(textureName); 158 bb->setSize(50, 50); 159 this->flares.push_back(bb); 160 bb->setVisibility(true); 161 162 PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str()); 163 164 // the first flare belongs to the light source 165 if( this->flares.size() == 1 && this->lightSource != NULL) { 166 bb->setBindNode(static_cast<PNode*>(this->lightSource)); 167 } 168 169 PRINTF(4)("Finished adding\n"); 170 } 171 172 173 void LenseFlare::setSourceVisibility(bool visibility) { 174 if (this->bVisible == visibility) 175 return; 176 177 std::vector<ImagePlane*>::const_iterator it; 181 178 for(it = ++flares.begin(); it != flares.end(); it++) 182 (*it)->setVisibility(visibility);183 this->bVisible = visibility;179 (*it)->setVisibility(visibility); 180 this->bVisible = visibility; 184 181 } 185 182 … … 188 185 * tick the effect 189 186 */ 190 void LenseFlare::tick(float dt) 191 { 192 if( unlikely(!this->bActivated || this->flares.size() == 0)) 193 return; 194 195 // refetch light source information if needed 196 if( unlikely( this->lightSource == NULL)) 197 { 198 this->lightSource = (LightManager::getInstance())->getLight(0); 199 if( this->flares.size() > 0) 200 this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource)); 201 } 187 void LenseFlare::tick(float dt) { 188 if( unlikely(!this->bActivated || this->flares.size() == 0)) 189 return; 190 191 // refetch light source information if needed 192 if( unlikely( this->lightSource == NULL)) { 193 this->lightSource = (LightManager::getInstance())->getLight(0); 194 if( this->flares.size() > 0) 195 this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource)); 196 } 202 197 203 198 //set the frustum plane 204 if (!flares.empty()) 205 this->setSourceVisibility(this->flares[0]->isVisible()); 206 207 208 // always update the screen center, it could be, that the window is resized 209 this->screenCenter = Vector2D(State::getResX()/2.0f, State::getResY()/2.0f); 210 211 // flare vector is the direction from the center to the light source 212 this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter; 213 this->distance = this->flareVector.len(); 214 this->flareVector.normalize(); 215 216 // now calculate the new coordinates of the billboards 217 std::vector<ImagePlane*>::iterator it; 218 int i; 219 for( it = flares.begin(), i = 0; it != flares.end(); it++, i++) 220 { 221 // set the new position 222 if( i == 0) 223 continue; 224 225 (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance); 226 (*it)->setSize2D(50.0f * this->flareMatrix[i * 2 + 1], 50.0f * this->flareMatrix[i * 2 + 1]); 227 PRINTF(5)("Tick flare %i @ (%f, %f)\n", i, (*it)->getAbsCoor2D().x, (*it)->getAbsCoor2D().y); 228 } 199 if (!flares.empty()) 200 this->setSourceVisibility(this->flares[0]->isVisible()); 201 202 203 // always update the screen center, it could be, that the window is resized 204 this->screenCenter = Vector2D(State::getResX()/2.0f, State::getResY()/2.0f); 205 206 // flare vector is the direction from the center to the light source 207 this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter; 208 this->distance = this->flareVector.len(); 209 this->flareVector.normalize(); 210 211 // now calculate the new coordinates of the billboards 212 std::vector<ImagePlane*>::iterator it; 213 int i; 214 for( it = flares.begin(), i = 0; it != flares.end(); it++, i++) { 215 // set the new position 216 if( i == 0) 217 continue; 218 219 (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance); 220 (*it)->setSize2D(50.0f * this->flareMatrix[i * 2 + 1], 50.0f * this->flareMatrix[i * 2 + 1]); 221 PRINTF(5)("Tick flare %i @ (%f, %f)\n", i, (*it)->getAbsCoor2D().x, (*it)->getAbsCoor2D().y); 222 } 229 223 } 230 224 … … 233 227 * draws the LenseFlares 234 228 */ 235 void LenseFlare::draw() const 236 { 237 if( !this->bActivated) 238 return; 239 } 229 void LenseFlare::draw() const { 230 if( !this->bActivated) 231 return; 232 } -
branches/atmospheric_engine/src/lib/graphics/effects/lense_flare.h
r7844 r8457 31 31 virtual void loadParams(const TiXmlElement* root); 32 32 33 virtual boolinit();33 virtual void init(); 34 34 35 virtual boolactivate();36 virtual booldeactivate();35 virtual void activate(); 36 virtual void deactivate(); 37 37 38 38 virtual void draw() const; -
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
r8455 r8457 39 39 40 40 /* TODO: 41 42 43 44 45 46 41 - preCaching 42 - test multiple rain emitters 43 - Think about what happens with building poss. to hang movewithcam off 44 - Possible to activate lightening 45 - turn off visibility when in a building 46 - variable emitter size depending on playable 47 47 */ 48 48 49 RainEffect::RainEffect(const TiXmlElement* root) 50 { 51 this->setClassID(CL_RAIN_EFFECT, "RainEffect"); 52 53 this->init(); 54 55 if (root != NULL) 56 this->loadParams(root); 57 58 //load rain sound 59 if (this->rainBuffer != NULL) 60 ResourceManager::getInstance()->unload(this->rainBuffer); 61 this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/rain.wav", WAV); 62 63 //load wind sound 64 if (this->rainWindForce != 0) { 65 if (this->windBuffer != NULL) 66 ResourceManager::getInstance()->unload(this->windBuffer); 67 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV); 68 } 69 70 if(rainActivate) 71 this->activate(); 72 } 73 74 RainEffect::~RainEffect() 75 { 76 this->deactivate(); 77 78 if (this->rainBuffer != NULL) 79 ResourceManager::getInstance()->unload(this->rainBuffer); 80 81 if (this->windBuffer != NULL) 82 ResourceManager::getInstance()->unload(this->windBuffer); 83 } 84 85 void RainEffect::loadParams(const TiXmlElement* root) 86 { 87 WeatherEffect::loadParams(root); 88 89 LoadParam(root, "coord", this, RainEffect, setRainCoord); 90 LoadParam(root, "size", this, RainEffect, setRainSize); 91 LoadParam(root, "rate", this, RainEffect, setRainRate); 92 LoadParam(root, "velocity", this, RainEffect, setRainVelocity); 93 LoadParam(root, "life", this, RainEffect, setRainLife); 94 LoadParam(root, "wind", this, RainEffect, setRainWind); 95 LoadParam(root, "fadeinduration", this, RainEffect, setRainFadeIn); 96 LoadParam(root, "fadeoutduration", this, RainEffect, setRainFadeOut); 97 98 LOAD_PARAM_START_CYCLE(root, element); 99 { 100 LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption); 101 } 102 LOAD_PARAM_END_CYCLE(element); 103 104 } 105 106 107 void RainEffect::init() 108 { 109 //Default values 110 this->rainActivate = false; 111 this->rainMove = false; 112 this->rainCoord = Vector(500, 500, 500); 113 this->rainSize = Vector2D(1000, 1000); 114 this->rainRate = 4000; 115 this->rainVelocity = -300; 116 this->rainLife = 4; 117 this->rainMaxParticles = this->rainRate * this->rainLife; 118 this->rainWindForce = 0; 119 this->rainFadeInDuration = 0; 120 this->rainFadeOutDuration = 0; 121 this->localTimer = 0; 122 this->soundRainVolume = 0.8f; 123 124 this->emitter = new PlaneEmitter(this->rainSize); 125 126 lightMan = LightManager::getInstance(); 127 this->rainAmbient = lightMan->getAmbientColor(); 49 RainEffect::RainEffect(const TiXmlElement* root) { 50 this->setClassID(CL_RAIN_EFFECT, "RainEffect"); 51 52 this->init(); 53 54 if (root != NULL) 55 this->loadParams(root); 56 57 //load rain sound 58 if (this->rainBuffer != NULL) 59 ResourceManager::getInstance()->unload(this->rainBuffer); 60 this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/rain.wav", WAV); 61 62 //load wind sound 63 if (this->rainWindForce != 0) { 64 if (this->windBuffer != NULL) 65 ResourceManager::getInstance()->unload(this->windBuffer); 66 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV); 67 } 68 69 if(rainActivate) 70 this->activate(); 71 } 72 73 RainEffect::~RainEffect() { 74 this->deactivate(); 75 76 if (this->rainBuffer != NULL) 77 ResourceManager::getInstance()->unload(this->rainBuffer); 78 79 if (this->windBuffer != NULL) 80 ResourceManager::getInstance()->unload(this->windBuffer); 81 } 82 83 void RainEffect::loadParams(const TiXmlElement* root) { 84 WeatherEffect::loadParams(root); 85 86 LoadParam(root, "coord", this, RainEffect, setRainCoord); 87 LoadParam(root, "size", this, RainEffect, setRainSize); 88 LoadParam(root, "rate", this, RainEffect, setRainRate); 89 LoadParam(root, "velocity", this, RainEffect, setRainVelocity); 90 LoadParam(root, "life", this, RainEffect, setRainLife); 91 LoadParam(root, "wind", this, RainEffect, setRainWind); 92 LoadParam(root, "fadeinduration", this, RainEffect, setRainFadeIn); 93 LoadParam(root, "fadeoutduration", this, RainEffect, setRainFadeOut); 94 95 LOAD_PARAM_START_CYCLE(root, element); 96 { 97 LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption); 98 } 99 LOAD_PARAM_END_CYCLE(element); 100 101 } 102 103 104 void RainEffect::init() { 105 //Default values 106 this->rainActivate = false; 107 this->rainMove = false; 108 this->rainCoord = Vector(500, 500, 500); 109 this->rainSize = Vector2D(1000, 1000); 110 this->rainRate = 4000; 111 this->rainVelocity = -300; 112 this->rainLife = 4; 113 this->rainMaxParticles = this->rainRate * this->rainLife; 114 this->rainWindForce = 0; 115 this->rainFadeInDuration = 0; 116 this->rainFadeOutDuration = 0; 117 this->localTimer = 0; 118 this->soundRainVolume = 0.8f; 119 120 this->emitter = new PlaneEmitter(this->rainSize); 121 122 lightMan = LightManager::getInstance(); 123 this->rainAmbient = lightMan->getAmbientColor(); 128 124 } 129 125 … … 131 127 SparkParticles* RainEffect::rainParticles = NULL; 132 128 133 void RainEffect::activate() 134 { 135 PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" ); 136 137 this->rainActivate = true; 138 139 if (unlikely(RainEffect::rainParticles == NULL)) 140 { 141 RainEffect::rainParticles = new SparkParticles((int) this->rainMaxParticles); 142 RainEffect::rainParticles->setName("RainParticles"); 143 RainEffect::rainParticles->precache((int)this->rainLife, 30); // TODO: Why doesnt this work?? 144 RainEffect::rainParticles->setLifeSpan(this->rainLife, 2); 145 RainEffect::rainParticles->setRadius(0, 0.03); 146 RainEffect::rainParticles->setRadius(0.2, 0.02); 147 RainEffect::rainParticles->setRadius(1, 0.01); 148 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2); // grey blue 1 149 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2); // grey blue 2 150 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2); // light grey 151 } 152 153 this->emitter->setSystem(RainEffect::rainParticles); 154 155 this->emitter->setRelCoor(this->rainCoord); 156 157 this->emitter->setEmissionRate(this->rainRate); 158 this->emitter->setEmissionVelocity(this->rainVelocity); 159 160 this->emitter->setSpread(this->rainWindForce / 50, 0.2); 161 162 this->soundSource.loop(this->rainBuffer, this->soundRainVolume); 163 if (this->rainWindForce != 0) this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce); 164 165 if (this->rainFadeInDuration == 0) 166 lightMan->setAmbientColor(.1,.1,.1); 167 168 } 169 170 171 void RainEffect::deactivate() 172 { 173 PRINTF(0)("Deactivating RainEffect\n"); 174 175 this->rainActivate = false; 176 this->emitter->setSystem(NULL); 177 178 // Stop Sound 179 this->soundSource.stop(); 180 181 // Restore Light Ambient 182 lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient); 183 184 } 185 186 void RainEffect::tick (float dt) 187 { 188 if (!this->rainActivate) 189 return; 190 191 if (this->rainMove) { 192 this->rainCoord = State::getCameraNode()->getAbsCoor(); 193 this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z); 194 } 195 196 if (this->rainFadeInDuration != 0 && this->localTimer < this->rainFadeInDuration) { 197 this->localTimer += dt; 198 float progress = this->localTimer / this->rainFadeInDuration; 199 200 // Dim Light 201 lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9); 202 203 // use alpha in color to fade in 204 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1 205 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2 206 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey 207 208 // increase radius for more "heavy" rain 209 RainEffect::rainParticles->setRadius(0, 0.03 * progress); 210 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress); 211 RainEffect::rainParticles->setRadius(1, 0.01 * progress); 212 213 // increase sound volume 214 // this->soundSource.fadein(this->rainBuffer, 10); 215 } 216 else if ( this->rainFadeOutDuration != 0 ) { 217 if ( this->localTimer < this->rainFadeOutDuration ) { 218 this->localTimer += dt; 219 float progress = 1 - (this->localTimer / this->rainFadeOutDuration); 220 221 // Fade In Light 222 lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9); 223 224 // use alpha in color to fade out 225 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1 226 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2 227 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey 228 229 // decrease radius 230 RainEffect::rainParticles->setRadius(0, 0.03 * progress); 231 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress); 232 RainEffect::rainParticles->setRadius(1, 0.01 * progress); 233 234 // decrease sound volume 235 // this->soundSource.fadeout(this->rainBuffer, 10); 236 } 237 else 238 this->deactivate(); 239 } 240 129 void RainEffect::activate() { 130 PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" ); 131 132 this->rainActivate = true; 133 134 if (unlikely(RainEffect::rainParticles == NULL)) { 135 RainEffect::rainParticles = new SparkParticles((int) this->rainMaxParticles); 136 RainEffect::rainParticles->setName("RainParticles"); 137 RainEffect::rainParticles->setLifeSpan(this->rainLife, 2); 138 RainEffect::rainParticles->setRadius(0, 0.03); 139 RainEffect::rainParticles->setRadius(0.2, 0.02); 140 RainEffect::rainParticles->setRadius(1, 0.01); 141 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2); // grey blue 1 142 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2); // grey blue 2 143 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2); // light grey 144 } 145 146 this->emitter->setSystem(RainEffect::rainParticles); 147 148 this->emitter->setRelCoor(this->rainCoord); 149 150 this->emitter->setEmissionRate(this->rainRate); 151 this->emitter->setEmissionVelocity(this->rainVelocity); 152 153 this->emitter->setSpread(this->rainWindForce / 50, 0.2); 154 155 RainEffect::rainParticles->precache((int)this->rainLife); 156 157 this->soundSource.loop(this->rainBuffer, this->soundRainVolume); 158 if (this->rainWindForce != 0) 159 this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce); 160 161 if (this->rainFadeInDuration == 0) 162 lightMan->setAmbientColor(.1,.1,.1); 163 164 } 165 166 167 void RainEffect::deactivate() { 168 PRINTF(0)("Deactivating RainEffect\n"); 169 170 this->rainActivate = false; 171 this->emitter->setSystem(NULL); 172 173 // Stop Sound 174 this->soundSource.stop(); 175 176 // Restore Light Ambient 177 lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient); 178 179 } 180 181 void RainEffect::tick (float dt) { 182 if (!this->rainActivate) 183 return; 184 185 if (this->rainMove) { 186 this->rainCoord = State::getCameraNode()->getAbsCoor(); 187 this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z); 188 } 189 190 if (this->rainFadeInDuration != 0 && this->localTimer < this->rainFadeInDuration) { 191 this->localTimer += dt; 192 float progress = this->localTimer / this->rainFadeInDuration; 193 194 // Dim Light 195 lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9); 196 197 // use alpha in color to fade in 198 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1 199 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2 200 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey 201 202 // increase radius for more "heavy" rain 203 RainEffect::rainParticles->setRadius(0, 0.03 * progress); 204 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress); 205 RainEffect::rainParticles->setRadius(1, 0.01 * progress); 206 207 // increase sound volume 208 // this->soundSource.fadein(this->rainBuffer, 10); 209 } else if ( this->rainFadeOutDuration != 0 ) { 210 if ( this->localTimer < this->rainFadeOutDuration ) { 211 this->localTimer += dt; 212 float progress = 1 - (this->localTimer / this->rainFadeOutDuration); 213 214 // Fade In Light 215 lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9); 216 217 // use alpha in color to fade out 218 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1 219 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2 220 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey 221 222 // decrease radius 223 RainEffect::rainParticles->setRadius(0, 0.03 * progress); 224 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress); 225 RainEffect::rainParticles->setRadius(1, 0.01 * progress); 226 227 // decrease sound volume 228 // this->soundSource.fadeout(this->rainBuffer, 10); 229 } else 230 this->deactivate(); 231 } 232 241 233 } 242 234 243 235 void RainEffect::startRaining() { 244 236 245 246 247 248 249 250 251 252 253 237 if (this->rainActivate) 238 this->deactivate(); 239 240 if (!this->rainFadeInDuration > 0) 241 this->rainFadeInDuration = 20; 242 243 this->localTimer = 0; 244 245 this->activate(); 254 246 255 247 } … … 257 249 void RainEffect::stopRaining() { 258 250 259 260 261 262 263 264 265 266 267 } 251 if (!this->rainActivate) 252 this->activate(); 253 254 if (!this->rainFadeOutDuration > 0) 255 this->rainFadeOutDuration = 20; 256 257 this->localTimer = 0; 258 259 } -
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h
r8455 r8457 22 22 23 23 24 class RainEffect : public WeatherEffect 25 { 26 public: 27 RainEffect(const TiXmlElement* root = NULL); 28 virtual ~RainEffect(); 24 class RainEffect : public WeatherEffect { 25 public: 26 RainEffect(const TiXmlElement* root = NULL); 27 virtual ~RainEffect(); 29 28 30 29 virtual void loadParams(const TiXmlElement* root); 31 30 32 31 virtual void init(); 33 32 34 35 33 virtual void activate(); 34 virtual void deactivate(); 36 35 37 inline void activateRain() { this->activate(); } 38 inline void deactivateRain() { this->deactivate(); } 36 inline void activateRain() { 37 this->activate(); 38 } 39 inline void deactivateRain() { 40 this->deactivate(); 41 } 39 42 40 43 virtual void tick(float dt); 41 44 42 43 45 void startRaining(); 46 void stopRaining(); 44 47 45 inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); } 46 inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); } 47 inline void setRainRate(float rate) { this->rainRate = rate;} 48 inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; } 49 inline void setRainLife(float life) { this->rainLife = life; } 50 inline void setRainWind(int force) { this->rainWindForce = force; } 48 inline void setRainCoord(float x, float y, float z) { 49 this->rainCoord = Vector(x, y, z); 50 } 51 inline void setRainSize(float x, float y) { 52 this->rainSize = Vector2D(x, y); 53 } 54 inline void setRainRate(float rate) { 55 this->rainRate = rate; 56 } 57 inline void setRainVelocity(float velocity) { 58 this->rainVelocity = -velocity; 59 } 60 inline void setRainLife(float life) { 61 this->rainLife = life; 62 } 63 inline void setRainWind(int force) { 64 this->rainWindForce = force; 65 } 51 66 52 inline void setRainFadeIn(float fadein) { this->rainFadeInDuration = fadein; } 53 inline void setRainFadeOut(float fadeout) { this->rainFadeOutDuration = fadeout; } 67 inline void setRainFadeIn(float fadein) { 68 this->rainFadeInDuration = fadein; 69 } 70 inline void setRainFadeOut(float fadeout) { 71 this->rainFadeOutDuration = fadeout; 72 } 54 73 55 inline void setRainOption(const std::string& option) { 56 if (option == "moverain") this->rainMove = true; 57 if (option == "activate") this->rainActivate = true; 58 } 74 inline void setRainOption(const std::string& option) { 75 if (option == "moverain") 76 this->rainMove = true; 77 if (option == "activate") 78 this->rainActivate = true; 79 } 59 80 60 81 61 62 static SparkParticles*rainParticles;63 ParticleEmitter*emitter;82 private: 83 static SparkParticles* rainParticles; 84 ParticleEmitter* emitter; 64 85 65 GLfloatrainFadeInDuration;66 GLfloatrainFadeOutDuration;67 floatlocalTimer;86 GLfloat rainFadeInDuration; 87 GLfloat rainFadeOutDuration; 88 float localTimer; 68 89 69 VectorrainCoord;70 Vector2DrainSize;71 GLfloatrainRate;72 GLfloatrainVelocity;73 GLfloatrainLife;74 GLfloatrainMaxParticles;75 intrainWindForce;76 boolrainMove;77 boolrainActivate;90 Vector rainCoord; 91 Vector2D rainSize; 92 GLfloat rainRate; 93 GLfloat rainVelocity; 94 GLfloat rainLife; 95 GLfloat rainMaxParticles; 96 int rainWindForce; 97 bool rainMove; 98 bool rainActivate; 78 99 79 OrxSound::SoundSourcesoundSource;80 OrxSound::SoundBuffer*rainBuffer;81 OrxSound::SoundBuffer*windBuffer;100 OrxSound::SoundSource soundSource; 101 OrxSound::SoundBuffer* rainBuffer; 102 OrxSound::SoundBuffer* windBuffer; 82 103 83 floatsoundRainVolume;104 float soundRainVolume; 84 105 85 LightManager*lightMan;86 GLfloatrainAmbient;106 LightManager* lightMan; 107 GLfloat rainAmbient; 87 108 88 109 }; -
branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.cc
r8455 r8457 96 96 this->particles = 12000; 97 97 this->texture = "maps/snow_flake_01_32x32.png"; 98 this-> life = 8;98 this->snowLife = 8; 99 99 this->randomLife = 2; 100 100 this->snowRadius = 3.5; … … 122 122 SnowEffect::snowParticles->setName("SnowEffectTrailParticles"); 123 123 SnowEffect::snowParticles->setMaterialTexture(texture); 124 SnowEffect::snowParticles->setLifeSpan( life, randomLife);124 SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife); 125 125 SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius); 126 126 SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8); … … 139 139 this->emitter->setSize(snowSize); 140 140 141 // SnowEffect::snowParticles->precache(8);141 SnowEffect::snowParticles->precache((int) this->snowLife); 142 142 143 143 if (this->snowWindForce > 1) -
branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.h
r8455 r8457 20 20 #include "sound_buffer.h" 21 21 22 class SnowEffect : public WeatherEffect 23 { 24 public: 25 SnowEffect(const TiXmlElement* root = NULL); 26 virtual ~SnowEffect(); 22 class SnowEffect : public WeatherEffect { 23 public: 24 SnowEffect(const TiXmlElement* root = NULL); 25 virtual ~SnowEffect(); 27 26 28 27 virtual void loadParams(const TiXmlElement* root); 29 28 30 29 virtual void init(); 31 30 32 33 31 virtual void activate(); 32 virtual void deactivate(); 34 33 35 inline void activateSnow() { this->activate(); } 36 inline void deactivateSnow() { this->deactivate(); } 37 38 virtual void draw() const; 39 virtual void tick(float dt); 34 inline void activateSnow() { 35 this->activate(); 36 } 37 inline void deactivateSnow() { 38 this->deactivate(); 39 } 40 41 virtual void draw() const; 42 virtual void tick(float dt); 40 43 41 44 42 inline void numParticles(int n) { this->particles = n; } 43 inline void materialTexture(const std::string& texture) { this->texture = texture; } 44 inline void lifeSpan(float lifeSpan, float randomLifeSpan) { this->life = lifeSpan; this->randomLife = randomLifeSpan; } 45 inline void radius(float radius, float randomRadius) { this->snowRadius = radius; this->randomRadius = randomRadius; } 46 inline void mass(float mass, float randomMass) { this->snowMass = mass; this->randomMass = randomMass; } 47 inline void emissionRate(float emissionRate){ this->rate = emissionRate; } 48 inline void emissionVelocity(float velocity, float randomVelocity){ this->velocity = velocity; this->randomVelocity = randomVelocity; } 49 inline void size(float sizeX, float sizeY) { this->snowSize = Vector2D(sizeX, sizeY); } 50 inline void coord(float x, float y, float z) { this->snowCoord = Vector(x, y, z); } 51 inline void wind(int force) { this->snowWindForce = force; } 45 inline void numParticles(int n) { 46 this->particles = n; 47 } 48 inline void materialTexture(const std::string& texture) { 49 this->texture = texture; 50 } 51 inline void lifeSpan(float lifeSpan, float randomLifeSpan) { 52 this->snowLife = lifeSpan; 53 this->randomLife = randomLifeSpan; 54 } 55 inline void radius(float radius, float randomRadius) { 56 this->snowRadius = radius; 57 this->randomRadius = randomRadius; 58 } 59 inline void mass(float mass, float randomMass) { 60 this->snowMass = mass; 61 this->randomMass = randomMass; 62 } 63 inline void emissionRate(float emissionRate) { 64 this->rate = emissionRate; 65 } 66 inline void emissionVelocity(float velocity, float randomVelocity) { 67 this->velocity = velocity; 68 this->randomVelocity = randomVelocity; 69 } 70 inline void size(float sizeX, float sizeY) { 71 this->snowSize = Vector2D(sizeX, sizeY); 72 } 73 inline void coord(float x, float y, float z) { 74 this->snowCoord = Vector(x, y, z); 75 } 76 inline void wind(int force) { 77 this->snowWindForce = force; 78 } 52 79 53 inline void setSnowOption(const std::string& option) { 54 /*if (option == "fade") this->snowFade = true;*/ 55 if (option == "movesnow") this->snowMove = true; 56 if (option == "activate") this->snowActivate = true; 57 } 80 inline void setSnowOption(const std::string& option) { 81 /*if (option == "fade") this->snowFade = true;*/ 82 if (option == "movesnow") 83 this->snowMove = true; 84 if (option == "activate") 85 this->snowActivate = true; 86 } 58 87 59 88 60 61 intparticles;62 std::stringtexture;63 float life, randomLife;64 floatsnowRadius, randomRadius;65 floatsnowMass, randomMass;66 floatrate;67 floatvelocity, randomVelocity;68 floatangle, randomAngle;69 floatalpha;70 VectorsnowCoord;71 Vector2DsnowSize;72 intsnowWindForce;89 private: 90 int particles; 91 std::string texture; 92 float snowLife, randomLife; 93 float snowRadius, randomRadius; 94 float snowMass, randomMass; 95 float rate; 96 float velocity, randomVelocity; 97 float angle, randomAngle; 98 float alpha; 99 Vector snowCoord; 100 Vector2D snowSize; 101 int snowWindForce; 73 102 74 boolsnowMove;75 boolsnowActivate;103 bool snowMove; 104 bool snowActivate; 76 105 77 PlaneEmitter*emitter;106 PlaneEmitter* emitter; 78 107 79 static SpriteParticles*snowParticles;80 OrxSound::SoundSourcesoundSource;81 OrxSound::SoundBuffer*windBuffer;108 static SpriteParticles* snowParticles; 109 OrxSound::SoundSource soundSource; 110 OrxSound::SoundBuffer* windBuffer; 82 111 83 112 }; -
branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc
r8455 r8457 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 … … 51 51 CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT); 52 52 53 VolFogEffect::VolFogEffect(const TiXmlElement* root) 54 { 55 this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect"); 53 VolFogEffect::VolFogEffect(const TiXmlElement* root) { 54 this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect"); 56 55 57 58 56 if (root != NULL) 57 this->loadParams(root); 59 58 60 61 59 // Initialize Effect 60 this->init(); 62 61 63 64 62 // Activate Effect 63 this->activate(); 65 64 } 66 65 67 66 68 VolFogEffect::~VolFogEffect() 69 { 70 this->deactivate(); 67 VolFogEffect::~VolFogEffect() { 68 this->deactivate(); 71 69 } 72 70 73 void VolFogEffect::loadParams(const TiXmlElement* root) 74 { 75 WeatherEffect::loadParams(root); 71 void VolFogEffect::loadParams(const TiXmlElement* root) { 72 WeatherEffect::loadParams(root); 76 73 } 77 74 78 void VolFogEffect::init() 79 { 80 PRINTF(0)("Initalize VolFogEffect\n"); 75 void VolFogEffect::init() { 76 PRINTF(0)("Initalize VolFogEffect\n"); 81 77 82 83 78 // set fog mode 79 GLenum fogMode = GL_EXP; 84 80 85 86 81 // set fog density 82 float fogDensity = 0.001f; 87 83 88 89 90 84 // set fog near & far distance 85 float fogStart = 0.0f; 86 float fogEnd = 1000.0f; 91 87 92 93 88 // Set fog color 89 float fogColor[4] = {0.6f,0.58f,0.79f,0.0f}; 94 90 95 91 96 97 98 99 100 92 glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT"); 93 glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfvEXT"); 94 glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddEXT"); 95 glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddvEXT"); 96 glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordPointerEXT"); 101 97 102 103 104 105 106 107 108 98 // set the fog attributes 99 glFogf (GL_FOG_START, fogStart); 100 glFogf (GL_FOG_END, fogEnd); 101 glFogfv(GL_FOG_COLOR, fogColor); 102 glFogi (GL_FOG_MODE, fogMode); 103 glFogf (GL_FOG_DENSITY,fogDensity); 104 glFogi (GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE_EXT); 109 105 110 111 106 // enable the fog 107 glEnable(GL_FOG); 112 108 113 114 115 116 109 if (glewInit() == GLEW_OK) 110 PRINTF(0)("glewInit OK\n"); 111 else 112 PRINTF(0)("glewInit failed\n"); 117 113 118 119 114 if (glewGetExtension("GL_EXT_fog_coord")) 115 PRINTF(0)("GL_EXT_fog_coord extension found\n"); 120 116 } 121 117 122 118 123 void VolFogEffect::activate() 124 { 125 PRINTF(0)("Activating VolFogEffect\n"); 119 void VolFogEffect::activate() { 120 PRINTF(0)("Activating VolFogEffect\n"); 126 121 } 127 122 128 void VolFogEffect::deactivate() 129 { 130 PRINTF(0)("Deactivating VolFogEffect\n"); 123 void VolFogEffect::deactivate() { 124 PRINTF(0)("Deactivating VolFogEffect\n"); 131 125 132 126 glDisable(GL_FOG); 133 127 } 134 128 … … 137 131 * draws the effect, if needed 138 132 */ 139 void VolFogEffect::draw() const 140 { 141 glPushAttrib(GL_ENABLE_BIT); 142 glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f); 143 glShadeModel(GL_SMOOTH); 144 glEnable(GL_DEPTH_TEST); 145 glEnable(GL_CULL_FACE); 146 glCullFace(GL_BACK); 133 void VolFogEffect::draw() const { 134 glPushAttrib(GL_ENABLE_BIT); 135 glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f); 136 glShadeModel(GL_SMOOTH); 137 glEnable(GL_DEPTH_TEST); 138 glEnable(GL_CULL_FACE); 139 glCullFace(GL_BACK); 147 140 148 149 141 /* clear all pixels in colour buffer */ 142 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 150 143 151 152 153 144 /* Enable blending */ 145 //glEnable(GL_BLEND); 146 //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); 154 147 155 156 148 int i; 149 glLoadIdentity(); 157 150 158 151 159 glBegin( GL_LINES ); 160 glNormal3f(0,1,0); 161 for(i=-20;i<=20;i+=2) 162 { 163 float fog_c; 164 float diff[3]; 152 glBegin( GL_LINES ); 153 glNormal3f(0,1,0); 154 for(i=-20;i<=20;i+=2) { 155 float fog_c; 156 float diff[3]; 165 157 166 167 168 169 170 171 158 diff[0] = State::getCameraNode()->getAbsCoor().x - i; 159 diff[2] = State::getCameraNode()->getAbsCoor().z + 20; 160 diff[1] = State::getCameraNode()->getAbsCoor().y; 161 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]); 162 glFogCoordfEXT(fog_c*2); 163 glVertex3f(i,0,-20); 172 164 173 174 175 176 177 178 165 diff[0] = State::getCameraNode()->getAbsCoor().x - i; 166 diff[2] = State::getCameraNode()->getAbsCoor().z + 20; 167 diff[1] = State::getCameraNode()->getAbsCoor().y; 168 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]); 169 glFogCoordfEXT(fog_c*2); 170 glVertex3f(i,0,20); 179 171 180 181 182 183 184 185 172 diff[0] = State::getCameraNode()->getAbsCoor().x - i; 173 diff[2] = State::getCameraNode()->getAbsCoor().z + 20; 174 diff[1] = State::getCameraNode()->getAbsCoor().y; 175 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]); 176 glFogCoordfEXT(fog_c*2); 177 glVertex3f(-20,0,i); 186 178 187 188 189 190 191 192 193 194 179 diff[0] = State::getCameraNode()->getAbsCoor().x - i; 180 diff[2] = State::getCameraNode()->getAbsCoor().z + 20; 181 diff[1] = State::getCameraNode()->getAbsCoor().y; 182 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]); 183 glFogCoordfEXT(fog_c*2); 184 glVertex3f(20,0,i); 185 } 186 glEnd(); 195 187 196 glPopAttrib();188 glPopAttrib(); 197 189 198 190 } … … 202 194 * ticks the effect if there is any time dependancy 203 195 */ 204 void VolFogEffect::tick(float dt) 205 { 206 } 196 void VolFogEffect::tick(float dt) {} -
branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h
r8455 r8457 10 10 #include "weather_effect.h" 11 11 12 class VolFogEffect : public WeatherEffect 13 { 14 public: 15 VolFogEffect(const TiXmlElement* root = NULL); 16 virtual ~VolFogEffect(); 12 class VolFogEffect : public WeatherEffect { 13 public: 14 VolFogEffect(const TiXmlElement* root = NULL); 15 virtual ~VolFogEffect(); 17 16 18 17 virtual void loadParams(const TiXmlElement* root); 19 18 20 19 virtual void init(); 21 20 22 23 21 virtual void activate(); 22 virtual void deactivate(); 24 23 25 26 24 virtual void draw() const; 25 virtual void tick(float dt); 27 26 28 29 27 private: 28 GLfloat fogColor[4]; 30 29 31 30 }; -
branches/atmospheric_engine/src/lib/graphics/effects/weather_effect.h
r8455 r8457 1 1 /*! 2 2 * @file weather_effect.h 3 * 3 * 4 4 */ 5 5 … … 20 20 virtual void init(); 21 21 22 virtual void activate() ;23 virtual void deactivate() ;22 virtual void activate() = 0; 23 virtual void deactivate() = 0; 24 24 25 25 virtual void draw() const; -
branches/atmospheric_engine/src/lib/graphics/shader.cc
r8255 r8457 153 153 glAttachObjectARB(this->shaderProgram, shader); 154 154 } 155 156 return true; 155 157 } 156 158 -
branches/atmospheric_engine/src/lib/gui/gl/glmenu/glmenu_imagescreen.cc
r8145 r8457 269 269 glEnd(); 270 270 271 / *draw black border271 // draw black border 272 272 glBegin(GL_QUADS); 273 273 glColor3f(0.0, 0.0, 0.0); -
branches/atmospheric_engine/src/lib/gui/qt/gui_control.cc
r8145 r8457 285 285 return -1; 286 286 } 287 288 return 0; 289 287 290 } 288 291 -
branches/atmospheric_engine/src/subprojects/benchmark.cc
r5750 r8457 455 455 } 456 456 printf("\n"); 457 458 459 460 457 } 461 458 459 return 0; 462 460 } 463 461 -
branches/atmospheric_engine/src/util/kill_target.cc
r7466 r8457 31 31 */ 32 32 KillTarget::KillTarget (const TiXmlElement* root) 33 : MissionGoal(root) 34 { 35 this->setClassID(CL_KILL_TARGET, "KillTarget"); 33 : MissionGoal(root) { 34 this->setClassID(CL_KILL_TARGET, "KillTarget"); 36 35 37 if( root != NULL)38 this->loadParams(root);36 if( root != NULL) 37 this->loadParams(root); 39 38 } 40 39 … … 43 42 * standard deconstructor 44 43 */ 45 KillTarget::~KillTarget () 46 { 47 44 KillTarget::~KillTarget () { 48 45 } 49 46 50 47 51 void KillTarget::loadParams(const TiXmlElement* root) 52 { 53 MissionGoal::loadParams(root); 48 void KillTarget::loadParams(const TiXmlElement* root) { 49 MissionGoal::loadParams(root); 54 50 55 LoadParam(root, "numberofkills", this, KillTarget, setNumberOfKills)56 57 LoadParam(root, "targetclassid", this, KillTarget, setTargetClassID)58 51 LoadParam(root, "numberofkills", this, KillTarget, setNumberOfKills) 52 .describe("sets the number of kills a target has to be killed"); 53 LoadParam(root, "targetclassid", this, KillTarget, setTargetClassID) 54 .describe("sets the targets class id"); 59 55 } 60 56 61 57 62 MissionState KillTarget::checkMissionGoal(float dt) 63 { 58 MissionState KillTarget::checkMissionGoal(float dt) {} 64 59 65 }66 67 68 69 70 -
branches/atmospheric_engine/src/world_entities/movie_entity.cc
r7221 r8457 120 120 counter = (int)(fps * timer); 121 121 122 if ( counter >= media_container->getFrameCount())122 if ((unsigned int)counter >= media_container->getFrameCount()) 123 123 { 124 124 timer = 0; … … 138 138 void MovieEntity::draw() const 139 139 { 140 if(!mediaLoaded)141 false;140 // if(!mediaLoaded) 141 // false; 142 142 143 143 glPushAttrib(GL_ENABLE_BIT);
Note: See TracChangeset
for help on using the changeset viewer.