1 | /** |
---|
2 | * @file fog_effect.h |
---|
3 | */ |
---|
4 | |
---|
5 | #ifndef _FOG_EFFECT |
---|
6 | #define _FOG_EFFECT |
---|
7 | |
---|
8 | #include "vector.h" |
---|
9 | |
---|
10 | #include "weather_effect.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 | GLint stringToFogMode(const std::string& mode); |
---|
65 | |
---|
66 | bool fogActivate; |
---|
67 | |
---|
68 | bool fogFadeInActivate; |
---|
69 | bool fogFadeOutActivate; |
---|
70 | |
---|
71 | GLfloat fogFadeInDuration; |
---|
72 | GLfloat fogFadeOutDuration; |
---|
73 | |
---|
74 | float localTimer; |
---|
75 | |
---|
76 | GLint fogMode; |
---|
77 | GLfloat fogDensity; |
---|
78 | GLfloat fogFadeDensity; |
---|
79 | |
---|
80 | GLfloat fogStart; |
---|
81 | GLfloat fogEnd; |
---|
82 | Vector colorVector; |
---|
83 | }; |
---|
84 | |
---|
85 | |
---|
86 | #endif /* _FOG_EFFECT */ |
---|