Ignore:
Timestamp:
12/17/07 18:39:12 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2567 r2569  
    845845        mUseTransparency = false; 
    846846 
    847         mTransferFunction = 0.2f; 
     847        mTransferFunction = 1.0f; 
    848848        mIndexBufferSize = 0; 
    849849 
     
    866866        mShowPiercingRays = false; 
    867867        mShowWeightedRays = false; 
     868        mShowWeightedCost = false; 
     869 
     870        mShowDistanceWeightedPvs = true; 
     871        mShowDistanceWeightedTriangles = false; 
     872        mShowWeightedTriangles = false; 
    868873 
    869874        mSpatialFilterSize = 0.01; 
     
    909914        connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool))); 
    910915        connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool))); 
     916        connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool))); 
     917 
     918        connect(mControlWidget, SIGNAL(SetShowDistanceWeightedTriangles(bool)), this, SLOT(SetShowDistanceWeightedTriangles(bool))); 
     919        connect(mControlWidget, SIGNAL(SetShowDistanceWeightedPvs(bool)), this, SLOT(SetShowDistanceWeightedPvs(bool))); 
     920        connect(mControlWidget, SIGNAL(SetShowWeightedTriangles(bool)), this, SLOT(SetShowWeightedTriangles(bool))); 
    911921 
    912922        connect(mControlWidget, 
     
    11541164{ 
    11551165        mHidingCost = (float)number / 1000.0f; 
    1156         //cout << "hiding cost " << mHidingCost << endl; 
    11571166} 
    11581167 
     
    11611170QtGlRendererWidget::SetTopDistance(int number) 
    11621171{ 
    1163         mTopDistance = number/1000.0f; 
     1172        mTopDistance = number / 1000.0f; 
    11641173        updateGL(); 
    11651174} 
    11661175 
    1167 void 
    1168 QtGlRendererWidget::SetTransparency(int number) 
    1169 { 
    1170         mTransparency = number/1000.0f; 
     1176void QtGlRendererWidget::SetTransparency(int number) 
     1177{ 
     1178        mTransparency = number / 1000.0f; 
    11711179        updateGL(); 
    11721180} 
     1181 
     1182 
     1183float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc) 
     1184{ 
     1185        ObjectPvs basePvs; 
     1186         
     1187        basePvs = vc->CopyPvs(); 
     1188        ObjectPvsIterator pit = basePvs.GetIterator(); 
     1189 
     1190        float renderCost = 0; 
     1191 
     1192        //cout << "cost vis: " << mShowDistanceWeightedPvs << " " << " " << mShowDistanceWeightedTriangles << " " << mShowWeightedTriangles << endl; 
     1193         
     1194        // first mark all objects from this pvs 
     1195        while (pit.HasMoreEntries())     
     1196        { 
     1197                if (mShowDistanceWeightedPvs) 
     1198                { 
     1199                        KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 
     1200                        const AxisAlignedBox3 box = kdObj->GetBox(); 
     1201 
     1202                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
     1203                        renderCost += 1.0f / dist; 
     1204                } 
     1205                else if (mShowDistanceWeightedTriangles) 
     1206                { 
     1207                        KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 
     1208                        const AxisAlignedBox3 box = kdObj->GetBox(); 
     1209 
     1210                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
     1211                        renderCost += kdObj->ComputeNumTriangles() / dist; 
     1212                } 
     1213                else //if (mShowWeightedTriangles) 
     1214                { 
     1215                        KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 
     1216                        renderCost += kdObj->ComputeNumTriangles(); 
     1217                } 
     1218                //if (pit.Next()->Mail(); 
     1219        } 
     1220 
     1221        return renderCost; 
     1222} 
     1223 
    11731224 
    11741225void 
     
    11981249 
    11991250        ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 
     1251         
    12001252        int maxPvs = -1; 
    12011253        int maxPiercingRays = 1; // not zero for savety 
    12021254        float maxRelativeRays = Limits::Small; // not zero for savety 
     1255        float maxRcCost = Limits::Small; 
    12031256 
    12041257        for (i = 0; i < viewcells.size(); ++ i)  
     
    12061259                ViewCell *vc = viewcells[i]; 
    12071260 
    1208                 //const int p = vc->GetPvs().CountObjectsInPvs(); 
    1209                 const int p = vc->GetPvs().GetSize(); 
    1210                 if (p > maxPvs) 
    1211                         maxPvs = p; 
    1212  
    1213                 const int piercingRays = vc->GetNumPiercingRays(); 
    1214                  
    1215                 if (piercingRays > maxPiercingRays) 
    1216                         maxPiercingRays = piercingRays; 
    1217  
    1218                 const float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 
    1219  
    1220                 if ((float)piercingRays / relativeArea > maxRelativeRays) 
    1221                         maxRelativeRays = (float)piercingRays / relativeArea; 
    1222         } 
    1223  
    1224         if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays) 
     1261                if (mShowPvsSizes) // pv 
     1262                { 
     1263                        //const int p = vc->GetPvs().CountObjectsInPvs(); 
     1264                        const int p = vc->GetPvs().GetSize(); 
     1265                        if (p > maxPvs) 
     1266                                maxPvs = p; 
     1267                } 
     1268                else if (mShowPiercingRays) // relative number of rays 
     1269                { 
     1270                        const int piercingRays = vc->GetNumPiercingRays(); 
     1271 
     1272                        if (piercingRays > maxPiercingRays) 
     1273                                maxPiercingRays = piercingRays; 
     1274                }  
     1275                else if (mShowWeightedRays) 
     1276                { 
     1277                        const int piercingRays = vc->GetNumPiercingRays(); 
     1278 
     1279                        const float relativeArea =  
     1280                                vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 
     1281 
     1282                        if ((float)piercingRays / relativeArea > maxRelativeRays) 
     1283                                maxRelativeRays = (float)piercingRays / relativeArea; 
     1284                } 
     1285                else if (mShowWeightedCost) 
     1286                { 
     1287                        const float rcCost = ComputeRenderCost(vc); 
     1288                        mViewCellsManager->UpdateScalarPvsCost(vc, rcCost); 
     1289 
     1290                        if (rcCost > maxRcCost) 
     1291                                maxRcCost = rcCost; 
     1292                } 
     1293        } 
     1294 
     1295        if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost) 
    12251296        { 
    12261297                for (i = 0; i < viewcells.size(); ++ i)  
     
    12371308                        glColor3f(c.r, c.g, c.b); 
    12381309 
    1239                         if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))  
     1310                        if (!mHideByCost || (mHidingCost < (vc->GetNumPiercingRays() / (float)maxPiercingRays)))  
    12401311                        { 
    12411312                RenderViewCell(vc); 
     
    12691340 
    12701341                                const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center()); 
    1271  
    12721342                                vc->SetDistance(dist); 
    12731343                        } 
     
    12851355                        if (mShowPiercingRays) 
    12861356                        { 
    1287                                 // importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    12881357                                importance = mTransferFunction * 
    12891358                                        ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 
     
    12911360                        else if (mShowWeightedRays) // relative number of rays 
    12921361                        { 
    1293                                 // importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    12941362                                float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 
    12951363 
     
    13011369                        else if (mShowPvsSizes) // pvs size 
    13021370                        { 
    1303                                 //importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    13041371                                importance = mTransferFunction * 
    13051372                                        ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
    13061373                        } // weighted render cost 
    1307                 /*      else 
     1374                        else if (mShowWeightedCost) 
    13081375                        { 
    1309                                 ObjectPvs basePvs = viewCell->GetPvs(); 
    1310                                 ObjectPvsIterator pit = basePvs.GetIterator(); 
    1311  
    1312                                 // first mark all objects from this pvs 
    1313                                 while (pit.HasMoreEntries())     
    1314                                 { 
    1315                                         if (pit.Next()->Mail(); 
    1316                                 } 
    1317                         }*/ 
     1376                                const float rcCost = mTransferFunction * vc->GetTrianglesInPvs(); 
     1377                                importance = rcCost / maxRcCost; 
     1378                        } 
    13181379 
    13191380                        // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    1320                         c = RainbowColorMapping(5.0f * importance); 
     1381                        c = RainbowColorMapping(importance); 
    13211382 
    13221383                        glColor4f(c.r, c.g, c.b, 1.0f - mTransparency); 
     
    13621423} 
    13631424 
     1425 
     1426QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent) 
     1427{ 
     1428        QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5; 
     1429         
     1430        // Create a check box to be in the group box 
     1431        rb1 = new QRadioButton("piercing rays", parent); 
     1432        rb1->setText("piercing rays"); 
     1433        //vl->addWidget(rb1); 
     1434        connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 
     1435 
     1436        rb2 = new QRadioButton("pvs size", parent); 
     1437        rb2->setText("pvs size"); 
     1438        connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 
     1439 
     1440        rb3 = new QRadioButton("wireframe", parent); 
     1441        rb3->setText("wireframe"); 
     1442         
     1443        rb4 = new QRadioButton("weighted rays", parent); 
     1444        rb4->setText("weighted rays"); 
     1445        connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool))); 
     1446         
     1447        rb5 = new QRadioButton("pvs cost", parent); 
     1448        rb5->setText("pvs cost"); 
     1449        connect(rb5, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedCost(bool))); 
     1450 
     1451        QGroupBox *groupBox = new QGroupBox("Visualization options"); 
     1452 
     1453        QVBoxLayout *vbox2 = new QVBoxLayout; 
     1454     
     1455        vbox2->addWidget(rb3); 
     1456        vbox2->addWidget(rb1); 
     1457        vbox2->addWidget(rb2); 
     1458        vbox2->addWidget(rb4); 
     1459        vbox2->addWidget(rb5); 
     1460         
     1461        rb3->setChecked(true); 
     1462 
     1463        vbox2->addStretch(1); 
     1464        groupBox->setLayout(vbox2); 
     1465 
     1466        return groupBox; 
     1467} 
     1468 
     1469 
     1470 
     1471QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent) 
     1472{ 
     1473        QRadioButton *rb1, *rb2, *rb3; 
     1474         
     1475        // Create a check box to be in the group box 
     1476        rb1 = new QRadioButton("triangles", parent); 
     1477        rb1->setText("triangles"); 
     1478        //vl->addWidget(rb1); 
     1479        connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedTriangles(bool))); 
     1480 
     1481        rb2 = new QRadioButton("distance weighted pvs", parent); 
     1482        rb2->setText("distance weighted"); 
     1483        connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedPvs(bool))); 
     1484 
     1485        rb3 = new QRadioButton("distance weighted triangles", parent); 
     1486        rb3->setText("distance weighted triangles"); 
     1487        connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedTriangles(bool))); 
     1488 
     1489        QGroupBox *groupBox = new QGroupBox("Render cost options"); 
     1490 
     1491        QVBoxLayout *vbox2 = new QVBoxLayout; 
     1492     
     1493        vbox2->addWidget(rb1); 
     1494        vbox2->addWidget(rb2); 
     1495        vbox2->addWidget(rb3); 
     1496         
     1497        rb2->setChecked(true); 
     1498 
     1499        vbox2->addStretch(1); 
     1500        groupBox->setLayout(vbox2); 
     1501 
     1502        return groupBox; 
     1503} 
    13641504 
    13651505QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f): 
     
    14591599        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRenderCost(bool))); 
    14601600 
    1461         /*cb = new QCheckBox("Show render cost", hbox); 
    1462         hlayout->addWidget(cb); 
    1463         cb->setChecked(false); 
    1464         connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 
    1465         */ 
    1466  
    14671601        cb = new QCheckBox("Show rays", hbox); 
    14681602        hlayout->addWidget(cb); 
     
    14701604        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool))); 
    14711605 
    1472         /*cb = new QCheckBox("Show piercing rays", hbox); 
    1473         hlayout->addWidget(cb); 
    1474         cb->setChecked(false); 
    1475         connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 
    1476         */ 
    1477  
    1478  
    1479         QRadioButton *rb1, *rb2, *rb3, *rb4; 
    1480  
    1481         // Create a check box to be in the group box 
    1482          
    1483         rb1 = new QRadioButton("piercing rays", hbox); 
    1484         rb1->setText("piercing rays"); 
    1485         //vl->addWidget(rb1); 
    1486         connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 
    1487  
    1488         rb2 = new QRadioButton("render cost", hbox); 
    1489         rb2->setText("render cost"); 
    1490         //vl->addWidget(rb2); 
    1491         connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 
    1492  
    1493         rb3 = new QRadioButton("wireframe", hbox); 
    1494         rb3->setText("wireframe"); 
    1495          
    1496         rb4 = new QRadioButton("weighted rays", hbox); 
    1497         rb4->setText("weighted rays"); 
    1498         connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool))); 
    1499  
    1500         //vl->addWidget(rb2); 
    1501         //connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 
    1502  
    1503         QGroupBox *groupBox = new QGroupBox("Visualization options"); 
    1504  
    1505         QVBoxLayout *vbox2 = new QVBoxLayout; 
    1506      
    1507         vbox2->addWidget(rb3); 
    1508         vbox2->addWidget(rb1); 
    1509         vbox2->addWidget(rb2); 
    1510         vbox2->addWidget(rb4); 
    1511         rb3->setChecked(true); 
    1512  
    1513         vbox2->addStretch(1); 
    1514         groupBox->setLayout(vbox2); 
    1515  
    1516         vl->addWidget(groupBox, 0, 0); 
     1606 
     1607        ////////////////// 
     1608 
     1609        QHBoxLayout *vh = new QHBoxLayout; 
     1610 
     1611        QGroupBox *myBox = new QGroupBox("Visualization"); 
     1612 
     1613        myBox->setLayout(vh); 
     1614 
     1615        vl->addWidget(myBox, 0, 0); 
     1616 
     1617        QGroupBox *groupBox = CreateVisualizationPanel(hbox); 
     1618 
     1619        vh->addWidget(groupBox, 0, 0); 
     1620 
     1621        QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 
     1622 
     1623        vh->addWidget(groupBox2, 0, 0); 
    15171624 
    15181625        ////////////////////////////////// 
     
    16801787 
    16811788 
    1682         if (0) { 
     1789        if (0)  
     1790        { 
    16831791                vbox = new QGroupBox("PVS Errors", this); 
    16841792                layout()->addWidget(vbox); 
     
    16991807                connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void))); 
    17001808        } 
    1701  
    17021809         
    17031810        //mHidingCost = 0.1f; 
Note: See TracChangeset for help on using the changeset viewer.