- Timestamp:
- Jun 6, 2006, 10:22:40 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src/lib/graphics/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc
r8177 r8179 59 59 LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency); 60 60 LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime); 61 LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime); 61 62 LoadParam(root, "size", this, LighteningEffect, setFlashSize); 62 63 LoadParam(root, "seed", this, LighteningEffect, setFlashSeed); … … 69 70 70 71 this->time = 0.0; 71 this->flashFrequency = 0.6f; 72 this->flashConstTime = 0.07f; 72 this->flashFrequency = 1.4f; 73 this->flashConstTime = 0.8f; 74 this->flashRisingTime = 0.5f; 73 75 74 76 this->width = 40.0f; … … 80 82 this->seedTime = 4.0f; 81 83 82 this->billboard = new Billboard(NULL); 83 this->billboard->setTexture("maps/lightning_bolt.png"); 84 this->billboard->setSize(this->width, this->height); 85 this->billboard->setAbsCoor(0.0f, 50.0f, 0.0f); 86 this->billboard->setVisibiliy(false); 87 84 this->billboard[0] = new Billboard(NULL); 85 this->billboard[0]->setTexture("maps/lightning_bolt1.png"); 86 this->billboard[0]->setSize(this->width, this->height); 87 this->billboard[0]->setAbsCoor(0.0f, 50.0f, 0.0f); 88 this->billboard[0]->setVisibiliy(false); 89 90 this->billboard[1] = new Billboard(NULL); 91 this->billboard[1]->setTexture("maps/lightning_bolt2.png"); 92 this->billboard[1]->setSize(this->width, this->height); 93 this->billboard[1]->setAbsCoor(0.0f, 50.0f, 0.0f); 94 this->billboard[1]->setVisibiliy(false); 95 96 this->billboard[2] = new Billboard(NULL); 97 this->billboard[2]->setTexture("maps/lightning_bolt3.png"); 98 this->billboard[2]->setSize(this->width, this->height); 99 this->billboard[2]->setAbsCoor(0.0f, 50.0f, 0.0f); 100 this->billboard[2]->setVisibiliy(false); 101 102 this->billboard[3] = new Billboard(NULL); 103 this->billboard[3]->setTexture("maps/lightning_bolt4.png"); 104 this->billboard[3]->setSize(this->width, this->height); 105 this->billboard[3]->setAbsCoor(0.0f, 50.0f, 0.0f); 106 this->billboard[3]->setVisibiliy(false); 88 107 /* 89 108 this->soundSource = NULL; … … 100 119 void LighteningEffect::coord(float x, float y, float z) 101 120 { 102 this->billboard->setAbsCoor(x, y, z); 121 this->billboard[0]->setAbsCoor(x, y, z); 122 this->billboard[1]->setAbsCoor(x, y, z); 123 this->billboard[2]->setAbsCoor(x, y, z); 124 this->billboard[3]->setAbsCoor(x, y, z); 103 125 this->mainPosX = x; 104 126 this->mainPosY = y; … … 110 132 { 111 133 PRINTF(0)( "Activating LighteningEffect\n" ); 112 this-> billboard->setVisibiliy(true);134 this->time = 0; 113 135 lighteningActivate = true; 114 136 } … … 118 140 { 119 141 PRINTF(0)("Deactivating LighteningEffect\n"); 120 this->billboard->setVisibiliy(false); 142 this->billboard[0]->setVisibiliy(false); 143 this->billboard[1]->setVisibiliy(false); 144 this->billboard[2]->setVisibiliy(false); 145 this->billboard[3]->setVisibiliy(false); 121 146 lighteningActivate = false; 122 147 } … … 131 156 if( this->time > this->flashFrequency) 132 157 { 133 this->billboard ->setVisibiliy(true);158 this->billboard[0]->setVisibiliy(true); 134 159 this->time = 0.0f; 135 160 //this->soundSource.play(this->thunderBuffer); 136 161 } 137 else if( this->billboard ->isVisible() && this->time > this->flashConstTime)138 { 139 this->billboard ->setVisibiliy(false);162 else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime) 163 { 164 this->billboard[3]->setVisibiliy(false); 140 165 this->time = 0.0f; 141 166 this->bNewCoordinate = true; 142 167 } 143 168 169 if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime) 170 { 171 this->billboard[2]->setVisibiliy(false); 172 this->billboard[3]->setVisibiliy(true); 173 } 174 else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 ) 175 { 176 this->billboard[1]->setVisibiliy(false); 177 this->billboard[2]->setVisibiliy(true); 178 } 179 else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 ) 180 { 181 this->billboard[0]->setVisibiliy(false); 182 this->billboard[1]->setVisibiliy(true); 183 } 184 144 185 if( this->bNewCoordinate) 145 186 { 146 this->flashFrequency = this->seedTime * (float)rand()/(float)RAND_MAX + 0.1; 147 this->billboard->setAbsCoor(this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX, this->mainPosY, this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX); 187 float posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX; 188 float posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX; 189 this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ); 190 this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ); 191 this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ); 192 this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ); 148 193 this->bNewCoordinate = false; 149 194 } -
branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h
r8177 r8179 38 38 inline void setFlashFrequency(float flashFrequency) { this->flashFrequency = flashFrequency; } 39 39 inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; } 40 inline void setFlashRisingTime(float flashRisingTime) { if(flashRisingTime > this->flashConstTime) 41 this->flashRisingTime = this->flashConstTime/2; 42 else 43 this->flashRisingTime = flashRisingTime; } 40 44 inline void setFlashSize(float width, float height) { this->width = width; 41 45 this->height = height; } … … 48 52 49 53 private: 50 Billboard* billboard ;54 Billboard* billboard[4]; 51 55 bool lighteningActivate; 52 56 53 57 float flashFrequency; 54 58 float flashConstTime; 59 float flashRisingTime; 55 60 56 61 float time;
Note: See TracChangeset
for help on using the changeset viewer.