| 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 | { |
|---|
| 26 | public: |
|---|
| 27 | RainEffect(const TiXmlElement* root = NULL); |
|---|
| 28 | virtual ~RainEffect(); |
|---|
| 29 | |
|---|
| 30 | virtual void loadParams(const TiXmlElement* root); |
|---|
| 31 | |
|---|
| 32 | virtual bool init(); |
|---|
| 33 | |
|---|
| 34 | virtual bool activate(); |
|---|
| 35 | virtual bool deactivate(); |
|---|
| 36 | |
|---|
| 37 | inline void activateRain() { this->activate(); } |
|---|
| 38 | inline void deactivateRain() { this->deactivate(); } |
|---|
| 39 | |
|---|
| 40 | virtual void tick(float dt); |
|---|
| 41 | |
|---|
| 42 | void startRaining(); |
|---|
| 43 | void stopRaining(); |
|---|
| 44 | |
|---|
| 45 | inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); } |
|---|
| 46 | inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); } |
|---|
| 47 | inline void setRainRate(float rate) { this->rainRate = rate;} |
|---|
| 48 | inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; } |
|---|
| 49 | inline void setRainLife(float life) { this->rainLife = life; } |
|---|
| 50 | inline void setRainWind(int force) { this->rainWindForce = force; } |
|---|
| 51 | |
|---|
| 52 | inline void setRainFadeIn(float fadein) { this->rainFadeInDuration = fadein; } |
|---|
| 53 | inline void setRainFadeOut(float fadeout) { this->rainFadeOutDuration = fadeout; } |
|---|
| 54 | |
|---|
| 55 | inline void setRainOption(const std::string& option) { |
|---|
| 56 | if (option == "moverain") this->rainMove = true; |
|---|
| 57 | if (option == "activate") this->rainActivate = true; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | private: |
|---|
| 62 | static SparkParticles* rainParticles; |
|---|
| 63 | ParticleEmitter* emitter; |
|---|
| 64 | |
|---|
| 65 | GLfloat rainFadeInDuration; |
|---|
| 66 | GLfloat rainFadeOutDuration; |
|---|
| 67 | float localTimer; |
|---|
| 68 | |
|---|
| 69 | Vector rainCoord; |
|---|
| 70 | Vector2D rainSize; |
|---|
| 71 | GLfloat rainRate; |
|---|
| 72 | GLfloat rainVelocity; |
|---|
| 73 | GLfloat rainLife; |
|---|
| 74 | GLfloat rainMaxParticles; |
|---|
| 75 | int rainWindForce; |
|---|
| 76 | bool rainMove; |
|---|
| 77 | bool rainActivate; |
|---|
| 78 | |
|---|
| 79 | OrxSound::SoundSource soundSource; |
|---|
| 80 | OrxSound::SoundBuffer* rainBuffer; |
|---|
| 81 | OrxSound::SoundBuffer* windBuffer; |
|---|
| 82 | |
|---|
| 83 | float soundRainVolume; |
|---|
| 84 | |
|---|
| 85 | LightManager* lightMan; |
|---|
| 86 | GLfloat rainAmbient; |
|---|
| 87 | |
|---|
| 88 | }; |
|---|
| 89 | |
|---|
| 90 | #endif /* _RAIN_EFFECT */ |
|---|