| 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 | { |
|---|
| 24 | public: |
|---|
| 25 | SnowEffect(const TiXmlElement* root = NULL); |
|---|
| 26 | virtual ~SnowEffect(); |
|---|
| 27 | |
|---|
| 28 | virtual void loadParams(const TiXmlElement* root); |
|---|
| 29 | |
|---|
| 30 | virtual bool init(); |
|---|
| 31 | |
|---|
| 32 | virtual bool activate(); |
|---|
| 33 | virtual bool deactivate(); |
|---|
| 34 | |
|---|
| 35 | inline void activateSnow() { this->activate(); } |
|---|
| 36 | inline void deactivateSnow() { this->deactivate(); } |
|---|
| 37 | |
|---|
| 38 | virtual void draw() const; |
|---|
| 39 | virtual void tick(float dt); |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | inline void numParticles(int n) { this->particles = n; } |
|---|
| 43 | inline void materialTexture(const std::string& texture) { this->texture = texture; } |
|---|
| 44 | inline void lifeSpan(float lifeSpan, float randomLifeSpan) { this->life = lifeSpan; this->randomLife = randomLifeSpan; } |
|---|
| 45 | inline void radius(float radius, float randomRadius) { this->snowRadius = radius; this->randomRadius = randomRadius; } |
|---|
| 46 | inline void mass(float mass, float randomMass) { this->snowMass = mass; this->randomMass = randomMass; } |
|---|
| 47 | inline void emissionRate(float emissionRate){ this->rate = emissionRate; } |
|---|
| 48 | inline void emissionVelocity(float velocity, float randomVelocity){ this->velocity = velocity; this->randomVelocity = randomVelocity; } |
|---|
| 49 | inline void size(float sizeX, float sizeY) { this->snowSize = Vector2D(sizeX, sizeY); } |
|---|
| 50 | inline void coord(float x, float y, float z) { this->snowCoord = Vector(x, y, z); } |
|---|
| 51 | inline void wind(int force) { this->snowWindForce = force; } |
|---|
| 52 | |
|---|
| 53 | inline void setSnowOption(const std::string& option) { |
|---|
| 54 | /*if (option == "fade") this->snowFade = true;*/ |
|---|
| 55 | if (option == "movesnow") this->snowMove = true; |
|---|
| 56 | if (option == "activate") this->snowActivate = true; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | private: |
|---|
| 61 | int particles; |
|---|
| 62 | std::string texture; |
|---|
| 63 | float life, randomLife; |
|---|
| 64 | float snowRadius, randomRadius; |
|---|
| 65 | float snowMass, randomMass; |
|---|
| 66 | float rate; |
|---|
| 67 | float velocity, randomVelocity; |
|---|
| 68 | float angle, randomAngle; |
|---|
| 69 | float alpha; |
|---|
| 70 | Vector snowCoord; |
|---|
| 71 | Vector2D snowSize; |
|---|
| 72 | int snowWindForce; |
|---|
| 73 | |
|---|
| 74 | bool snowMove; |
|---|
| 75 | bool snowActivate; |
|---|
| 76 | |
|---|
| 77 | PlaneEmitter* emitter; |
|---|
| 78 | |
|---|
| 79 | static SpriteParticles* snowParticles; |
|---|
| 80 | OrxSound::SoundSource soundSource; |
|---|
| 81 | OrxSound::SoundBuffer* windBuffer; |
|---|
| 82 | |
|---|
| 83 | }; |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | #endif /* _SNOW_EFFECT */ |
|---|