[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; |
---|
[9235] | 18 | class CloudEffect; |
---|
[7573] | 19 | |
---|
[7810] | 20 | #include "sound_source.h" |
---|
[7696] | 21 | #include "sound_buffer.h" |
---|
| 22 | |
---|
[8495] | 23 | class SnowEffect : public WeatherEffect { |
---|
| 24 | public: |
---|
| 25 | SnowEffect(const TiXmlElement* root = NULL); |
---|
| 26 | virtual ~SnowEffect(); |
---|
[7573] | 27 | |
---|
[8495] | 28 | virtual void loadParams(const TiXmlElement* root); |
---|
[7573] | 29 | |
---|
[8495] | 30 | virtual void init(); |
---|
[7573] | 31 | |
---|
[8495] | 32 | virtual void activate(); |
---|
| 33 | virtual void deactivate(); |
---|
[7573] | 34 | |
---|
[8495] | 35 | inline void activateSnow() { |
---|
| 36 | this->activate(); |
---|
| 37 | } |
---|
| 38 | inline void deactivateSnow() { |
---|
| 39 | this->deactivate(); |
---|
| 40 | } |
---|
[7649] | 41 | |
---|
[8495] | 42 | virtual void draw() const; |
---|
| 43 | virtual void tick(float dt); |
---|
[7651] | 44 | |
---|
[7696] | 45 | |
---|
[8495] | 46 | inline void numParticles(int n) { |
---|
| 47 | this->particles = n; |
---|
| 48 | } |
---|
| 49 | inline void materialTexture(const std::string& texture) { |
---|
| 50 | this->texture = texture; |
---|
| 51 | } |
---|
| 52 | inline void lifeSpan(float lifeSpan, float randomLifeSpan) { |
---|
| 53 | this->snowLife = lifeSpan; |
---|
| 54 | this->randomLife = randomLifeSpan; |
---|
| 55 | } |
---|
| 56 | inline void radius(float radius, float randomRadius) { |
---|
| 57 | this->snowRadius = radius; |
---|
| 58 | this->randomRadius = randomRadius; |
---|
| 59 | } |
---|
| 60 | inline void mass(float mass, float randomMass) { |
---|
| 61 | this->snowMass = mass; |
---|
| 62 | this->randomMass = randomMass; |
---|
| 63 | } |
---|
| 64 | inline void emissionRate(float emissionRate) { |
---|
| 65 | this->rate = emissionRate; |
---|
| 66 | } |
---|
| 67 | inline void emissionVelocity(float velocity, float randomVelocity) { |
---|
| 68 | this->velocity = velocity; |
---|
| 69 | this->randomVelocity = randomVelocity; |
---|
| 70 | } |
---|
| 71 | inline void size(float sizeX, float sizeY) { |
---|
| 72 | this->snowSize = Vector2D(sizeX, sizeY); |
---|
| 73 | } |
---|
| 74 | inline void coord(float x, float y, float z) { |
---|
| 75 | this->snowCoord = Vector(x, y, z); |
---|
| 76 | } |
---|
| 77 | inline void wind(int force) { |
---|
| 78 | this->snowWindForce = force; |
---|
| 79 | } |
---|
[9235] | 80 | inline void setCloudColor(float colorX, float colorY, float colorZ) |
---|
| 81 | { |
---|
| 82 | this->cloudColor = Vector(colorX, colorY, colorZ); |
---|
| 83 | } |
---|
| 84 | inline void setSkyColor(float colorX, float colorY, float colorZ) |
---|
| 85 | { |
---|
| 86 | this->skyColor = Vector(colorX, colorY, colorZ); |
---|
| 87 | } |
---|
| 88 | inline void setFadeTime(float time) |
---|
| 89 | { |
---|
| 90 | this->fadeTime = time; |
---|
| 91 | } |
---|
[7696] | 92 | |
---|
[8495] | 93 | inline void setSnowOption(const std::string& option) { |
---|
| 94 | /*if (option == "fade") this->snowFade = true;*/ |
---|
| 95 | if (option == "movesnow") |
---|
| 96 | this->snowMove = true; |
---|
| 97 | if (option == "activate") |
---|
| 98 | this->snowActivate = true; |
---|
| 99 | } |
---|
[8255] | 100 | |
---|
[7651] | 101 | |
---|
[8495] | 102 | private: |
---|
[9406] | 103 | int particles; |
---|
[8495] | 104 | std::string texture; |
---|
[9406] | 105 | float snowLife, randomLife; |
---|
| 106 | float snowRadius, randomRadius; |
---|
| 107 | float snowMass, randomMass; |
---|
| 108 | float rate; |
---|
| 109 | float velocity, randomVelocity; |
---|
| 110 | float angle, randomAngle; |
---|
| 111 | float alpha; |
---|
| 112 | float fadeTime; |
---|
| 113 | Vector snowCoord; |
---|
| 114 | Vector2D snowSize; |
---|
| 115 | int snowWindForce; |
---|
[7573] | 116 | |
---|
[9406] | 117 | bool snowMove; |
---|
| 118 | bool snowActivate; |
---|
[7651] | 119 | |
---|
[8495] | 120 | PlaneEmitter* emitter; |
---|
[7651] | 121 | |
---|
[8495] | 122 | static SpriteParticles* snowParticles; |
---|
[9406] | 123 | OrxSound::SoundSource soundSource; |
---|
[8495] | 124 | OrxSound::SoundBuffer* windBuffer; |
---|
| 125 | |
---|
[9406] | 126 | Vector oldSkyColor; |
---|
| 127 | Vector oldCloudColor; |
---|
| 128 | Vector skyColor; |
---|
| 129 | Vector cloudColor; |
---|
[7573] | 130 | }; |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | #endif /* _SNOW_EFFECT */ |
---|