- Timestamp:
- 01/16/08 23:32:51 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2601 r2604 47 47 const static int SAMPLES_INCR = 2000000; 48 48 49 50 49 51 static inline bool ilt(Intersectable *obj1, Intersectable *obj2) 50 52 { … … 271 273 GlRenderer::InitGL(); 272 274 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}; 284 287 285 288 … … 515 518 else 516 519 { 517 if (!mRenderVisibilityEstimates )520 if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject) 518 521 { 519 522 _RenderPvs(); … … 529 532 Intersectable *object = it.Next(pvsData); 530 533 534 RgbColor color; 535 531 536 //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 532 537 // glColor3f(visibility, 0.0f, 0.0f); 533 538 //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 535 555 glColor3f(color.r, color.g, color.b); 536 556 … … 562 582 else 563 583 { 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); 567 587 RenderScene(); 568 588 } … … 772 792 QtGlRendererWidget::keyPressEvent ( QKeyEvent * e ) 773 793 { 774 switch (e->key()) { 794 switch (e->key()) 795 { 796 case Qt::Key_E: 797 mRenderErrors = !mRenderErrors; 798 updateGL(); 799 break; 800 case Qt::Key_R: 801 mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject;; 802 updateGL(); 803 break; 775 804 case Qt::Key_T: 776 805 mTopView = !mTopView; … … 819 848 } 820 849 default: 850 cerr << "unknown key" << endl; 821 851 e->ignore(); 822 852 break; … … 848 878 mRenderVisibilityEstimates = false; 849 879 880 mUseRandomColorPerPvsObject = false; 881 850 882 mHideByCost = false; 851 883 mUseTransparency = false; … … 874 906 mShowPiercingRays = false; 875 907 mShowWeightedRays = false; 876 mShowWeightedCost = false; 908 mUseStandardColors = false; 909 mShowWeightedCost = true; 877 910 878 911 mShowDistanceWeightedPvs = true; … … 922 955 connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool))); 923 956 connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool))); 957 connect(mControlWidget, SIGNAL(SetShowWireFrame(bool)), this, SLOT(SetShowWireFrame(bool))); 924 958 connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool))); 925 959 connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool))); … … 1108 1142 1109 1143 QString s; 1144 1110 1145 int vc = 0; 1111 1146 if (mViewCellsManager) … … 1116 1151 filter = mViewCellsManager->GetMaxFilterSize(); 1117 1152 1118 glColor3f(1.0f,1.0f,1.0f); 1119 1153 glColor3f(0.0f, 0.0f, 1.0f); 1154 1155 #if REMOVE_TEMPORARY 1120 1156 s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 1121 1157 mFrame, … … 1128 1164 ); 1129 1165 1130 renderText(20, 20,s);1166 renderText(20, 20, s); 1131 1167 1132 1168 s.sprintf("viewcells:%04d filter:%04d pvs:%04d error:%5.5f %", … … 1136 1172 mRenderError*100.0f); 1137 1173 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); 1144 1180 } 1145 1181 … … 1361 1397 int i; 1362 1398 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 1363 1426 // normal rendering 1364 if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison) 1427 //if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison) 1428 if (mUseStandardColors) 1365 1429 { 1366 1430 for (i = 0; i < viewcells.size(); ++ i) … … 1369 1433 RgbColor c; 1370 1434 1371 if (!mShowPvsSizes && !mShowPiercingRays) 1372 { 1373 mWireFrame = true; 1374 c = vc->GetColor(); 1375 } 1376 1435 //if (!mShowPvsSizes && !mShowPiercingRays) 1436 c = vc->GetColor(); 1437 1377 1438 glColor3f(c.r, c.g, c.b); 1378 1439 … … 1385 1446 else // using specialised colors 1386 1447 { 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 1411 1449 1412 1450 if (!mShowComparison) … … 1499 1537 if (viewcells.size() > compareInfo.size()) 1500 1538 { 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; 1502 1540 return; 1503 1541 } … … 1556 1594 QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5; 1557 1595 1558 rb1 = new QRadioButton(" wireframe", parent);1596 rb1 = new QRadioButton("random colors", parent); 1559 1597 rb1->setText("wireframe"); 1560 1598 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool))); … … 1588 1626 vbox2->addWidget(rb5); 1589 1627 1590 rb 1->setChecked(true);1628 rb5->setChecked(true); 1591 1629 1592 1630 vbox2->addStretch(1); … … 1710 1748 vbox->setLayout(vl); 1711 1749 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"); 1713 1757 vbox->layout()->addWidget(label); 1714 1758 1715 QSlider *slider = new QSlider(Qt::Horizontal, vbox);1759 slider = new QSlider(Qt::Horizontal, vbox); 1716 1760 vl->addWidget(slider); 1717 1761 slider->show(); … … 1739 1783 ////////////////////////////////////////7 1740 1784 1741 1742 QPushButton *button = new QPushButton("Update all PVSs", vbox); 1785 button = new QPushButton("Update all PVSs", vbox); 1743 1786 vbox->layout()->addWidget(button); 1744 1787 connect(button, SIGNAL(clicked()), SLOT(UpdateAllPvs())); 1745 1746 1788 1747 1789 ////////////////////////////////////////77777 … … 1758 1800 1759 1801 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetVisibilityFilterSize(int))); 1802 1803 #endif 1760 1804 1761 1805 … … 1923 1967 ////////////////////////////// 1924 1968 1925 1969 #if REMOVE_TEMPORARY 1926 1970 cb = new QCheckBox("Cut scene", vbox); 1927 1971 vbox->layout()->addWidget(cb); 1928 1972 cb->setChecked(false); 1929 1973 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutScene(bool))); 1930 1974 #endif 1931 1975 cb = new QCheckBox("Render boxes", vbox); 1932 1976 vbox->layout()->addWidget(cb); … … 1945 1989 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 1946 1990 1947 1948 1991 bool tmp; 1992 #if REMOVE_TEMPORARY 1949 1993 1950 1994 cb = new QCheckBox("Use filter", vbox); … … 1953 1997 cb->setChecked(tmp); 1954 1998 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool))); 1955 1999 #endif 1956 2000 1957 2001 cb = new QCheckBox("Use spatial filter", vbox);
Note: See TracChangeset
for help on using the changeset viewer.