1 #include "CameraViewFrustum.hh"
2 #include <Base/Common/W32Compat.hh>
3 #include <Base/Debug/Error.hh>
9 #ifdef BIAS_HAVE_OPENGL
10 # include <Gui/biasgl.h>
26 double fovY = fabs(atan2(top, zNear));
27 fovY += fabs(atan2(bottom, zNear));
34 double fovX = fabs(atan2(left,zNear));
35 fovX += fabs(atan2(right,zNear));
41 const double w = right - left;
42 const double h = top - bottom;
48 const double & fovAspect,
49 const double & zNearX,
55 top = this->zNear * tan(fovYdeg/2. *M_PI/180.);
57 right = fovAspect * top;
63 os<<
"CameraViewFrustum: "<<endl
65 <<
"right "<<right<<endl
66 <<
"bottom "<<bottom<<endl
68 <<
"near "<<zNear<<endl
76 BIASASSERT(vpAspectRatioDesired >0);
77 BIASASSERT(this->GetAspect()>0);
79 const double scale = vpAspectRatioDesired / this->GetAspect();
82 const double center = left +0.5*(right-left);
86 this->right -= center;
94 this->right += center;
98 #ifdef BIAS_HAVE_OPENGL
101 BIASASSERT(left<right);
102 BIASASSERT(bottom<top);
103 BIASASSERT(zNear<zFar);
105 glMatrixMode(GL_PROJECTION);
116 glMatrixMode(GL_MODELVIEW);
118 #endif // BIAS_HAVE_OPENGL
void SetPerspective(const double &fovYdeg, const double &fovAspect, const double &zNear=1., const double &zFar=1000.)
sets a symmetric, centered frustum like gluPerspective does fovYdeg is the y field of view in degree...
CameraViewFrustum()
destructor
std::ostream & Print(std::ostream &os=std::cout) const
void AdaptWidth(const double &vpAspectRatioDesired)
adapt left and right to match an aspect ratio useful to adapth frustum to viewport bound to windows s...