1 | /** |
---|
2 | * @file fog_effect.h |
---|
3 | */ |
---|
4 | |
---|
5 | #ifndef _FOG_EFFECT |
---|
6 | #define _FOG_EFFECT |
---|
7 | |
---|
8 | #include "weather_effect.h" |
---|
9 | #include "glincl.h" |
---|
10 | #include "vector.h" |
---|
11 | |
---|
12 | class FogEffect : public WeatherEffect { |
---|
13 | public: |
---|
14 | FogEffect(const TiXmlElement* root = NULL); |
---|
15 | virtual ~FogEffect(); |
---|
16 | |
---|
17 | virtual void loadParams(const TiXmlElement* root); |
---|
18 | |
---|
19 | virtual void init(); |
---|
20 | |
---|
21 | virtual void activate(); |
---|
22 | virtual void deactivate(); |
---|
23 | |
---|
24 | void activateFog() { |
---|
25 | this->activate(); |
---|
26 | } |
---|
27 | void deactivateFog() { |
---|
28 | this->deactivate(); |
---|
29 | } |
---|
30 | |
---|
31 | virtual void draw() const; |
---|
32 | virtual void tick(float dt); |
---|
33 | |
---|
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 | } |
---|
53 | |
---|
54 | inline void setFogOption(const std::string& option) { |
---|
55 | if (option == "activate") |
---|
56 | this->fogActivate = true; |
---|
57 | } |
---|
58 | |
---|
59 | void fadeInFog(); |
---|
60 | void fadeOutFog(); |
---|
61 | |
---|
62 | |
---|
63 | private: |
---|
64 | inline GLint stringToFogMode(const std::string& mode) { |
---|
65 | if(mode == "GL_LINEAR") |
---|
66 | return GL_LINEAR; |
---|
67 | else if(mode == "GL_EXP") |
---|
68 | return GL_EXP; |
---|
69 | else if(mode == "GL_EXP2" ) |
---|
70 | return GL_EXP2; |
---|
71 | else |
---|
72 | return -1; |
---|
73 | } |
---|
74 | |
---|
75 | bool fogActivate; |
---|
76 | |
---|
77 | bool fogFadeInActivate; |
---|
78 | bool fogFadeOutActivate; |
---|
79 | |
---|
80 | GLfloat fogFadeInDuration; |
---|
81 | GLfloat fogFadeOutDuration; |
---|
82 | |
---|
83 | float localTimer; |
---|
84 | |
---|
85 | GLint fogMode; |
---|
86 | GLfloat fogDensity; |
---|
87 | GLfloat fogFadeDensity; |
---|
88 | |
---|
89 | GLfloat fogStart; |
---|
90 | GLfloat fogEnd; |
---|
91 | Vector colorVector; |
---|
92 | }; |
---|
93 | |
---|
94 | |
---|
95 | #endif /* _FOG_EFFECT */ |
---|