Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CameraViewFrustum.hh
1 #ifndef __CameraViewFrustum_h__
2 #define __CameraViewFrustum_h__
3 
4 #include <bias_config.h>
5 #include <iostream>
6 
7 #define FRUSTUM_IS_FIXED_DEFAULT false
8 
9 namespace BIAS {
10 
11  /** @class CameraViewFrustum
12  \brief describes internal parameter Frustum of an (OpenGL) camera view
13 
14  \author Jan Woetzel 09/2003 */
15  class BIASGui_EXPORT CameraViewFrustum {
16  public:
17  virtual ~CameraViewFrustum(){}; ///< destructor
18 
19  /// ctors
21 
22  CameraViewFrustum(const double czNear,
23  const double czFar,
24  const double cleft,
25  const double cright,
26  const double cbottom,
27  const double ctop,
28  const bool cisFixed=FRUSTUM_IS_FIXED_DEFAULT )
29  :
30  zNear(czNear),zFar(czFar),
31  left(cleft), right(cright),
32  bottom(cbottom), top(ctop),
33  isFixed(cisFixed)
34  {}
35 
36 
37  /// sets a symmetric, centered frustum like gluPerspective does
38  /// fovYdeg is the y field of view in degree.
39  void SetPerspective(const double & fovYdeg,
40  const double & fovAspect,
41  const double & zNear=1.,
42  const double & zFar=1000.);
43 
44  /// @return the approximate field of view in degree
45  double GetFovY() const;
46  double GetFovX() const;
47 
48  /// @return aspect ratio x/y of field of image size (NOT field of view)
49  double GetAspect() const;
50 
51  /// adapt left and right to match an aspect ratio
52  /// useful to adapth frustum to viewport bound to windows size reshape
53  void AdaptWidth(const double & vpAspectRatioDesired );
54 
55  std::ostream & Print(std::ostream & os=std::cout ) const;
56 
57 #ifdef BIAS_HAVE_OPENGL
58  void DisplayGL() const;
59 #endif // BIAS_HAVE_OPENGL
60 
61  inline void InitMembers()
62  {
63  this->zNear = 0.1;
64  this->zFar = 1000.;
65 
66  this->left = -1. *zNear;
67  this->right = -left;
68  this->bottom = -1. *zNear;
69  this->top = -bottom;
70 
71  this->isFixed=FRUSTUM_IS_FIXED_DEFAULT;
72  }
73 
74  public:
75  double zNear;
76  double zFar;
77 
78  double left;
79  double right;
80  double bottom;
81  double top;
82 
83  /// Should reshape adapt aspect ?
84  /// or keep aspect, thus window aspect and frustum aspect may be different
85  bool isFixed;
86 
87  }; // CameraViewFrustum
88 } // namespace BIAS
89 #endif
describes internal parameter Frustum of an (OpenGL) camera view
bool isFixed
Should reshape adapt aspect ? or keep aspect, thus window aspect and frustum aspect may be different...
CameraViewFrustum(const double czNear, const double czFar, const double cleft, const double cright, const double cbottom, const double ctop, const bool cisFixed=FRUSTUM_IS_FIXED_DEFAULT)