- Timestamp:
- 01/17/08 21:46:32 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2604 r2609 369 369 glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 370 370 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 382 void QtGlRendererWidget::PreparePvs() 375 383 { 376 384 int indexBufferSize = 0; … … 381 389 mPvsSize = mPvsCache.mPvs.GetSize(); 382 390 391 mDynamicObjects.clear(); 392 383 393 ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 384 394 … … 386 396 { 387 397 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 } 391 412 } 392 413 … … 421 442 static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 422 443 423 // check if already rendered424 /*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 }*/434 444 if (obj->mRenderedFrame != mCurrentFrame) 435 445 { … … 481 491 if (mUseSpatialFilter) 482 492 { 483 //ObjectPvs pvs;484 485 493 //mMutex.lock(); 486 494 // mSpatialFilter size is in range 0.001 - 0.1 … … 500 508 501 509 /// update the indices for rendering 502 _UpdatePvsIndices();510 PreparePvs(); 503 511 504 512 emit PvsUpdated(); 505 513 } 506 514 507 //Intersectable::NewMail();508 PvsData pvsData;509 515 510 516 // Render PVS … … 519 525 { 520 526 if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject) 521 {522 527 _RenderPvs(); 523 }524 528 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(); 562 530 } 563 531 … … 587 555 RenderScene(); 588 556 } 589 590 //DisableDrawArrays();591 //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);592 557 } 593 558 … … 673 638 { 674 639 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 ; 678 643 679 644 int x = e->pos().x(); … … 685 650 if (e->modifiers() & Qt::ControlModifier) 686 651 { 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; 689 654 } 690 655 else … … 930 895 connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this, SLOT(SetRandomViewPoint())); 931 896 connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void))); 897 connect(mControlWidget, SIGNAL(LoadObject(void)), this, SLOT(LoadObject(void))); 932 898 933 899 connect(mControlWidget, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int))); … … 1029 995 } 1030 996 997 998 void 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 1031 1012 void 1032 1013 QtGlRendererWidget::RenderRenderCost() … … 1176 1157 1177 1158 QFont font40; font40.setPointSize(30); 1178 s.sprintf(" pvs:%04d", mPvsSize);1159 s.sprintf("PVS: %04d", mPvsSize); 1179 1160 renderText(20, 40, s, font40); 1180 1161 } … … 1862 1843 QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 1863 1844 vh->addWidget(groupBox2, 0, 0); 1864 1865 1845 1866 1846 QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox); … … 1877 1857 1878 1858 vbox->resize(800,150); 1879 1880 1859 1881 1860 vbox = new QGroupBox("Rendering", this); … … 2034 2013 connect(button, SIGNAL(clicked()), SIGNAL(StoreStatistics())); 2035 2014 2015 button = new QPushButton("Load object", vbox); 2016 vbox->layout()->addWidget(button); 2017 connect(button, SIGNAL(clicked()), SIGNAL(LoadObject())); 2018 2036 2019 /*cb = new QCheckBox("Stats", vbox); 2037 2020 vbox->layout()->addWidget(cb); 2038 2021 cb->setChecked(false); 2039 connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics())); 2040 */ 2022 connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));*/ 2041 2023 if (0) 2042 2024 { … … 2207 2189 2208 2190 2209 } 2191 void 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.