Changeset 7112 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Feb 8, 2006, 1:53:01 AM (19 years ago)
- Location:
- trunk/src/world_entities/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/effects/lightning_bolt.cc
r7111 r7112 20 20 #include "material.h" 21 21 22 #include "resource_manager.h" 23 24 25 22 26 using namespace std; 23 27 … … 37 41 this->time = 0.0; 38 42 this->flashFrequency = 0.6f; 39 this->flashConstTime = 0. 1f;43 this->flashConstTime = 0.07f; 40 44 41 45 this->material = new Material(); 42 46 this->material->setDiffuseMap("maps/lightning_bolt.png"); 43 this->offset = Vector(-1440.00, 100.00, 280.00);47 //this->offset = Vector(-1440.00, 100.00, 280.00); 44 48 45 49 this->setAbsCoor(offset); 46 50 this->width = 100.0f; 47 51 this->height = 300.0f; 52 this->bNewCoordinate = false; 53 54 this->seedX = 200.f; 55 this->seedZ = 500.0f; 56 this->seedTime = 2.0f; 57 58 this->soundSource.setSourceNode(this); 59 60 //load sound 61 if (this->thunderBuffer != NULL) 62 ResourceManager::getInstance()->unload(this->thunderBuffer); 63 this->thunderBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV); 48 64 } 49 65 … … 73 89 void LightningBolt::tick (float dt) 74 90 { 75 76 77 78 79 91 this->time += dt; 80 PRINTF(0)("time: %f, bRender: %i\n", this->time, this->bRender);81 92 82 93 if( this->time > this->flashFrequency) … … 84 95 this->bRender = true; 85 96 this->time = 0.0f; 97 this->soundSource.play(this->thunderBuffer); 86 98 } 87 99 else if( this->bRender && this->time > this->flashConstTime) 88 100 { 89 101 this->bRender = false; 90 this->time = 0.0; 102 this->time = 0.0f; 103 this->bNewCoordinate = true; 91 104 } 92 else 105 106 if( this->bNewCoordinate) 93 107 { 108 this->flashFrequency = this->seedTime * (float)rand()/(float)RAND_MAX + 0.1; 109 this->setAbsCoor( - 800.0f - this->seedX * (float)rand()/(float)RAND_MAX, 250.00, -200.0f + this->seedZ * (float)rand()/(float)RAND_MAX); 94 110 111 PRINTF(0)("timeout: %f\n", this->flashFrequency); 112 this->getAbsCoor().debug(); 113 114 this->bNewCoordinate = false; 95 115 } 96 116 } … … 101 121 if( this->bRender) 102 122 { 103 PRINTF(0)("draw\n");104 123 105 124 glPushMatrix(); … … 108 127 this->getAbsCoor ().z); 109 128 110 // glRotatef(axis, 0.0f, 1.0f, 0.0f); 129 glRotatef(90, 0.0f,1.0f,0.0f); 130 131 // Vector tmpRot = drawPart->orientation.getSpacialAxis(); 132 // glRotatef (drawPart->orientation.getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 111 133 112 134 // glPushAttrib(GL_ENABLE_BIT); -
trunk/src/world_entities/effects/lightning_bolt.h
r7111 r7112 8 8 9 9 #include "world_entity.h" 10 11 #include "sound_buffer.h" 12 #include "sound_source.h" 10 13 11 14 class Material; … … 32 35 33 36 bool bRender; 37 bool bNewCoordinate; 34 38 Material* material; 35 39 Vector offset; 36 40 float width; 37 41 float height; 42 43 float seedX; 44 float seedZ; 45 float seedTime; 46 47 SoundSource soundSource; 48 SoundBuffer* thunderBuffer; 38 49 }; 39 50
Note: See TracChangeset
for help on using the changeset viewer.