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