Ignore:
Timestamp:
01/16/08 23:32:51 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
7 edited

Legend:

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

    r2601 r2604  
    396396        glEnable(GL_NORMALIZE); 
    397397 
    398         glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 
     398        glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 
    399399 
    400400        OcclusionQuery::GenQueries(mOcclusionQueries, 10); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r2575 r2604  
    170170 
    171171KdIntersectable::KdIntersectable(KdNode *item, const AxisAlignedBox3 &box) : 
    172   IntersectableWrapper<KdNode *>(item), mNumTriangles(-1), mBox(box) 
     172  IntersectableWrapper<KdNode *>(item), mNumTriangles(-1), mBox(box), mGenericIdx(-1) 
    173173{ 
    174174} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2599 r2604  
    182182        AxisAlignedBox3 mBox; 
    183183 
     184        int mGenericIdx; 
     185 
    184186protected: 
    185187 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2601 r2604  
    4747const static int SAMPLES_INCR = 2000000; 
    4848 
     49 
     50 
    4951static inline bool ilt(Intersectable *obj1, Intersectable *obj2) 
    5052{ 
     
    271273        GlRenderer::InitGL(); 
    272274 
    273         GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  }; 
    274         /*  mat_specular and mat_shininess are NOT default values       */ 
    275         GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  }; 
    276         GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  }; 
    277         GLfloat mat_shininess[] = {  1.0  }; 
    278  
    279         GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  }; 
    280         GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  }; 
    281         GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  }; 
    282  
    283         GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  }; 
     275        GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 
     276         
     277        // mat_specular and mat_shininess are NOT default values 
     278        GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 
     279        GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     280        GLfloat mat_shininess[] = {1.0f}; 
     281 
     282        GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f}; 
     283        GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f}; 
     284        GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     285 
     286        GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    284287 
    285288 
     
    515518                else  
    516519                { 
    517                         if (!mRenderVisibilityEstimates) 
     520                        if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject) 
    518521                        { 
    519522                                _RenderPvs(); 
     
    529532                                        Intersectable *object = it.Next(pvsData); 
    530533 
     534                                        RgbColor color; 
     535 
    531536                                        //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
    532537                                        // glColor3f(visibility, 0.0f, 0.0f); 
    533538                                        //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
    534                                         RgbColor color = RainbowColorMapping(mTransferFunction*log10(pvsData.mSumPdf + 1)); 
     539                                        if (mUseRandomColorPerPvsObject) 
     540                                        { 
     541                                                KdIntersectable *kdint = static_cast<KdIntersectable *>(object); 
     542 
     543                                                if (kdint->mGenericIdx == -1) 
     544                                                { 
     545                                                        kdint->mGenericIdx = (int)mColors.size(); 
     546                                                        mColors.push_back(RandomColor()); 
     547                                                } 
     548                                                color = mColors[kdint->mGenericIdx]; 
     549                                        }  
     550                                        else 
     551                                        { 
     552                                                color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1)); 
     553                                        } 
     554 
    535555                                        glColor3f(color.r, color.g, color.b); 
    536556 
     
    562582        else  
    563583        { 
    564                 /*ObjectContainer::const_iterator oi = mObjects.begin(); 
    565                 for (; oi != mObjects.end(); oi++) 
    566                 RenderIntersectable(*oi);*/ 
     584                //ObjectContainer::const_iterator oi = mObjects.begin(); 
     585                //for (; oi != mObjects.end(); oi++) 
     586                //      RenderIntersectable(*oi); 
    567587                RenderScene(); 
    568588        } 
     
    772792QtGlRendererWidget::keyPressEvent ( QKeyEvent * e ) 
    773793{ 
    774         switch (e->key()) { 
     794        switch (e->key())  
     795        { 
     796case Qt::Key_E: 
     797        mRenderErrors = !mRenderErrors; 
     798        updateGL(); 
     799        break; 
     800case Qt::Key_R: 
     801        mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject;; 
     802        updateGL(); 
     803        break; 
    775804case Qt::Key_T: 
    776805        mTopView = !mTopView; 
     
    819848                                } 
    820849default: 
     850        cerr << "unknown key" << endl; 
    821851        e->ignore(); 
    822852        break; 
     
    848878        mRenderVisibilityEstimates = false; 
    849879 
     880        mUseRandomColorPerPvsObject = false; 
     881 
    850882        mHideByCost = false; 
    851883        mUseTransparency = false; 
     
    874906        mShowPiercingRays = false; 
    875907        mShowWeightedRays = false; 
    876         mShowWeightedCost = false; 
     908        mUseStandardColors = false; 
     909        mShowWeightedCost = true; 
    877910 
    878911        mShowDistanceWeightedPvs = true; 
     
    922955        connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool))); 
    923956        connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool))); 
     957        connect(mControlWidget, SIGNAL(SetShowWireFrame(bool)), this, SLOT(SetShowWireFrame(bool))); 
    924958        connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool))); 
    925959        connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool))); 
     
    11081142 
    11091143        QString s; 
     1144 
    11101145        int vc = 0; 
    11111146        if (mViewCellsManager) 
     
    11161151                filter = mViewCellsManager->GetMaxFilterSize(); 
    11171152 
    1118         glColor3f(1.0f,1.0f,1.0f); 
    1119  
     1153        glColor3f(0.0f, 0.0f, 1.0f); 
     1154 
     1155#if REMOVE_TEMPORARY 
    11201156        s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 
    11211157                mFrame, 
     
    11281164                ); 
    11291165 
    1130         renderText(20,20,s); 
     1166        renderText(20, 20, s); 
    11311167 
    11321168        s.sprintf("viewcells:%04d filter:%04d pvs:%04d error:%5.5f %", 
     
    11361172                mRenderError*100.0f); 
    11371173 
    1138  
    1139         renderText(20,40,s); 
    1140  
    1141  
    1142  
    1143  
     1174        renderText(20, 40, s); 
     1175#endif 
     1176         
     1177        QFont font40; font40.setPointSize(30); 
     1178        s.sprintf("pvs:%04d", mPvsSize); 
     1179        renderText(20, 40, s, font40); 
    11441180} 
    11451181 
     
    13611397        int i; 
    13621398 
     1399        // transparency  
     1400        if (!mUseTransparency) 
     1401        { 
     1402                glEnable(GL_DEPTH_TEST); 
     1403                glDisable(GL_BLEND); 
     1404        } 
     1405        else 
     1406        { 
     1407                glDisable(GL_DEPTH_TEST); 
     1408                glEnable(GL_BLEND); 
     1409 
     1410                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     1411                //glBlendFunc(GL_SRC_ALPHA, GL_ONE); 
     1412 
     1413                for (i = 0; i < viewcells.size(); ++ i)  
     1414                { 
     1415                        ViewCell *vc = viewcells[i]; 
     1416 
     1417                        const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center()); 
     1418                        vc->SetDistance(dist); 
     1419                } 
     1420 
     1421                sort(viewcells.begin(), viewcells.end(), nearerThan); 
     1422        } 
     1423 
     1424        //mWireFrame = true; 
     1425                 
    13631426        // normal rendering 
    1364         if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison) 
     1427        //if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison) 
     1428        if (mUseStandardColors) 
    13651429        { 
    13661430                for (i = 0; i < viewcells.size(); ++ i)  
     
    13691433                        RgbColor c; 
    13701434 
    1371                         if (!mShowPvsSizes && !mShowPiercingRays) 
    1372                         { 
    1373                                 mWireFrame = true; 
    1374                                 c = vc->GetColor(); 
    1375                         }  
    1376  
     1435                        //if (!mShowPvsSizes && !mShowPiercingRays) 
     1436                        c = vc->GetColor(); 
     1437                         
    13771438                        glColor3f(c.r, c.g, c.b); 
    13781439 
     
    13851446        else // using specialised colors 
    13861447        { 
    1387                 // transparency  
    1388                 if (!mUseTransparency) 
    1389                 { 
    1390                         glEnable(GL_DEPTH_TEST); 
    1391                         glDisable(GL_BLEND); 
    1392                 } 
    1393                 else 
    1394                 { 
    1395                         glDisable(GL_DEPTH_TEST); 
    1396                         glEnable(GL_BLEND); 
    1397  
    1398                         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
    1399                         //glBlendFunc(GL_SRC_ALPHA, GL_ONE); 
    1400  
    1401                         for (i = 0; i < viewcells.size(); ++ i)  
    1402                         { 
    1403                                 ViewCell *vc = viewcells[i]; 
    1404  
    1405                                 const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center()); 
    1406                                 vc->SetDistance(dist); 
    1407                         } 
    1408  
    1409                         sort(viewcells.begin(), viewcells.end(), nearerThan); 
    1410                 } 
     1448         
    14111449 
    14121450                if (!mShowComparison) 
     
    14991537        if (viewcells.size() > compareInfo.size()) 
    15001538        { 
    1501                 cerr << "loaded size (" << compareInfo.size() << ") does not fit to view cells size (" << viewcells.size() << ")" << endl; 
     1539                cerr << "loaded size (" << (int)compareInfo.size() << ") does not fit to view cells size (" << (int)viewcells.size() << ")" << endl; 
    15021540                return; 
    15031541        } 
     
    15561594        QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5; 
    15571595         
    1558         rb1 = new QRadioButton("wireframe", parent); 
     1596        rb1 = new QRadioButton("random colors", parent); 
    15591597        rb1->setText("wireframe"); 
    15601598        connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool))); 
     
    15881626        vbox2->addWidget(rb5); 
    15891627         
    1590         rb1->setChecked(true); 
     1628        rb5->setChecked(true); 
    15911629 
    15921630        vbox2->addStretch(1); 
     
    17101748        vbox->setLayout(vl); 
    17111749 
    1712         QLabel *label = new QLabel("Granularity"); 
     1750        QLabel *label; 
     1751        QSlider *slider; 
     1752        QPushButton *button; 
     1753 
     1754#if REMOVE_TEMPORARY 
     1755 
     1756        label = new QLabel("Granularity"); 
    17131757        vbox->layout()->addWidget(label); 
    17141758 
    1715         QSlider *slider = new QSlider(Qt::Horizontal, vbox); 
     1759        slider = new QSlider(Qt::Horizontal, vbox); 
    17161760        vl->addWidget(slider); 
    17171761        slider->show(); 
     
    17391783        ////////////////////////////////////////7 
    17401784 
    1741  
    1742         QPushButton *button = new QPushButton("Update all PVSs", vbox); 
     1785        button = new QPushButton("Update all PVSs", vbox); 
    17431786        vbox->layout()->addWidget(button); 
    17441787        connect(button, SIGNAL(clicked()), SLOT(UpdateAllPvs())); 
    1745  
    17461788 
    17471789        ////////////////////////////////////////77777 
     
    17581800 
    17591801        connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetVisibilityFilterSize(int))); 
     1802 
     1803#endif 
    17601804 
    17611805 
     
    19231967        ////////////////////////////// 
    19241968 
    1925  
     1969#if REMOVE_TEMPORARY 
    19261970        cb = new QCheckBox("Cut scene", vbox); 
    19271971        vbox->layout()->addWidget(cb); 
    19281972        cb->setChecked(false); 
    19291973        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutScene(bool))); 
    1930  
     1974#endif 
    19311975        cb = new QCheckBox("Render boxes", vbox); 
    19321976        vbox->layout()->addWidget(cb); 
     
    19451989        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 
    19461990 
    1947  
    19481991        bool tmp; 
     1992#if REMOVE_TEMPORARY 
    19491993 
    19501994        cb = new QCheckBox("Use filter", vbox); 
     
    19531997        cb->setChecked(tmp); 
    19541998        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool))); 
    1955  
     1999#endif 
    19562000 
    19572001        cb = new QCheckBox("Use spatial filter", vbox); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2591 r2604  
    1414#include "QtPreprocessorThread.h" 
    1515#include "LogReader.h" 
     16#include "Material.h" 
     17 
    1618 
    1719 
     
    127129  void SetShowRenderCost(bool); 
    128130  void SetShowPvsSizes(bool); 
     131  void SetShowWireFrame(bool); 
    129132  void SetShowPiercingRays(bool); 
    130133  void SetShowWeightedRays(bool); 
    131    void SetShowComparison(bool); 
     134  void SetShowComparison(bool); 
    132135  void SetShowWeightedCost(bool); 
    133136  
     
    176179        bool mShowPiercingRays; 
    177180        bool mShowWeightedRays; 
     181        bool mUseStandardColors; 
    178182        bool mShowRays; 
    179183 
     
    215219 
    216220        ViewCellInfoContainer mCompareInfo; 
     221 
     222        vector<RgbColor> mColors; 
     223 
     224        bool mUseRandomColorPerPvsObject; 
    217225 
    218226        QtGlRendererWidget(SceneGraph *sceneGraph, 
     
    392400                updateGL(); 
    393401        } 
     402 
     403        void SetShowWireFrame(bool b) { 
     404                mUseStandardColors = b; 
     405                updateGL(); 
     406        } 
     407         
    394408 
    395409        void SetShowWeightedRays(bool b) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2593 r2604  
    5252void QtGlViewer::RenderScene() 
    5353{ 
    54         GLfloat mat_ambient[] = {0.1, 0.1, 0.1, 1.0}; 
    55  
     54        GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  }; 
     55         
    5656        // mat_specular and mat_shininess are NOT default values 
    57         GLfloat mat_diffuse[] = {0.5, 1.0, 0.5, 1.0}; 
    58         GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0}; 
    59         GLfloat mat_shininess[] = {1.0}; 
    60  
    61         GLfloat light_ambient[] = {0.1, 0.1, 0.1, 1.0}; 
    62         GLfloat light_diffuse[] = {0.5, 0.5, 0.5, 1.0}; 
    63         GLfloat light_specular[] = {0.0, 0.0, 0.0, 1.0}; 
    64  
    65         GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0}; 
    66  
     57        GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  }; 
     58        GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  }; 
     59        GLfloat mat_shininess[] = {  1.0  }; 
     60 
     61        GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  }; 
     62        GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  }; 
     63        GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  }; 
     64 
     65        GLfloat lmodel_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
     66 
     67 
     68        // set position of the light 
     69        GLfloat infinite_light[] = {1.0, 0.8, 1.0, 0.0}; 
     70        glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); 
     71 
     72        // set position of the light2 
     73        GLfloat infinite_light2[] = {-0.3, 1.5, 1.0, 0.0}; 
     74        glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
    6775 
    6876        // default material 
     
    7684        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
    7785        glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
     86         
     87        glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 
     88        glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); 
     89        glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); 
     90         
    7891        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
    7992 
    80          
    8193        //GLfloat infinite_light2[] = {-0.3, 1.5f, 1.0f, 0.0f}; 
    8294        //glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
     95        //glColor3f(1.0f, 1.0f, 1.0f); 
    8396        glColor3f(0.8f, 0.8f, 0.8f); 
    8497         
    8598        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
    86         glDisable(GL_COLOR_MATERIAL); 
    87         //glEnable(GL_COLOR_MATERIAL); 
     99        glEnable(GL_COLOR_MATERIAL); 
    88100 
    89101        ++ mRenderer->mFrame; 
     
    99111        mRenderer->mDummyViewPoint = mDummyViewPoint; 
    100112         
    101         glDisable(GL_LIGHTING); 
    102         //glEnable(GL_LIGHTING); 
     113        glEnable(GL_NORMALIZE); 
     114        glEnable(GL_LIGHTING); 
     115        glEnable(GL_LIGHT0); 
     116        glEnable(GL_LIGHT1); 
    103117 
    104118        mRenderer->RenderPvs(); 
     
    163177 
    164178        glLoadIdentity(); 
    165         gluLookAt(0.0, 0.0, 1.0,  /* eye is at (0,0,30) */ 
    166                       0.0, 0.0, 0.0,  /* center is at (0,0,0) */ 
    167                       0.0, 1.0, 0.);  /* up is in positive Y direction */ 
     179        gluLookAt(0.0f, 10.0f, 0.0f,  // eye is at (0,0,30)  
     180                      0.0f, 0.0f, 0.0f,  // center is at (0,0,0)  
     181                      0.0f, 0.0f, 1.0f); // up is in positive Y direction  
    168182 
    169183        build_rotmatrix(m.x, manipulatorLastQuat); 
     
    212226 
    213227void 
    214 QtGlViewer::keyPressEvent ( QKeyEvent * e ) 
     228QtGlViewer::keyPressEvent(QKeyEvent * e) 
    215229{ 
    216230  switch (e->key()) { 
    217231  case Qt::Key_W: 
    218                 mWireframe  = !mWireframe; 
     232                mWireframe = !mWireframe; 
    219233                updateGL(); 
    220234  default: 
    221235                e->ignore(); 
     236                cerr << "unknown key" << endl; 
    222237                break; 
    223238  } 
    224   updateGL(); 
     239  //updateGL(); 
    225240} 
    226241 
     
    228243QtGlViewer::mouseMoveEvent(QMouseEvent *event) 
    229244{ 
    230   int dx = event->x() - lastPos.x(); 
    231   int dy = event->y() - lastPos.y();   
     245  int dx = event->x() + lastPos.x(); 
     246  int dy = event->y() + lastPos.y();   
    232247   
    233248  if (event->modifiers() & Qt::CTRL) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2598 r2604  
    8282struct VizBuffer 
    8383{ 
    84         VizBuffer(): mIndex(0), mMaxSize(10000) 
     84        VizBuffer(): mIndex(0), mMaxSize(1000) 
    8585        { 
    8686        } 
Note: See TracChangeset for help on using the changeset viewer.