Changeset 1148


Ignore:
Timestamp:
07/25/06 01:39:35 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj

    r1146 r1148  
    344344                        </File> 
    345345                        <File 
     346                                RelativePath="..\src\RenderSimulator.cpp"> 
     347                        </File> 
     348                        <File 
     349                                RelativePath="..\src\RenderSimulator.h"> 
     350                        </File> 
     351                        <File 
    346352                                RelativePath="..\src\ResourceManager.h"> 
    347353                        </File> 
     
    530536                        </File> 
    531537                        <File 
     538                                RelativePath="..\src\QtGlRenderer.cpp"> 
     539                        </File> 
     540                        <File 
     541                                RelativePath="..\src\QtGlRenderer.h"> 
     542                        </File> 
     543                        <File 
    532544                                RelativePath="..\src\Renderer.cpp"> 
    533545                        </File> 
    534546                        <File 
    535547                                RelativePath="..\src\Renderer.h"> 
    536                         </File> 
    537                         <File 
    538                                 RelativePath="..\src\RenderSimulator.cpp"> 
    539                         </File> 
    540                         <File 
    541                                 RelativePath="..\src\RenderSimulator.h"> 
    542548                        </File> 
    543549                </Filter> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1145 r1148  
    12981298} 
    12991299 
     1300 
    13001301int ViewCellsManager::CountValidViewcells() const 
    13011302{ 
  • 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 
     16class QWidget; 
    617 
    718namespace GtpVisibilityPreprocessor { 
    819 
    9 class GlRenderer: public Renderer 
     20class SceneGraph; 
     21class ViewCellsManager; 
     22class Mesh; 
     23class MeshInstance; 
     24class Intersectable; 
     25class Material; 
     26class Beam; 
     27class KdTree; 
     28class GlRendererBuffer; 
     29class BeamSampleStatistics; 
     30class OcclusionQuery; 
     31class TransformedMeshInstance; 
     32 
     33struct VssRayContainer; 
     34struct PvsRenderStatistics;  
     35struct RenderCostSample; 
     36 
     37 
     38class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer 
    1039{ 
    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 
     41public: 
     42        QtGlRendererBuffer(const int w, 
     43                const int h, 
     44                SceneGraph *sceneGraph, 
     45                ViewCellsManager *viewcells, 
     46                KdTree *tree); 
     47 
     48        ~QtGlRendererBuffer(); 
    8949 
    9050        /** Evaluates render cost of a point sample. 
    91                 @param sample the render cost sample to be evaluated 
    92                 @param useOcclusionQueries if occlusion queries should be used or item buffer 
    93                 @param threshold number of pixels / samples from where an object is considered visible. 
     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. 
    9454        */ 
    9555        void EvalRenderCostSample(RenderCostSample &sample, 
    96                                                           const bool useOcclusionQueries, 
    97                                                           const int threshold); 
     56                const bool useOcclusionQueries, 
     57                const int threshold); 
    9858 
    9959        /** Evaluates render cost of a number of point samples. The point samples 
    100                 are distributed uniformly over the defined view space. 
    101  
    102                 @param numSamples the number of point samples taken 
    103                 @param samples stores the taken point samples in a container 
    104                 @param useOcclusionQueries if occlusion queries should be used or item buffer 
    105                 @param threshold number of pixels / samples from where an object is considered visible. 
     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. 
    10666        */ 
    10767        void SampleRenderCost(const int numSamples,  
    108                                                   vector<RenderCostSample> &samples, 
    109                                                   const bool useOcclusionQueries, 
    110                                                   const int threshold = 0) 
    111         {} 
    112  
    113         /** Implerment in subclasses. 
    114         */ 
    115         void EvalPvsStat() {}; 
    116  
    117         void ClearErrorBuffer(); 
    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  
    12585  void SampleBeamContributions( 
    12686                                                           Intersectable *sourceObject, 
     
    151111 
    152112  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
    153  
    154   PvsRenderStatistics mPvsStat; 
     113      
    155114    
    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          
     115private: 
     116         
    173117        void SetupProjectionForViewPoint(const Vector3 &viewPoint,  
    174118                                                                         const Beam &beam,  
    175  
    176119                                                                         Intersectable *sourceObject); 
    177120 
    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 
     122public: 
     123  signals: 
     124        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 
     125}; 
     126 
     127 
     128class RendererControlWidget : public QWidget 
    195129{ 
    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 
     131public: 
     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 
     165class GlRendererWidget : public QGLWidget, public GlRenderer 
     166{ 
     167  Q_OBJECT 
     168public: 
     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 
     307extern GlRendererWidget *rendererWidget; 
     308 
     309class GlDebuggerWidget : public QGLWidget 
     310{ 
     311        Q_OBJECT 
     312public: 
     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 
     332private: 
     333    GLuint dynamicTexture; 
     334    int timerId; 
     335}; 
     336 
     337extern GlDebuggerWidget *debuggerWidget; 
    219338 
    220339}; 
Note: See TracChangeset for help on using the changeset viewer.