[6741] | 1 | /** |
---|
[8793] | 2 | * @file fog_effect.h |
---|
| 3 | * Generates simple openGL fog |
---|
[7810] | 4 | */ |
---|
[6741] | 5 | |
---|
| 6 | #ifndef _FOG_EFFECT |
---|
| 7 | #define _FOG_EFFECT |
---|
| 8 | |
---|
[7810] | 9 | #include "weather_effect.h" |
---|
[8362] | 10 | #include "glincl.h" |
---|
[8495] | 11 | #include "vector.h" |
---|
[6741] | 12 | |
---|
[8793] | 13 | class FogEffect : public WeatherEffect |
---|
| 14 | { |
---|
[8495] | 15 | public: |
---|
[8793] | 16 | FogEffect(const TiXmlElement* root = NULL); |
---|
| 17 | virtual ~FogEffect(); |
---|
[8362] | 18 | |
---|
[8793] | 19 | virtual void loadParams(const TiXmlElement* root); |
---|
[6741] | 20 | |
---|
[8793] | 21 | virtual void init(); |
---|
[6741] | 22 | |
---|
[8793] | 23 | virtual void activate(); |
---|
| 24 | virtual void deactivate(); |
---|
[6741] | 25 | |
---|
[8793] | 26 | void activateFog() |
---|
| 27 | { |
---|
| 28 | this->activate(); |
---|
| 29 | } |
---|
[6772] | 30 | |
---|
[8793] | 31 | void deactivateFog() |
---|
| 32 | { |
---|
| 33 | this->deactivate(); |
---|
| 34 | } |
---|
[8255] | 35 | |
---|
[8793] | 36 | virtual void draw() const; |
---|
| 37 | virtual void tick(float dt); |
---|
[8255] | 38 | |
---|
[8793] | 39 | inline void setFogMode(const std::string& mode) |
---|
| 40 | { |
---|
| 41 | this->fogMode = this->stringToFogMode(mode); |
---|
| 42 | } |
---|
[6772] | 43 | |
---|
[8793] | 44 | inline void setFogDensity(float density) |
---|
| 45 | { |
---|
| 46 | this->fogDensity = density; |
---|
| 47 | } |
---|
[8255] | 48 | |
---|
[8793] | 49 | inline void setFogRange(float start, float end) |
---|
| 50 | { |
---|
| 51 | this->fogStart = start; |
---|
| 52 | this->fogEnd = end; |
---|
| 53 | } |
---|
[6772] | 54 | |
---|
[8793] | 55 | inline void setFogColor(float r, float g, float b) |
---|
| 56 | { |
---|
| 57 | this->colorVector = Vector(r, g, b); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | inline void setFogFadeIn(float fadein) |
---|
| 61 | { |
---|
| 62 | this->fogFadeInDuration = fadein; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | inline void setFogFadeOut(float fadeout) |
---|
| 66 | { |
---|
| 67 | this->fogFadeOutDuration = fadeout; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | inline void setFogOption(const std::string& option) |
---|
| 71 | { |
---|
| 72 | if (option == "activate") |
---|
| 73 | this->fogActivate = true; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void fadeInFog(); |
---|
| 77 | void fadeOutFog(); |
---|
| 78 | |
---|
| 79 | |
---|
[8495] | 80 | private: |
---|
[8793] | 81 | inline GLint stringToFogMode(const std::string& mode) |
---|
| 82 | { |
---|
| 83 | if(mode == "GL_LINEAR") |
---|
| 84 | return GL_LINEAR; |
---|
| 85 | else if(mode == "GL_EXP") |
---|
| 86 | return GL_EXP; |
---|
| 87 | else if(mode == "GL_EXP2" ) |
---|
| 88 | return GL_EXP2; |
---|
| 89 | else |
---|
| 90 | return -1; |
---|
| 91 | } |
---|
[8362] | 92 | |
---|
[8793] | 93 | bool fogActivate; |
---|
[8255] | 94 | |
---|
[8793] | 95 | bool fogFadeInActivate; |
---|
| 96 | bool fogFadeOutActivate; |
---|
[8495] | 97 | |
---|
[8793] | 98 | GLfloat fogFadeInDuration; |
---|
| 99 | GLfloat fogFadeOutDuration; |
---|
[8495] | 100 | |
---|
[8793] | 101 | GLint fogMode; |
---|
| 102 | GLfloat fogDensity; |
---|
| 103 | GLfloat fogFadeDensity; |
---|
[8495] | 104 | |
---|
[8793] | 105 | GLfloat fogStart; |
---|
| 106 | GLfloat fogEnd; |
---|
| 107 | GLfloat fogFadeEnd; |
---|
[8495] | 108 | |
---|
[8793] | 109 | Vector colorVector; |
---|
| 110 | float localTimer; |
---|
[6741] | 111 | }; |
---|
| 112 | |
---|
[7810] | 113 | #endif /* _FOG_EFFECT */ |
---|