source: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h @ 2569

Revision 2569, 8.2 KB checked in by mattausch, 17 years ago (diff)
RevLine 
[1252]1#ifndef __QTGLRENDERER_H
2#define __QTGLRENDERER_H
3
4#include <QtOpenGL>
5#include <QWaitCondition>
[2543]6#include <QMutex>
[1252]7
8#include "Vector3.h"
9#include "Containers.h"
10#include "Halton.h"
11#include "Renderer.h"
12#include "GlRenderer.h"
13#include "Beam.h"
[1942]14#include "QtPreprocessorThread.h"
[2543]15
16
[1252]17class QWidget;
18
[2543]19
20
[1252]21namespace GtpVisibilityPreprocessor {
22
23class SceneGraph;
24class ViewCellsManager;
25class Mesh;
26class MeshInstance;
27class Intersectable;
28class Material;
29class Beam;
30class KdTree;
31class GlRendererBuffer;
32class BeamSampleStatistics;
33class OcclusionQuery;
34class TransformedMeshInstance;
35
[1942]36
[1252]37struct VssRayContainer;
38struct PvsRenderStatistics;
39struct RenderCostSample;
40
41
[1942]42class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
[1252]43{
44        Q_OBJECT
45public:
46        QtGlRendererBuffer(const int w,
[1942]47                const int h,
48                SceneGraph *sceneGraph,
49                ViewCellsManager *viewcells,
50                KdTree *tree);
[1252]51
[1942]52  ~QtGlRendererBuffer() {}
[1252]53
[1942]54  virtual void MakeCurrent();
55  virtual void DoneCurrent();
[1252]56
[1942]57  virtual int GetWidth() const { return width(); }
58  virtual int GetHeight() const { return height(); }
[1252]59
[1942]60  int ComputePvs() const { return 0; }
61 
62  float
63  GetPixelError(int &pvsSize);
64 
65  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
66     
67 
68 
69 
[1252]70public:
[1942]71  signals:
72  void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
[1252]73};
74
75
[1942]76class QtRendererControlWidget : public QWidget
[1252]77{
[1942]78  Q_OBJECT
[1252]79public:
80
[1942]81  QListWidget *mPvsErrorWidget;
[1252]82
[1942]83  QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
[1252]84
[2569]85  QGroupBox *CreateVisualizationPanel(QWidget *parent);
86
[1942]87  public slots:
[1252]88
[1942]89  void FocusNextPvsErrorFrame();
90  void UpdatePvsErrorItem(int i,
91                                                  GlRendererBuffer::PvsErrorEntry &);
[1252]92
[2569]93 
94  QGroupBox *CreateRenderCostPanel(QWidget *parent);
95
96
[1942]97  signals:
[1252]98
[1942]99  void ComputeVisibility();
100  void StopComputation();
101  void SetRandomViewPoint();
102  void UpdateAllPvs();
103  void SetViewCellGranularity(int);
104  void SetTransferFunction(int);
105  void SetSceneCut(int);
106  void SetTopDistance(int);
[2562]107  void SetHidingCost(int);
[1942]108  void SetVisibilityFilterSize(int);
109  void SetSpatialFilterSize(int);
[2563]110  void SetTransparency(int);
[1252]111
[1942]112  void SetShowRays(bool);
113  void SetRenderFilter(bool);
114  void SetRenderVisibilityEstimates(bool);
115  void SetUseFilter(bool);
116  void SetUseSpatialFilter(bool);
117  void SetRenderErrors(bool);
118  void SetRenderBoxes(bool);
119  void SetShowViewCells(bool);
120  void SetShowRenderCost(bool);
121  void SetShowPvsSizes(bool);
[2560]122  void SetShowPiercingRays(bool);
[2566]123  void SetShowWeightedRays(bool);
[2569]124  void SetShowWeightedCost(bool);
125 
[1942]126  void SetTopView(bool);
127  void SetCutViewCells(bool);
128  void SetCutScene(bool);
[2562]129
130  void SetHideByCost(bool);
[2564]131  void SetUseTransparency(bool);
[2569]132
133  void SetShowDistanceWeightedTriangles(bool);
134  void SetShowWeightedTriangles(bool);
135  void SetShowDistanceWeightedPvs(bool);
[1252]136};
137
[1926]138
[1942]139class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
[1252]140{
[2543]141        Q_OBJECT
[1252]142public:
143
[2543]144        // point of the last mouse click used for movement in the scene
145        Vector3 mousePoint;
[1252]146
[2543]147        bool mTopView;
148        bool mRenderViewCells;
149        bool mCutViewCells;
150        bool mCutScene;
[2562]151        bool mHideByCost;
[2543]152        bool mRenderErrors;
153        bool mRenderFilter;
154        bool mRenderVisibilityEstimates;
155        bool mUseFilter;
156        bool mUseSpatialFilter;
157        bool mShowRenderCost;
[2560]158        bool mShowPiercingRays;
[2566]159        bool mShowWeightedRays;
[2543]160        bool mShowRays;
[1252]161
[2543]162        bool mShowPvsSizes;
163        float mSpatialFilterSize;
[1252]164
[2543]165        Plane3 mSceneCutPlane;
[2562]166        float mHidingCost;
167
[2543]168        float mTopDistance;
[1252]169
[2563]170        float mTransparency;
[2564]171        bool mUseTransparency;
[2563]172
[2569]173        bool mShowWeightedCost;
174
175        bool mShowDistanceWeightedTriangles;
176        bool mShowDistanceWeightedPvs;
177        bool mShowWeightedTriangles;
178
[2543]179        // some statistics
180        int mPvsSize;
181        float mRenderError;
182        float mTransferFunction;
[1252]183
[2543]184        unsigned int mIndexBufferSize;
[1252]185
[2566]186        Vector3 mDummyViewPoint;
187
[2543]188        QtRendererControlWidget *mControlWidget;
[1252]189
[2543]190        QtPreprocessorThread *mPreprocessorThread;
[1252]191
[2543]192        QtGlRendererWidget(SceneGraph *sceneGraph,
193                ViewCellsManager *viewcells,
194                KdTree *tree,
195                QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
196                );
[1997]197
[2543]198        QtGlRendererWidget() {};
[1252]199
[2543]200        void SetThread(QtPreprocessorThread *t) {
201                mPreprocessorThread = t;
202        }
203        void
204                RenderRenderCost();
[1252]205
[2543]206        virtual void SetupCamera();
[1252]207
[2543]208        void initializeGL() {
209                InitGL();
210        }
[1252]211
[2543]212        virtual void InitGL();
[1252]213
[2543]214        void resizeGL(int w, int h);
215        void paintGL();
216        void timerEvent(QTimerEvent *event);
217        void mousePressEvent(QMouseEvent *);
218        void mouseReleaseEvent(QMouseEvent *);
219        void mouseMoveEvent(QMouseEvent *);
[1252]220
[2543]221        void keyPressEvent(QKeyEvent * e);
[1252]222
[2543]223        void RenderPvs();
[1252]224
[2543]225        float RenderErrors();
226        void RenderInfo();
[1252]227
[2543]228        virtual int GetWidth() const { return width(); }
229        virtual int GetHeight() const { return height(); }
[1252]230
[2543]231        // virtual void
232        //  SetupProjection(const int w, const int h, const float angle = 70.0f);
[2538]233
[2543]234        virtual void
235                SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
[2538]236
[2543]237        void
238                RenderViewCells();
[1252]239
240
[2543]241        virtual void Show() {
242                show();
243        }
[1252]244
[2543]245        bool PvsChanged(ViewCell *viewcell) const;
[1252]246
[2543]247        /////////
[1252]248
[2543]249        //QMutex mMutex;
[1252]250
251
[2543]252public slots:
[1926]253
[2543]254        void UpdateAllPvs();
255        void ComputeVisibility();
256        void StopComputation();
257        void SetRandomViewPoint();
[1926]258
[2543]259        void SetRenderErrors(bool b) {
260                mRenderErrors = b;
261                updateGL();
262        }
[1926]263
[2543]264        void SetRenderBoxes(bool b) {
265                mRenderBoxes = b;
266                updateGL();
267        }
[1926]268
[2543]269        void SetRenderFilter(bool b) {
270                mRenderFilter = b;
271                updateGL();
272        }
[1926]273
[2543]274        void SetRenderVisibilityEstimates(bool b) {
275                mRenderVisibilityEstimates = b;
276                updateGL();
277        }
[1926]278
[2543]279        void SetUseFilter(bool b) {
280                mUseFilter = b;
281                mPvsCache.Reset();
282                updateGL();
283        }
[1926]284
[2543]285        void SetUseSpatialFilter(bool b) {
286                mUseSpatialFilter = b;
287                mPvsCache.Reset();
288                updateGL();
289        }
[1926]290
[1942]291
[2543]292        void
293                SetViewCellGranularity(int number);
[1942]294
[2543]295        void SetTransferFunction(int number)
296        {
297                mTransferFunction = number/1000.0f;
298                updateGL();
299        }
[2538]300
[2543]301        void SetVisibilityFilterSize(int number);
[2538]302
[2543]303        void
304                SetSpatialFilterSize(int number);
305
306        void
307                SetSceneCut(int cut);
308
309        void
310                SetTopDistance(int dist);
311
[2562]312        void
[2563]313                SetTransparency(int dist);
314
315        void
[2562]316                SetHidingCost(int dist);
317
[2543]318        void SetShowViewCells(bool b) {
319                mRenderViewCells = b;
320                updateGL();
321        }
322
323        void SetShowRays(bool b) {
324                mShowRays = b;
325                updateGL();
326        }
327
328        void SetShowRenderCost(bool b) {
329                mShowRenderCost = b;
330                updateGL();
331        }
332
333        void SetShowPvsSizes(bool b) {
334                mShowPvsSizes = b;
335                updateGL();
336        }
337
[2560]338        void SetShowPiercingRays(bool b) {
339                mShowPiercingRays = b;
340                updateGL();
341        }
342
[2566]343        void SetShowWeightedRays(bool b) {
344                mShowWeightedRays = b;
345                updateGL();
346        }
347
[2543]348        void SetTopView(bool b) {
349                mTopView = b;
350                updateGL();
351        }
352
353        void SetCutViewCells(bool b) {
354                mCutViewCells = b;
355                updateGL();
356        }
357        void SetCutScene(bool b) {
358                mCutScene = b;
359                updateGL();
360        }
361
[2562]362        void SetHideByCost(bool b) {
363                mHideByCost = b;
364                updateGL();
365        }
366
[2564]367        void SetUseTransparency(bool b) {
368                mUseTransparency = b;
369                updateGL();
370        }
371
[2569]372        void SetShowWeightedCost(bool b)
373        {
374                mShowWeightedCost = b;
375                updateGL();
376        }
377
378        void SetShowDistanceWeightedPvs(bool b)
379        {
380                mShowDistanceWeightedPvs = b;
381                updateGL();
382        }
383
384
385        void SetShowDistanceWeightedTriangles(bool b)
386        {
387                mShowDistanceWeightedTriangles = b;
388                updateGL();
389        }
390       
391        void SetShowWeightedTriangles(bool b)
392        {
393                mShowWeightedTriangles = b;
394                updateGL();
395        }
396
397
[2543]398        void _RenderPvs();
399
400        void _UpdatePvsIndices();
401
402        void _UpdatePvsIndices(KdNode *node, int &indexBufferSize);
403
[2569]404        float ComputeRenderCost(ViewCell *vc);
[2543]405
406        /////////
407
408signals:
409        void PvsUpdated();
[1252]410};
411
412
413class QtGlDebuggerWidget : public QGLWidget
414{
415        Q_OBJECT
416public:
[1942]417    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
418    ~QtGlDebuggerWidget();
419    void initializeGL();
420    void resizeGL(int w, int h);
421    void paintGL();
422    void timerEvent(QTimerEvent *) { update(); }
423    void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
424    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
[1252]425
[1942]426    void initCommon();
427    void initPbuffer();
[1252]428
[1942]429 
430         QtGlRendererBuffer *mRenderBuffer;
[1252]431
[1942]432         Beam mBeam;
433         int mSamples;
434         Intersectable *mSourceObject;
[1252]435
436private:
[2543]437
[1942]438    GLuint dynamicTexture;
439    int timerId;
[1252]440};
441
[2543]442
[1252]443extern QtGlDebuggerWidget *debuggerWidget;
444
445};
446
447#endif
448
Note: See TracBrowser for help on using the repository browser.