[1387] | 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"
|
---|
[1613] | 15 | #include "QtPreprocessorThread.h"
|
---|
[1387] | 16 | class QWidget;
|
---|
[1613] | 17 | //class QtPreprocessorThread;
|
---|
[1387] | 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 |
|
---|
[1581] | 34 |
|
---|
[1387] | 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 |
|
---|
[1785] | 50 | ~QtGlRendererBuffer() {}
|
---|
[1387] | 51 |
|
---|
[1785] | 52 | virtual void MakeCurrent();
|
---|
| 53 | virtual void DoneCurrent();
|
---|
[1387] | 54 |
|
---|
| 55 | virtual int GetWidth() const { return width(); }
|
---|
| 56 | virtual int GetHeight() const { return height(); }
|
---|
| 57 |
|
---|
[1785] | 58 | int ComputePvs() const { return 0; }
|
---|
| 59 |
|
---|
[1387] | 60 | float
|
---|
| 61 | GetPixelError(int &pvsSize);
|
---|
[1785] | 62 |
|
---|
[1387] | 63 | int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
|
---|
| 64 |
|
---|
[1785] | 65 |
|
---|
| 66 |
|
---|
| 67 |
|
---|
[1387] | 68 | public:
|
---|
| 69 | signals:
|
---|
[1785] | 70 | void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
|
---|
[1387] | 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:
|
---|
[1613] | 90 |
|
---|
| 91 | void ComputeVisibility();
|
---|
| 92 | void StopComputation();
|
---|
| 93 | void UpdateAllPvs();
|
---|
[1387] | 94 | void SetViewCellGranularity(int);
|
---|
[1694] | 95 | void SetTransferFunction(int);
|
---|
[1387] | 96 | void SetSceneCut(int);
|
---|
| 97 | void SetTopDistance(int);
|
---|
| 98 | void SetVisibilityFilterSize(int);
|
---|
| 99 | void SetSpatialFilterSize(int);
|
---|
| 100 |
|
---|
[1581] | 101 | void SetShowRays(bool);
|
---|
[1387] | 102 | void SetRenderFilter(bool);
|
---|
[1594] | 103 | void SetRenderVisibilityEstimates(bool);
|
---|
[1387] | 104 | void SetUseFilter(bool);
|
---|
| 105 | void SetUseSpatialFilter(bool);
|
---|
| 106 | void SetRenderErrors(bool);
|
---|
[1594] | 107 | void SetRenderBoxes(bool);
|
---|
[1387] | 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 |
|
---|
[1743] | 117 |
|
---|
[1387] | 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;
|
---|
[1594] | 132 | bool mRenderVisibilityEstimates;
|
---|
[1387] | 133 | bool mUseFilter;
|
---|
| 134 | bool mUseSpatialFilter;
|
---|
| 135 | bool mShowRenderCost;
|
---|
[1581] | 136 | bool mShowRays;
|
---|
| 137 |
|
---|
[1387] | 138 | bool mShowPvsSizes;
|
---|
| 139 | float mSpatialFilterSize;
|
---|
| 140 |
|
---|
| 141 | Plane3 mSceneCutPlane;
|
---|
| 142 | float mTopDistance;
|
---|
| 143 |
|
---|
| 144 | // some statistics
|
---|
| 145 | int mPvsSize;
|
---|
| 146 | float mRenderError;
|
---|
[1694] | 147 | float mTransferFunction;
|
---|
[1387] | 148 |
|
---|
[1581] | 149 |
|
---|
[1387] | 150 | QtRendererControlWidget *mControlWidget;
|
---|
[1613] | 151 |
|
---|
| 152 | QtPreprocessorThread *mPreprocessorThread;
|
---|
[1387] | 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 |
|
---|
[1613] | 162 | void SetThread(QtPreprocessorThread *t) {
|
---|
| 163 | mPreprocessorThread = t;
|
---|
| 164 | }
|
---|
[1584] | 165 | void
|
---|
| 166 | RenderRenderCost();
|
---|
| 167 |
|
---|
[1387] | 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 |
|
---|
[1581] | 196 | // virtual void
|
---|
| 197 | // SetupProjection(const int w, const int h, const float angle = 70.0f);
|
---|
[1387] | 198 |
|
---|
[1581] | 199 | virtual void
|
---|
| 200 | SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
|
---|
| 201 |
|
---|
[1387] | 202 | void
|
---|
| 203 | RenderViewCells();
|
---|
| 204 |
|
---|
| 205 |
|
---|
| 206 | virtual void Show() {
|
---|
| 207 | show();
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | public slots:
|
---|
| 211 |
|
---|
[1613] | 212 | void UpdateAllPvs();
|
---|
| 213 | void ComputeVisibility();
|
---|
| 214 | void StopComputation();
|
---|
| 215 |
|
---|
[1387] | 216 | void SetRenderErrors(bool b) {
|
---|
| 217 | mRenderErrors = b;
|
---|
| 218 | updateGL();
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[1594] | 221 | void SetRenderBoxes(bool b) {
|
---|
| 222 | mRenderBoxes = b;
|
---|
| 223 | updateGL();
|
---|
| 224 | }
|
---|
| 225 |
|
---|
[1387] | 226 | void SetRenderFilter(bool b) {
|
---|
| 227 | mRenderFilter = b;
|
---|
| 228 | updateGL();
|
---|
| 229 | }
|
---|
| 230 |
|
---|
[1594] | 231 | void SetRenderVisibilityEstimates(bool b) {
|
---|
| 232 | mRenderVisibilityEstimates = b;
|
---|
| 233 | updateGL();
|
---|
| 234 | }
|
---|
| 235 |
|
---|
[1387] | 236 | void SetUseFilter(bool b) {
|
---|
| 237 | mUseFilter = b;
|
---|
[1743] | 238 | mPvsCache.Reset();
|
---|
[1387] | 239 | updateGL();
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | void SetUseSpatialFilter(bool b) {
|
---|
| 243 | mUseSpatialFilter = b;
|
---|
[1743] | 244 | mPvsCache.Reset();
|
---|
[1387] | 245 | updateGL();
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | void
|
---|
| 250 | SetViewCellGranularity(int number);
|
---|
[1694] | 251 |
|
---|
[1387] | 252 | void
|
---|
[1694] | 253 | SetTransferFunction(int number) {
|
---|
| 254 | mTransferFunction = number/1000.0f;
|
---|
| 255 | updateGL();
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | void
|
---|
[1387] | 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 |
|
---|
[1581] | 275 | void SetShowRays(bool b) {
|
---|
| 276 | mShowRays = b;
|
---|
| 277 | updateGL();
|
---|
| 278 | }
|
---|
| 279 |
|
---|
[1387] | 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 |
|
---|
[1832] | 304 | signals:
|
---|
| 305 | void PvsUpdated();
|
---|
[1387] | 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 |
|
---|