Changeset 8455 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc
- Timestamp:
- Jun 15, 2006, 1:12:24 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc
r8449 r8455 38 38 { 39 39 this->setClassID(CL_LIGHTENING_EFFECT, "LighteningEffect"); 40 40 41 41 this->init(); 42 42 … … 72 72 73 73 74 boolLighteningEffect::init()74 void LighteningEffect::init() 75 75 { 76 76 //default values 77 77 this->lighteningActivate = false; 78 78 79 79 this->time = 0.0; 80 80 this->flashFrequency = 4.0f; … … 82 82 this->flashConstTime = 0.1f; 83 83 this->flashRisingTime = 0.03f; 84 84 85 85 this->width = 700.0f; 86 86 this->height = 250.0f; … … 89 89 this->bNewCoordinate = false; 90 90 this->lighteningMove = false; 91 91 92 92 this->seedX = 500.f; 93 93 this->seedZ = 1000.0f; 94 94 this->seedTime = 2.0f; 95 95 96 96 this->mainPosX = 3000; 97 97 this->mainPosY = 900; 98 98 this->mainPosZ = 0; 99 99 100 100 // initialize lightening textures 101 101 this->billboard[0] = new Billboard(NULL); … … 103 103 this->billboard[0]->setSize(this->width, this->height); 104 104 this->billboard[0]->setVisibiliy(false); 105 105 106 106 this->billboard[1] = new Billboard(NULL); 107 107 this->billboard[1]->setTexture("maps/lightning_bolt2.png"); 108 108 this->billboard[1]->setSize(this->width, this->height); 109 109 this->billboard[1]->setVisibiliy(false); 110 110 111 111 this->billboard[2] = new Billboard(NULL); 112 112 this->billboard[2]->setTexture("maps/lightning_bolt3.png"); 113 113 this->billboard[2]->setSize(this->width, this->height); 114 114 this->billboard[2]->setVisibiliy(false); 115 115 116 116 this->billboard[3] = new Billboard(NULL); 117 117 this->billboard[3]->setTexture("maps/lightning_bolt4.png"); 118 118 this->billboard[3]->setSize(this->width, this->height); 119 119 this->billboard[3]->setVisibiliy(false); 120 120 121 121 if (this->lighteningMove) { 122 122 this->cameraCoor = State::getCameraNode()->getAbsCoor(); … … 131 131 this->billboard[3]->setAbsCoor(3000,900,0); 132 132 } 133 133 134 134 this->flashLight = new Light(); 135 135 this->flashLight->setDiffuseColor(0,0,0); 136 136 this->flashLight->setSpecularColor(0,0,0); 137 137 138 138 /* 139 139 this->soundSource = NULL; 140 140 this->thunderBuffer = NULL; 141 141 142 142 this->soundSource.setSourceNode(this); 143 143 144 144 //load sound 145 145 if (this->thunderBuffer != NULL) … … 147 147 this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/ 148 148 149 return 0;150 149 } 151 150 … … 185 184 186 185 187 boolLighteningEffect::activate()186 void LighteningEffect::activate() 188 187 { 189 188 PRINTF(0)( "Activating LighteningEffect\n" ); … … 191 190 192 191 this->time = 0; 193 194 return 0; 195 } 196 197 198 bool LighteningEffect::deactivate() 192 } 193 194 195 void LighteningEffect::deactivate() 199 196 { 200 197 PRINTF(0)("Deactivating LighteningEffect\n"); … … 205 202 this->billboard[2]->setVisibiliy(false); 206 203 this->billboard[3]->setVisibiliy(false); 207 208 return 0;209 204 } 210 205 … … 213 208 if(!lighteningActivate) 214 209 return; 215 210 216 211 this->time += dt; 217 212 218 213 // TODO: Make random flashing with short light dingsda:) 219 214 220 215 if( this->time > this->flashFrequency) { 221 216 222 217 this->billboard[0]->setVisibiliy(true); 223 218 this->time = 0.0f; 224 219 225 220 this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z); 226 221 … … 228 223 this->flashLight->setDiffuseColor(1,1,1); 229 224 this->flashLight->setSpecularColor(1,1,1); 230 225 231 226 //this->soundSource.play(this->thunderBuffer); 232 227 233 228 } else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime) { 234 229 235 230 this->billboard[3]->setVisibiliy(false); 236 231 this->time = 0.0f; … … 240 235 241 236 } 242 237 243 238 if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime) { 244 239 245 240 this->billboard[2]->setVisibiliy(false); 246 241 this->billboard[3]->setVisibiliy(true); 247 242 // this->flashLight->setDiffuseColor(1,1,1); 248 243 // this->flashLight->setSpecularColor(1,1,1); 249 244 250 245 } else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 ) { 251 246 252 247 this->billboard[1]->setVisibiliy(false); 253 248 this->billboard[2]->setVisibiliy(true); 254 249 //this->flashLight->setDiffuseColor(0,0,0); 255 250 //this->flashLight->setSpecularColor(0,0,0); 256 251 257 252 } else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 ) { 258 253 259 254 this->billboard[0]->setVisibiliy(false); 260 255 this->billboard[1]->setVisibiliy(true); 261 256 //this->flashLight->setDiffuseColor(1,1,1); 262 257 //this->flashLight->setSpecularColor(1,1,1); 263 264 } 265 258 259 } 260 266 261 if( this->bNewCoordinate) { 267 262 float posX, posZ; 268 263 269 264 if(this->lighteningMove) { 270 265 271 266 this->cameraCoor = State::getCameraNode()->getAbsCoor(); 272 267 posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX + this->cameraCoor.x; … … 274 269 275 270 } else { 276 271 277 272 posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX; 278 273 posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX; 279 274 280 275 } 281 276 282 277 this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ); 283 278 this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ); 284 279 this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ); 285 280 this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ); 286 281 287 282 this->flashFrequency = this->mainFrequency + this->seedTime * (float)rand()/(float)RAND_MAX; 288 283 289 284 float w = this->width + this->seedWidth * (float)rand()/(float)RAND_MAX; 290 285 float h = this->height + this->seedHeight * (float)rand()/(float)RAND_MAX; 291 286 292 287 this->billboard[0]->setSize(w, h); 293 288 this->billboard[1]->setSize(w, h); 294 289 this->billboard[2]->setSize(w, h); 295 290 this->billboard[3]->setSize(w, h); 296 291 297 292 this->bNewCoordinate = false; 298 293 }
Note: See TracChangeset
for help on using the changeset viewer.