Ignore:
Timestamp:
12/10/07 18:43:33 (17 years ago)
Author:
mattausch
Message:

worked on visualization

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2560 r2562  
    309309                SetupMaterial(mesh->mMaterial); 
    310310 
    311         for (i=0; i < mesh->mFaces.size(); i++)  
     311        for (i = 0; i < mesh->mFaces.size(); i++)  
    312312        { 
    313313                if (mWireFrame) 
     
    337337  glFrontFace(GL_CCW); 
    338338  glCullFace(GL_BACK); 
    339   glEnable(GL_CULL_FACE); 
     339 
    340340  glShadeModel(GL_FLAT); 
    341   glDepthFunc( GL_LESS ); 
     341  glDepthFunc(GL_LESS ); 
    342342  glEnable(GL_DEPTH_TEST); 
    343343  glEnable(GL_CULL_FACE); 
     
    345345  InitExtensions(); 
    346346 
    347   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 
    348  
    349   glEnable( GL_NORMALIZE ); 
     347  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 
     348 
     349  glEnable(GL_NORMALIZE); 
    350350   
    351351  glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2560 r2562  
    5050} 
    5151 
     52 
     53inline static bool nearerThan(ViewCell *vc1, ViewCell *vc2) 
     54{ 
     55        return vc1->GetDistance() > vc2->GetDistance(); 
     56} 
     57 
     58 
    5259#if USE_CG 
    5360static void handleCgError()  
     
    322329                glMatrixMode(GL_PROJECTION); 
    323330                glLoadIdentity(); 
    324                 gluPerspective(angle, ww/(float)hh, 0.1, 2.0*Magnitude(mSceneGraph->GetBox().Diagonal())); 
     331                gluPerspective(angle, ww/(float)hh, 0.1, 2.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 
    325332                glMatrixMode(GL_MODELVIEW); 
    326333        } else { 
     
    330337                glMatrixMode(GL_PROJECTION); 
    331338                glLoadIdentity(); 
    332                 gluPerspective(50.0, ww/(float)hh, 0.1, 20.0*Magnitude(mSceneGraph->GetBox().Diagonal())); 
     339                gluPerspective(50.0, ww / (float)hh, 0.1, 20.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 
    333340                glMatrixMode(GL_MODELVIEW); 
    334341        } 
     
    830837        mRenderFilter = true; 
    831838        mRenderVisibilityEstimates = false; 
     839 
     840        mHideByCost = false; 
     841 
    832842        mTransferFunction = 0.2f; 
    833843        mIndexBufferSize = 0; 
     
    835845        //mCurrentFrame = 0; 
    836846 
    837         const int delay = 500; // half a second 
     847        const int delay = 250; // in milliseconds 
    838848        timerId = startTimer(delay); 
    839849 
     
    873883        connect(mControlWidget, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int))); 
    874884        connect(mControlWidget, SIGNAL(SetSpatialFilterSize(int)), this, SLOT(SetSpatialFilterSize(int))); 
     885        connect(mControlWidget, SIGNAL(SetHidingCost(int)), this, SLOT(SetHidingCost(int))); 
    875886 
    876887        connect(mControlWidget, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool))); 
     
    879890        connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool))); 
    880891        connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool))); 
     892        connect(mControlWidget, SIGNAL(SetHideByCost(bool)), this, SLOT(SetHideByCost(bool))); 
    881893        connect(mControlWidget, SIGNAL(SetCutScene(bool)), this, SLOT(SetCutScene(bool))); 
    882894        connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool))); 
     
    11191131        // shift it along y according to number, which is percentage of the bounding 
    11201132        // box position 
    1121         if (mViewCellsManager) { 
     1133        if (mViewCellsManager)  
     1134        { 
    11221135                AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 
    11231136                Vector3 p = box.Min() + (number/1000.0f)*box.Max(); 
    11241137                mSceneCutPlane.mNormal = Vector3(0,-1,0); 
    11251138                mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p); 
     1139 
    11261140                updateGL(); 
    11271141        } 
    11281142} 
     1143 
     1144void 
     1145QtGlRendererWidget::SetHidingCost(int number) 
     1146{ 
     1147        mHidingCost = (float)number / 1000.0f; 
     1148        cout << "hiding cost " << mHidingCost << endl; 
     1149} 
     1150 
    11291151 
    11301152void 
     
    11441166        glEnable(GL_CULL_FACE); 
    11451167        glCullFace(GL_FRONT); 
    1146  
    1147         glDisable(GL_CULL_FACE); 
     1168        //glDisable(GL_CULL_FACE); 
     1169 
    11481170        double eq[4]; 
    11491171        eq[0] = mSceneCutPlane.mNormal.x; 
     
    11591181 
    11601182        int i; 
     1183 
    11611184        ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 
    11621185        int maxPvs = -1; 
    1163         int maxPiercingRays = 0; 
     1186        int maxPiercingRays = 1; // for savety 
    11641187 
    11651188        for (i = 0; i < viewcells.size(); ++ i)  
     
    11711194                if (p > maxPvs) 
    11721195                        maxPvs = p; 
     1196 
    11731197                const int piercingRays = vc->GetNumPiercingRays(); 
     1198                 
    11741199                if (piercingRays > maxPiercingRays) 
    11751200                        maxPiercingRays = piercingRays; 
    11761201        } 
    11771202 
    1178  
    1179         for (i = 0; i < viewcells.size(); ++ i)  
     1203        cout << "here22 " << mHideByCost << " " << mHidingCost << endl; 
     1204 
     1205        if (!mShowPvsSizes && !mShowPiercingRays) 
    11801206        { 
    1181                 ViewCell *vc = viewcells[i]; 
    1182                 //      Mesh *m = vc->GetMesh(); 
     1207                for (i = 0; i < viewcells.size(); ++ i)  
     1208                { 
     1209                        ViewCell *vc = viewcells[i]; 
     1210                        RgbColor c; 
     1211 
     1212                        if (!mShowPvsSizes && !mShowPiercingRays) 
     1213                        { 
     1214                                mWireFrame = true; 
     1215                                c = vc->GetColor(); 
     1216                        }  
     1217 
     1218                        glColor3f(c.r, c.g, c.b); 
     1219 
     1220                        if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))  
     1221                        { 
     1222                RenderViewCell(vc); 
     1223                        } 
     1224                } 
     1225        } 
     1226        else 
     1227        { 
     1228                //glDisable(GL_CULL_FACE); 
     1229                //glEnable(GL_CULL_FACE); 
     1230                //glFrontFace(GL_CCW);   
     1231                //glCullFace(GL_BACK); 
     1232                glEnable(GL_DEPTH_TEST); 
     1233                glDisable(GL_BLEND); 
     1234 
     1235                //glDisable(GL_DEPTH_TEST); 
     1236                //glEnable(GL_BLEND); 
     1237         
     1238                //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     1239                glBlendFunc(GL_SRC_ALPHA, GL_ONE); 
     1240 
     1241                for (i = 0; i < viewcells.size(); ++ i)  
     1242                { 
     1243                        ViewCell *vc = viewcells[i]; 
     1244                        const float dist = SqrDistance(mViewPoint, vc->GetBox().Center()); 
     1245 
     1246                        vc->SetDistance(dist); 
     1247                } 
     1248 
     1249                sort(viewcells.begin(), viewcells.end(), nearerThan); 
    11831250 
    11841251                RgbColor c; 
    11851252 
    1186                 if (!mShowPvsSizes && !mShowPiercingRays) 
     1253        for (i = 0; i < viewcells.size(); ++ i)  
    11871254                { 
    1188                         mWireFrame = true; 
    1189                         c = vc->GetColor(); 
    1190                 }  
    1191                 else if (mShowPiercingRays) 
    1192                 { 
    1193                         // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    1194                         const float importance = 5.0f * mTransferFunction * 
    1195                                 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 
    1196                         // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    1197                         c = RainbowColorMapping(importance); 
     1255            ViewCell *vc = viewcells[i]; 
     1256                         
     1257                        //cout << "dist: " << vc->GetDistance() << " "; 
     1258 
     1259                        if (mShowPiercingRays) 
     1260                        { 
     1261                                // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
     1262                                const float importance = 5.0f * mTransferFunction * 
     1263                                        ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 
     1264                                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
     1265                                c = RainbowColorMapping(importance); 
     1266                        } 
     1267                        else 
     1268                        { 
     1269                                // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
     1270                                const float importance = 5.0f * mTransferFunction * 
     1271                                        ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
     1272                                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
     1273                                c = RainbowColorMapping(importance); 
     1274                        } 
     1275                         
     1276                        const float alpha = 0.2f; 
     1277                        glColor4f(c.r, c.g, c.b, alpha); 
     1278                         
     1279                        if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))  
     1280                        { 
     1281                RenderViewCell(vc); 
     1282                        } 
    11981283                } 
    1199                 else 
    1200                 { 
    1201                         // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    1202                         const float importance = 5.0f * mTransferFunction * 
    1203                                 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
    1204                         // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    1205                         c = RainbowColorMapping(importance); 
    1206                 } 
    1207  
    1208                 glColor3f(c.r, c.g, c.b); 
    1209  
    1210                 RenderViewCell(vc); 
     1284 
     1285                glEnable(GL_DEPTH_TEST);         
    12111286        } 
    12121287 
     
    14741549                connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void))); 
    14751550        } 
     1551 
     1552        // the render cost visualization 
     1553        slider = new QSlider(Qt::Horizontal, vbox); 
     1554        vbox->layout()->addWidget(slider); 
     1555        slider->show(); 
     1556        slider->setRange(0, 1000); 
     1557        slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
     1558        slider->setValue(100); 
     1559        connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetHidingCost(int))); 
     1560         
     1561        cb = new QCheckBox("Hide view cells by render cost ", vbox); 
     1562        vbox->layout()->addWidget(cb); 
     1563        cb->setChecked(false); 
     1564        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetHideByCost(bool))); 
    14761565 
    14771566        setWindowTitle("Preprocessor Control Widget"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2560 r2562  
    9999  void SetSceneCut(int); 
    100100  void SetTopDistance(int); 
     101  void SetHidingCost(int); 
    101102  void SetVisibilityFilterSize(int); 
    102103  void SetSpatialFilterSize(int); 
     
    116117  void SetCutViewCells(bool); 
    117118  void SetCutScene(bool); 
     119 
     120  void SetHideByCost(bool); 
    118121}; 
    119122 
     
    131134        bool mCutViewCells; 
    132135        bool mCutScene; 
     136        bool mHideByCost; 
    133137        bool mRenderErrors; 
    134138        bool mRenderFilter; 
     
    144148 
    145149        Plane3 mSceneCutPlane; 
     150        float mHidingCost; 
     151 
    146152        float mTopDistance; 
    147153 
     
    277283                SetTopDistance(int dist); 
    278284 
     285        void 
     286                SetHidingCost(int dist); 
     287 
    279288        void SetShowViewCells(bool b) { 
    280289                mRenderViewCells = b; 
     
    308317 
    309318        void SetCutViewCells(bool b) { 
     319                std::cout << "here64" << std::endl; 
     320 
    310321                mCutViewCells = b; 
    311322                updateGL(); 
     
    313324        void SetCutScene(bool b) { 
    314325                mCutScene = b; 
     326                updateGL(); 
     327        } 
     328 
     329        void SetHideByCost(bool b) { 
     330                std::cout << "here45" << std::endl; 
     331                mHideByCost = b; 
    315332                updateGL(); 
    316333        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2560 r2562  
    2929        mWireframe = false; 
    3030        trackball(manipulatorLastQuat, 0.0f, 0.0f, 0.0f, 0.0f); 
    31         connect(renderer, SIGNAL(PvsUpdated()), this, SLOT(updateGL())); 
     31        //connect(renderer, SIGNAL(PvsUpdated()), this, SLOT(updateGL())); 
     32        //connect(renderer, SIGNAL(cutupdated), this, SLOT(updateGL())); 
     33 
     34        const int delay = 250; // in milliseconds 
     35        timerId = startTimer(delay); 
    3236} 
    3337   
     
    4751QtGlViewer::RenderScene() 
    4852{ 
    49         mRenderer->mFrame++; 
     53        ++ mRenderer->mFrame; 
    5054         
    51         // render into the right side of the window buffer 
    52         if (mRenderer->mRenderViewCells)  
    53           mRenderer->RenderViewCells(); 
    54          
     55        glDisable(GL_DEPTH_TEST); 
     56 
    5557        glColor3f(0.8f, 0.8f, 0.8f); 
    5658        mRenderer->RenderPvs(); 
     
    6870//        } 
    6971//      } 
    70          
     72 
    7173        if (mRenderer->mShowRenderCost)  
    7274          mRenderer->RenderRenderCost(); 
     75 
     76        // render into the right side of the window buffer 
     77        if (mRenderer->mRenderViewCells) 
     78                mRenderer->RenderViewCells(); 
    7379 
    7480        glColor3f(1.0f, 1.0f, 1.0f); 
     
    190196} 
    191197 
    192 } 
    193  
     198void QtGlViewer::timerEvent(QTimerEvent *event)  
     199{ 
     200        update(); 
     201} 
     202 
     203 
     204} 
     205 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h

    r2017 r2562  
    55 
    66 
    7 namespace GtpVisibilityPreprocessor { 
     7namespace GtpVisibilityPreprocessor  
     8{ 
    89 
    910class QtGlRendererWidget; 
    1011 
     12 
    1113class QtGlViewer : public QGLWidget 
    1214{ 
    13  
    14   //Q_OBJECT 
     15        //Q_OBJECT 
    1516 
    1617        friend class QtGlRendererWidget; 
     
    1920public: 
    2021        QtGlRendererWidget *mRenderer; 
    21          
     22 
    2223        QtGlViewer(QWidget *parent, 
    23                            QtGlRendererWidget *renderer); 
    24          
    25   virtual ~QtGlViewer(){}; 
    26    
    27   QSize minimumSizeHint() const; 
    28   QSize sizeHint() const; 
    29    
    30   // This method has to be rendefined by all renderer implementations 
    31   virtual void RenderScene(); 
    32    
     24                QtGlRendererWidget *renderer); 
     25 
     26        virtual ~QtGlViewer(){}; 
     27 
     28        QSize minimumSizeHint() const; 
     29        QSize sizeHint() const; 
     30 
     31        // This method has to be rendefined by all renderer implementations 
     32        virtual void RenderScene(); 
     33 
     34        void timerEvent(QTimerEvent *event); 
     35 
    3336protected: 
    34   void initializeGL(); 
    35   void paintGL(); 
    36   void resizeGL(int width, int height); 
    37   void mousePressEvent(QMouseEvent *event); 
    38   void mouseMoveEvent(QMouseEvent *event); 
     37        void initializeGL(); 
     38        void paintGL(); 
     39        void resizeGL(int width, int height); 
     40        void mousePressEvent(QMouseEvent *event); 
     41        void mouseMoveEvent(QMouseEvent *event); 
    3942 
    4043        void keyPressEvent ( QKeyEvent * e ); 
    41          
    42   bool mWireframe; 
     44 
     45        bool mWireframe; 
     46 
     47        int timerId; 
    4348 
    4449private: 
    4550 
    4651        float manipulatorLastQuat[4]; 
    47   float scale; 
    48   QPoint lastPos; 
     52        float scale; 
     53        QPoint lastPos; 
    4954 
    5055}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r2560 r2562  
    298298        } 
    299299 
    300         int GetNumPiercingRays() 
     300        int GetNumPiercingRays() const 
    301301        { 
    302302                return mNumPiercingRays; 
    303303        } 
    304304 
     305        float GetDistance() const 
     306        { 
     307                return mDistance; 
     308        } 
     309 
     310        void SetDistance(float dist) 
     311        { 
     312                mDistance = dist; 
     313        } 
    305314 
    306315protected: 
     
    333342        /// number of rays piercing this view cell 
    334343        int mNumPiercingRays; 
     344 
     345        /// distance from the current view point 
     346        float mDistance; 
    335347}; 
    336348 
Note: See TracChangeset for help on using the changeset viewer.