Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GLProjectionParametersPerspective.hh
1 #ifndef __GLPROJECTIONPARAMSPERSP_HH__
2 #define __GLPROJECTIONPARAMSPERSP_HH__
3 
4 #include <bias_config.h>
5 #include <OpenGLFramework/Base/glfRenderTarget.hh>
6 #include <GLviewer/GLProjectionParametersBase.hh>
7 #include <Geometry/ProjectionParametersPerspective.hh>
8 
9 #include <GLviewer/OutputAttachments/OutputLensDistortion.hh>
10 
11 namespace BIAS
12 {
13 
14  /** @class GLProjectionParametersPerspective
15  * @brief class for rendering with projection parameters of ProjectionParametersPerspective
16  * @ingroup g_glviewer
17  */
18 
19  class BIASGLviewer_EXPORT GLProjectionParametersPerspective:
22  {
23  public:
24 
27 
28  /**
29  the pure virtual GetMyselfAsProjectionParameterBase() forces the child
30  classes to inherit from a projectionparameterbase class and
31  allows to access the projectionparams in cases where only a GLPPB* is
32  available. this avoids the undesired need to derive GLPPB from PPB.
33  */
35  const{return((ProjectionParametersBase*) this);};
36 
37 #ifdef BIAS_HAVE_XML2
38  virtual int XMLRead (const std::string &Filename);
39  virtual int XMLWrite(const std::string &Filename) const;
40  virtual int Load (const std::string& filename);
41  virtual int Save (const std::string& filename) const;
42 #endif
43 
44  int SetSimplePerspectiveCam(double fovyDEG,
45  int imageWidth = -1,
46  int imageHeight = -1);
47 
48  /** Method loads the parameters into the projection and modelview Matrix.
49  * \param forceUpdate do not check if camera state changed always
50  * recalculate.
51  * \attention make sure your rendering context is current.
52  * \attention Method is not equivalent to draw yet. */
53  virtual int SetGLMatrices(bool forceUpdate = true);
54 
55  void SetIntrinsics(BIAS::ProjectionParametersBase *p);
56 
57  void Set(BIAS::ProjectionParametersBase *p);
58 
59  /** setclearcolor is pure virtual. In some cases like for example
60  distortion rendering the lower render layers (offscreen surfaces)
61  must informed about changes of the clear color thus the child classes
62  have to deal with the clear color on their own. */
63  virtual void SetClearColor(const BIAS::Vector4<float>& cc);
64 
65  void UseStencilBuffer(bool b){useStencilBuffer_ = b;};
66  void IgnoreDistortion(bool b){ignoreDistortion_ = b;};
67 
70 
71  protected:
72  virtual double Z2Depth_(const int x,const int y, const double z) const;
73 
74  virtual void InitShaders_();
75  virtual void Rescale_(float scale);
76 
77  virtual int UpdateGLProjectionMatrix_(unsigned x0, unsigned y0,
78  unsigned width, unsigned height);
79 
80  int DrawWithMatchedParamsAndViewport_(int viewport[4],int imageWidth,int imageHeight,
81  std::vector<SceneBase*>& scenes);
82 
83 
84 
85  /** Rendering with current matrices GLProjectionMatrix_,
86  GLModelViewMatrix_. Those matrices are assumed to be up to date.
87  Does not clear framebuffer. Sets informScenesOfChange_ to false.
88  */
89  virtual int Draw_(std::vector<SceneBase *>& scenes,
90  BIAS::glfFramebufferObject* theTarget = NULL);
91 
92  void ClearDepthAndAlpha_();
93 
95 
96  private:
97 
98  int distorter_;
99  };
100 }
101 #endif
102 
103 
GLPPB encapsulates the opengl rendering interface for the projectionparameter classes.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual BIAS::ProjectionParametersBase * GetMyselfAsProjectionParametersBase() const
the pure virtual GetMyselfAsProjectionParameterBase() forces the child classes to inherit from a proj...
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
class for rendering with projection parameters of ProjectionParametersPerspective ...