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

Revision 1151, 7.0 KB checked in by mattausch, 18 years ago (diff)

worded on dll loading

Line 
1#ifndef __QTGLRENDERER_H
2#define __QTGLRENDERER_H
3
4#include <QtOpenGL>
5#include <QWaitCondition>
6
7//#include <QGLPixelBuffer>
8
9#include "Vector3.h"
10#include "Containers.h"
11#include "Halton.h"
12#include "Renderer.h"
13#include "GlRenderer.h"
14#include "Beam.h"
15
16class QWidget;
17
18namespace GtpVisibilityPreprocessor {
19
20class SceneGraph;
21class ViewCellsManager;
22class Mesh;
23class MeshInstance;
24class Intersectable;
25class Material;
26class Beam;
27class KdTree;
28class GlRendererBuffer;
29class BeamSampleStatistics;
30class OcclusionQuery;
31class TransformedMeshInstance;
32
33struct VssRayContainer;
34struct PvsRenderStatistics;
35struct RenderCostSample;
36
37
38class __declspec(dllexport) QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
39{
40        Q_OBJECT
41public:
42        QtGlRendererBuffer(const int w,
43                const int h,
44                SceneGraph *sceneGraph,
45                ViewCellsManager *viewcells,
46                KdTree *tree);
47
48        ~QtGlRendererBuffer();
49
50        /** Evaluates render cost of a point sample.
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.
54        */
55        void EvalRenderCostSample(RenderCostSample &sample,
56                const bool useOcclusionQueries,
57                const int threshold);
58
59        /** Evaluates render cost of a number of point samples. The point samples
60        are distributed uniformly over the defined view space.
61
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.
66        */
67        void SampleRenderCost(const int numSamples,
68                vector<RenderCostSample> &samples,
69                const bool useOcclusionQueries,
70                const int threshold = 0);
71
72
73  void
74  EvalPvsStat();
75
76  void
77  ClearErrorBuffer();
78 
79
80  virtual int GetWidth() const { return width(); }
81  virtual int GetHeight() const { return height(); }
82
83
84 
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;
113     
114   
115private:
116       
117        void SetupProjectionForViewPoint(const Vector3 &viewPoint,
118                                                                         const Beam &beam,
119                                                                         Intersectable *sourceObject);
120
121
122public:
123  signals:
124        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
125};
126
127
128class __declspec(dllexport) QtRendererControlWidget : public QWidget
129{
130  Q_OBJECT
131public:
132
133  QListWidget *mPvsErrorWidget;
134
135  QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
136
137  public slots:
138
139  void FocusNextPvsErrorFrame();
140  void UpdatePvsErrorItem(int i,
141                                                  GlRendererBuffer::PvsErrorEntry &);
142
143  signals:
144 
145  void SetViewCellGranularity(int);
146  void SetSceneCut(int);
147  void SetTopDistance(int);
148  void SetVisibilityFilterSize(int);
149  void SetSpatialFilterSize(int);
150
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 
163};
164
165class __declspec(dllexport) QtGlRendererWidget : public QGLWidget, public GlRendererWidget
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  QtRendererControlWidget *mControlWidget;
194 
195  QtGlRendererWidget(SceneGraph *sceneGraph,
196                                   ViewCellsManager *viewcells,
197                                   KdTree *tree,
198                                   QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
199                                   );
200
201  QtGlRendererWidget() {};
202
203  virtual void SetupCamera();
204
205  void initializeGL() {
206        InitGL();
207  }
208  void resizeGL(int w, int h);
209  void paintGL();
210  void timerEvent(QTimerEvent *) {
211          update();
212  }
213
214  void mousePressEvent(QMouseEvent *);
215  void mouseReleaseEvent(QMouseEvent *);
216  void mouseMoveEvent(QMouseEvent *);
217
218  void keyPressEvent ( QKeyEvent * e ) ;
219
220  void
221  RenderPvs();
222
223  float
224  RenderErrors();
225  void
226  RenderInfo();
227
228  virtual int GetWidth() const { return width(); }
229  virtual int GetHeight() const { return height(); }
230
231 virtual void
232  SetupProjection(const int w, const int h, const float angle = 70.0f);
233
234  void
235  RenderViewCells();
236
237 public slots:
238
239 void SetRenderErrors(bool b) {
240   mRenderErrors = b;
241   updateGL();
242 }
243
244 void SetRenderFilter(bool b) {
245   mRenderFilter = b;
246   updateGL();
247 }
248
249  void SetUseFilter(bool b) {
250   mUseFilter = b;
251   updateGL();
252 }
253
254  void SetUseSpatialFilter(bool b) {
255        mUseSpatialFilter = b;
256        updateGL();
257  }
258
259 
260  void
261  SetViewCellGranularity(int number);
262 
263  void
264  SetVisibilityFilterSize(int number);
265
266  void
267  SetSpatialFilterSize(int number);
268 
269  void
270  SetSceneCut(int cut);
271 
272  void
273  SetTopDistance(int dist);
274 
275  void SetShowViewCells(bool b) {
276        mRenderViewCells = b;
277        updateGL();
278  }
279
280  void SetShowRenderCost(bool b) {
281        mShowRenderCost = b;
282        updateGL();
283  }
284
285  void SetShowPvsSizes(bool b) {
286        mShowPvsSizes = b;
287        updateGL();
288  }
289
290  void SetTopView(bool b) {
291        mTopView = b;
292        updateGL();
293  }
294
295  void SetCutViewCells(bool b) {
296        mCutViewCells = b;
297        updateGL();
298  }
299  void SetCutScene(bool b) {
300        mCutScene = b;
301        updateGL();
302  }
303
304
305};
306
307
308class QtGlDebuggerWidget : public QGLWidget
309{
310        Q_OBJECT
311public:
312    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
313    ~QtGlDebuggerWidget();
314    void initializeGL();
315    void resizeGL(int w, int h);
316    void paintGL();
317    void timerEvent(QTimerEvent *) { update(); }
318    void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
319    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
320
321    void initCommon();
322    void initPbuffer();
323
324 
325         QtGlRendererBuffer *mRenderBuffer;
326
327         Beam mBeam;
328         int mSamples;
329         Intersectable *mSourceObject;
330
331private:
332    GLuint dynamicTexture;
333    int timerId;
334};
335
336extern QtGlDebuggerWidget *debuggerWidget;
337
338};
339
340#endif
341
Note: See TracBrowser for help on using the repository browser.