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 | #include "QtPreprocessorThread.h"
|
---|
16 | class QWidget;
|
---|
17 | //class QtPreprocessorThread;
|
---|
18 |
|
---|
19 | namespace GtpVisibilityPreprocessor {
|
---|
20 |
|
---|
21 | class SceneGraph;
|
---|
22 | class ViewCellsManager;
|
---|
23 | class Mesh;
|
---|
24 | class MeshInstance;
|
---|
25 | class Intersectable;
|
---|
26 | class Material;
|
---|
27 | class Beam;
|
---|
28 | class KdTree;
|
---|
29 | class GlRendererBuffer;
|
---|
30 | class BeamSampleStatistics;
|
---|
31 | class OcclusionQuery;
|
---|
32 | class TransformedMeshInstance;
|
---|
33 |
|
---|
34 |
|
---|
35 | struct VssRayContainer;
|
---|
36 | struct PvsRenderStatistics;
|
---|
37 | struct RenderCostSample;
|
---|
38 |
|
---|
39 |
|
---|
40 | class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
|
---|
41 | {
|
---|
42 | Q_OBJECT
|
---|
43 | public:
|
---|
44 | QtGlRendererBuffer(const int w,
|
---|
45 | const int h,
|
---|
46 | SceneGraph *sceneGraph,
|
---|
47 | ViewCellsManager *viewcells,
|
---|
48 | KdTree *tree);
|
---|
49 |
|
---|
50 | ~QtGlRendererBuffer() {}
|
---|
51 |
|
---|
52 | virtual void MakeCurrent();
|
---|
53 | virtual void DoneCurrent();
|
---|
54 |
|
---|
55 | virtual int GetWidth() const { return width(); }
|
---|
56 | virtual int GetHeight() const { return height(); }
|
---|
57 |
|
---|
58 | int ComputePvs() const { return 0; }
|
---|
59 |
|
---|
60 | float
|
---|
61 | GetPixelError(int &pvsSize);
|
---|
62 |
|
---|
63 | int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | public:
|
---|
69 | signals:
|
---|
70 | void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
|
---|
71 | };
|
---|
72 |
|
---|
73 |
|
---|
74 | class QtRendererControlWidget : public QWidget
|
---|
75 | {
|
---|
76 | Q_OBJECT
|
---|
77 | public:
|
---|
78 |
|
---|
79 | QListWidget *mPvsErrorWidget;
|
---|
80 |
|
---|
81 | QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
|
---|
82 |
|
---|
83 | public slots:
|
---|
84 |
|
---|
85 | void FocusNextPvsErrorFrame();
|
---|
86 | void UpdatePvsErrorItem(int i,
|
---|
87 | GlRendererBuffer::PvsErrorEntry &);
|
---|
88 |
|
---|
89 | signals:
|
---|
90 |
|
---|
91 | void ComputeVisibility();
|
---|
92 | void StopComputation();
|
---|
93 | void SetRandomViewPoint();
|
---|
94 | void UpdateAllPvs();
|
---|
95 | void SetViewCellGranularity(int);
|
---|
96 | void SetTransferFunction(int);
|
---|
97 | void SetSceneCut(int);
|
---|
98 | void SetTopDistance(int);
|
---|
99 | void SetVisibilityFilterSize(int);
|
---|
100 | void SetSpatialFilterSize(int);
|
---|
101 |
|
---|
102 | void SetShowRays(bool);
|
---|
103 | void SetRenderFilter(bool);
|
---|
104 | void SetRenderVisibilityEstimates(bool);
|
---|
105 | void SetUseFilter(bool);
|
---|
106 | void SetUseSpatialFilter(bool);
|
---|
107 | void SetRenderErrors(bool);
|
---|
108 | void SetRenderBoxes(bool);
|
---|
109 | void SetShowViewCells(bool);
|
---|
110 | void SetShowRenderCost(bool);
|
---|
111 | void SetShowPvsSizes(bool);
|
---|
112 | void SetTopView(bool);
|
---|
113 | void SetCutViewCells(bool);
|
---|
114 | void SetCutScene(bool);
|
---|
115 |
|
---|
116 | };
|
---|
117 |
|
---|
118 |
|
---|
119 | class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
|
---|
120 | {
|
---|
121 | Q_OBJECT
|
---|
122 | public:
|
---|
123 |
|
---|
124 | // point of the last mouse click used for movement in the scene
|
---|
125 | Vector3 mousePoint;
|
---|
126 |
|
---|
127 | bool mTopView;
|
---|
128 | bool mRenderViewCells;
|
---|
129 | bool mCutViewCells;
|
---|
130 | bool mCutScene;
|
---|
131 | bool mRenderErrors;
|
---|
132 | bool mRenderFilter;
|
---|
133 | bool mRenderVisibilityEstimates;
|
---|
134 | bool mUseFilter;
|
---|
135 | bool mUseSpatialFilter;
|
---|
136 | bool mShowRenderCost;
|
---|
137 | bool mShowRays;
|
---|
138 |
|
---|
139 | bool mShowPvsSizes;
|
---|
140 | float mSpatialFilterSize;
|
---|
141 |
|
---|
142 | Plane3 mSceneCutPlane;
|
---|
143 | float mTopDistance;
|
---|
144 |
|
---|
145 | // some statistics
|
---|
146 | int mPvsSize;
|
---|
147 | float mRenderError;
|
---|
148 | float mTransferFunction;
|
---|
149 |
|
---|
150 |
|
---|
151 | QtRendererControlWidget *mControlWidget;
|
---|
152 |
|
---|
153 | QtPreprocessorThread *mPreprocessorThread;
|
---|
154 |
|
---|
155 | QtGlRendererWidget(SceneGraph *sceneGraph,
|
---|
156 | ViewCellsManager *viewcells,
|
---|
157 | KdTree *tree,
|
---|
158 | QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
|
---|
159 | );
|
---|
160 |
|
---|
161 | QtGlRendererWidget() {};
|
---|
162 |
|
---|
163 | void SetThread(QtPreprocessorThread *t) {
|
---|
164 | mPreprocessorThread = t;
|
---|
165 | }
|
---|
166 | void
|
---|
167 | RenderRenderCost();
|
---|
168 |
|
---|
169 | virtual void SetupCamera();
|
---|
170 |
|
---|
171 | void initializeGL() {
|
---|
172 | InitGL();
|
---|
173 | }
|
---|
174 |
|
---|
175 | virtual void InitGL();
|
---|
176 |
|
---|
177 | void resizeGL(int w, int h);
|
---|
178 | void paintGL();
|
---|
179 | void timerEvent(QTimerEvent *) {
|
---|
180 | update();
|
---|
181 | }
|
---|
182 |
|
---|
183 | void mousePressEvent(QMouseEvent *);
|
---|
184 | void mouseReleaseEvent(QMouseEvent *);
|
---|
185 | void mouseMoveEvent(QMouseEvent *);
|
---|
186 |
|
---|
187 | void keyPressEvent ( QKeyEvent * e ) ;
|
---|
188 |
|
---|
189 | void
|
---|
190 | RenderPvs();
|
---|
191 |
|
---|
192 | float
|
---|
193 | RenderErrors();
|
---|
194 | void
|
---|
195 | RenderInfo();
|
---|
196 |
|
---|
197 | virtual int GetWidth() const { return width(); }
|
---|
198 | virtual int GetHeight() const { return height(); }
|
---|
199 |
|
---|
200 | // virtual void
|
---|
201 | // SetupProjection(const int w, const int h, const float angle = 70.0f);
|
---|
202 |
|
---|
203 | virtual void
|
---|
204 | SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
|
---|
205 |
|
---|
206 | void
|
---|
207 | RenderViewCells();
|
---|
208 |
|
---|
209 |
|
---|
210 | virtual void Show() {
|
---|
211 | show();
|
---|
212 | }
|
---|
213 |
|
---|
214 | public slots:
|
---|
215 |
|
---|
216 | void UpdateAllPvs();
|
---|
217 | void ComputeVisibility();
|
---|
218 | void StopComputation();
|
---|
219 | void SetRandomViewPoint();
|
---|
220 |
|
---|
221 | void SetRenderErrors(bool b) {
|
---|
222 | mRenderErrors = b;
|
---|
223 | updateGL();
|
---|
224 | }
|
---|
225 |
|
---|
226 | void SetRenderBoxes(bool b) {
|
---|
227 | mRenderBoxes = b;
|
---|
228 | updateGL();
|
---|
229 | }
|
---|
230 |
|
---|
231 | void SetRenderFilter(bool b) {
|
---|
232 | mRenderFilter = b;
|
---|
233 | updateGL();
|
---|
234 | }
|
---|
235 |
|
---|
236 | void SetRenderVisibilityEstimates(bool b) {
|
---|
237 | mRenderVisibilityEstimates = b;
|
---|
238 | updateGL();
|
---|
239 | }
|
---|
240 |
|
---|
241 | void SetUseFilter(bool b) {
|
---|
242 | mUseFilter = b;
|
---|
243 | mPvsCache.Reset();
|
---|
244 | updateGL();
|
---|
245 | }
|
---|
246 |
|
---|
247 | void SetUseSpatialFilter(bool b) {
|
---|
248 | mUseSpatialFilter = b;
|
---|
249 | mPvsCache.Reset();
|
---|
250 | updateGL();
|
---|
251 | }
|
---|
252 |
|
---|
253 |
|
---|
254 | void
|
---|
255 | SetViewCellGranularity(int number);
|
---|
256 |
|
---|
257 | void
|
---|
258 | SetTransferFunction(int number) {
|
---|
259 | mTransferFunction = number/1000.0f;
|
---|
260 | updateGL();
|
---|
261 | }
|
---|
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 SetShowRays(bool b) {
|
---|
281 | mShowRays = b;
|
---|
282 | updateGL();
|
---|
283 | }
|
---|
284 |
|
---|
285 | void SetShowRenderCost(bool b) {
|
---|
286 | mShowRenderCost = b;
|
---|
287 | updateGL();
|
---|
288 | }
|
---|
289 |
|
---|
290 | void SetShowPvsSizes(bool b) {
|
---|
291 | mShowPvsSizes = b;
|
---|
292 | updateGL();
|
---|
293 | }
|
---|
294 |
|
---|
295 | void SetTopView(bool b) {
|
---|
296 | mTopView = b;
|
---|
297 | updateGL();
|
---|
298 | }
|
---|
299 |
|
---|
300 | void SetCutViewCells(bool b) {
|
---|
301 | mCutViewCells = b;
|
---|
302 | updateGL();
|
---|
303 | }
|
---|
304 | void SetCutScene(bool b) {
|
---|
305 | mCutScene = b;
|
---|
306 | updateGL();
|
---|
307 | }
|
---|
308 |
|
---|
309 | signals:
|
---|
310 | void PvsUpdated();
|
---|
311 | };
|
---|
312 |
|
---|
313 |
|
---|
314 | class QtGlDebuggerWidget : public QGLWidget
|
---|
315 | {
|
---|
316 | Q_OBJECT
|
---|
317 | public:
|
---|
318 | QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
|
---|
319 | ~QtGlDebuggerWidget();
|
---|
320 | void initializeGL();
|
---|
321 | void resizeGL(int w, int h);
|
---|
322 | void paintGL();
|
---|
323 | void timerEvent(QTimerEvent *) { update(); }
|
---|
324 | void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
|
---|
325 | void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
|
---|
326 |
|
---|
327 | void initCommon();
|
---|
328 | void initPbuffer();
|
---|
329 |
|
---|
330 |
|
---|
331 | QtGlRendererBuffer *mRenderBuffer;
|
---|
332 |
|
---|
333 | Beam mBeam;
|
---|
334 | int mSamples;
|
---|
335 | Intersectable *mSourceObject;
|
---|
336 |
|
---|
337 | private:
|
---|
338 | GLuint dynamicTexture;
|
---|
339 | int timerId;
|
---|
340 | };
|
---|
341 |
|
---|
342 | extern QtGlDebuggerWidget *debuggerWidget;
|
---|
343 |
|
---|
344 | };
|
---|
345 |
|
---|
346 | #endif
|
---|
347 |
|
---|