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