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