GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
PanoEvalRenderer.h
1 /*
2  * Copyright (c) 2018, Stefan Osswald
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef INCLUDE_ARTICULATION_PanoEvalRenderer_H_
32 #define INCLUDE_ARTICULATION_PanoEvalRenderer_H_
33 
34 #include <gpu_coverage/Programs.h>
35 #include <gpu_coverage/AbstractRenderer.h>
36 #include <gpu_coverage/BellmanFordRenderer.h>
37 #include <gpu_coverage/PanoRenderer.h>
38 #include <list>
39 
40 namespace gpu_coverage {
41 
43 public:
44  PanoEvalRenderer(const Scene * const scene, const bool renderToWindow, const bool renderToTexture,
45  PanoRenderer * const panoRenderer, AbstractRenderer * const bellmanFordRenderer);
46  virtual ~PanoEvalRenderer();
47  virtual void display();
48  inline const GLuint& getTexture() const {
49  return textures[EVAL];
50  }
51  inline const int& getTextureWidth() const {
52  return panoWidth;
53  }
54  inline const int& getTextureHeight() const {
55  return panoHeight;
56  }
57  inline const GLuint& getUtilityMap() const {
58  return textures[curUtilityMap];
59  }
60  inline const GLuint& getUtilityMapVisual() const {
61  return textures[UTILITY_MAP_VISUAL];
62  }
63 
64  inline void setBenchmark() {
65  benchmark = true;
66  }
67 
68  void addCamera(CameraPanorama * const cam);
69  void addCameraPair(CameraPanorama * const first, CameraPanorama * const second);
70 
71 protected:
72  const bool renderToWindow;
73  const bool renderToTexture;
74  bool benchmark;
75  PanoRenderer * const panoRenderer;
76  ProgramVisualizeIntTexture *progVisualizeIntTexture;
77  ProgramTLEdge progTLEdge;
78  ProgramTLStep progTLStep;
79  ProgramCounterToFB progCounterToFB;
80  ProgramPanoEval progPanoEval;
81  ProgramUtility1 progUtility1;
82  ProgramUtility2 progUtility2;
83  ProgramShowTexture *progShowTexture;
84 
85  GLuint framebuffer;
86  GLuint vao;
87  GLuint vbo;
88  GLuint textures[9];
89 
90  GLuint counterBuffer;
91  GLuint pbo[3];
92  const size_t numPbo;
93  const size_t maxIterations;
94 
95  GLuint panoTexture;
96  int panoWidth;
97  int panoHeight;
98 
99  GLuint bellmanFordTexture;
100  GLuint bellmanFordWidth;
101  GLuint bellmanFordHeight;
102 
103  enum TextureRole {
104  EVAL,
105  SWAP1,
106  SWAP2,
107  GAIN1,
108  GAIN2,
109  UTILITY_MAP_1,
110  UTILITY_MAP_2,
111  UTILITY_MAP_VISUAL,
112  COUNTER
113  } textureToVisualize, curUtilityMap;
114 
115  struct PanoEdge {
116  CameraPanorama * camera;
117  bool clockwise;
118  PanoEdge(CameraPanorama * const camera, bool clockwise) : camera(camera), clockwise(clockwise) {}
119  };
120  typedef std::pair<PanoEdge, PanoEdge> PanoEdgePair;
121  typedef std::list<PanoEdgePair> PanoEdgePairs;
122  PanoEdgePairs panoEdgePairs;
123 
124  Node * targetNode;
125  Node * projectionPlaneNode;
126 
127  bool link(const GLuint program, const char * const name) const;
128 
129 };
130 
131 } /* namespace gpu_coverage */
132 
133 #endif /* INCLUDE_ARTICULATION_PanoEvalRenderer_H_ */
Definition: Programs.h:422
Definition: PanoRenderer.h:43
Definition: Programs.h:436
Definition: Programs.h:504
Definition: Programs.h:169
const int & getTextureHeight() const
Height of the result texture.
Definition: PanoEvalRenderer.h:54
Scene graph corresponding to Assimp&#39;s aiScene.
Definition: Scene.h:59
Scene graph node, corresponding to Assimp&#39;s aiNode.
Definition: Node.h:52
Definition: PanoEvalRenderer.h:115
const int & getTextureWidth() const
Width of the result texture.
Definition: PanoEvalRenderer.h:51
Definition: Programs.h:491
const Scene *const scene
Pointer to the scene to be rendered.
Definition: AbstractRenderer.h:101
Abstract superclass for all renderers.
Definition: AbstractRenderer.h:45
Definition: AbstractCamera.h:41
const std::string name
Name of the renderer, see getName().
Definition: AbstractRenderer.h:102
Definition: Programs.h:378
const GLuint & getTexture() const
Returns the OpenGL texture ID of the result texture.
Definition: PanoEvalRenderer.h:48
Definition: PanoEvalRenderer.h:42
Omnidirectional panorama camera.
Definition: CameraPanorama.h:44
virtual void display()
Renders the scene.
Definition: Programs.h:402