[8835] | 1 | /** |
---|
| 2 | * @file lightning_effect.h |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #ifndef _LIGHTNING_EFFECT |
---|
| 6 | #define _LIGHTNING_EFFECT |
---|
| 7 | |
---|
| 8 | #include "vector.h" |
---|
| 9 | #include "vector2D.h" |
---|
| 10 | |
---|
| 11 | #include "weather_effect.h" |
---|
| 12 | |
---|
| 13 | #include "sound_buffer.h" |
---|
| 14 | #include "sound_source.h" |
---|
| 15 | |
---|
| 16 | class Billboard; |
---|
| 17 | class Light; |
---|
| 18 | |
---|
[9686] | 19 | class LightningEffect : public WeatherEffect |
---|
| 20 | { |
---|
[9715] | 21 | ObjectListDeclaration(LightningEffect); |
---|
[8835] | 22 | public: |
---|
[9686] | 23 | LightningEffect(const TiXmlElement* root = NULL); |
---|
| 24 | virtual ~LightningEffect(); |
---|
[8835] | 25 | |
---|
[9686] | 26 | virtual void loadParams(const TiXmlElement* root); |
---|
[8835] | 27 | |
---|
[9686] | 28 | virtual void init(); |
---|
[8835] | 29 | |
---|
[9686] | 30 | virtual void activate(); |
---|
| 31 | virtual void deactivate(); |
---|
[8835] | 32 | |
---|
[9686] | 33 | inline void activateLightning() |
---|
| 34 | { |
---|
| 35 | this->activate(); |
---|
| 36 | } |
---|
| 37 | inline void deactivateLightning() |
---|
| 38 | { |
---|
| 39 | this->deactivate(); |
---|
| 40 | } |
---|
[8835] | 41 | |
---|
[9686] | 42 | virtual void tick(float dt); |
---|
[8835] | 43 | |
---|
[9686] | 44 | void coord(float x, float y, float z); |
---|
| 45 | void setFlashSize(float width, float height, float seedWidth, float seedHeight); |
---|
[8835] | 46 | |
---|
[9686] | 47 | inline void setLightningOption(const std::string& option) |
---|
| 48 | { |
---|
| 49 | if (option == "activate") |
---|
| 50 | this->lightningActivate = true; |
---|
| 51 | if (option == "movelightning") |
---|
| 52 | this->lightningMove = true; |
---|
| 53 | } |
---|
[8835] | 54 | |
---|
[9686] | 55 | inline void setFlashFrequency(float baseFrequency, float seedTime) |
---|
| 56 | { |
---|
| 57 | this->flashFrequencyBase = baseFrequency; |
---|
| 58 | this->flashFrequency = baseFrequency; |
---|
| 59 | this->flashFrequencySeed = seedTime; |
---|
| 60 | } |
---|
[8835] | 61 | |
---|
[9686] | 62 | inline void setFlashConstTime(float holdTime) |
---|
| 63 | { |
---|
| 64 | this->flashHoldTime = holdTime; |
---|
| 65 | } |
---|
[8835] | 66 | |
---|
[9686] | 67 | inline void setFlashRisingTime(float flashRisingTime) |
---|
| 68 | { |
---|
| 69 | if(flashRisingTime > this->flashHoldTime) |
---|
| 70 | this->flashRisingTime = this->flashHoldTime * 0.5; |
---|
| 71 | else |
---|
| 72 | this->flashRisingTime = flashRisingTime; |
---|
| 73 | } |
---|
[8835] | 74 | |
---|
[9686] | 75 | inline void setFlashSeed(float seedX, float seedZ) |
---|
| 76 | { |
---|
| 77 | this->seedX = seedX; |
---|
| 78 | this->seedZ = seedZ; |
---|
| 79 | } |
---|
[8835] | 80 | |
---|
| 81 | |
---|
| 82 | private: |
---|
| 83 | |
---|
[9686] | 84 | void newCoordinates(); |
---|
| 85 | void setTexture(); |
---|
| 86 | void switchTexture(); |
---|
[8835] | 87 | |
---|
[9686] | 88 | Billboard* thunderBolt[4]; |
---|
| 89 | bool thunderTextureA; |
---|
[8835] | 90 | |
---|
[9686] | 91 | bool lightningActivate; |
---|
| 92 | bool lightningMove; |
---|
[8835] | 93 | |
---|
[9686] | 94 | float flashFrequency; |
---|
| 95 | float flashFrequencyBase; |
---|
| 96 | float flashHoldTime; |
---|
| 97 | float flashRisingTime; |
---|
[8835] | 98 | |
---|
[9686] | 99 | float time; |
---|
[8835] | 100 | |
---|
[9686] | 101 | float width; |
---|
| 102 | float height; |
---|
| 103 | float seedWidth; |
---|
| 104 | float seedHeight; |
---|
[8835] | 105 | |
---|
[9686] | 106 | float seedX; |
---|
| 107 | float seedZ; |
---|
| 108 | float flashFrequencySeed; |
---|
[8835] | 109 | |
---|
[9686] | 110 | float mainPosX; |
---|
| 111 | float mainPosY; |
---|
| 112 | float mainPosZ; |
---|
[8835] | 113 | |
---|
[9686] | 114 | Vector origSkyColor; |
---|
| 115 | Vector cameraCoor; |
---|
[8835] | 116 | |
---|
[9686] | 117 | Light* flashLight; |
---|
[8835] | 118 | |
---|
[9686] | 119 | OrxSound::SoundSource soundSource; |
---|
| 120 | OrxSound::SoundBuffer* thunderBuffer; |
---|
[8835] | 121 | |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | #endif /* _LIGHTNING_EFFECT */ |
---|