[7561] | 1 | /** |
---|
[8793] | 2 | * @file rain_effect.h |
---|
| 3 | * Generates rain using the particle engine |
---|
[7652] | 4 | */ |
---|
[7561] | 5 | |
---|
| 6 | #ifndef _RAIN_EFFECT |
---|
| 7 | #define _RAIN_EFFECT |
---|
| 8 | |
---|
[8793] | 9 | #include "weather_effect.h" |
---|
| 10 | |
---|
[7562] | 11 | #include "vector.h" |
---|
[7628] | 12 | #include "vector2D.h" |
---|
[7685] | 13 | #include <string> |
---|
[7628] | 14 | |
---|
[7561] | 15 | #include "particle_system.h" |
---|
| 16 | |
---|
[7577] | 17 | class SparkParticles; |
---|
[7628] | 18 | class PlainEmitter; |
---|
[8255] | 19 | class LightManager; |
---|
[8793] | 20 | class CloudEffect; |
---|
[7577] | 21 | |
---|
[7646] | 22 | #include "sound_buffer.h" |
---|
| 23 | #include "sound_source.h" |
---|
[7562] | 24 | |
---|
[8793] | 25 | class RainEffect : public WeatherEffect |
---|
| 26 | { |
---|
[8495] | 27 | public: |
---|
[8793] | 28 | RainEffect(const TiXmlElement* root = NULL); |
---|
| 29 | virtual ~RainEffect(); |
---|
[7561] | 30 | |
---|
[8793] | 31 | virtual void loadParams(const TiXmlElement* root); |
---|
[7561] | 32 | |
---|
[8793] | 33 | virtual void init(); |
---|
[7561] | 34 | |
---|
[8793] | 35 | virtual void activate(); |
---|
| 36 | virtual void deactivate(); |
---|
[7561] | 37 | |
---|
[8793] | 38 | inline void activateRain() |
---|
| 39 | { |
---|
| 40 | this->activate(); |
---|
| 41 | } |
---|
[7646] | 42 | |
---|
[8793] | 43 | inline void deactivateRain() |
---|
| 44 | { |
---|
| 45 | this->deactivate(); |
---|
| 46 | } |
---|
[8255] | 47 | |
---|
[8793] | 48 | virtual void tick(float dt); |
---|
[7561] | 49 | |
---|
[8793] | 50 | void startRaining(); |
---|
| 51 | void stopRaining(); |
---|
[7577] | 52 | |
---|
[8793] | 53 | void hideRain(); |
---|
[8255] | 54 | |
---|
[8793] | 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 | } |
---|
[7646] | 79 | |
---|
[8793] | 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 | } |
---|
[7652] | 97 | |
---|
[8793] | 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 | |
---|
[8495] | 107 | private: |
---|
[8793] | 108 | static SparkParticles* rainParticles; |
---|
| 109 | ParticleEmitter* emitter; |
---|
[8255] | 110 | |
---|
[8793] | 111 | float localTimer; |
---|
[8255] | 112 | |
---|
[8793] | 113 | GLfloat rainFadeInDuration; |
---|
| 114 | GLfloat rainFadeOutDuration; |
---|
[8255] | 115 | |
---|
[8793] | 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; |
---|
[8255] | 125 | |
---|
[8793] | 126 | OrxSound::SoundSource soundSource; |
---|
| 127 | OrxSound::SoundBuffer* rainBuffer; |
---|
| 128 | OrxSound::SoundBuffer* windBuffer; |
---|
[8495] | 129 | |
---|
[8793] | 130 | float soundRainVolume; |
---|
[8495] | 131 | |
---|
[8793] | 132 | LightManager* lightMan; |
---|
| 133 | GLfloat rainAmbient; |
---|
| 134 | |
---|
| 135 | Vector oldSkyColor; |
---|
| 136 | Vector oldCloudColor; |
---|
| 137 | Vector skyColor; |
---|
| 138 | Vector cloudColor; |
---|
| 139 | |
---|
[7561] | 140 | }; |
---|
| 141 | |
---|
| 142 | #endif /* _RAIN_EFFECT */ |
---|