Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7015 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Feb 3, 2006, 2:42:30 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: flare work

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

Legend:

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

    r7014 r7015  
    6161  PRINTF(0)("light is: %p\n", this->lightSource);
    6262
     63  this->isVisible = true;
     64
    6365  if (root != NULL)
    6466  {
     
    6668    this->activate();
    6769  }
     70
     71  this->setSourceVisibility(false);
     72  this->isVisible = true;
     73
    6874}
    6975
     
    165171
    166172
    167 bool LenseFlare::sourceVisible() const
    168 {
     173void LenseFlare::setSourceVisibility(bool visibility)
     174{
     175  if (this->isVisible == visibility)
     176    return;
    169177
    170178  float dist = this->frustumPlane.distancePoint(this->lightSource->getAbsCoor());
    171   if( dist < 0.0f)
    172   {
    173     std::vector<Billboard*>::const_iterator it = flares.begin(); it++;
    174     for(; it != flares.end(); it++)
    175       (*it)->setVisibility(true);
    176     return true;
    177   }
    178 
    179   std::vector<Billboard*>::const_iterator it = flares.begin(); it++;
    180   for(; it != flares.end(); it++)
    181     (*it)->setVisibility(false);
    182 
    183   return false;
     179  PRINTF(0)("dist: %f\n", dist);
     180  std::vector<Billboard*>::const_iterator it;
     181    for(it = flares.begin(); it != flares.end(); it++)
     182      (*it)->setVisibility(visibility);
     183  this->isVisible = visibility;
    184184}
    185185
     
    202202
    203203    //set the frustum plane
    204   Vector psTarget = (State::getCameraTargetNode())->getAbsCoor();
    205   Vector psCamera = (State::getCameraNode())->getAbsCoor();
    206   Vector psCameraDir = psCamera - psTarget;
    207   //PRINTF(0)("camera Dir: %f %f %f, camera: %f %f %f\n", psCameraDir.x, psCameraDir.y, psCameraDir.z, psCamera.x, psCamera.y, psCamera.z);
    208   this->frustumPlane = Plane(psCameraDir, Vector(-70.0,0.0,0.0));
     204
     205  this->frustumPlane = State::getCamera()->getViewFrustum();
     206
     207  if (State::getCamera()->distance(lightSource) < 0)
     208    this->setSourceVisibility(false);
     209  else
     210    this->setSourceVisibility(true);
    209211
    210212
    211213  // always update the screen center, it could be, that the window is resized
    212214  this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f);
     215
    213216  // flare vector is the direction from the center to the light source
    214217  this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter;
     
    242245  if( !this->bActivated)
    243246    return;
    244 
    245   this->sourceVisible();
    246 }
     247}
  • trunk/src/lib/graphics/effects/lense_flare.h

    r6889 r7015  
    4444  private:
    4545    GLint charToFogMode(const char* mode);
    46     bool sourceVisible() const;
     46    void setSourceVisibility(bool visibility) ;
    4747
    4848
    4949  private:
     50    float                    isVisible;          //!< Checks visibility
    5051    Light*                   lightSource;        //!< reference to the sun (or primary light source)
    5152    std::vector<Billboard*>  flares;             //!< the flares array
Note: See TracChangeset for help on using the changeset viewer.