[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 |
|
---|
| 118 | struct PvsCache {
|
---|
| 119 | PvsCache():mViewCell(NULL) {}
|
---|
[1757] | 120 | void Reset() { mViewCell = NULL; mPvs.Clear(); }
|
---|
[1743] | 121 | ViewCell *mViewCell;
|
---|
| 122 | ObjectPvs mPvs;
|
---|
| 123 | };
|
---|
| 124 |
|
---|
[1387] | 125 | class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
|
---|
| 126 | {
|
---|
| 127 | Q_OBJECT
|
---|
| 128 | public:
|
---|
| 129 |
|
---|
| 130 | // point of the last mouse click used for movement in the scene
|
---|
| 131 | Vector3 mousePoint;
|
---|
| 132 |
|
---|
| 133 | bool mTopView;
|
---|
| 134 | bool mRenderViewCells;
|
---|
| 135 | bool mCutViewCells;
|
---|
| 136 | bool mCutScene;
|
---|
| 137 | bool mRenderErrors;
|
---|
| 138 | bool mRenderFilter;
|
---|
[1594] | 139 | bool mRenderVisibilityEstimates;
|
---|
[1387] | 140 | bool mUseFilter;
|
---|
| 141 | bool mUseSpatialFilter;
|
---|
| 142 | bool mShowRenderCost;
|
---|
[1581] | 143 | bool mShowRays;
|
---|
| 144 |
|
---|
[1387] | 145 | bool mShowPvsSizes;
|
---|
| 146 | float mSpatialFilterSize;
|
---|
| 147 |
|
---|
| 148 | Plane3 mSceneCutPlane;
|
---|
| 149 | float mTopDistance;
|
---|
| 150 |
|
---|
| 151 | // some statistics
|
---|
| 152 | int mPvsSize;
|
---|
| 153 | float mRenderError;
|
---|
[1694] | 154 | float mTransferFunction;
|
---|
[1387] | 155 |
|
---|
[1581] | 156 | float mManipulatorLastQuat[4];
|
---|
| 157 | float mManipulatorScale;
|
---|
[1743] | 158 | PvsCache mPvsCache;
|
---|
[1581] | 159 |
|
---|
[1387] | 160 | QtRendererControlWidget *mControlWidget;
|
---|
[1613] | 161 |
|
---|
| 162 | QtPreprocessorThread *mPreprocessorThread;
|
---|
[1387] | 163 |
|
---|
| 164 | QtGlRendererWidget(SceneGraph *sceneGraph,
|
---|
| 165 | ViewCellsManager *viewcells,
|
---|
| 166 | KdTree *tree,
|
---|
| 167 | QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
|
---|
| 168 | );
|
---|
| 169 |
|
---|
| 170 | QtGlRendererWidget() {};
|
---|
| 171 |
|
---|
[1613] | 172 | void SetThread(QtPreprocessorThread *t) {
|
---|
| 173 | mPreprocessorThread = t;
|
---|
| 174 | }
|
---|
[1584] | 175 | void
|
---|
| 176 | RenderRenderCost();
|
---|
| 177 |
|
---|
[1387] | 178 | virtual void SetupCamera();
|
---|
[1581] | 179 | // setup a transformation for manipulator
|
---|
| 180 | void
|
---|
| 181 | SetupManipulator();
|
---|
[1387] | 182 |
|
---|
| 183 | void initializeGL() {
|
---|
| 184 | InitGL();
|
---|
| 185 | }
|
---|
| 186 | void resizeGL(int w, int h);
|
---|
| 187 | void paintGL();
|
---|
| 188 | void timerEvent(QTimerEvent *) {
|
---|
| 189 | update();
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | void mousePressEvent(QMouseEvent *);
|
---|
| 193 | void mouseReleaseEvent(QMouseEvent *);
|
---|
| 194 | void mouseMoveEvent(QMouseEvent *);
|
---|
| 195 |
|
---|
| 196 | void keyPressEvent ( QKeyEvent * e ) ;
|
---|
| 197 |
|
---|
| 198 | void
|
---|
| 199 | RenderPvs();
|
---|
| 200 |
|
---|
| 201 | float
|
---|
| 202 | RenderErrors();
|
---|
| 203 | void
|
---|
| 204 | RenderInfo();
|
---|
| 205 |
|
---|
| 206 | virtual int GetWidth() const { return width(); }
|
---|
| 207 | virtual int GetHeight() const { return height(); }
|
---|
| 208 |
|
---|
[1581] | 209 | // virtual void
|
---|
| 210 | // SetupProjection(const int w, const int h, const float angle = 70.0f);
|
---|
[1387] | 211 |
|
---|
[1581] | 212 | virtual void
|
---|
| 213 | SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
|
---|
| 214 |
|
---|
| 215 | virtual void
|
---|
| 216 | SetupManipulatorProjection(const int w, const int h, const float angle = 70.0f);
|
---|
| 217 |
|
---|
[1387] | 218 | void
|
---|
| 219 | RenderViewCells();
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 | virtual void Show() {
|
---|
| 223 | show();
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | public slots:
|
---|
| 227 |
|
---|
[1613] | 228 | void UpdateAllPvs();
|
---|
| 229 | void ComputeVisibility();
|
---|
| 230 | void StopComputation();
|
---|
| 231 |
|
---|
[1387] | 232 | void SetRenderErrors(bool b) {
|
---|
| 233 | mRenderErrors = b;
|
---|
| 234 | updateGL();
|
---|
| 235 | }
|
---|
| 236 |
|
---|
[1594] | 237 | void SetRenderBoxes(bool b) {
|
---|
| 238 | mRenderBoxes = b;
|
---|
| 239 | updateGL();
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[1387] | 242 | void SetRenderFilter(bool b) {
|
---|
| 243 | mRenderFilter = b;
|
---|
| 244 | updateGL();
|
---|
| 245 | }
|
---|
| 246 |
|
---|
[1594] | 247 | void SetRenderVisibilityEstimates(bool b) {
|
---|
| 248 | mRenderVisibilityEstimates = b;
|
---|
| 249 | updateGL();
|
---|
| 250 | }
|
---|
| 251 |
|
---|
[1387] | 252 | void SetUseFilter(bool b) {
|
---|
| 253 | mUseFilter = b;
|
---|
[1743] | 254 | mPvsCache.Reset();
|
---|
[1387] | 255 | updateGL();
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | void SetUseSpatialFilter(bool b) {
|
---|
| 259 | mUseSpatialFilter = b;
|
---|
[1743] | 260 | mPvsCache.Reset();
|
---|
[1387] | 261 | updateGL();
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 |
|
---|
| 265 | void
|
---|
| 266 | SetViewCellGranularity(int number);
|
---|
[1694] | 267 |
|
---|
[1387] | 268 | void
|
---|
[1694] | 269 | SetTransferFunction(int number) {
|
---|
| 270 | mTransferFunction = number/1000.0f;
|
---|
| 271 | updateGL();
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | void
|
---|
[1387] | 275 | SetVisibilityFilterSize(int number);
|
---|
| 276 |
|
---|
| 277 | void
|
---|
| 278 | SetSpatialFilterSize(int number);
|
---|
| 279 |
|
---|
| 280 | void
|
---|
| 281 | SetSceneCut(int cut);
|
---|
| 282 |
|
---|
| 283 | void
|
---|
| 284 | SetTopDistance(int dist);
|
---|
| 285 |
|
---|
| 286 | void SetShowViewCells(bool b) {
|
---|
| 287 | mRenderViewCells = b;
|
---|
| 288 | updateGL();
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[1581] | 291 | void SetShowRays(bool b) {
|
---|
| 292 | mShowRays = b;
|
---|
| 293 | updateGL();
|
---|
| 294 | }
|
---|
| 295 |
|
---|
[1387] | 296 | void SetShowRenderCost(bool b) {
|
---|
| 297 | mShowRenderCost = b;
|
---|
| 298 | updateGL();
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | void SetShowPvsSizes(bool b) {
|
---|
| 302 | mShowPvsSizes = b;
|
---|
| 303 | updateGL();
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 | void SetTopView(bool b) {
|
---|
| 307 | mTopView = b;
|
---|
| 308 | updateGL();
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | void SetCutViewCells(bool b) {
|
---|
| 312 | mCutViewCells = b;
|
---|
| 313 | updateGL();
|
---|
| 314 | }
|
---|
| 315 | void SetCutScene(bool b) {
|
---|
| 316 | mCutScene = b;
|
---|
| 317 | updateGL();
|
---|
| 318 | }
|
---|
| 319 |
|
---|
| 320 |
|
---|
| 321 | };
|
---|
| 322 |
|
---|
| 323 |
|
---|
| 324 | class QtGlDebuggerWidget : public QGLWidget
|
---|
| 325 | {
|
---|
| 326 | Q_OBJECT
|
---|
| 327 | public:
|
---|
| 328 | QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
|
---|
| 329 | ~QtGlDebuggerWidget();
|
---|
| 330 | void initializeGL();
|
---|
| 331 | void resizeGL(int w, int h);
|
---|
| 332 | void paintGL();
|
---|
| 333 | void timerEvent(QTimerEvent *) { update(); }
|
---|
| 334 | void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
|
---|
| 335 | void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
|
---|
| 336 |
|
---|
| 337 | void initCommon();
|
---|
| 338 | void initPbuffer();
|
---|
| 339 |
|
---|
| 340 |
|
---|
| 341 | QtGlRendererBuffer *mRenderBuffer;
|
---|
| 342 |
|
---|
| 343 | Beam mBeam;
|
---|
| 344 | int mSamples;
|
---|
| 345 | Intersectable *mSourceObject;
|
---|
| 346 |
|
---|
| 347 | private:
|
---|
| 348 | GLuint dynamicTexture;
|
---|
| 349 | int timerId;
|
---|
| 350 | };
|
---|
| 351 |
|
---|
| 352 | extern QtGlDebuggerWidget *debuggerWidget;
|
---|
| 353 |
|
---|
| 354 | };
|
---|
| 355 |
|
---|
| 356 | #endif
|
---|
| 357 |
|
---|