Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6889 in orxonox.OLD for trunk/src/lib/graphics


Ignore:
Timestamp:
Jan 31, 2006, 1:21:29 PM (18 years ago)
Author:
patrick
Message:

trunk: lenseflare is not drawn if behind the camera

Location:
trunk/src/lib/graphics
Files:
3 edited

Legend:

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

    r6888 r6889  
    3131
    3232#include "light.h"
     33#include "camera.h"
    3334
    3435using namespace std;
     
    147148  {
    148149    bb->setBindNode(static_cast<PNode*>(this->lightSource));
     150    bb->setVisibility(true);
    149151  }
    150152}
     
    154156{
    155157
    156   return true;
     158  float dist = this->frustumPlane.distancePoint(this->lightSource->getAbsCoor());
     159  if( dist < 0.0f)
     160  {
     161    std::vector<Billboard*>::const_iterator it = flares.begin(); it++;
     162    for(; it != flares.end(); it++)
     163      (*it)->setVisibility(true);
     164    return true;
     165  }
     166
     167  std::vector<Billboard*>::const_iterator it = flares.begin(); it++;
     168  for(; it != flares.end(); it++)
     169    (*it)->setVisibility(false);
     170
     171  return false;
    157172}
    158173
     
    173188      this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource));
    174189  }
     190
     191    //set the frustum plane
     192  Vector psTarget = (State::getCameraTarget())->getAbsCoor();
     193  Vector psCamera = (State::getCamera())->getAbsCoor();
     194  Vector psCameraDir = psCamera - psTarget;
     195  //PRINTF(0)("camera Dir: %f %f %f, camera: %f %f %f\n", psCameraDir.x, psCameraDir.y, psCameraDir.z, psCamera.x, psCamera.y, psCamera.z);
     196  this->frustumPlane = Plane(psCameraDir, Vector(-70.0,0.0,0.0));
    175197
    176198
     
    191213    if( i == 0)
    192214      continue;
    193     PRINTF(0)("calculus: (%f %f %f) * %f * %f\n", this->flareVector.x, this->flareVector.y, this->flareVector.z, this->flareMatrix[i * 2], this->distance);
     215
    194216    (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance);
    195217    (*it)->setSize2D(50.0f * this->flareMatrix[i * 2 + 1], 50.0f * this->flareMatrix[i * 2 + 1]);
     
    209231    return;
    210232
    211   if( !this->sourceVisible())
    212     return;
    213 
    214   std::vector<Billboard*>::const_iterator it;
    215   for( it = flares.begin(); it != flares.end(); it++)
    216     (*it)->draw();
    217 }
     233  this->sourceVisible();
     234}
  • trunk/src/lib/graphics/effects/lense_flare.h

    r6885 r6889  
    1212
    1313#include "vector.h"
     14#include "plane.h"
    1415
    1516
     
    5556
    5657    float*                   flareMatrix;
     58    Plane                    frustumPlane;       //!< plane that marks the view frustum
    5759};
    5860
  • trunk/src/lib/graphics/render2D/billboard.cc

    r6815 r6889  
    149149void Billboard::draw() const
    150150{
     151  if( !this->isVisible())
     152    return;
     153
    151154  glPushMatrix();
    152155
Note: See TracChangeset for help on using the changeset viewer.