Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TriangleMeshSplatRendering.hh
1 #ifndef __TriangleMeshSplatRendering_hh__
2 #define __TriangleMeshSplatRendering_hh__
3 
4 #include <bias_config.h>
5 
6 #include <GLviewer/GLProjectionParametersInterface.hh>
7 #include <OpenGLFramework/Base/glfShaderProgram.hh>
8 #include <OpenGLFramework/Base/glfTexture2D.hh>
9 #include <OpenGLFramework/Base/glfFramebufferObject.hh>
10 #include <OpenGLFramework/Base/glfScreen.hh>
11 #include <Utils/ThreeDOut.hh>
12 #include <GLviewer/Scenes/SceneBase.hh>
13 #include <vector>
14 
15 namespace BIAS {
16 
17  /**
18  * @class TriangleMeshSplatRendering
19  * @brief Scene for rendering multiple triangle meshes generated from depth
20  * maps. Overlapping regions of the meshes will be blended, i.e. a
21  * per-pixel average is computed in screen space.
22  * @ingroup g_glviewer
23  * @author jkollmann/ischiller
24  */
25  class BIASGLviewer_EXPORT TriangleMeshSplatRendering {
26  public:
29 
30  /**
31  * Sets the resolution of the internal framebuffer object.
32  */
33  void SetInternalResolution(int width, int height);
34 
35  /**
36  * Sets the maximum depth difference at which geometry is considered
37  * to represent the same surface and is blended.
38  */
39  void SetDepthTolerance(float depthTolerance);
40 
41  void SetCamera(BIAS::GLProjectionParametersInterface* camera);
42 
43  /**
44  * Set depth tolerance based on fraction of bounding box of tdo objects.
45  */
46  void ComputeDepthTolerance(float fraction = 0.01f);
47 
48  /**
49  * Returns the current depth tolerance.
50  */
51  float GetDepthTolerance() const { return depthTolerance_; }
52 
53  /**
54  * Adds an arbitrary triangle ThreeDOut object to the scene.
55  * The tdo must have been allocated with 'new'. The scene takes
56  * responsibility to delete the tdo.
57  * Note: Only the indexed face sets are rendered.
58  */
59  void AddThreeDOut(BIAS::ThreeDOut* tdo);
60  void ClearThreeDOuts();
61  /**
62  *@brief main splatting routine
63  */
64  void Splat();
65 
66  void GetBoundingBox(BIAS::Vector3<double>& min,
68  private:
69 
70  // configuration
71  int internalWidth_, internalHeight_;
72  float depthTolerance_;
73  bool enableBlending_;
74 
75  bool mustCreateShaders_;
76  bool mustCreateFrameBuffer_;
77 
78  void CreateShaders();
79  void CreateFrameBuffer(int width, int height);
80 
81  BIAS::glfShaderProgram depthPassProgram_;
82  BIAS::glfShaderProgram normalizationPassProgram_;
83 
84  BIAS::glfTexture2D colorBuffer_;
85  BIAS::glfTexture2D depthBuffer_;
88  std::vector<BIAS::ThreeDOut*> tdos_;
89  };
90 
91 }
92 
93 #endif // __TriangleMeshSplatRendering_hh__
94 
float GetDepthTolerance() const
Returns the current depth tolerance.
A 2D texture.
Definition: glfTexture2D.hh:40
Unified output of 3D entities via OpenGL or VRML.
Definition: ThreeDOut.hh:349
Scene for rendering multiple triangle meshes generated from depth maps.
A shader program composed of several shaders.
Abstract interface class to handle changes in rendering parameters by controllers and in rendering co...