Ignore:
Timestamp:
05/26/08 01:05:56 (16 years ago)
Author:
mattausch
Message:

sheduling dynamic object only when necessary

Location:
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
Files:
3 edited

Legend:

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

    r2707 r2709  
    5050QtGlDebuggerWidget *debuggerWidget = NULL; 
    5151 
    52 const static int SAMPLES_INCR = 2000000; 
    5352 
    5453 
    5554static SimpleRayContainer sViewPointsList; 
    5655static SimpleRayContainer::const_iterator sViewPointsListIt; 
    57  
     56static int sCurrentSamples = 0; 
     57static int sNextSamplesThreshold[] = {10000000, 50000000, 100000000, 250000000}; 
     58//static int sNextSamplesThreshold[] = {100000000, 200000000}; 
     59static int sNumReplays = 4; 
     60static int sCurrentSamplesThreshold = 0; 
    5861 
    5962 
     
    125128                                                                           KdTree *tree): 
    126129QGLPixelBuffer(QSize(w, h),  
    127                            QGLFormat(QGL::StencilBuffer |  
     130                           QGLFormat(QGL::SampleBuffers) 
     131                           /*,| 
     132                                                 QGL::StencilBuffer |  
    128133                                                 QGL::DepthBuffer |  
    129134                                                 QGL::DoubleBuffer | 
    130135                                                 QGL::Rgba) 
    131                                                  ), 
     136                                                 */), 
    132137GlRendererBuffer(sceneGraph, viewcells, tree) 
    133138{ 
     
    190195 
    191196// reimplemented here so that we can snap the error windows 
    192 float QtGlRendererBuffer::GetPixelError(int &pvsSize) 
     197float QtGlRendererBuffer::GetPixelError(int &pvsSize, int pass) 
    193198{ 
    194199        MakeLive(); 
     
    237242 
    238243        // use shading 
    239         if (mSnapErrorFrames) 
    240         { 
     244        if (1)//mSnapErrorFrames) 
     245        { 
     246                glEnable(GL_NORMALIZE); 
     247 
     248                // mat_specular and mat_shininess are NOT default values 
     249        GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 
     250        GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 
     251        GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     252        GLfloat mat_shininess[] = {1.0f}; 
     253 
     254        glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 
     255        glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 
     256        glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); 
     257        glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 
     258 
    241259                GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
     260                //GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
    242261                GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
    243262                GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
    244263 
     264                glEnable(GL_LIGHTING); 
    245265                //GLfloat light_position[] =  {278.0f, 548.8f,279.0f, 1.0f}; 
    246                 GLfloat light_position[] =  {0.f,0.f,0.f, 1.0f}; 
     266                //GLfloat light_position[] =  {0.f, 0.f, 0.f, 1.0f}; 
     267                GLfloat light_position[] =  {0.f, 0.0f, 0.f, 1.0f}; 
    247268 
    248269                glEnable(GL_LIGHT0);  
     
    252273                glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
    253274                glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
    254  
    255                 glEnable(GL_LIGHTING); 
    256275                glLightfv (GL_LIGHT0, GL_POSITION, light_position); 
    257276 
    258277                glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
    259                 glEnable(GL_COLOR_MATERIAL); 
     278                //glEnable(GL_COLOR_MATERIAL); 
     279 
     280                GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     281                glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
    260282 
    261283                glShadeModel(GL_SMOOTH); 
    262284        } 
    263285 
    264         glDisable(GL_ALPHA_TEST); 
     286        //glDisable(GL_ALPHA_TEST); 
    265287                 
    266288        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    267289        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    268290 
    269         //glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); 
    270         glColor3f(0, 1, 0); 
     291        glColor3f(0.6f, 0.6f, 0.6f); 
     292        //glColor3f(0, 1, 0); 
    271293 
    272294        glDepthFunc(GL_LESS); 
     
    274296        glEnable(GL_DEPTH_TEST); 
    275297 
     298        glFrontFace(GL_CCW); 
     299        glCullFace(GL_BACK); 
     300 
    276301        glStencilFunc(GL_EQUAL, 0x0, 0x1); 
    277302        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
     
    301326        query->BeginQuery(); 
    302327 
     328        // current frame has to be increased at each rendering pass 
    303329        ++ mCurrentFrame; 
    304330 
     
    317343 
    318344        // some error happened 
    319         if (pixelCount > pixelThres)  
     345        if (1) // pixelCount > pixelThres)  
    320346        { 
    321347                cout << "f " << mFrame << " id " << viewcell->GetId() << " pvs " << pvsSize  
    322348                         << " e " << pixelCount << " vp " << mViewPoint << " vd " << mViewDirection << endl; 
    323349         
     350                format().setSampleBuffers(true); 
     351                cout << "here3 " << format().sampleBuffers() << endl; 
    324352                if (mSnapErrorFrames)  
    325353                { 
     
    327355                        //glReadBuffer(GL_FRONT); 
    328356 
    329  
    330357                        ////////////// 
    331358                        //-- output error visualization 
    332359 
    333360                        char filename[256]; 
    334                         //sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    335                         sprintf(filename, "error-frame-%04d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 
     361                        sprintf(filename, "error-frame-%04d-%05d.bmp", pass, mFrame); 
     362                        //sprintf(filename, "error-frame-%05d-%0.5f.png", mFrame, pErrorPixels); 
     363                        //sprintf_s(filename, "error-frame-%05d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 
     364 
    336365                        QImage im = toImage(); 
    337366                        string str = mSnapPrefix + filename; 
    338367                        QString qstr(str.c_str()); 
    339368 
    340                         im.save(qstr, "PNG"); 
     369                        //im.save(qstr, "PNG"); 
     370                        // use bmp for lossless storage (for video) 
     371                        im.save(qstr, "BMP"); 
    341372 
    342373                        if (0) 
     
    367398 
    368399                                im = toImage(); 
    369                                 sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
     400                                sprintf_s(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
    370401                                str = mSnapPrefix + filename; 
    371402                                qstr = str.c_str(); 
     
    433464        //glEnable(GL_FOG); 
    434465        //glFogi(GL_FOG_MODE, GL_EXP); 
     466        //glFogf(GL_FOG_DENSITY, .2f); 
    435467        glFogi(GL_FOG_MODE, GL_LINEAR); 
    436  
    437 //      glFogf(GL_FOG_DENSITY, .2f); 
    438468        glFogf(GL_FOG_START, 50.f); 
    439469        glFogf(GL_FOG_END, 500.f); 
    440470 
    441         GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
    442     GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
    443     GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
    444     GLfloat light_position[] =  //{278.0f, 548.8f,279.0f, 1.0f }; 
    445     { 0.f,0.f,0.f,1.0f }; 
    446  
    447     /*glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
    448     glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
    449     glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
    450     glLightfv(GL_LIGHT0, GL_POSITION, light_position); 
    451 */ 
    452     glEnable(GL_LIGHT0);  
    453  
     471         
     472        // mat_specular and mat_shininess are NOT default values 
    454473        GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 
    455          
    456         // mat_specular and mat_shininess are NOT default values 
    457474        GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 
    458475        GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    459476        GLfloat mat_shininess[] = {1.0f}; 
    460477 
    461 /*      GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f}; 
    462         GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f}; 
    463         GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    464  
    465         GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    466 */ 
    467  
    468         // default Material 
    469478        glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 
    470479        glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 
     
    472481        glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 
    473482 
    474         // a light 
     483 
     484        glEnable(GL_LIGHTING); 
     485 
     486        // a light       
     487        GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
     488    GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
     489    GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
     490    GLfloat light_position[] =  {0.f, .0f, 0.f, 1.0f}; 
     491    //GLfloat light_position[] =  {600.0f, 250.0f, -500.f, 1.0f}; 
     492    //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f}; 
     493 
    475494        glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
    476495        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
    477496        glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
    478497 
    479         /*glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 
     498        glLightfv(GL_LIGHT0, GL_POSITION, light_position); 
     499 
     500        //glDisable(GL_LIGHT0); 
     501        glEnable(GL_LIGHT0); 
     502 
     503        glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 
    480504        glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); 
    481505        glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); 
    482 */ 
    483         //glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
    484  
    485         glEnable(GL_LIGHTING); 
    486         glEnable(GL_LIGHT0); 
    487 //      glEnable(GL_LIGHT1); 
    488  
    489         // set position of the light 
    490         /*GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  }; 
    491         glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); 
    492  
     506                 
    493507        // set position of the light2 
    494508        GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  }; 
    495509        glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
    496 */ 
    497         glLightfv (GL_LIGHT0, GL_POSITION, light_position); 
    498  
    499         glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
    500         // glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 
     510        //glEnable(GL_LIGHT1); 
     511 
     512        GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
     513        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
     514 
     515        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
     516        //glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); 
    501517        glEnable(GL_COLOR_MATERIAL); 
    502518 
     
    568584        dit, dit_end = p->mDynamicObjects.end(); 
    569585 
    570         for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit) 
    571         { 
    572                 glColor3f(0, 1, 0); 
     586        int i = 0; 
     587        for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit, ++ i) 
     588        { 
     589                if (i == mCurrentDynamicObjectIdx) 
     590                        glColor3f(1, 0, 1); 
     591                else 
     592                        glColor3f(0, 1, 0); 
     593 
    573594                glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
    574595                _RenderDynamicObject(*dit); 
    575596                glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 
    576597        } 
    577  
    578         //_RenderDynamicObject(mPendingDynamicObject); 
    579598} 
    580599 
     
    692711                        mWireFrame = false; 
    693712                } 
    694                  
    695                 //mCurrentPvsCost = viewcell->GetPvs().EvalPvsCost(); 
    696713        }  
    697714        else  
     
    722739 
    723740        glEnable(GL_STENCIL_TEST);  
    724  
    725741        glDisable(GL_LIGHTING); 
    726742 
     
    770786                        cout << "stopping replay" << endl; 
    771787                        mReplayMode = false; 
     788                        GetPreprocessor()->mSynchronize = false; 
    772789                } 
    773790                else 
     
    781798                } 
    782799 
    783  
    784800                updateGL(); 
    785         } 
    786  
    787         if (timerEvent->timerId() == mUpdateTimerId) 
     801 
     802                // output the current frame buffer 
     803                if (mExportFrameBuffer) 
     804                { 
     805                        const int dist = sViewPointsListIt - sViewPointsList.begin(); 
     806 
     807                        char filename[200]; 
     808                        sprintf(filename, "error-frame-%04d-%05d.bmp", sCurrentSamples, dist); 
     809                        //QPixmap img = renderPixmap(0, 0, true); 
     810                        QImage im = grabFrameBuffer(); 
     811 
     812                        string str = mSnapPrefix + filename; 
     813                        QString qstr(str.c_str()); 
     814 
     815                        //im.save(qstr, "PNG"); 
     816                        // use bmp for lossless storage (for video) 
     817                        im.save(qstr, "BMP"); 
     818                } 
     819        } 
     820        else if (timerEvent->timerId() == mUpdateTimerId) 
     821                // update pvss from time to time 
    788822                update(); 
     823 
     824        // grab frame buffer after a certain number of samples 
     825        if (!mReplayMode &&  
     826                (sCurrentSamplesThreshold < sNumReplays) &&  
     827                ((GetPreprocessor()->mCurrentSamples > sNextSamplesThreshold[sCurrentSamplesThreshold]))) 
     828        { 
     829                ++ sCurrentSamplesThreshold; 
     830                cout << "replaying at total samples: " << GetPreprocessor()->mCurrentSamples << endl; 
     831                ReplayViewPoints(); 
     832        } 
     833 
    789834} 
    790835 
     
    803848                { 
    804849                        Vector3 pt = Unproject(x, y); 
    805                         cout << "unproject: " << pt << endl; 
    806850 
    807851                        mPlacer->PlaceObject(pt); 
     
    813857                        SceneGraphLeaf *newObj = new SceneGraphLeaf(*leaf); 
    814858 
    815                         mViewCellsManager->GetPreprocessor()->RegisterDynamicObject(newObj); 
    816                         //mPendingDynamicObjects.push_back(); 
     859                        // make current object 
     860                        // the object is added at the end of the vector 
     861                        mCurrentDynamicObjectIdx = (int)GetPreprocessor()->mDynamicObjects.size(); 
     862 
     863                        GetPreprocessor()->RegisterDynamicObject(newObj); 
    817864                } 
    818865        } 
     
    828875        mousePoint.y = y; 
    829876 
    830         if (e->modifiers() & Qt::AltModifier)  
     877        if (e->modifiers() & Qt::ShiftModifier)  
    831878        { 
    832879                const Vector3 pt = Unproject(x, y); 
     
    834881                int idx = FindDynamicObject(x, y); 
    835882                 
    836                 Preprocessor *p = GetPreprocessor(); 
    837  
    838                 swap(p->mDynamicObjects[idx], p->mDynamicObjects.back()); 
    839                 p->mDynamicObjects.pop_back(); 
    840                 //preprocessor->ScheduleUpdateDynamicObjects(); 
     883                if (idx >= 0) 
     884                { 
     885                        mCurrentDynamicObjectIdx = idx; 
     886                } 
    841887        } 
    842888} 
     
    865911                mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 
    866912        } 
    867 #if 0// DYNAMIC_OBJECTS_HACK 
    868913        else if (e->modifiers() & Qt::AltModifier) 
    869914        { 
     
    896941                        case 2: 
    897942                                { 
    898                                   // tm = RotationXMatrix(diffx) * RotationYMatrix(diffy); 
    899                                   tm = RotationYMatrix(diffx); 
     943                                        // tm = RotationXMatrix(diffx) * RotationYMatrix(diffy); 
     944                                        tm = RotationYMatrix(diffx); 
    900945                                } 
    901946                                break; 
     
    911956                } 
    912957        } 
    913 #endif 
    914958        else 
    915959        { 
     
    10431087                        break; 
    10441088 
    1045                 if (sscanf(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 
     1089                if (sscanf_s(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 
    10461090                        text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 
    10471091                        text = QInputDialog::getText(this, 
     
    10531097                        if (!ok) 
    10541098                                break; 
    1055                         if (sscanf(text.toAscii(), "%f %f %f", &mViewDirection.x, 
     1099                        if (sscanf_s(text.toAscii(), "%f %f %f", &mViewDirection.x, 
    10561100                                &mViewDirection.y, &mViewDirection.z) == 3) { 
    10571101                                        updateGL(); 
     
    10751119                                                                           QWidget * parent, 
    10761120                                                                           const QGLWidget * shareWidget, 
    1077                                                                            Qt::WFlags f 
    1078                                                                            ) 
    1079                                                                            : 
    1080 GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f) 
     1121                                                                           Qt::WFlags f): 
     1122GlRendererWidget(sceneGraph, viewcells, tree),  
     1123QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f) 
    10811124{ 
    10821125        mPreprocessorThread = NULL; 
     
    11391182        mPlacer = new ObjectPlacer(); 
    11401183 
    1141         //mPendingDynamicObject = NULL; 
     1184        mCurrentDynamicObjectIdx = -1; 
     1185 
     1186        //mExportFrameBuffer = true; 
     1187        mExportFrameBuffer = false; 
    11421188 
    11431189        SetSceneCut(1000); 
     
    12001246        connect(mControlWidget, SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool))); 
    12011247 
    1202 #if 0 
     1248#if 1 
    12031249        connect(mControlWidget, SIGNAL(SetTranslation(bool)), this, SLOT(SetTranslation(bool))); 
    12041250        connect(mControlWidget, SIGNAL(SetRotation(bool)), this, SLOT(SetRotation(bool))); 
     
    12061252#endif 
    12071253        connect(mControlWidget, SIGNAL(UpdateDynamicObjects()), this, SLOT(UpdateDynamicObjects())); 
     1254        connect(mControlWidget, SIGNAL(DeleteDynamicObject()), this, SLOT(DeleteDynamicObject())); 
    12081255 
    12091256        setWindowTitle("PVS Visualization"); 
    12101257 
    12111258        // setting the main window size here 
    1212         resize(800, 600); 
    1213         //resize(640, 400); 
     1259        //resize(800, 600); 
     1260        resize(640, 480); 
    12141261         
    12151262        mControlWidget->show(); 
     
    14281475                filter = mViewCellsManager->GetMaxFilterSize(); 
    14291476 
    1430         glColor3f(0.0f, 0.0f, 1.0f); 
    1431  
    1432 #if REMOVE_TEMPORARY 
     1477#if 0 //REMOVE_TEMPORARY 
    14331478        s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 
    14341479                mFrame, 
     
    14471492                filter, 
    14481493                mPvsSize, 
    1449                 mRenderError*100.0f); 
     1494                mRenderError * 100.0f); 
    14501495 
    14511496        renderText(20, 40, s); 
    14521497#endif 
    14531498 
    1454         QFont font40; font40.setPointSize(30); 
     1499        glDisable(GL_LIGHTING); 
     1500        //qglColor(QColor(0, 255, 0)); 
     1501        glColor3f(0, 1, 0); 
     1502        QFont font40; font40.setPointSize(25); 
    14551503        //s.sprintf("PVS: %04d", mPvsSize); 
    14561504        //renderText(20, 40, s, font40); 
     
    14611509        //renderText(290, 70, s, font40); 
    14621510 
    1463         s.sprintf("PVS TRI: %07d", (int)mCurrentPvsCost); 
    1464         renderText(290, 70, s, font40); 
     1511        s.sprintf("PVS TRI: %08d", (int)mCurrentPvsCost); 
    14651512        //renderText(290, 70, s, font40); 
     1513        renderText(325, 40, s, font40); 
     1514        s.sprintf("error: %3.3f %", mRenderError * 100.0f); 
     1515        renderText(20, 40, s, font40); 
     1516 
     1517        //renderText(290, 70, s, font40); 
     1518        glEnable(GL_LIGHTING); 
    14661519 
    14671520} 
     
    18091862                        importance = rcCost / maxRcCost; 
    18101863                } 
    1811 if (importance > 1.0f) importance = 1.0f; 
     1864                 
     1865                if (importance > 1.0f) importance = 1.0f; 
    18121866                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    18131867                c = RainbowColorMapping(importance); 
     
    19622016        connect(button, SIGNAL(clicked()), SIGNAL(UpdateDynamicObjects())); 
    19632017         
     2018        button = new QPushButton("Delete", groupBox); 
     2019        vbox2->addWidget(button); 
     2020        connect(button, SIGNAL(clicked()), SIGNAL(DeleteDynamicObject())); 
    19642021         
    19652022        groupBox->setLayout(vbox2); 
     
    25382595        // set up the pbuffer context 
    25392596        mRenderBuffer->makeCurrent(); 
    2540          
    25412597        // generate a texture that has the same size/format as the pbuffer 
    25422598        dynamicTexture = mRenderBuffer->generateDynamicTexture(); 
    2543  
    25442599        // bind the dynamic texture to the pbuffer - this is a no-op under X11 
    25452600        mRenderBuffer->bindToDynamicTexture(dynamicTexture); 
     
    26272682        { 
    26282683                cout << "replaying " << (int)sViewPointsList.size() << " view points " << endl; 
    2629  
     2684                 
    26302685                mReplayMode = true; 
     2686                 
     2687                if (mExportFrameBuffer) 
     2688                        GetPreprocessor()->mSynchronize = true; 
     2689 
     2690                sCurrentSamples = GetPreprocessor()->mCurrentSamples; 
    26312691                sViewPointsListIt = sViewPointsList.begin(); 
    26322692        } 
     
    26622722int QtGlRendererWidget::FindDynamicObject(float x, float y)  
    26632723{  
     2724 
     2725        if (GetPreprocessor()->mDynamicObjects.empty()) 
     2726                return -1; 
     2727 
    26642728        makeCurrent(); 
    2665         // we need to lock the rendering context  
    2666         //glw.lockGLContext();  
    26672729         
    26682730        // this is the same as in every OpenGL picking example  
     
    27152777        glPopMatrix(); 
    27162778 
    2717         int hits; 
     2779        int hits = glRenderMode(GL_RENDER); 
     2780 
    27182781        // finally release the rendering context again  
    2719         if ((hits = glRenderMode(GL_RENDER)) < 0)  
     2782        if (!hits)  
    27202783        {  
    27212784                cout << "no object picked" << endl; 
    2722                 //glw.unlockGLContext();  
    27232785                return -1;  
    27242786        }  
    27252787 
    2726  
    27272788        //processHits(hits, buffer); 
    2728  
    2729          
    2730         //glw.unlockGLContext();  
    27312789         
    27322790        // Each hit takes 4 items in the buffer.  
     
    27432801 
    27442802 
    2745 } 
     2803void QtGlRendererWidget::DeleteDynamicObject() 
     2804{ 
     2805        Preprocessor *p = GetPreprocessor(); 
     2806 
     2807        if ((mCurrentDynamicObjectIdx < 0) || 
     2808                (mCurrentDynamicObjectIdx >= p->mDynamicObjects.size())) 
     2809                return; 
     2810 
     2811        cout << "deleting object" << endl; 
     2812 
     2813        SceneGraphLeaf *l = p->mDynamicObjects[mCurrentDynamicObjectIdx]; 
     2814 
     2815        // tell the preprocessor that an object was deleted 
     2816        p->ObjectRemoved(l); 
     2817 
     2818        swap(p->mDynamicObjects[mCurrentDynamicObjectIdx], p->mDynamicObjects.back()); 
     2819        p->mDynamicObjects.pop_back(); 
     2820 
     2821        delete l; 
     2822 
     2823        mCurrentDynamicObjectIdx = -1; 
     2824}        
     2825 
     2826} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2704 r2709  
    7272        void RenderPvs(const ObjectPvs &pvs); 
    7373 
    74         float GetPixelError(int &pvsSize); 
     74        float GetPixelError(int &pvsSize, int pass); 
    7575 
    7676        int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
     
    114114  void ReplayViewPoints(); 
    115115  void UpdateDynamicObjects(); 
     116  void DeleteDynamicObject(); 
    116117  void ComputeVisibility(); 
    117118  void StopComputation(); 
     
    246247        ObjectPlacer *mPlacer; 
    247248 
    248         //DynamicObjectsContainer mPendingDynamicObjects; 
     249        int mCurrentDynamicObjectIdx; 
     250 
     251        bool mExportFrameBuffer; 
     252 
    249253        DynamicObjectsContainer mDynamicPvsObjects; 
    250254 
     
    334338        void ReplayViewPoints(); 
    335339        void UpdateDynamicObjects(); 
     340        void DeleteDynamicObject(); 
    336341        void UpdateAllPvs(); 
    337342        void ComputeVisibility(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2705 r2709  
    5252        // set viewer size here 
    5353        return QSize(512, 320); 
    54  
    5554        //return QSize(512, 384); 
    5655        //return QSize(640, 480); 
     
    6867 
    6968        GLfloat light_ambient[]  = {0.2f, 0.2f, 0.2f, 1.0f}; 
    70         GLfloat light_diffuse[]  = {0.4f, 0.4f, 0.4f, 1.0f}; 
     69        GLfloat light_diffuse[]  = {0.6f, 0.6f, 0.6f, 1.0f}; 
    7170        GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 
    7271 
     
    8281        glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
    8382 
    84         // default material 
    85         /*glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); 
    86         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); 
    87         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); 
    88         glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); 
    89 */ 
    9083        // a light 
    9184        glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
Note: See TracChangeset for help on using the changeset viewer.