#ifndef __QTGLRENDERER_H #define __QTGLRENDERER_H #include #include //#include #include "Vector3.h" #include "Containers.h" #include "Halton.h" #include "Renderer.h" #include "GlRenderer.h" #include "Beam.h" #include "QtPreprocessorThread.h" class QWidget; //class QtPreprocessorThread; namespace GtpVisibilityPreprocessor { class SceneGraph; class ViewCellsManager; class Mesh; class MeshInstance; class Intersectable; class Material; class Beam; class KdTree; class GlRendererBuffer; class BeamSampleStatistics; class OcclusionQuery; class TransformedMeshInstance; struct VssRayContainer; struct PvsRenderStatistics; struct RenderCostSample; class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer { Q_OBJECT public: QtGlRendererBuffer(const int w, const int h, SceneGraph *sceneGraph, ViewCellsManager *viewcells, KdTree *tree); ~QtGlRendererBuffer() {} virtual void MakeCurrent(); virtual void DoneCurrent(); virtual int GetWidth() const { return width(); } virtual int GetHeight() const { return height(); } int ComputePvs() const { return 0; } float GetPixelError(int &pvsSize); int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; public: signals: void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); }; class QtRendererControlWidget : public QWidget { Q_OBJECT public: QListWidget *mPvsErrorWidget; QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0); public slots: void FocusNextPvsErrorFrame(); void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); signals: void ComputeVisibility(); void StopComputation(); void UpdateAllPvs(); void SetViewCellGranularity(int); void SetTransferFunction(int); void SetSceneCut(int); void SetTopDistance(int); void SetVisibilityFilterSize(int); void SetSpatialFilterSize(int); void SetShowRays(bool); void SetRenderFilter(bool); void SetRenderVisibilityEstimates(bool); void SetUseFilter(bool); void SetUseSpatialFilter(bool); void SetRenderErrors(bool); void SetRenderBoxes(bool); void SetShowViewCells(bool); void SetShowRenderCost(bool); void SetShowPvsSizes(bool); void SetTopView(bool); void SetCutViewCells(bool); void SetCutScene(bool); }; struct PvsCache { PvsCache():mViewCell(NULL) {} void Reset() { mViewCell = NULL; mPvs.Clear(); } ViewCell *mViewCell; ObjectPvs mPvs; }; class QtGlRendererWidget : public QGLWidget, public GlRendererWidget { Q_OBJECT public: // point of the last mouse click used for movement in the scene Vector3 mousePoint; bool mTopView; bool mRenderViewCells; bool mCutViewCells; bool mCutScene; bool mRenderErrors; bool mRenderFilter; bool mRenderVisibilityEstimates; bool mUseFilter; bool mUseSpatialFilter; bool mShowRenderCost; bool mShowRays; bool mShowPvsSizes; float mSpatialFilterSize; Plane3 mSceneCutPlane; float mTopDistance; // some statistics int mPvsSize; float mRenderError; float mTransferFunction; float mManipulatorLastQuat[4]; float mManipulatorScale; PvsCache mPvsCache; QtRendererControlWidget *mControlWidget; QtPreprocessorThread *mPreprocessorThread; QtGlRendererWidget(SceneGraph *sceneGraph, ViewCellsManager *viewcells, KdTree *tree, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0 ); QtGlRendererWidget() {}; void SetThread(QtPreprocessorThread *t) { mPreprocessorThread = t; } void RenderRenderCost(); virtual void SetupCamera(); // setup a transformation for manipulator void SetupManipulator(); void initializeGL() { InitGL(); } void resizeGL(int w, int h); void paintGL(); void timerEvent(QTimerEvent *) { update(); } void mousePressEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); void keyPressEvent ( QKeyEvent * e ) ; void RenderPvs(); float RenderErrors(); void RenderInfo(); virtual int GetWidth() const { return width(); } virtual int GetHeight() const { return height(); } // virtual void // SetupProjection(const int w, const int h, const float angle = 70.0f); virtual void SetupCameraProjection(const int w, const int h, const float angle = 70.0f); virtual void SetupManipulatorProjection(const int w, const int h, const float angle = 70.0f); void RenderViewCells(); virtual void Show() { show(); } public slots: void UpdateAllPvs(); void ComputeVisibility(); void StopComputation(); void SetRenderErrors(bool b) { mRenderErrors = b; updateGL(); } void SetRenderBoxes(bool b) { mRenderBoxes = b; updateGL(); } void SetRenderFilter(bool b) { mRenderFilter = b; updateGL(); } void SetRenderVisibilityEstimates(bool b) { mRenderVisibilityEstimates = b; updateGL(); } void SetUseFilter(bool b) { mUseFilter = b; mPvsCache.Reset(); updateGL(); } void SetUseSpatialFilter(bool b) { mUseSpatialFilter = b; mPvsCache.Reset(); updateGL(); } void SetViewCellGranularity(int number); void SetTransferFunction(int number) { mTransferFunction = number/1000.0f; updateGL(); } void SetVisibilityFilterSize(int number); void SetSpatialFilterSize(int number); void SetSceneCut(int cut); void SetTopDistance(int dist); void SetShowViewCells(bool b) { mRenderViewCells = b; updateGL(); } void SetShowRays(bool b) { mShowRays = b; updateGL(); } void SetShowRenderCost(bool b) { mShowRenderCost = b; updateGL(); } void SetShowPvsSizes(bool b) { mShowPvsSizes = b; updateGL(); } void SetTopView(bool b) { mTopView = b; updateGL(); } void SetCutViewCells(bool b) { mCutViewCells = b; updateGL(); } void SetCutScene(bool b) { mCutScene = b; updateGL(); } }; class QtGlDebuggerWidget : public QGLWidget { Q_OBJECT public: QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL); ~QtGlDebuggerWidget(); void initializeGL(); void resizeGL(int w, int h); void paintGL(); void timerEvent(QTimerEvent *) { update(); } void mousePressEvent(QMouseEvent *) { killTimer(timerId); } void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); } void initCommon(); void initPbuffer(); QtGlRendererBuffer *mRenderBuffer; Beam mBeam; int mSamples; Intersectable *mSourceObject; private: GLuint dynamicTexture; int timerId; }; extern QtGlDebuggerWidget *debuggerWidget; }; #endif