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 | class CloudEffect; |
---|
19 | |
---|
20 | #include "sound_source.h" |
---|
21 | #include "sound_buffer.h" |
---|
22 | |
---|
23 | class SnowEffect : public WeatherEffect { |
---|
24 | public: |
---|
25 | SnowEffect(const TiXmlElement* root = NULL); |
---|
26 | virtual ~SnowEffect(); |
---|
27 | |
---|
28 | virtual void loadParams(const TiXmlElement* root); |
---|
29 | |
---|
30 | virtual void init(); |
---|
31 | |
---|
32 | virtual void activate(); |
---|
33 | virtual void deactivate(); |
---|
34 | |
---|
35 | inline void activateSnow() { |
---|
36 | this->activate(); |
---|
37 | } |
---|
38 | inline void deactivateSnow() { |
---|
39 | this->deactivate(); |
---|
40 | } |
---|
41 | |
---|
42 | virtual void draw() const; |
---|
43 | virtual void tick(float dt); |
---|
44 | |
---|
45 | |
---|
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 | } |
---|
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 | } |
---|
92 | |
---|
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 | } |
---|
100 | |
---|
101 | |
---|
102 | private: |
---|
103 | int particles; |
---|
104 | std::string texture; |
---|
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; |
---|
116 | |
---|
117 | bool snowMove; |
---|
118 | bool snowActivate; |
---|
119 | |
---|
120 | PlaneEmitter* emitter; |
---|
121 | |
---|
122 | static SpriteParticles* snowParticles; |
---|
123 | OrxSound::SoundSource soundSource; |
---|
124 | OrxSound::SoundBuffer* windBuffer; |
---|
125 | |
---|
126 | Vector oldSkyColor; |
---|
127 | Vector oldCloudColor; |
---|
128 | Vector skyColor; |
---|
129 | Vector cloudColor; |
---|
130 | }; |
---|
131 | |
---|
132 | |
---|
133 | #endif /* _SNOW_EFFECT */ |
---|