Changeset 1148 for GTP/trunk/Lib/Vis/QtRenderer
- Timestamp:
- 07/25/06 01:39:35 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/QtRenderer
- Files:
-
- 1 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.h
r1146 r1148 1 #ifndef __GLRENDERER_H 2 #define __GLRENDERER_H 3 4 5 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 16 class QWidget; 6 17 7 18 namespace GtpVisibilityPreprocessor { 8 19 9 class GlRenderer: public Renderer 20 class SceneGraph; 21 class ViewCellsManager; 22 class Mesh; 23 class MeshInstance; 24 class Intersectable; 25 class Material; 26 class Beam; 27 class KdTree; 28 class GlRendererBuffer; 29 class BeamSampleStatistics; 30 class OcclusionQuery; 31 class TransformedMeshInstance; 32 33 struct VssRayContainer; 34 struct PvsRenderStatistics; 35 struct RenderCostSample; 36 37 38 class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer 10 39 { 11 12 public: 13 ObjectContainer mObjects; 14 15 Vector3 mViewPoint; 16 Vector3 mViewDirection; 17 18 int timerId; 19 bool mUseFalseColors; 20 bool mUseForcedColors; 21 22 HaltonSequence halton; 23 24 int mFrame; 25 bool mWireFrame; 26 27 bool mDetectEmptyViewSpace; 28 bool mSnapErrorFrames; 29 30 bool mUseGlLists; 31 32 string mSnapPrefix; 33 34 KdTree *mKdTree; 35 36 //QWaitCondition mRenderingFinished; 37 38 vector<OcclusionQuery *> mOcclusionQueries; 39 40 GlRenderer(SceneGraph *sceneGraph, 41 ViewCellsManager *viewcells, 42 KdTree *tree); 43 44 virtual ~GlRenderer(); 45 46 47 void SetupFalseColor(const int id); 48 void RenderIntersectable(Intersectable *); 49 void RenderViewCell(ViewCell *vc); 50 void RenderMeshInstance(MeshInstance *mi); 51 void RenderTransformedMeshInstance(TransformedMeshInstance *mi); 52 void RenderMesh(Mesh *m); 53 void SetupMaterial(Material *m); 54 virtual void SetupCamera(); 55 56 bool 57 RenderScene(); 58 59 void 60 _RenderScene(); 61 62 63 virtual void 64 SetupProjection(const int w, const int h, const float angle = 70.0f); 65 66 67 68 69 void InitGL(); 70 71 virtual int GetWidth() const = 0; 72 virtual int GetHeight() const = 0; 73 74 int GetId(int r, int g, int b) const; 75 }; 76 77 78 /* Class implementing an OpenGl render buffer. 79 */ 80 class GlRendererBuffer: public GlRenderer 81 { 82 83 //Q_OBJECT 84 public: 85 GlRendererBuffer(SceneGraph *sceneGraph, 86 ViewCellsManager *viewcells, 87 KdTree *tree); 88 40 Q_OBJECT 41 public: 42 QtGlRendererBuffer(const int w, 43 const int h, 44 SceneGraph *sceneGraph, 45 ViewCellsManager *viewcells, 46 KdTree *tree); 47 48 ~QtGlRendererBuffer(); 89 49 90 50 /** Evaluates render cost of a point sample. 91 92 93 51 @param sample the render cost sample to be evaluated 52 @param useOcclusionQueries if occlusion queries should be used or item buffer 53 @param threshold number of pixels / samples from where an object is considered visible. 94 54 */ 95 55 void EvalRenderCostSample(RenderCostSample &sample, 96 97 56 const bool useOcclusionQueries, 57 const int threshold); 98 58 99 59 /** Evaluates render cost of a number of point samples. The point samples 100 101 102 103 104 105 60 are distributed uniformly over the defined view space. 61 62 @param numSamples the number of point samples taken 63 @param samples stores the taken point samples in a container 64 @param useOcclusionQueries if occlusion queries should be used or item buffer 65 @param threshold number of pixels / samples from where an object is considered visible. 106 66 */ 107 67 void SampleRenderCost(const int numSamples, 108 109 110 const int threshold = 0)111 {} 112 113 /** Implerment in subclasses. 114 */ 115 void EvalPvsStat() {}; 116 117 voidClearErrorBuffer();118 119 120 virtual int GetWidth() const { return 0; }121 virtual int GetHeight() const { return 0; }122 123 124 void RandomViewPoint();68 vector<RenderCostSample> &samples, 69 const bool useOcclusionQueries, 70 const int threshold = 0); 71 72 73 void 74 EvalPvsStat(); 75 76 void 77 ClearErrorBuffer(); 78 79 80 virtual int GetWidth() const { return width(); } 81 virtual int GetHeight() const { return height(); } 82 83 84 125 85 void SampleBeamContributions( 126 86 Intersectable *sourceObject, … … 151 111 152 112 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 153 154 PvsRenderStatistics mPvsStat; 113 155 114 156 int mPvsStatFrames; 157 struct PvsErrorEntry { 158 PvsErrorEntry() {} 159 float mError; 160 int mPvsSize; 161 Vector3 mPosition; 162 Vector3 mDirection; 163 }; 164 165 vector<PvsErrorEntry> mPvsErrorBuffer; 166 167 168 protected: 169 unsigned int *mPixelBuffer; 170 171 static void GenQueries(const int numQueries); 172 115 private: 116 173 117 void SetupProjectionForViewPoint(const Vector3 &viewPoint, 174 118 const Beam &beam, 175 176 119 Intersectable *sourceObject); 177 120 178 /** Evaluates query for one direction using item buffer. 179 */ 180 void EvalQueryWithItemBuffer(); 181 /** Evaluates query for one direction using occlusion queries. 182 */ 183 void EvalQueryWithOcclusionQueries(); 184 185 public: 186 // matt: remove qt dependencies 187 // signals: 188 // void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 189 }; 190 191 192 /** Abstract class for implmenenting a gl render widget. 193 */ 194 class GlRenderWidget 121 122 public: 123 signals: 124 void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 125 }; 126 127 128 class RendererControlWidget : public QWidget 195 129 { 196 public: 197 198 GlRenderWidget(SceneGraph *sceneGraph, ViewCellsManager *vcm, KdTree *kdTree): 199 mSceneGraph(sceneGraph), mViewCellsManager(vcm), mKdTree(kdTree) 200 { 201 } 202 203 204 GlRenderWidget() {} 205 206 virtual ~GlRenderWidget() {} 207 208 //virtual void Create() {} 209 virtual void Show() {} 210 211 212 protected: 213 214 215 SceneGraph *mSceneGraph; 216 ViewCellsManager *mViewCellsManager; 217 KdTree *mKdTree; 218 }; 130 Q_OBJECT 131 public: 132 133 QListWidget *mPvsErrorWidget; 134 135 RendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0); 136 137 public slots: 138 139 void FocusNextPvsErrorFrame(); 140 void UpdatePvsErrorItem(int i, 141 GlRendererBuffer::PvsErrorEntry &); 142 143 signals: 144 145 void SetViewCellGranularity(int); 146 void SetSceneCut(int); 147 void SetTopDistance(int); 148 void SetVisibilityFilterSize(int); 149 void SetSpatialFilterSize(int); 150 151 void SetRenderFilter(bool); 152 void SetUseFilter(bool); 153 void SetUseSpatialFilter(bool); 154 void SetRenderErrors(bool); 155 void SetShowViewCells(bool); 156 void SetShowRenderCost(bool); 157 void SetShowPvsSizes(bool); 158 void SetTopView(bool); 159 void SetCutViewCells(bool); 160 void SetCutScene(bool); 161 162 163 }; 164 165 class GlRendererWidget : public QGLWidget, public GlRenderer 166 { 167 Q_OBJECT 168 public: 169 170 // point of the last mouse click used for movement in the scene 171 Vector3 mousePoint; 172 173 bool mTopView; 174 bool mRenderViewCells; 175 bool mCutViewCells; 176 bool mCutScene; 177 bool mRenderErrors; 178 bool mRenderFilter; 179 bool mUseFilter; 180 bool mUseSpatialFilter; 181 bool mShowRenderCost; 182 183 bool mShowPvsSizes; 184 float mSpatialFilterSize; 185 186 Plane3 mSceneCutPlane; 187 float mTopDistance; 188 189 // some statistics 190 int mPvsSize; 191 float mRenderError; 192 193 RendererControlWidget *mControlWidget; 194 195 GlRendererWidget(SceneGraph *sceneGraph, 196 ViewCellsManager *viewcells, 197 KdTree *tree, 198 QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0 199 ); 200 201 202 virtual void SetupCamera(); 203 204 void initializeGL() { 205 InitGL(); 206 } 207 void resizeGL(int w, int h); 208 void paintGL(); 209 void timerEvent(QTimerEvent *) { 210 update(); 211 } 212 213 void mousePressEvent(QMouseEvent *); 214 void mouseReleaseEvent(QMouseEvent *); 215 void mouseMoveEvent(QMouseEvent *); 216 217 void keyPressEvent ( QKeyEvent * e ) ; 218 219 void 220 RenderPvs(); 221 222 float 223 RenderErrors(); 224 void 225 RenderInfo(); 226 227 virtual int GetWidth() const { return width(); } 228 virtual int GetHeight() const { return height(); } 229 230 virtual void 231 SetupProjection(const int w, const int h, const float angle = 70.0f); 232 233 void 234 RenderViewCells(); 235 236 public slots: 237 238 void SetRenderErrors(bool b) { 239 mRenderErrors = b; 240 updateGL(); 241 } 242 243 void SetRenderFilter(bool b) { 244 mRenderFilter = b; 245 updateGL(); 246 } 247 248 void SetUseFilter(bool b) { 249 mUseFilter = b; 250 updateGL(); 251 } 252 253 void SetUseSpatialFilter(bool b) { 254 mUseSpatialFilter = b; 255 updateGL(); 256 } 257 258 259 void 260 SetViewCellGranularity(int number); 261 262 void 263 SetVisibilityFilterSize(int number); 264 265 void 266 SetSpatialFilterSize(int number); 267 268 void 269 SetSceneCut(int cut); 270 271 void 272 SetTopDistance(int dist); 273 274 void SetShowViewCells(bool b) { 275 mRenderViewCells = b; 276 updateGL(); 277 } 278 279 void SetShowRenderCost(bool b) { 280 mShowRenderCost = b; 281 updateGL(); 282 } 283 284 void SetShowPvsSizes(bool b) { 285 mShowPvsSizes = b; 286 updateGL(); 287 } 288 289 void SetTopView(bool b) { 290 mTopView = b; 291 updateGL(); 292 } 293 294 void SetCutViewCells(bool b) { 295 mCutViewCells = b; 296 updateGL(); 297 } 298 void SetCutScene(bool b) { 299 mCutScene = b; 300 updateGL(); 301 } 302 303 304 }; 305 306 307 extern GlRendererWidget *rendererWidget; 308 309 class GlDebuggerWidget : public QGLWidget 310 { 311 Q_OBJECT 312 public: 313 GlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL); 314 ~GlDebuggerWidget(); 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 GlDebuggerWidget *debuggerWidget; 219 338 220 339 };
Note: See TracChangeset
for help on using the changeset viewer.