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

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
[1150]38class __declspec(dllexport) 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
[1151]128class __declspec(dllexport) QtRendererControlWidget : public QWidget
[1146]129{
[1148]130  Q_OBJECT
[1146]131public:
132
[1148]133  QListWidget *mPvsErrorWidget;
[1146]134
[1151]135  QtRendererControlWidget(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
[1151]165class __declspec(dllexport) QtGlRendererWidget : public QGLWidget, public GlRendererWidget
[1148]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
[1151]193  QtRendererControlWidget *mControlWidget;
[1148]194 
[1151]195  QtGlRendererWidget(SceneGraph *sceneGraph,
[1148]196                                   ViewCellsManager *viewcells,
197                                   KdTree *tree,
198                                   QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
199                                   );
200
[1151]201  QtGlRendererWidget() {};
[1148]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
[1146]305};
306
[1148]307
[1151]308class QtGlDebuggerWidget : public QGLWidget
[1148]309{
310        Q_OBJECT
311public:
[1151]312    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
313    ~QtGlDebuggerWidget();
[1148]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
[1151]336extern QtGlDebuggerWidget *debuggerWidget;
[1148]337
338};
339
[1146]340#endif
341
Note: See TracBrowser for help on using the repository browser.