| 1 | /** | 
|---|
| 2 | * @file snow_effect.h | 
|---|
| 3 | */ | 
|---|
| 4 |  | 
|---|
| 5 | #ifndef _SNOW_EFFECT | 
|---|
| 6 | #define _SNOW_EFFECT | 
|---|
| 7 |  | 
|---|
| 8 | #include "vector.h" | 
|---|
| 9 | #include "particle_system.h" | 
|---|
| 10 | #include "material.h" | 
|---|
| 11 | #include "vector2D.h" | 
|---|
| 12 |  | 
|---|
| 13 | #include "weather_effect.h" | 
|---|
| 14 |  | 
|---|
| 15 | class SpriteParticles; | 
|---|
| 16 | class PlaneEmitter; | 
|---|
| 17 | class PNode; | 
|---|
| 18 |  | 
|---|
| 19 | #include "sound_source.h" | 
|---|
| 20 | #include "sound_buffer.h" | 
|---|
| 21 |  | 
|---|
| 22 | class SnowEffect : public WeatherEffect { | 
|---|
| 23 | public: | 
|---|
| 24 |     SnowEffect(const TiXmlElement* root = NULL); | 
|---|
| 25 |     virtual ~SnowEffect(); | 
|---|
| 26 |  | 
|---|
| 27 |     virtual void loadParams(const TiXmlElement* root); | 
|---|
| 28 |  | 
|---|
| 29 |     virtual void init(); | 
|---|
| 30 |  | 
|---|
| 31 |     virtual void activate(); | 
|---|
| 32 |     virtual void deactivate(); | 
|---|
| 33 |  | 
|---|
| 34 |     inline void activateSnow() { | 
|---|
| 35 |         this->activate(); | 
|---|
| 36 |     } | 
|---|
| 37 |     inline void deactivateSnow() { | 
|---|
| 38 |         this->deactivate(); | 
|---|
| 39 |     } | 
|---|
| 40 |  | 
|---|
| 41 |     virtual void draw() const; | 
|---|
| 42 |     virtual void tick(float dt); | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 |     inline void numParticles(int n) { | 
|---|
| 46 |         this->particles = n; | 
|---|
| 47 |     } | 
|---|
| 48 |     inline void materialTexture(const std::string& texture) { | 
|---|
| 49 |         this->texture = texture; | 
|---|
| 50 |     } | 
|---|
| 51 |     inline void lifeSpan(float lifeSpan, float randomLifeSpan) { | 
|---|
| 52 |         this->snowLife = lifeSpan; | 
|---|
| 53 |         this->randomLife = randomLifeSpan; | 
|---|
| 54 |     } | 
|---|
| 55 |     inline void radius(float radius, float randomRadius) { | 
|---|
| 56 |         this->snowRadius = radius; | 
|---|
| 57 |         this->randomRadius = randomRadius; | 
|---|
| 58 |     } | 
|---|
| 59 |     inline void mass(float mass, float randomMass) { | 
|---|
| 60 |         this->snowMass = mass; | 
|---|
| 61 |         this->randomMass = randomMass; | 
|---|
| 62 |     } | 
|---|
| 63 |     inline void emissionRate(float emissionRate) { | 
|---|
| 64 |         this->rate = emissionRate; | 
|---|
| 65 |     } | 
|---|
| 66 |     inline void emissionVelocity(float velocity, float randomVelocity) { | 
|---|
| 67 |         this->velocity = velocity; | 
|---|
| 68 |         this->randomVelocity = randomVelocity; | 
|---|
| 69 |     } | 
|---|
| 70 |     inline void size(float sizeX, float sizeY) { | 
|---|
| 71 |         this->snowSize = Vector2D(sizeX, sizeY); | 
|---|
| 72 |     } | 
|---|
| 73 |     inline void coord(float x, float y, float z) { | 
|---|
| 74 |         this->snowCoord = Vector(x, y, z); | 
|---|
| 75 |     } | 
|---|
| 76 |     inline void wind(int force) { | 
|---|
| 77 |         this->snowWindForce = force; | 
|---|
| 78 |     } | 
|---|
| 79 |  | 
|---|
| 80 |     inline void setSnowOption(const std::string& option) { | 
|---|
| 81 |         /*if (option == "fade") this->snowFade = true;*/ | 
|---|
| 82 |         if (option == "movesnow") | 
|---|
| 83 |             this->snowMove = true; | 
|---|
| 84 |         if (option == "activate") | 
|---|
| 85 |             this->snowActivate = true; | 
|---|
| 86 |     } | 
|---|
| 87 |  | 
|---|
| 88 |  | 
|---|
| 89 | private: | 
|---|
| 90 |     int         particles; | 
|---|
| 91 |     std::string       texture; | 
|---|
| 92 |     float       snowLife, randomLife; | 
|---|
| 93 |     float       snowRadius, randomRadius; | 
|---|
| 94 |     float       snowMass, randomMass; | 
|---|
| 95 |     float         rate; | 
|---|
| 96 |     float         velocity, randomVelocity; | 
|---|
| 97 |     float         angle, randomAngle; | 
|---|
| 98 |     float         alpha; | 
|---|
| 99 |     Vector        snowCoord; | 
|---|
| 100 |     Vector2D      snowSize; | 
|---|
| 101 |     int       snowWindForce; | 
|---|
| 102 |  | 
|---|
| 103 |     bool        snowMove; | 
|---|
| 104 |     bool        snowActivate; | 
|---|
| 105 |  | 
|---|
| 106 |     PlaneEmitter*     emitter; | 
|---|
| 107 |  | 
|---|
| 108 |     static SpriteParticles*   snowParticles; | 
|---|
| 109 |     OrxSound::SoundSource   soundSource; | 
|---|
| 110 |     OrxSound::SoundBuffer*    windBuffer; | 
|---|
| 111 |  | 
|---|
| 112 | }; | 
|---|
| 113 |  | 
|---|
| 114 |  | 
|---|
| 115 | #endif  /* _SNOW_EFFECT */ | 
|---|