Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8251 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 8, 2006, 3:15:59 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engiengine: lightening effect

Location:
branches/atmospheric_engine/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc

    r8223 r8251  
    7474  this->flashRisingTime = 0.5f;
    7575
    76   this->width = 40.0f;
    77   this->height = 10.0f;
     76  this->width = 400.0f;
     77  this->height = 100.0f;
     78  this->seedWidth = 5;
     79  this->seedHeight = 5;
    7880  this->bNewCoordinate = false;
    7981
     
    8183  this->seedZ = 10.0f;
    8284  this->seedTime = 4.0f;
    83  
    84   lightening1 = 1;
    85   lightening2 = 2;
    86   lightening3 = 3;
    8785
    8886  this->billboard[0] = new Billboard(NULL);
     
    130128  this->mainPosY = y;
    131129  this->mainPosZ = z;
    132  
    133 }
     130}
     131
     132
     133void LighteningEffect::setFlashSize(float width, float height, float seedWidth, float seedHeight)
     134{
     135  this->width = width;
     136  this->height = height;
     137  this->seedWidth = seedWidth;
     138  this->seedHeight = seedHeight;
     139  this->billboard[0]->setSize(this->width, this->height);
     140  this->billboard[1]->setSize(this->width, this->height);
     141  this->billboard[2]->setSize(this->width, this->height);
     142  this->billboard[3]->setSize(this->width, this->height);
     143}
     144
    134145
    135146bool LighteningEffect::activate()
     
    158169  this->time += dt;
    159170
     171  /*if( flashLight != NULL)
     172  {
     173    if((int)(100*time)%2)
     174      this->flashLight->setDiffuseColor(0,0,0);
     175    else
     176      this->flashLight->setDiffuseColor(100,100,100);
     177   
     178    //PRINTF(0)("100*time: %f %i\n", 100*time, (int)(100*time));
     179}*/
     180 
    160181  if( this->time > this->flashFrequency)
    161182  {
    162183    this->billboard[0]->setVisibiliy(true);
    163184    this->time = 0.0f;
     185   
     186    this->flashLight = new Light();
     187    this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
     188    this->flashLight->setDiffuseColor(100,100,100);
     189   
    164190    //this->soundSource.play(this->thunderBuffer);
    165191  }
    166   else if( this->billboard[lightening3]->isVisible() && this->time > this->flashConstTime)
    167   {
    168     this->billboard[lightening3]->setVisibiliy(false);
     192  else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime)
     193  {
     194    this->billboard[3]->setVisibiliy(false);
    169195    this->time = 0.0f;
    170196    this->bNewCoordinate = true;
    171   }
    172 
    173   if( this->billboard[lightening2]->isVisible() && this->time > this->flashRisingTime)
    174   {
    175     this->billboard[lightening2]->setVisibiliy(false);
    176     this->billboard[lightening3]->setVisibiliy(true);
    177   }
    178   else if( this->billboard[lightening1]->isVisible() && this->time > this->flashRisingTime*2/3 )
    179   {
    180     this->billboard[lightening1]->setVisibiliy(false);
    181     this->billboard[lightening2]->setVisibiliy(true);
     197   
     198    if(flashLight != NULL)
     199    {
     200      delete this->flashLight;
     201      flashLight = NULL;
     202    }
     203  }
     204
     205  if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime)
     206  {
     207    this->billboard[2]->setVisibiliy(false);
     208    this->billboard[3]->setVisibiliy(true);
     209    //this->flashLight->setDiffuseColor(0,0,0);
     210  }
     211  else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 )
     212  {
     213    this->billboard[1]->setVisibiliy(false);
     214    this->billboard[2]->setVisibiliy(true);
     215   // this->flashLight->setDiffuseColor(0,0,0);
    182216  }
    183217  else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 )
    184218  {
    185219    this->billboard[0]->setVisibiliy(false);
    186     this->billboard[lightening1]->setVisibiliy(true);
     220    this->billboard[1]->setVisibiliy(true);
     221   // this->flashLight->setDiffuseColor(100,100,100);
    187222  }
    188223
     
    194229    this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
    195230    this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
    196     this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);   
     231    this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
    197232    this->bNewCoordinate = false;
    198233  }
     
    201236void LighteningEffect::draw() const
    202237{
    203   /*if(!this->billboard->isVisible())
    204     return;
    205  
    206   LightManager* lightMan = LightManager::getInstance();
    207  
    208   (new Light())->setAbsCoor(this->billboard->getAbsCoor().x, this->billboard->getAbsCoor().y, this->billboard->getAbsCoor().z);
    209   (new Light())->setDiffuseColor(1,1,1);
    210   LightManager::getInstance()->draw();
    211  
    212   delete lightMan;*/
    213 }
     238}
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h

    r8223 r8251  
    1616
    1717class Billboard;
     18class Light;
    1819
    1920class LighteningEffect : public WeatherEffect
     
    3435   
    3536    void coord(float x, float y, float z);
     37    void setFlashSize(float width, float height, float seedWidth, float seedHeight);
    3638   
    3739    inline void setLighteningOption(const std::string& option) { if (option == "activate") this->lighteningActivate = true;}
     
    3941    inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; }
    4042    inline void setFlashRisingTime(float flashRisingTime) { if(flashRisingTime > this->flashConstTime)
    41                                                               this->flashRisingTime = this->flashConstTime/2;
    42                                                             else
    43                                                               this->flashRisingTime = flashRisingTime; }
    44     inline void setFlashSize(float width, float height) { this->width = width;
    45                                                           this->height = height; }
     43                                                                                        this->flashRisingTime = this->flashConstTime/2;
     44                                                                                      else
     45                                                                                        this->flashRisingTime = flashRisingTime; }
    4646    inline void setFlashSeed(float seedX, float seedZ, float seedTime) { this->seedX = seedX;
    47                                                                          this->seedZ = seedZ;
    48                                                                          this->seedTime = seedTime; }
     47                                                                                                         this->seedZ = seedZ;
     48                                                                                                         this->seedTime = seedTime; }
    4949
    5050    void activateLightening() { this->activate(); }
     
    5454    Billboard* billboard[4];
    5555    bool lighteningActivate;
    56     int lightening1;
    57     int lightening2;
    58     int lightening3;
    5956
    6057    float flashFrequency;
     
    6764    float width;
    6865    float height;
     66    float seedWidth;
     67    float seedHeight;
    6968
    7069    float seedX;
     
    7675    float mainPosZ;
    7776
     77    Light* flashLight;
     78   
    7879    //OrxSound::SoundSource    soundSource;
    7980    //OrxSound::SoundBuffer*   thunderBuffer;
  • branches/atmospheric_engine/src/world_entities/effects/billboard.cc

    r8176 r8251  
    7575void Billboard::loadParams(const TiXmlElement* root)
    7676{
    77   LoadParam(root, "texture", this->material, Material, setDiffuseMap)
     77  /*LoadParam(root, "texture", this->material, Material, setDiffuseMap)
    7878      .describe("the texture-file to load onto the Billboard");
    7979
    8080  LoadParam(root, "size", this, Billboard, setSize)
    81       .describe("the size of the Billboard in Pixels");
     81  .describe("the size of the Billboard in Pixels");*/
    8282}
    8383
     
    9191  this->sizeX = sizeX;
    9292  this->sizeY = sizeY;
    93 
    94   PRINTF(0)("sizeX: %f sizeY: %f\n", sizeX, sizeY);
    9593}
    9694
Note: See TracChangeset for help on using the changeset viewer.