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