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

Revision 1932, 6.8 KB checked in by mattausch, 18 years ago (diff)
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 InitGL();
97
98        /** Computes rays from information gained with hw sampling-
99        */
100        void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
101
102        float GetPixelError(int &pvsSize);
103
104        int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
105
106
107private:
108
109        void SetupProjectionForViewPoint(const Vector3 &viewPoint,
110                                                                         const Beam &beam,
111                                                                         Intersectable *sourceObject);
112
113
114public:
115signals:
116        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
117};
118
119
120class __declspec(dllexport) QtRendererControlWidget : public QWidget
121{
122        Q_OBJECT
123public:
124
125        QListWidget *mPvsErrorWidget;
126
127        QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
128
129public slots:
130
131        void FocusNextPvsErrorFrame();
132        void UpdatePvsErrorItem(int i,
133                GlRendererBuffer::PvsErrorEntry &);
134
135signals:
136
137        void SetViewCellGranularity(int);
138        void SetSceneCut(int);
139        void SetTopDistance(int);
140        void SetVisibilityFilterSize(int);
141        void SetSpatialFilterSize(int);
142
143        void SetRenderFilter(bool);
144        void SetUseFilter(bool);
145        void SetUseSpatialFilter(bool);
146        void SetRenderErrors(bool);
147        void SetShowViewCells(bool);
148        void SetShowRenderCost(bool);
149        void SetShowPvsSizes(bool);
150        void SetTopView(bool);
151        void SetCutViewCells(bool);
152        void SetCutScene(bool);
153
154
155};
156
157
158class __declspec(dllexport) QtGlRendererWidget : public QGLWidget, public GlRendererWidget
159{
160        Q_OBJECT
161public:
162
163        // point of the last mouse click used for movement in the scene
164        Vector3 mousePoint;
165
166        bool mTopView;
167        bool mRenderViewCells;
168        bool mCutViewCells;
169        bool mCutScene;
170        bool mRenderErrors;
171        bool mRenderFilter;
172        bool mUseFilter;
173        bool mUseSpatialFilter;
174        bool mShowRenderCost;
175
176        bool mShowPvsSizes;
177        float mSpatialFilterSize;
178
179        Plane3 mSceneCutPlane;
180        float mTopDistance;
181
182        // some statistics
183        int mPvsSize;
184        float mRenderError;
185
186        QtRendererControlWidget *mControlWidget;
187
188        QtGlRendererWidget(SceneGraph *sceneGraph,
189                ViewCellsManager *viewcells,
190                KdTree *tree,
191                QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
192                );
193
194        QtGlRendererWidget() {};
195
196        virtual void SetupCamera();
197
198        void initializeGL() {
199                InitGL();
200        }
201        void resizeGL(int w, int h);
202        void paintGL();
203        void timerEvent(QTimerEvent *) {
204                update();
205        }
206
207        void mousePressEvent(QMouseEvent *);
208        void mouseReleaseEvent(QMouseEvent *);
209        void mouseMoveEvent(QMouseEvent *);
210
211        void keyPressEvent ( QKeyEvent * e ) ;
212
213        void
214                RenderPvs();
215
216        float
217                RenderErrors();
218        void
219                RenderInfo();
220
221        virtual int GetWidth() const { return width(); }
222        virtual int GetHeight() const { return height(); }
223
224        virtual void
225                SetupProjection(const int w, const int h, const float angle = 70.0f);
226
227        void
228                RenderViewCells();
229
230public slots:
231
232        void SetRenderErrors(bool b) {
233                mRenderErrors = b;
234                updateGL();
235        }
236
237        void SetRenderFilter(bool b) {
238                mRenderFilter = b;
239                updateGL();
240        }
241
242        void SetUseFilter(bool b) {
243                mUseFilter = b;
244                updateGL();
245        }
246
247        void SetUseSpatialFilter(bool b) {
248                mUseSpatialFilter = b;
249                updateGL();
250        }
251
252
253        void
254                SetViewCellGranularity(int number);
255
256        void
257                SetVisibilityFilterSize(int number);
258
259        void
260                SetSpatialFilterSize(int number);
261
262        void
263                SetSceneCut(int cut);
264
265        void
266                SetTopDistance(int dist);
267
268        void SetShowViewCells(bool b) {
269                mRenderViewCells = b;
270                updateGL();
271        }
272
273        void SetShowRenderCost(bool b) {
274                mShowRenderCost = b;
275                updateGL();
276        }
277
278        void SetShowPvsSizes(bool b) {
279                mShowPvsSizes = b;
280                updateGL();
281        }
282
283        void SetTopView(bool b) {
284                mTopView = b;
285                updateGL();
286        }
287
288        void SetCutViewCells(bool b) {
289                mCutViewCells = b;
290                updateGL();
291        }
292        void SetCutScene(bool b) {
293                mCutScene = b;
294                updateGL();
295        }
296
297        // matt: dummy function, must be provided by bittner
298        void RenderRenderCost() {}
299
300};
301
302
303class QtGlDebuggerWidget : public QGLWidget
304{
305        Q_OBJECT
306public:
307        QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
308        ~QtGlDebuggerWidget();
309        void initializeGL();
310        void resizeGL(int w, int h);
311        void paintGL();
312        void timerEvent(QTimerEvent *) { update(); }
313        void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
314        void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
315
316        void initCommon();
317        void initPbuffer();
318
319
320        QtGlRendererBuffer *mRenderBuffer;
321
322        Beam mBeam;
323        int mSamples;
324        Intersectable *mSourceObject;
325
326private:
327
328        GLuint dynamicTexture;
329        int timerId;
330};
331
332extern QtGlDebuggerWidget *debuggerWidget;
333
334};
335
336#endif
337
Note: See TracBrowser for help on using the repository browser.