[7573] | 1 | /** |
---|
[7652] | 2 | * @file snow_effect.h |
---|
| 3 | */ |
---|
[7573] | 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; |
---|
[7576] | 16 | class PlaneEmitter; |
---|
[7650] | 17 | class PNode; |
---|
[7573] | 18 | |
---|
[7810] | 19 | #include "sound_source.h" |
---|
[7696] | 20 | #include "sound_buffer.h" |
---|
| 21 | |
---|
[8495] | 22 | class SnowEffect : public WeatherEffect { |
---|
| 23 | public: |
---|
| 24 | SnowEffect(const TiXmlElement* root = NULL); |
---|
| 25 | virtual ~SnowEffect(); |
---|
[7573] | 26 | |
---|
[8495] | 27 | virtual void loadParams(const TiXmlElement* root); |
---|
[7573] | 28 | |
---|
[8495] | 29 | virtual void init(); |
---|
[7573] | 30 | |
---|
[8495] | 31 | virtual void activate(); |
---|
| 32 | virtual void deactivate(); |
---|
[7573] | 33 | |
---|
[8495] | 34 | inline void activateSnow() { |
---|
| 35 | this->activate(); |
---|
| 36 | } |
---|
| 37 | inline void deactivateSnow() { |
---|
| 38 | this->deactivate(); |
---|
| 39 | } |
---|
[7649] | 40 | |
---|
[8495] | 41 | virtual void draw() const; |
---|
| 42 | virtual void tick(float dt); |
---|
[7651] | 43 | |
---|
[7696] | 44 | |
---|
[8495] | 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 | } |
---|
[7696] | 79 | |
---|
[8495] | 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 | } |
---|
[8255] | 87 | |
---|
[7651] | 88 | |
---|
[8495] | 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; |
---|
[7573] | 102 | |
---|
[8495] | 103 | bool snowMove; |
---|
| 104 | bool snowActivate; |
---|
[7651] | 105 | |
---|
[8495] | 106 | PlaneEmitter* emitter; |
---|
[7651] | 107 | |
---|
[8495] | 108 | static SpriteParticles* snowParticles; |
---|
| 109 | OrxSound::SoundSource soundSource; |
---|
| 110 | OrxSound::SoundBuffer* windBuffer; |
---|
| 111 | |
---|
[7573] | 112 | }; |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | #endif /* _SNOW_EFFECT */ |
---|