Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6885 in orxonox.OLD for trunk/src/lib/graphics/effects


Ignore:
Timestamp:
Jan 31, 2006, 4:06:11 AM (19 years ago)
Author:
patrick
Message:

trunk: implemented a working lense-flare

Location:
trunk/src/lib/graphics/effects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r6884 r6885  
    139139  Billboard* bb = new Billboard(NULL);
    140140  bb->setTexture(textureName);
     141  bb->setSize(50, 50);
    141142  this->flares.push_back(bb);
    142143  PRINTF(0)("Added a Lenseflare Billboard with texture %s\n", textureName);
     
    150151
    151152
     153bool LenseFlare::sourceVisible() const
     154{}
     155
    152156
    153157/**
     
    159163    return;
    160164
     165  // refetch light source information if needed
    161166  if( unlikely( this->lightSource == NULL))
     167  {
    162168    this->lightSource = (LightManager::getInstance())->getLight(0);
    163   else
    164     this->lightSource->debug();
     169    if( this->flares.size() > 0)
     170      this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource));
     171  }
     172
    165173
    166174  // always update the screen center, it could be, that the window is resized
    167175  this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f);
    168176  // flare vector is the direction from the center to the light source
    169   this->flareVector = this->flares[0]->getAbsCoor2D();
     177  this->flareVector = this->screenCenter - this->flares[0]->getAbsCoor2D();
    170178  this->distance = this->flareVector.len();
    171179  this->flareVector.normalize();
    172 
    173   PRINTF(0)("Debug: screenCenter: %f, %f - flareVec: %f, %f\n", screenCenter.x, screenCenter.y, flareVector.x, flareVector.y);
    174180
    175181  // now calculate the new coordinates of the billboards
     
    179185  {
    180186    // set the new position
    181     (*it)->setAbsCoor2D(this->flareVector * this->flareMatrix[i * 2]);
     187    if( i == 0)
     188      continue;
     189    (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance);
    182190    PRINTF(0)("Tick flare %i @ (%f, %f)\n", i, (*it)->getAbsCoor2D().x, (*it)->getAbsCoor2D().y);
    183191    // tick them
     
    195203    return;
    196204
     205  if( !this->sourceVisible())
     206    return;
     207
    197208  std::vector<Billboard*>::const_iterator it;
    198209  for( it = flares.begin(); it != flares.end(); it++)
  • trunk/src/lib/graphics/effects/lense_flare.h

    r6815 r6885  
    4343  private:
    4444    GLint charToFogMode(const char* mode);
     45    bool sourceVisible() const;
    4546
    4647
Note: See TracChangeset for help on using the changeset viewer.