Ignore:
Timestamp:
01/17/08 21:46:32 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2604 r2609  
    369369        glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
    370370        glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
    371 } 
    372  
    373  
    374 void QtGlRendererWidget::_UpdatePvsIndices() 
     371 
     372        // handle dynamic objects 
     373        DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 
     374 
     375        for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 
     376        { 
     377                RenderIntersectable(*dit); 
     378        } 
     379} 
     380 
     381 
     382void QtGlRendererWidget::PreparePvs() 
    375383{ 
    376384        int indexBufferSize = 0; 
     
    381389        mPvsSize = mPvsCache.mPvs.GetSize(); 
    382390 
     391        mDynamicObjects.clear(); 
     392 
    383393        ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    384394 
     
    386396        { 
    387397                Intersectable *obj = it.Next(); 
    388                 KdNode *node = static_cast<KdIntersectable *>(obj)->GetItem(); 
    389  
    390                 _UpdatePvsIndices(node, indexBufferSize); 
     398                switch (obj->Type()) 
     399                { 
     400                case Intersectable::KD_INTERSECTABLE: 
     401                        { 
     402                                KdNode *node = static_cast<KdIntersectable *>(obj)->GetItem(); 
     403                                _UpdatePvsIndices(node, indexBufferSize); 
     404                        } 
     405                        break; 
     406                case Intersectable::TRANSFORMED_MESH_INSTANCE: 
     407                        mDynamicObjects.push_back(static_cast<TransformedMeshInstance *>(obj)); 
     408                        break; 
     409                default: 
     410                        cerr << "PreparePvs: type " << Intersectable::GetTypeName(obj) << " not handled yet" << endl; 
     411                } 
    391412        } 
    392413 
     
    421442                                static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
    422443 
    423                         // check if already rendered 
    424                         /*if (!obj->Mailed()) 
    425                         { 
    426                                 obj->Mail(); 
    427  
    428                                 mIndices[indexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0; 
    429                                 mIndices[indexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1; 
    430                                 mIndices[indexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2; 
    431  
    432                                 indexBufferSize += 3; 
    433                         }*/ 
    434444                        if (obj->mRenderedFrame != mCurrentFrame) 
    435445                        { 
     
    481491                        if (mUseSpatialFilter)  
    482492                        { 
    483                                 //ObjectPvs pvs; 
    484  
    485493                                //mMutex.lock(); 
    486494                                // mSpatialFilter size is in range 0.001 - 0.1 
     
    500508 
    501509                        /// update the indices for rendering 
    502                         _UpdatePvsIndices(); 
     510                        PreparePvs(); 
    503511 
    504512                        emit PvsUpdated(); 
    505513                } 
    506514 
    507                 //Intersectable::NewMail(); 
    508                 PvsData pvsData; 
    509515 
    510516                // Render PVS 
     
    519525                { 
    520526                        if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject) 
    521                         { 
    522527                                _RenderPvs(); 
    523                         } 
    524528                        else 
    525                         { 
    526                                 mPvsSize = mPvsCache.mPvs.GetSize(); 
    527  
    528                                 ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    529  
    530                                 while (it.HasMoreEntries()) 
    531                                 { 
    532                                         Intersectable *object = it.Next(pvsData); 
    533  
    534                                         RgbColor color; 
    535  
    536                                         //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
    537                                         // glColor3f(visibility, 0.0f, 0.0f); 
    538                                         //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
    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  
    555                                         glColor3f(color.r, color.g, color.b); 
    556  
    557                                         mUseForcedColors = true; 
    558                                         RenderIntersectable(object); 
    559                                         mUseForcedColors = false; 
    560                                 } 
    561                         } 
     529                                _RenderColoredPvs(); 
    562530                } 
    563531 
     
    587555                RenderScene(); 
    588556        } 
    589  
    590         //DisableDrawArrays(); 
    591         //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    592557} 
    593558 
     
    673638{ 
    674639        float MOVE_SENSITIVITY = Magnitude(mSceneGraph->GetBox().Diagonal())*1e-3; 
    675         float TURN_SENSITIVITY=0.1f; 
    676         float TILT_SENSITIVITY=32.0 ; 
    677         float TURN_ANGLE= M_PI/36.0 ; 
     640        float TURN_SENSITIVITY = 0.1f; 
     641        float TILT_SENSITIVITY = 32.0 ; 
     642        float TURN_ANGLE= M_PI  /36.0 ; 
    678643 
    679644        int x = e->pos().x(); 
     
    685650        if (e->modifiers() & Qt::ControlModifier)  
    686651        { 
    687                 mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY/2.0; 
    688                 mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY/2.0; 
     652                mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY / 2.0; 
     653                mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 
    689654        }  
    690655        else  
     
    930895        connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this,     SLOT(SetRandomViewPoint())); 
    931896        connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void))); 
     897        connect(mControlWidget, SIGNAL(LoadObject(void)), this, SLOT(LoadObject(void))); 
    932898 
    933899        connect(mControlWidget, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int))); 
     
    1029995} 
    1030996 
     997 
     998void QtGlRendererWidget::LoadObject() 
     999{ 
     1000        string filename("../data/bunny.bn"); 
     1001         
     1002        cout << "Loading model << " << filename << endl; 
     1003 
     1004        if (mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename)) 
     1005                cout << "Loading finished" << endl; 
     1006        else 
     1007                cerr << "Loading failed" << endl; 
     1008 
     1009    updateGL(); 
     1010} 
     1011 
    10311012void 
    10321013QtGlRendererWidget::RenderRenderCost() 
     
    11761157         
    11771158        QFont font40; font40.setPointSize(30); 
    1178         s.sprintf("pvs:%04d", mPvsSize); 
     1159        s.sprintf("PVS: %04d", mPvsSize); 
    11791160        renderText(20, 40, s, font40); 
    11801161} 
     
    18621843        QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 
    18631844        vh->addWidget(groupBox2, 0, 0); 
    1864  
    18651845         
    18661846        QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox); 
     
    18771857 
    18781858        vbox->resize(800,150); 
    1879  
    18801859 
    18811860        vbox = new QGroupBox("Rendering", this); 
     
    20342013        connect(button, SIGNAL(clicked()), SIGNAL(StoreStatistics())); 
    20352014 
     2015        button = new QPushButton("Load object", vbox); 
     2016        vbox->layout()->addWidget(button); 
     2017        connect(button, SIGNAL(clicked()), SIGNAL(LoadObject())); 
     2018 
    20362019        /*cb = new QCheckBox("Stats", vbox); 
    20372020        vbox->layout()->addWidget(cb); 
    20382021        cb->setChecked(false); 
    2039         connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics())); 
    2040 */ 
     2022        connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));*/ 
    20412023        if (0)  
    20422024        { 
     
    22072189 
    22082190 
    2209 } 
     2191void QtGlRendererWidget::_RenderColoredPvs() 
     2192{ 
     2193        // note: could be done more efficiently using color buffers 
     2194        mPvsSize = mPvsCache.mPvs.GetSize(); 
     2195 
     2196        ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
     2197 
     2198        PvsData pvsData; 
     2199 
     2200        while (it.HasMoreEntries()) 
     2201        { 
     2202                Intersectable *object = it.Next(pvsData); 
     2203 
     2204                RgbColor color; 
     2205 
     2206                //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
     2207                // glColor3f(visibility, 0.0f, 0.0f); 
     2208                //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
     2209                if (mUseRandomColorPerPvsObject) 
     2210                { 
     2211                        KdIntersectable *kdint = static_cast<KdIntersectable *>(object); 
     2212 
     2213                        if (kdint->mGenericIdx == -1) 
     2214                        { 
     2215                                kdint->mGenericIdx = (int)mColors.size(); 
     2216                                mColors.push_back(RandomColor()); 
     2217                        } 
     2218                        color = mColors[kdint->mGenericIdx]; 
     2219                }  
     2220                else 
     2221                { 
     2222                        color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1)); 
     2223                } 
     2224 
     2225                glColor3f(color.r, color.g, color.b); 
     2226 
     2227                mUseForcedColors = true; 
     2228                RenderIntersectable(object); 
     2229                mUseForcedColors = false; 
     2230        } 
     2231} 
     2232 
     2233} 
Note: See TracChangeset for help on using the changeset viewer.