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

Revision 1935, 6.9 KB checked in by mattausch, 18 years ago (diff)

started depth peeling

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