[1252] | 1 | #ifndef __QTGLRENDERER_H
|
---|
| 2 | #define __QTGLRENDERER_H
|
---|
| 3 |
|
---|
| 4 | #include <QtOpenGL>
|
---|
| 5 | #include <QWaitCondition>
|
---|
| 6 |
|
---|
[1942] | 7 | //#include <QGLPixelBuffer>
|
---|
| 8 |
|
---|
[1252] | 9 | #include "Vector3.h"
|
---|
| 10 | #include "Containers.h"
|
---|
| 11 | #include "Halton.h"
|
---|
| 12 | #include "Renderer.h"
|
---|
| 13 | #include "GlRenderer.h"
|
---|
| 14 | #include "Beam.h"
|
---|
[1942] | 15 | #include "QtPreprocessorThread.h"
|
---|
[1252] | 16 | class QWidget;
|
---|
[1942] | 17 | //class QtPreprocessorThread;
|
---|
[1252] | 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 |
|
---|
[1942] | 34 |
|
---|
[1252] | 35 | struct VssRayContainer;
|
---|
| 36 | struct PvsRenderStatistics;
|
---|
| 37 | struct RenderCostSample;
|
---|
| 38 |
|
---|
| 39 |
|
---|
[1942] | 40 | class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
|
---|
[1252] | 41 | {
|
---|
| 42 | Q_OBJECT
|
---|
| 43 | public:
|
---|
| 44 | QtGlRendererBuffer(const int w,
|
---|
[1942] | 45 | const int h,
|
---|
| 46 | SceneGraph *sceneGraph,
|
---|
| 47 | ViewCellsManager *viewcells,
|
---|
| 48 | KdTree *tree);
|
---|
[1252] | 49 |
|
---|
[1942] | 50 | ~QtGlRendererBuffer() {}
|
---|
[1252] | 51 |
|
---|
[1942] | 52 | virtual void MakeCurrent();
|
---|
| 53 | virtual void DoneCurrent();
|
---|
[1252] | 54 |
|
---|
[1942] | 55 | virtual int GetWidth() const { return width(); }
|
---|
| 56 | virtual int GetHeight() const { return height(); }
|
---|
[1252] | 57 |
|
---|
[1942] | 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 |
|
---|
[1252] | 68 | public:
|
---|
[1942] | 69 | signals:
|
---|
| 70 | void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
|
---|
[1252] | 71 | };
|
---|
| 72 |
|
---|
| 73 |
|
---|
[1942] | 74 | class QtRendererControlWidget : public QWidget
|
---|
[1252] | 75 | {
|
---|
[1942] | 76 | Q_OBJECT
|
---|
[1252] | 77 | public:
|
---|
| 78 |
|
---|
[1942] | 79 | QListWidget *mPvsErrorWidget;
|
---|
[1252] | 80 |
|
---|
[1942] | 81 | QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
|
---|
[1252] | 82 |
|
---|
[1942] | 83 | public slots:
|
---|
[1252] | 84 |
|
---|
[1942] | 85 | void FocusNextPvsErrorFrame();
|
---|
| 86 | void UpdatePvsErrorItem(int i,
|
---|
| 87 | GlRendererBuffer::PvsErrorEntry &);
|
---|
[1252] | 88 |
|
---|
[1942] | 89 | signals:
|
---|
[1252] | 90 |
|
---|
[1942] | 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);
|
---|
[1252] | 101 |
|
---|
[1942] | 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);
|
---|
[1926] | 115 |
|
---|
[1252] | 116 | };
|
---|
| 117 |
|
---|
[1926] | 118 |
|
---|
[1942] | 119 | class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
|
---|
[1252] | 120 | {
|
---|
[1942] | 121 | Q_OBJECT
|
---|
[1252] | 122 | public:
|
---|
| 123 |
|
---|
[1942] | 124 | // point of the last mouse click used for movement in the scene
|
---|
| 125 | Vector3 mousePoint;
|
---|
[1252] | 126 |
|
---|
[1942] | 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;
|
---|
[1252] | 138 |
|
---|
[1942] | 139 | bool mShowPvsSizes;
|
---|
| 140 | float mSpatialFilterSize;
|
---|
| 141 |
|
---|
| 142 | Plane3 mSceneCutPlane;
|
---|
| 143 | float mTopDistance;
|
---|
[1252] | 144 |
|
---|
[1942] | 145 | // some statistics
|
---|
| 146 | int mPvsSize;
|
---|
| 147 | float mRenderError;
|
---|
| 148 | float mTransferFunction;
|
---|
[1252] | 149 |
|
---|
[1942] | 150 |
|
---|
| 151 | QtRendererControlWidget *mControlWidget;
|
---|
[1252] | 152 |
|
---|
[1942] | 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() {};
|
---|
[1252] | 162 |
|
---|
[1942] | 163 | void SetThread(QtPreprocessorThread *t) {
|
---|
| 164 | mPreprocessorThread = t;
|
---|
| 165 | }
|
---|
| 166 | void
|
---|
| 167 | RenderRenderCost();
|
---|
[1252] | 168 |
|
---|
[1942] | 169 | virtual void SetupCamera();
|
---|
[1252] | 170 |
|
---|
[1942] | 171 | void initializeGL() {
|
---|
| 172 | InitGL();
|
---|
| 173 | }
|
---|
[1997] | 174 |
|
---|
| 175 | virtual void InitGL();
|
---|
| 176 |
|
---|
[1942] | 177 | void resizeGL(int w, int h);
|
---|
| 178 | void paintGL();
|
---|
| 179 | void timerEvent(QTimerEvent *) {
|
---|
| 180 | update();
|
---|
| 181 | }
|
---|
[1252] | 182 |
|
---|
[1942] | 183 | void mousePressEvent(QMouseEvent *);
|
---|
| 184 | void mouseReleaseEvent(QMouseEvent *);
|
---|
| 185 | void mouseMoveEvent(QMouseEvent *);
|
---|
[1252] | 186 |
|
---|
[1942] | 187 | void keyPressEvent ( QKeyEvent * e ) ;
|
---|
[1252] | 188 |
|
---|
[1942] | 189 | void
|
---|
| 190 | RenderPvs();
|
---|
[1252] | 191 |
|
---|
[1942] | 192 | float
|
---|
| 193 | RenderErrors();
|
---|
| 194 | void
|
---|
| 195 | RenderInfo();
|
---|
[1252] | 196 |
|
---|
[1942] | 197 | virtual int GetWidth() const { return width(); }
|
---|
| 198 | virtual int GetHeight() const { return height(); }
|
---|
[1252] | 199 |
|
---|
[1942] | 200 | // virtual void
|
---|
| 201 | // SetupProjection(const int w, const int h, const float angle = 70.0f);
|
---|
[1252] | 202 |
|
---|
[1942] | 203 | virtual void
|
---|
| 204 | SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
|
---|
[1252] | 205 |
|
---|
[1942] | 206 | void
|
---|
| 207 | RenderViewCells();
|
---|
[1252] | 208 |
|
---|
| 209 |
|
---|
[1942] | 210 | virtual void Show() {
|
---|
| 211 | show();
|
---|
| 212 | }
|
---|
[1252] | 213 |
|
---|
[1942] | 214 | public slots:
|
---|
[1252] | 215 |
|
---|
[1942] | 216 | void UpdateAllPvs();
|
---|
| 217 | void ComputeVisibility();
|
---|
| 218 | void StopComputation();
|
---|
| 219 | void SetRandomViewPoint();
|
---|
[1252] | 220 |
|
---|
[1942] | 221 | void SetRenderErrors(bool b) {
|
---|
| 222 | mRenderErrors = b;
|
---|
| 223 | updateGL();
|
---|
| 224 | }
|
---|
[1252] | 225 |
|
---|
[1942] | 226 | void SetRenderBoxes(bool b) {
|
---|
| 227 | mRenderBoxes = b;
|
---|
| 228 | updateGL();
|
---|
| 229 | }
|
---|
[1252] | 230 |
|
---|
[1942] | 231 | void SetRenderFilter(bool b) {
|
---|
| 232 | mRenderFilter = b;
|
---|
| 233 | updateGL();
|
---|
| 234 | }
|
---|
[1252] | 235 |
|
---|
[1942] | 236 | void SetRenderVisibilityEstimates(bool b) {
|
---|
| 237 | mRenderVisibilityEstimates = b;
|
---|
| 238 | updateGL();
|
---|
| 239 | }
|
---|
[1252] | 240 |
|
---|
[1942] | 241 | void SetUseFilter(bool b) {
|
---|
| 242 | mUseFilter = b;
|
---|
| 243 | mPvsCache.Reset();
|
---|
| 244 | updateGL();
|
---|
| 245 | }
|
---|
[1252] | 246 |
|
---|
[1942] | 247 | void SetUseSpatialFilter(bool b) {
|
---|
| 248 | mUseSpatialFilter = b;
|
---|
| 249 | mPvsCache.Reset();
|
---|
| 250 | updateGL();
|
---|
| 251 | }
|
---|
[1926] | 252 |
|
---|
[1942] | 253 |
|
---|
| 254 | void
|
---|
| 255 | SetViewCellGranularity(int number);
|
---|
[1926] | 256 |
|
---|
[1942] | 257 | void
|
---|
| 258 | SetTransferFunction(int number) {
|
---|
| 259 | mTransferFunction = number/1000.0f;
|
---|
| 260 | updateGL();
|
---|
| 261 | }
|
---|
[1926] | 262 |
|
---|
[1942] | 263 | void
|
---|
| 264 | SetVisibilityFilterSize(int number);
|
---|
[1926] | 265 |
|
---|
[1942] | 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 | }
|
---|
[1926] | 279 |
|
---|
[1942] | 280 | void SetShowRays(bool b) {
|
---|
| 281 | mShowRays = b;
|
---|
| 282 | updateGL();
|
---|
| 283 | }
|
---|
[1926] | 284 |
|
---|
[1942] | 285 | void SetShowRenderCost(bool b) {
|
---|
| 286 | mShowRenderCost = b;
|
---|
| 287 | updateGL();
|
---|
| 288 | }
|
---|
[1926] | 289 |
|
---|
[1942] | 290 | void SetShowPvsSizes(bool b) {
|
---|
| 291 | mShowPvsSizes = b;
|
---|
| 292 | updateGL();
|
---|
| 293 | }
|
---|
[1926] | 294 |
|
---|
[1942] | 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();
|
---|
[1252] | 311 | };
|
---|
| 312 |
|
---|
| 313 |
|
---|
| 314 | class QtGlDebuggerWidget : public QGLWidget
|
---|
| 315 | {
|
---|
| 316 | Q_OBJECT
|
---|
| 317 | public:
|
---|
[1942] | 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); }
|
---|
[1252] | 326 |
|
---|
[1942] | 327 | void initCommon();
|
---|
| 328 | void initPbuffer();
|
---|
[1252] | 329 |
|
---|
[1942] | 330 |
|
---|
| 331 | QtGlRendererBuffer *mRenderBuffer;
|
---|
[1252] | 332 |
|
---|
[1942] | 333 | Beam mBeam;
|
---|
| 334 | int mSamples;
|
---|
| 335 | Intersectable *mSourceObject;
|
---|
[1252] | 336 |
|
---|
| 337 | private:
|
---|
[1942] | 338 | GLuint dynamicTexture;
|
---|
| 339 | int timerId;
|
---|
[1252] | 340 | };
|
---|
| 341 |
|
---|
| 342 | extern QtGlDebuggerWidget *debuggerWidget;
|
---|
| 343 |
|
---|
| 344 | };
|
---|
| 345 |
|
---|
| 346 | #endif
|
---|
| 347 |
|
---|