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 "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 | public: |
---|
28 | RainEffect(const TiXmlElement* root = NULL); |
---|
29 | virtual ~RainEffect(); |
---|
30 | |
---|
31 | virtual void loadParams(const TiXmlElement* root); |
---|
32 | |
---|
33 | virtual void init(); |
---|
34 | |
---|
35 | virtual void activate(); |
---|
36 | virtual void deactivate(); |
---|
37 | |
---|
38 | inline void activateRain() |
---|
39 | { |
---|
40 | this->activate(); |
---|
41 | } |
---|
42 | |
---|
43 | inline void deactivateRain() |
---|
44 | { |
---|
45 | this->deactivate(); |
---|
46 | } |
---|
47 | |
---|
48 | virtual void tick(float dt); |
---|
49 | |
---|
50 | void startRaining(); |
---|
51 | void stopRaining(); |
---|
52 | |
---|
53 | void hideRain(); |
---|
54 | |
---|
55 | inline void setRainCoord(float x, float y, float z) |
---|
56 | { |
---|
57 | this->rainCoord = Vector(x, y, z); |
---|
58 | } |
---|
59 | inline void setRainSize(float x, float y) |
---|
60 | { |
---|
61 | this->rainSize = Vector2D(x, y); |
---|
62 | } |
---|
63 | inline void setRainRate(float rate) |
---|
64 | { |
---|
65 | this->rainRate = rate; |
---|
66 | } |
---|
67 | inline void setRainVelocity(float velocity) |
---|
68 | { |
---|
69 | this->rainVelocity = -velocity; |
---|
70 | } |
---|
71 | inline void setRainLife(float life) |
---|
72 | { |
---|
73 | this->rainLife = life; |
---|
74 | } |
---|
75 | inline void setRainWind(int force) |
---|
76 | { |
---|
77 | this->rainWindForce = force; |
---|
78 | } |
---|
79 | |
---|
80 | inline void setRainFadeIn(float fadein) |
---|
81 | { |
---|
82 | this->rainFadeInDuration = fadein; |
---|
83 | } |
---|
84 | inline void setRainFadeOut(float fadeout) |
---|
85 | { |
---|
86 | this->rainFadeOutDuration = fadeout; |
---|
87 | } |
---|
88 | |
---|
89 | inline void setCloudColor(float colorX, float colorY, float colorZ) |
---|
90 | { |
---|
91 | this->cloudColor = Vector(colorX, colorY, colorZ); |
---|
92 | } |
---|
93 | inline void setSkyColor(float colorX, float colorY, float colorZ) |
---|
94 | { |
---|
95 | this->skyColor = Vector(colorX, colorY, colorZ); |
---|
96 | } |
---|
97 | |
---|
98 | inline void setRainOption(const std::string& option) |
---|
99 | { |
---|
100 | if (option == "moverain") |
---|
101 | this->rainMove = true; |
---|
102 | if (option == "activate") |
---|
103 | this->rainActivate = true; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | private: |
---|
108 | static SparkParticles* rainParticles; |
---|
109 | ParticleEmitter* emitter; |
---|
110 | |
---|
111 | float localTimer; |
---|
112 | |
---|
113 | GLfloat rainFadeInDuration; |
---|
114 | GLfloat rainFadeOutDuration; |
---|
115 | |
---|
116 | Vector rainCoord; |
---|
117 | Vector2D rainSize; |
---|
118 | GLfloat rainRate; |
---|
119 | GLfloat rainVelocity; |
---|
120 | GLfloat rainLife; |
---|
121 | GLfloat rainMaxParticles; |
---|
122 | int rainWindForce; |
---|
123 | bool rainMove; |
---|
124 | bool rainActivate; |
---|
125 | |
---|
126 | OrxSound::SoundSource soundSource; |
---|
127 | OrxSound::SoundBuffer* rainBuffer; |
---|
128 | OrxSound::SoundBuffer* windBuffer; |
---|
129 | |
---|
130 | float soundRainVolume; |
---|
131 | |
---|
132 | LightManager* lightMan; |
---|
133 | GLfloat rainAmbient; |
---|
134 | |
---|
135 | Vector oldSkyColor; |
---|
136 | Vector oldCloudColor; |
---|
137 | Vector skyColor; |
---|
138 | Vector cloudColor; |
---|
139 | |
---|
140 | }; |
---|
141 | |
---|
142 | #endif /* _RAIN_EFFECT */ |
---|