Changeset 10445 in orxonox.OLD for trunk/src/world_entities/effects/blink.cc
- Timestamp:
- Jan 28, 2007, 3:24:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/effects/blink.cc
r10433 r10445 35 35 if(root) 36 36 this->loadParams(root); 37 38 // calculation of the symbolTime 39 this->symbolTime = this->period / this->blinkSequence.length(); 37 40 } 38 41 … … 60 63 this->bBoard = new Billboard; 61 64 this->bBoard->setVisibiliy(true); 62 this->bBoard->setTexture(" maps/star_alpha.png");65 this->bBoard->setTexture("textures/light/blink.png"); 63 66 64 67 /// Standard values … … 68 71 // 10x10 pxl if not defined in xml 69 72 this->size = 10; 70 // default angular rate 71 this->omega = 10; 73 // default period 74 this->period = 1; 75 // default blink sequence 76 this->blinkSequence = "00011234567889998876543211"; 72 77 73 // random start angle, blinkies shouldn't blink synchronous 74 this->angle = (float)rand()/(float)RAND_MAX * 2 * M_PI; 78 // start values of non-loadable variables 79 this->blinkStr = 0; 80 this->timer = 0; 81 this->seqCounter = 0; 75 82 } 76 83 … … 87 94 LoadParam(root, "size", this, Blink, setSize); 88 95 LoadParam(root, "color", this, Blink, setColor); 89 LoadParam(root, "omega", this, Blink, setOmega); 96 LoadParam(root, "period", this, Blink, setPeriod); 97 LoadParam(root, "sequence", this, Blink, loadBlinkSequence); 90 98 } 91 99 … … 97 105 void Blink::tick(float dt) 98 106 { 99 t his->angle += dt * this->omega;107 timer += dt; 100 108 101 while (this->angle > 2 * M_PI) 102 this->angle -= 2 * M_PI; 109 while(this->timer >= this->symbolTime) 110 { 111 this->blinkStr = (float)((int)(blinkSequence[seqCounter]) - 48) / 9; 103 112 104 // blinkStr should be element of [0, 1] 105 this->blinkStr = (sinf(angle) + 1) / 2; 113 this->timer -= symbolTime; 114 115 seqCounter++; 116 seqCounter %= this->blinkSequence.length(); 117 } 106 118 107 119 this->bBoard->colorTexture(Color(color.r(), color.g(), color.b(), this->blinkStr));
Note: See TracChangeset
for help on using the changeset viewer.