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