Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8179 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 6, 2006, 10:22:40 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: raising lightening effect

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  
    5959  LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency);
    6060  LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime);
     61  LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime);
    6162  LoadParam(root, "size", this, LighteningEffect, setFlashSize);
    6263  LoadParam(root, "seed", this, LighteningEffect, setFlashSeed);
     
    6970 
    7071  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;
    7375
    7476  this->width = 40.0f;
     
    8082  this->seedTime = 4.0f;
    8183
    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);
    88107/*
    89108  this->soundSource = NULL;
     
    100119void LighteningEffect::coord(float x, float y, float z)
    101120{
    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);
    103125  this->mainPosX = x;
    104126  this->mainPosY = y;
     
    110132{
    111133        PRINTF(0)( "Activating LighteningEffect\n" );
    112   this->billboard->setVisibiliy(true);
     134  this->time = 0;
    113135  lighteningActivate = true;
    114136}
     
    118140{
    119141        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);
    121146  lighteningActivate = false;
    122147}
     
    131156  if( this->time > this->flashFrequency)
    132157  {
    133     this->billboard->setVisibiliy(true);
     158    this->billboard[0]->setVisibiliy(true);
    134159    this->time = 0.0f;
    135160    //this->soundSource.play(this->thunderBuffer);
    136161  }
    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);
    140165    this->time = 0.0f;
    141166    this->bNewCoordinate = true;
    142167  }
    143168
     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
    144185  if( this->bNewCoordinate)
    145186  {
    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);   
    148193    this->bNewCoordinate = false;
    149194  }
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h

    r8177 r8179  
    3838    inline void setFlashFrequency(float flashFrequency) { this->flashFrequency = flashFrequency; }
    3939    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; }
    4044    inline void setFlashSize(float width, float height) { this->width = width;
    4145                                                          this->height = height; }
     
    4852   
    4953        private:
    50     Billboard* billboard;
     54    Billboard* billboard[4];
    5155    bool lighteningActivate;
    5256
    5357    float flashFrequency;
    5458    float flashConstTime;
     59    float flashRisingTime;
    5560
    5661    float time;
Note: See TracChangeset for help on using the changeset viewer.