source: GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.h @ 1148

Revision 1148, 7.0 KB checked in by mattausch, 18 years ago (diff)
RevLine 
[1148]1#ifndef __QTGLRENDERER_H
2#define __QTGLRENDERER_H
[1146]3
[1148]4#include <QtOpenGL>
5#include <QWaitCondition>
[1146]6
[1148]7//#include <QGLPixelBuffer>
[1146]8
[1148]9#include "Vector3.h"
10#include "Containers.h"
11#include "Halton.h"
12#include "Renderer.h"
13#include "GlRenderer.h"
14#include "Beam.h"
[1146]15
[1148]16class QWidget;
17
[1146]18namespace GtpVisibilityPreprocessor {
19
[1148]20class SceneGraph;
21class ViewCellsManager;
22class Mesh;
23class MeshInstance;
24class Intersectable;
25class Material;
26class Beam;
27class KdTree;
28class GlRendererBuffer;
29class BeamSampleStatistics;
30class OcclusionQuery;
31class TransformedMeshInstance;
[1146]32
[1148]33struct VssRayContainer;
34struct PvsRenderStatistics;
35struct RenderCostSample;
[1146]36
37
[1148]38class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
[1146]39{
[1148]40        Q_OBJECT
[1146]41public:
[1148]42        QtGlRendererBuffer(const int w,
43                const int h,
44                SceneGraph *sceneGraph,
45                ViewCellsManager *viewcells,
46                KdTree *tree);
[1146]47
[1148]48        ~QtGlRendererBuffer();
[1146]49
50        /** Evaluates render cost of a point sample.
[1148]51        @param sample the render cost sample to be evaluated
52        @param useOcclusionQueries if occlusion queries should be used or item buffer
53        @param threshold number of pixels / samples from where an object is considered visible.
[1146]54        */
55        void EvalRenderCostSample(RenderCostSample &sample,
[1148]56                const bool useOcclusionQueries,
57                const int threshold);
[1146]58
59        /** Evaluates render cost of a number of point samples. The point samples
[1148]60        are distributed uniformly over the defined view space.
[1146]61
[1148]62        @param numSamples the number of point samples taken
63        @param samples stores the taken point samples in a container
64        @param useOcclusionQueries if occlusion queries should be used or item buffer
65        @param threshold number of pixels / samples from where an object is considered visible.
[1146]66        */
67        void SampleRenderCost(const int numSamples,
[1148]68                vector<RenderCostSample> &samples,
69                const bool useOcclusionQueries,
70                const int threshold = 0);
[1146]71
72
[1148]73  void
74  EvalPvsStat();
75
76  void
77  ClearErrorBuffer();
[1146]78 
79
[1148]80  virtual int GetWidth() const { return width(); }
81  virtual int GetHeight() const { return height(); }
[1146]82
83
[1148]84 
[1146]85  void SampleBeamContributions(
86                                                           Intersectable *sourceObject,
87                                                           Beam &beam,
88                                                           const int samples,
89                                                           BeamSampleStatistics &stat
90                                                           );
91
92  void
93  SampleViewpointContributions(
94                                                           Intersectable *sourceObject,
95                                                           const Vector3 viewPoint,
96                                                           Beam &beam,
97                                                           const int desiredSamples,
98                                                           BeamSampleStatistics &stat
99                                                           );
100
101  void InitGL();
102
103  /** Computes rays from information gained with hw sampling-
104  */
105  void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
106
107  int ComputePvs() const;
108
109  float
110  GetPixelError(int &pvsSize);
111
112  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
[1148]113     
[1146]114   
[1148]115private:
116       
[1146]117        void SetupProjectionForViewPoint(const Vector3 &viewPoint,
118                                                                         const Beam &beam,
119                                                                         Intersectable *sourceObject);
120
121
122public:
[1148]123  signals:
124        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
[1146]125};
126
127
[1148]128class RendererControlWidget : public QWidget
[1146]129{
[1148]130  Q_OBJECT
[1146]131public:
132
[1148]133  QListWidget *mPvsErrorWidget;
[1146]134
[1148]135  RendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
[1146]136
[1148]137  public slots:
[1146]138
[1148]139  void FocusNextPvsErrorFrame();
140  void UpdatePvsErrorItem(int i,
141                                                  GlRendererBuffer::PvsErrorEntry &);
[1146]142
[1148]143  signals:
144 
145  void SetViewCellGranularity(int);
146  void SetSceneCut(int);
147  void SetTopDistance(int);
148  void SetVisibilityFilterSize(int);
149  void SetSpatialFilterSize(int);
[1146]150
[1148]151  void SetRenderFilter(bool);
152  void SetUseFilter(bool);
153  void SetUseSpatialFilter(bool);
154  void SetRenderErrors(bool);
155  void SetShowViewCells(bool);
156  void SetShowRenderCost(bool);
157  void SetShowPvsSizes(bool);
158  void SetTopView(bool);
159  void SetCutViewCells(bool);
160  void SetCutScene(bool);
161
162 
[1146]163};
164
[1148]165class GlRendererWidget : public QGLWidget, public GlRenderer
166{
167  Q_OBJECT
168public:
169
170  // point of the last mouse click used for movement in the scene
171  Vector3 mousePoint;
172
173  bool mTopView;
174  bool mRenderViewCells;
175  bool mCutViewCells;
176  bool mCutScene;
177  bool mRenderErrors;
178  bool mRenderFilter;
179  bool mUseFilter;
180  bool mUseSpatialFilter;
181  bool mShowRenderCost;
182 
183  bool mShowPvsSizes;
184  float mSpatialFilterSize;
185 
186  Plane3 mSceneCutPlane;
187  float mTopDistance;
188
189  // some statistics
190  int mPvsSize;
191  float mRenderError;
192
193  RendererControlWidget *mControlWidget;
194 
195  GlRendererWidget(SceneGraph *sceneGraph,
196                                   ViewCellsManager *viewcells,
197                                   KdTree *tree,
198                                   QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
199                                   );
200
201
202  virtual void SetupCamera();
203
204  void initializeGL() {
205        InitGL();
206  }
207  void resizeGL(int w, int h);
208  void paintGL();
209  void timerEvent(QTimerEvent *) {
210          update();
211  }
212
213  void mousePressEvent(QMouseEvent *);
214  void mouseReleaseEvent(QMouseEvent *);
215  void mouseMoveEvent(QMouseEvent *);
216
217  void keyPressEvent ( QKeyEvent * e ) ;
218
219  void
220  RenderPvs();
221
222  float
223  RenderErrors();
224  void
225  RenderInfo();
226
227  virtual int GetWidth() const { return width(); }
228  virtual int GetHeight() const { return height(); }
229
230 virtual void
231  SetupProjection(const int w, const int h, const float angle = 70.0f);
232
233  void
234  RenderViewCells();
235
236 public slots:
237
238 void SetRenderErrors(bool b) {
239   mRenderErrors = b;
240   updateGL();
241 }
242
243 void SetRenderFilter(bool b) {
244   mRenderFilter = b;
245   updateGL();
246 }
247
248  void SetUseFilter(bool b) {
249   mUseFilter = b;
250   updateGL();
251 }
252
253  void SetUseSpatialFilter(bool b) {
254        mUseSpatialFilter = b;
255        updateGL();
256  }
257
258 
259  void
260  SetViewCellGranularity(int number);
261 
262  void
263  SetVisibilityFilterSize(int number);
264
265  void
266  SetSpatialFilterSize(int number);
267 
268  void
269  SetSceneCut(int cut);
270 
271  void
272  SetTopDistance(int dist);
273 
274  void SetShowViewCells(bool b) {
275        mRenderViewCells = b;
276        updateGL();
277  }
278
279  void SetShowRenderCost(bool b) {
280        mShowRenderCost = b;
281        updateGL();
282  }
283
284  void SetShowPvsSizes(bool b) {
285        mShowPvsSizes = b;
286        updateGL();
287  }
288
289  void SetTopView(bool b) {
290        mTopView = b;
291        updateGL();
292  }
293
294  void SetCutViewCells(bool b) {
295        mCutViewCells = b;
296        updateGL();
297  }
298  void SetCutScene(bool b) {
299        mCutScene = b;
300        updateGL();
301  }
302
303
[1146]304};
305
[1148]306
307extern GlRendererWidget *rendererWidget;
308
309class GlDebuggerWidget : public QGLWidget
310{
311        Q_OBJECT
312public:
313    GlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
314    ~GlDebuggerWidget();
315    void initializeGL();
316    void resizeGL(int w, int h);
317    void paintGL();
318    void timerEvent(QTimerEvent *) { update(); }
319    void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
320    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
321
322    void initCommon();
323    void initPbuffer();
324
325 
326         QtGlRendererBuffer *mRenderBuffer;
327
328         Beam mBeam;
329         int mSamples;
330         Intersectable *mSourceObject;
331
332private:
333    GLuint dynamicTexture;
334    int timerId;
335};
336
337extern GlDebuggerWidget *debuggerWidget;
338
339};
340
[1146]341#endif
342
Note: See TracBrowser for help on using the repository browser.