| 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 |  | 
|---|
| 19 | class LightningEffect : public WeatherEffect | 
|---|
| 20 | { | 
|---|
| 21 |   ObjectListDeclaration(LightningEffect); | 
|---|
| 22 | public: | 
|---|
| 23 |   LightningEffect(const TiXmlElement* root = NULL); | 
|---|
| 24 |   virtual ~LightningEffect(); | 
|---|
| 25 |  | 
|---|
| 26 |   virtual void loadParams(const TiXmlElement* root); | 
|---|
| 27 |  | 
|---|
| 28 |   virtual void init(); | 
|---|
| 29 |  | 
|---|
| 30 |   virtual void activate(); | 
|---|
| 31 |   virtual void deactivate(); | 
|---|
| 32 |  | 
|---|
| 33 |   inline  void activateLightning() | 
|---|
| 34 |   { | 
|---|
| 35 |     this->activate(); | 
|---|
| 36 |   } | 
|---|
| 37 |   inline  void deactivateLightning() | 
|---|
| 38 |   { | 
|---|
| 39 |     this->deactivate(); | 
|---|
| 40 |   } | 
|---|
| 41 |  | 
|---|
| 42 |   virtual void tick(float dt); | 
|---|
| 43 |  | 
|---|
| 44 |   void coord(float x, float y, float z); | 
|---|
| 45 |   void setFlashSize(float width, float height, float seedWidth, float seedHeight); | 
|---|
| 46 |  | 
|---|
| 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 |   } | 
|---|
| 54 |  | 
|---|
| 55 |   inline void setFlashFrequency(float baseFrequency, float seedTime) | 
|---|
| 56 |   { | 
|---|
| 57 |     this->flashFrequencyBase = baseFrequency; | 
|---|
| 58 |     this->flashFrequency = baseFrequency; | 
|---|
| 59 |     this->flashFrequencySeed = seedTime; | 
|---|
| 60 |   } | 
|---|
| 61 |  | 
|---|
| 62 |   inline void setFlashConstTime(float holdTime) | 
|---|
| 63 |   { | 
|---|
| 64 |     this->flashHoldTime = holdTime; | 
|---|
| 65 |   } | 
|---|
| 66 |  | 
|---|
| 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 |   } | 
|---|
| 74 |  | 
|---|
| 75 |   inline void setFlashSeed(float seedX, float seedZ) | 
|---|
| 76 |   { | 
|---|
| 77 |     this->seedX = seedX; | 
|---|
| 78 |     this->seedZ = seedZ; | 
|---|
| 79 |   } | 
|---|
| 80 |  | 
|---|
| 81 |  | 
|---|
| 82 | private: | 
|---|
| 83 |  | 
|---|
| 84 |   void newCoordinates(); | 
|---|
| 85 |   void setTexture(); | 
|---|
| 86 |   void switchTexture(); | 
|---|
| 87 |  | 
|---|
| 88 |   Billboard* thunderBolt[4]; | 
|---|
| 89 |   bool thunderTextureA; | 
|---|
| 90 |  | 
|---|
| 91 |   bool lightningActivate; | 
|---|
| 92 |   bool lightningMove; | 
|---|
| 93 |  | 
|---|
| 94 |   float flashFrequency; | 
|---|
| 95 |   float flashFrequencyBase; | 
|---|
| 96 |   float flashHoldTime; | 
|---|
| 97 |   float flashRisingTime; | 
|---|
| 98 |  | 
|---|
| 99 |   float time; | 
|---|
| 100 |  | 
|---|
| 101 |   float width; | 
|---|
| 102 |   float height; | 
|---|
| 103 |   float seedWidth; | 
|---|
| 104 |   float seedHeight; | 
|---|
| 105 |  | 
|---|
| 106 |   float seedX; | 
|---|
| 107 |   float seedZ; | 
|---|
| 108 |   float flashFrequencySeed; | 
|---|
| 109 |  | 
|---|
| 110 |   float mainPosX; | 
|---|
| 111 |   float mainPosY; | 
|---|
| 112 |   float mainPosZ; | 
|---|
| 113 |  | 
|---|
| 114 |   Vector origSkyColor; | 
|---|
| 115 |   Vector cameraCoor; | 
|---|
| 116 |  | 
|---|
| 117 |   Light* flashLight; | 
|---|
| 118 |  | 
|---|
| 119 |   OrxSound::SoundSource    soundSource; | 
|---|
| 120 |   OrxSound::SoundBuffer    thunderBuffer; | 
|---|
| 121 |  | 
|---|
| 122 | }; | 
|---|
| 123 |  | 
|---|
| 124 | #endif  /* _LIGHTNING_EFFECT */ | 
|---|