1 | /** |
---|
2 | * @file rain_effect.h |
---|
3 | * Generates rain using the particle engine |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _RAIN_EFFECT |
---|
7 | #define _RAIN_EFFECT |
---|
8 | |
---|
9 | #include "weather_effect.h" |
---|
10 | |
---|
11 | #include "vector.h" |
---|
12 | #include "vector2D.h" |
---|
13 | #include <string> |
---|
14 | |
---|
15 | #include "particles/particle_system.h" |
---|
16 | |
---|
17 | class SparkParticles; |
---|
18 | class PlainEmitter; |
---|
19 | class LightManager; |
---|
20 | class CloudEffect; |
---|
21 | |
---|
22 | #include "sound_buffer.h" |
---|
23 | #include "sound_source.h" |
---|
24 | |
---|
25 | class RainEffect : public WeatherEffect |
---|
26 | { |
---|
27 | ObjectListDeclaration(RainEffect); |
---|
28 | public: |
---|
29 | RainEffect(const TiXmlElement* root = NULL); |
---|
30 | virtual ~RainEffect(); |
---|
31 | |
---|
32 | virtual void loadParams(const TiXmlElement* root); |
---|
33 | |
---|
34 | virtual void init(); |
---|
35 | |
---|
36 | virtual void activate(); |
---|
37 | virtual void deactivate(); |
---|
38 | |
---|
39 | inline void activateRain() |
---|
40 | { |
---|
41 | this->activate(); |
---|
42 | } |
---|
43 | |
---|
44 | inline void deactivateRain() |
---|
45 | { |
---|
46 | this->deactivate(); |
---|
47 | } |
---|
48 | |
---|
49 | virtual void tick(float dt); |
---|
50 | |
---|
51 | void startRaining(); |
---|
52 | void stopRaining(); |
---|
53 | |
---|
54 | void hideRain(); |
---|
55 | |
---|
56 | inline void setRainCoord(float x, float y, float z) |
---|
57 | { |
---|
58 | this->rainCoord = Vector(x, y, z); |
---|
59 | } |
---|
60 | inline void setRainSize(float x, float y) |
---|
61 | { |
---|
62 | this->rainSize = Vector2D(x, y); |
---|
63 | } |
---|
64 | inline void setRainRate(float rate) |
---|
65 | { |
---|
66 | this->rainRate = rate; |
---|
67 | } |
---|
68 | inline void setRainVelocity(float velocity) |
---|
69 | { |
---|
70 | this->rainVelocity = -velocity; |
---|
71 | } |
---|
72 | inline void setRainLife(float life) |
---|
73 | { |
---|
74 | this->rainLife = life; |
---|
75 | } |
---|
76 | inline void setRainWind(int force) |
---|
77 | { |
---|
78 | this->rainWindForce = force; |
---|
79 | } |
---|
80 | |
---|
81 | inline void setRainFadeIn(float fadein) |
---|
82 | { |
---|
83 | this->rainFadeInDuration = fadein; |
---|
84 | } |
---|
85 | inline void setRainFadeOut(float fadeout) |
---|
86 | { |
---|
87 | this->rainFadeOutDuration = fadeout; |
---|
88 | } |
---|
89 | |
---|
90 | inline void setCloudColor(float colorX, float colorY, float colorZ) |
---|
91 | { |
---|
92 | this->cloudColor = Vector(colorX, colorY, colorZ); |
---|
93 | } |
---|
94 | inline void setSkyColor(float colorX, float colorY, float colorZ) |
---|
95 | { |
---|
96 | this->skyColor = Vector(colorX, colorY, colorZ); |
---|
97 | } |
---|
98 | |
---|
99 | inline void setRainOption(const std::string& option) |
---|
100 | { |
---|
101 | if (option == "moverain") |
---|
102 | this->rainMove = true; |
---|
103 | if (option == "activate") |
---|
104 | this->rainActivate = true; |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | private: |
---|
109 | static SparkParticles* rainParticles; |
---|
110 | ParticleEmitter* emitter; |
---|
111 | |
---|
112 | float localTimer; |
---|
113 | |
---|
114 | GLfloat rainFadeInDuration; |
---|
115 | GLfloat rainFadeOutDuration; |
---|
116 | bool rainFadeInActivate; |
---|
117 | bool rainFadeOutActivate; |
---|
118 | |
---|
119 | Vector rainCoord; |
---|
120 | Vector2D rainSize; |
---|
121 | GLfloat rainRate; |
---|
122 | GLfloat rainVelocity; |
---|
123 | GLfloat rainLife; |
---|
124 | GLfloat rainMaxParticles; |
---|
125 | int rainWindForce; |
---|
126 | bool rainMove; |
---|
127 | bool rainActivate; |
---|
128 | |
---|
129 | OrxSound::SoundSource soundSource; |
---|
130 | OrxSound::SoundBuffer rainBuffer; |
---|
131 | OrxSound::SoundBuffer windBuffer; |
---|
132 | |
---|
133 | float soundRainVolume; |
---|
134 | |
---|
135 | Vector oldSkyColor; |
---|
136 | Vector oldCloudColor; |
---|
137 | Vector skyColor; |
---|
138 | Vector cloudColor; |
---|
139 | |
---|
140 | LightManager* lightMan; |
---|
141 | |
---|
142 | }; |
---|
143 | |
---|
144 | #endif /* _RAIN_EFFECT */ |
---|