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 UpdateAllPvs();
|
---|
94 | void SetViewCellGranularity(int);
|
---|
95 | void SetTransferFunction(int);
|
---|
96 | void SetSceneCut(int);
|
---|
97 | void SetTopDistance(int);
|
---|
98 | void SetVisibilityFilterSize(int);
|
---|
99 | void SetSpatialFilterSize(int);
|
---|
100 |
|
---|
101 | void SetShowRays(bool);
|
---|
102 | void SetRenderFilter(bool);
|
---|
103 | void SetRenderVisibilityEstimates(bool);
|
---|
104 | void SetUseFilter(bool);
|
---|
105 | void SetUseSpatialFilter(bool);
|
---|
106 | void SetRenderErrors(bool);
|
---|
107 | void SetRenderBoxes(bool);
|
---|
108 | void SetShowViewCells(bool);
|
---|
109 | void SetShowRenderCost(bool);
|
---|
110 | void SetShowPvsSizes(bool);
|
---|
111 | void SetTopView(bool);
|
---|
112 | void SetCutViewCells(bool);
|
---|
113 | void SetCutScene(bool);
|
---|
114 |
|
---|
115 | };
|
---|
116 |
|
---|
117 |
|
---|
118 | class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
|
---|
119 | {
|
---|
120 | Q_OBJECT
|
---|
121 | public:
|
---|
122 |
|
---|
123 | // point of the last mouse click used for movement in the scene
|
---|
124 | Vector3 mousePoint;
|
---|
125 |
|
---|
126 | bool mTopView;
|
---|
127 | bool mRenderViewCells;
|
---|
128 | bool mCutViewCells;
|
---|
129 | bool mCutScene;
|
---|
130 | bool mRenderErrors;
|
---|
131 | bool mRenderFilter;
|
---|
132 | bool mRenderVisibilityEstimates;
|
---|
133 | bool mUseFilter;
|
---|
134 | bool mUseSpatialFilter;
|
---|
135 | bool mShowRenderCost;
|
---|
136 | bool mShowRays;
|
---|
137 |
|
---|
138 | bool mShowPvsSizes;
|
---|
139 | float mSpatialFilterSize;
|
---|
140 |
|
---|
141 | Plane3 mSceneCutPlane;
|
---|
142 | float mTopDistance;
|
---|
143 |
|
---|
144 | // some statistics
|
---|
145 | int mPvsSize;
|
---|
146 | float mRenderError;
|
---|
147 | float mTransferFunction;
|
---|
148 |
|
---|
149 |
|
---|
150 | QtRendererControlWidget *mControlWidget;
|
---|
151 |
|
---|
152 | QtPreprocessorThread *mPreprocessorThread;
|
---|
153 |
|
---|
154 | QtGlRendererWidget(SceneGraph *sceneGraph,
|
---|
155 | ViewCellsManager *viewcells,
|
---|
156 | KdTree *tree,
|
---|
157 | QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
|
---|
158 | );
|
---|
159 |
|
---|
160 | QtGlRendererWidget() {};
|
---|
161 |
|
---|
162 | void SetThread(QtPreprocessorThread *t) {
|
---|
163 | mPreprocessorThread = t;
|
---|
164 | }
|
---|
165 | void
|
---|
166 | RenderRenderCost();
|
---|
167 |
|
---|
168 | virtual void SetupCamera();
|
---|
169 |
|
---|
170 | void initializeGL() {
|
---|
171 | InitGL();
|
---|
172 | }
|
---|
173 | void resizeGL(int w, int h);
|
---|
174 | void paintGL();
|
---|
175 | void timerEvent(QTimerEvent *) {
|
---|
176 | update();
|
---|
177 | }
|
---|
178 |
|
---|
179 | void mousePressEvent(QMouseEvent *);
|
---|
180 | void mouseReleaseEvent(QMouseEvent *);
|
---|
181 | void mouseMoveEvent(QMouseEvent *);
|
---|
182 |
|
---|
183 | void keyPressEvent ( QKeyEvent * e ) ;
|
---|
184 |
|
---|
185 | void
|
---|
186 | RenderPvs();
|
---|
187 |
|
---|
188 | float
|
---|
189 | RenderErrors();
|
---|
190 | void
|
---|
191 | RenderInfo();
|
---|
192 |
|
---|
193 | virtual int GetWidth() const { return width(); }
|
---|
194 | virtual int GetHeight() const { return height(); }
|
---|
195 |
|
---|
196 | // virtual void
|
---|
197 | // SetupProjection(const int w, const int h, const float angle = 70.0f);
|
---|
198 |
|
---|
199 | virtual void
|
---|
200 | SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
|
---|
201 |
|
---|
202 | void
|
---|
203 | RenderViewCells();
|
---|
204 |
|
---|
205 |
|
---|
206 | virtual void Show() {
|
---|
207 | show();
|
---|
208 | }
|
---|
209 |
|
---|
210 | public slots:
|
---|
211 |
|
---|
212 | void UpdateAllPvs();
|
---|
213 | void ComputeVisibility();
|
---|
214 | void StopComputation();
|
---|
215 |
|
---|
216 | void SetRenderErrors(bool b) {
|
---|
217 | mRenderErrors = b;
|
---|
218 | updateGL();
|
---|
219 | }
|
---|
220 |
|
---|
221 | void SetRenderBoxes(bool b) {
|
---|
222 | mRenderBoxes = b;
|
---|
223 | updateGL();
|
---|
224 | }
|
---|
225 |
|
---|
226 | void SetRenderFilter(bool b) {
|
---|
227 | mRenderFilter = b;
|
---|
228 | updateGL();
|
---|
229 | }
|
---|
230 |
|
---|
231 | void SetRenderVisibilityEstimates(bool b) {
|
---|
232 | mRenderVisibilityEstimates = b;
|
---|
233 | updateGL();
|
---|
234 | }
|
---|
235 |
|
---|
236 | void SetUseFilter(bool b) {
|
---|
237 | mUseFilter = b;
|
---|
238 | mPvsCache.Reset();
|
---|
239 | updateGL();
|
---|
240 | }
|
---|
241 |
|
---|
242 | void SetUseSpatialFilter(bool b) {
|
---|
243 | mUseSpatialFilter = b;
|
---|
244 | mPvsCache.Reset();
|
---|
245 | updateGL();
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 | void
|
---|
250 | SetViewCellGranularity(int number);
|
---|
251 |
|
---|
252 | void
|
---|
253 | SetTransferFunction(int number) {
|
---|
254 | mTransferFunction = number/1000.0f;
|
---|
255 | updateGL();
|
---|
256 | }
|
---|
257 |
|
---|
258 | void
|
---|
259 | SetVisibilityFilterSize(int number);
|
---|
260 |
|
---|
261 | void
|
---|
262 | SetSpatialFilterSize(int number);
|
---|
263 |
|
---|
264 | void
|
---|
265 | SetSceneCut(int cut);
|
---|
266 |
|
---|
267 | void
|
---|
268 | SetTopDistance(int dist);
|
---|
269 |
|
---|
270 | void SetShowViewCells(bool b) {
|
---|
271 | mRenderViewCells = b;
|
---|
272 | updateGL();
|
---|
273 | }
|
---|
274 |
|
---|
275 | void SetShowRays(bool b) {
|
---|
276 | mShowRays = 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 | signals:
|
---|
305 | void PvsUpdated();
|
---|
306 | };
|
---|
307 |
|
---|
308 |
|
---|
309 | class QtGlDebuggerWidget : public QGLWidget
|
---|
310 | {
|
---|
311 | Q_OBJECT
|
---|
312 | public:
|
---|
313 | QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
|
---|
314 | ~QtGlDebuggerWidget();
|
---|
315 | void initializeGL();
|
---|
316 | void resizeGL(int w, int h);
|
---|
317 | void paintGL();
|
---|
318 | void timerEvent(QTimerEvent *) { update(); }
|
---|
319 | void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
|
---|
320 | void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
|
---|
321 |
|
---|
322 | void initCommon();
|
---|
323 | void initPbuffer();
|
---|
324 |
|
---|
325 |
|
---|
326 | QtGlRendererBuffer *mRenderBuffer;
|
---|
327 |
|
---|
328 | Beam mBeam;
|
---|
329 | int mSamples;
|
---|
330 | Intersectable *mSourceObject;
|
---|
331 |
|
---|
332 | private:
|
---|
333 | GLuint dynamicTexture;
|
---|
334 | int timerId;
|
---|
335 | };
|
---|
336 |
|
---|
337 | extern QtGlDebuggerWidget *debuggerWidget;
|
---|
338 |
|
---|
339 | };
|
---|
340 |
|
---|
341 | #endif
|
---|
342 |
|
---|