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