Changeset 1594 for GTP/trunk/Lib
- Timestamp:
- 10/10/06 00:59:59 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r1589 r1594 13 13 #include "IntersectableWrapper.h" 14 14 #include "BvHierarchy.h" 15 #include "KdTree.h" 15 16 16 17 //#include <Cg/cg.h> … … 78 79 mSnapPrefix = "snap/"; 79 80 mUseForcedColors = false; 80 81 mRenderBoxes = false; 81 82 mUseGlLists = true; 82 83 //mUseGlLists = false; … … 108 109 GlRenderer::RenderIntersectable(Intersectable *object) 109 110 { 110 111 if (object->Mailed()) 112 return; 113 object->Mail(); 114 111 115 glPushAttrib(GL_CURRENT_BIT); 112 116 if (mUseFalseColors) … … 129 133 case Intersectable::BVH_INTERSECTABLE: { 130 134 135 131 136 BvhNode *node = (dynamic_cast<BvhIntersectable *>(object))->GetItem(); 132 // RenderBvhNode(node); 133 RenderBox(node->GetBoundingBox()); 137 138 if (mRenderBoxes) 139 RenderBox(node->GetBoundingBox()); 140 else 141 RenderBvhNode(node); 142 break; 143 } 144 case Intersectable::KD_INTERSECTABLE: { 145 KdNode *node = (dynamic_cast<KdIntersectable *>(object))->GetItem(); 146 147 if (mRenderBoxes) 148 RenderBox(mKdTree->GetBox(node)); 149 else 150 RenderKdNode(node); 134 151 break; 135 152 } … … 628 645 BvhLeaf *leaf = (BvhLeaf *) node; 629 646 for (int i=0; i < leaf->mObjects.size(); i++) 630 cout << "leaf obj " << i << endl; 631 //RenderIntersectable(mObjects[i]); 647 RenderIntersectable(leaf->mObjects[i]); 632 648 } else { 633 649 BvhInterior *in = (BvhInterior *)node; … … 635 651 RenderBvhNode(in->GetFront()); 636 652 } 637 638 } 639 640 } 653 654 //cout << "leaf obj " << i << endl; 655 656 } 657 658 void 659 GlRenderer::RenderKdNode(KdNode *node) 660 { 661 if (node->IsLeaf()) { 662 KdLeaf *leaf = (KdLeaf *) node; 663 for (int i=0; i < leaf->mObjects.size(); i++) { 664 RenderIntersectable(leaf->mObjects[i]); 665 } 666 } else { 667 KdInterior *in = (KdInterior *)node; 668 RenderKdNode(in->mBack); 669 RenderKdNode(in->mFront); 670 } 671 672 } 673 674 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r1585 r1594 113 113 void 114 114 RenderBvhNode(BvhNode *node); 115 115 116 void 117 RenderKdNode(KdNode *node); 118 116 119 bool 117 120 RenderScene(); … … 161 164 bool mDetectEmptyViewSpace; 162 165 bool mSnapErrorFrames; 166 167 bool mRenderBoxes; 163 168 164 169 bool mUseGlLists; -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r1587 r1594 157 157 158 158 159 typedef map<KdNode *, KdIntersectable *> KdIntersectableMap; 160 159 161 class BvhIntersectable: public IntersectableWrapper<BvhNode *> 160 162 { -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1584 r1594 1392 1392 } 1393 1393 1394 1395 } 1394 KdIntersectable * 1395 KdTree::GetOrCreateKdIntersectable(KdNode *node) 1396 { 1397 1398 if (node == NULL) 1399 return NULL; 1400 1401 // search nodes 1402 std::map<KdNode *, KdIntersectable *>:: 1403 const_iterator it = mKdIntersectables.find(node); 1404 1405 if (it != mKdIntersectables.end()) 1406 { 1407 return (*it).second; 1408 } 1409 1410 // not in map => create new entry 1411 KdIntersectable *kdObj = new KdIntersectable(node); 1412 mKdIntersectables[node] = kdObj; 1413 1414 return kdObj; 1415 } 1416 1417 KdNode * 1418 KdTree::GetNode(const Vector3 &point, 1419 const float maxArea) const 1420 { 1421 KdNode *node = mRoot; 1422 1423 while (!node->IsLeaf() && (GetSurfaceArea(node) > maxArea) ) { 1424 KdInterior *inter = (KdInterior *)node; 1425 if (point[inter->mAxis] < inter->mPosition) 1426 node = inter->mBack; 1427 else 1428 node = inter->mFront; 1429 } 1430 1431 return node; 1432 } 1433 1434 1435 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1286 r1594 11 11 #include "Viewcell.h" 12 12 #include "VssRay.h" 13 #include "IntersectableWrapper.h" 13 14 14 15 … … 336 337 } 337 338 339 /** Returns or creates a new intersectable for use in a kd based pvs. 340 The OspTree is responsible for destruction of the intersectable. 341 */ 342 KdIntersectable *GetOrCreateKdIntersectable(KdNode *node); 343 338 344 void 339 345 CollectObjects(KdNode *n, ObjectContainer &objects); … … 368 374 return box; 369 375 } 370 376 377 float GetSurfaceArea(const KdNode *node) const { 378 return GetBox(node).SurfaceArea(); 379 } 380 381 371 382 KdNode * 372 383 FindRandomNeighbor(KdNode *n, … … 379 390 KdNode * 380 391 GetRandomLeaf(const bool onlyUnmailed = false); 381 392 393 394 KdNode * 395 GetNode(const Vector3 &point, const float maxArea) const; 396 382 397 int 383 398 FindNeighbors(KdNode *n, … … 574 589 AxisAlignedBox3 mBox; 575 590 KdTreeStatistics mStat; 576 591 592 /// stores the kd node intersectables used for pvs 593 KdIntersectableMap mKdIntersectables; 594 577 595 }; 578 596 -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1585 r1594 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ne 8. X 23:47:35 20063 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 9. X 21:25:05 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1449 r1594 11 11 #include "gzstream.h" 12 12 #include "SubdivisionCandidate.h" 13 #include "IntersectableWrapper.h" 13 14 14 15 … … 135 136 136 137 137 typedef map<KdNode *, KdIntersectable *> KdIntersectableMap;138 138 139 139 … … 826 826 827 827 /// stores the kd node intersectables used for pvs 828 828 KdIntersectableMap mKdIntersectables; 829 829 830 830 private: -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp
r1585 r1594 870 870 871 871 int QtGlRendererBuffer::ComputePvs(ObjectContainer &objects, 872 ObjectContainer &pvs) const872 ObjectContainer &pvs) const 873 873 { 874 874 int pvsSize = 0; … … 950 950 { 951 951 952 952 Intersectable::NewMail(); 953 953 954 ViewCell *viewcell = NULL; 954 955 … … 975 976 976 977 977 // read back the texture978 978 ObjectPvsMap::const_iterator it = pvs.mEntries.begin(); 979 979 980 980 mPvsSize = pvs.mEntries.size(); 981 981 982 982 for (; it != pvs.mEntries.end(); ++ it) { 983 983 Intersectable *object = (*it).first; 984 float visibility = log10((*it).second.mSumPdf + 1)/5.0f; 985 glColor3f(visibility, 0.0f, 0.0f); 986 mUseForcedColors = true; 987 RenderIntersectable(object); 988 mUseForcedColors = false; 984 985 if (mRenderVisibilityEstimates) { 986 float visibility = log10((*it).second.mSumPdf + 1)/5.0f; 987 glColor3f(visibility, 0.0f, 0.0f); 988 mUseForcedColors = true; 989 RenderIntersectable(object); 990 mUseForcedColors = false; 991 } else { 992 mUseForcedColors = false; 993 RenderIntersectable(object); 994 } 989 995 } 990 996 … … 1360 1366 mCutScene = false; 1361 1367 mRenderErrors = false; 1368 mRenderBoxes = false; 1362 1369 mRenderFilter = true; 1370 mRenderVisibilityEstimates = false; 1371 1363 1372 mManipulatorScale = 1.0f; 1364 1373 trackball(mManipulatorLastQuat, 0.0f, 0.0f, 0.0f, 0.0f); … … 1370 1379 Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", 1371 1380 tmp ); 1372 1373 1381 mUseSpatialFilter = tmp; 1374 1382 … … 1396 1404 connect(mControlWidget, SIGNAL(SetCutScene(bool)), this, SLOT(SetCutScene(bool))); 1397 1405 connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool))); 1406 connect(mControlWidget, SIGNAL(SetRenderBoxes(bool)), this, SLOT(SetRenderBoxes(bool))); 1398 1407 connect(mControlWidget, SIGNAL(SetRenderFilter(bool)), this, SLOT(SetRenderFilter(bool))); 1408 connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)), 1409 this, SLOT(SetRenderVisibilityEstimates(bool))); 1399 1410 connect(mControlWidget, SIGNAL(SetUseFilter(bool)), this, SLOT(SetUseFilter(bool))); 1400 1411 connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), … … 1825 1836 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSceneCut(int))); 1826 1837 1838 1839 cb = new QCheckBox("Render boxes", vbox); 1840 vbox->layout()->addWidget(cb); 1841 cb->setChecked(false); 1842 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderBoxes(bool))); 1843 1844 cb = new QCheckBox("Render visibility estimates", vbox); 1845 vbox->layout()->addWidget(cb); 1846 cb->setChecked(false); 1847 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderVisibilityEstimates(bool))); 1848 1849 1827 1850 cb = new QCheckBox("Render errors", vbox); 1828 1851 vbox->layout()->addWidget(cb); … … 1830 1853 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 1831 1854 1855 1856 bool tmp; 1857 1832 1858 cb = new QCheckBox("Use filter", vbox); 1833 1859 vbox->layout()->addWidget(cb); 1834 cb->setChecked(true); 1860 Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", tmp ); 1861 cb->setChecked(tmp); 1835 1862 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool))); 1836 1863 1864 1837 1865 cb = new QCheckBox("Use spatial filter", vbox); 1838 1866 vbox->layout()->addWidget(cb); 1839 cb->setChecked(true); 1867 Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", 1868 tmp ); 1869 cb->setChecked(tmp); 1840 1870 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseSpatialFilter(bool))); 1841 1871 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h
r1584 r1594 152 152 void SetShowRays(bool); 153 153 void SetRenderFilter(bool); 154 void SetRenderVisibilityEstimates(bool); 154 155 void SetUseFilter(bool); 155 156 void SetUseSpatialFilter(bool); 156 157 void SetRenderErrors(bool); 158 void SetRenderBoxes(bool); 157 159 void SetShowViewCells(bool); 158 160 void SetShowRenderCost(bool); … … 179 181 bool mRenderErrors; 180 182 bool mRenderFilter; 183 bool mRenderVisibilityEstimates; 181 184 bool mUseFilter; 182 185 bool mUseSpatialFilter; … … 266 269 } 267 270 271 void SetRenderBoxes(bool b) { 272 mRenderBoxes = b; 273 updateGL(); 274 } 275 268 276 void SetRenderFilter(bool b) { 269 277 mRenderFilter = b; 278 updateGL(); 279 } 280 281 void SetRenderVisibilityEstimates(bool b) { 282 mRenderVisibilityEstimates = b; 270 283 updateGL(); 271 284 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h
r1584 r1594 46 46 Intersectable *mObject; 47 47 48 48 /// the face of the intersectable 49 49 int mFace; 50 50 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1589 r1594 29 29 #define SAMPLE_ORIGIN_OBJECTS 0 30 30 31 // $$JB HACK 32 #define USE_KD_PVS 1 33 #define KD_PVS_AREA 1e-3f 31 34 32 35 namespace GtpVisibilityPreprocessor { … … 1183 1186 const float filterWidth) 1184 1187 { 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 { 1196 1197 1198 1199 1200 1201 1188 ViewCell *currentViewCell = GetViewCell(viewPoint); 1189 1190 if (mMaxFilterSize < 1) { 1191 prvs.mViewCell = currentViewCell; 1192 return; 1193 } 1194 1195 const AxisAlignedBox3 box = GetFilterBBox(viewPoint, filterWidth); 1196 1197 if (currentViewCell) 1198 { 1199 ViewCellContainer viewCells; 1200 ComputeBoxIntersections(box, viewCells); 1201 1202 ViewCell *root = ConstructLocalMergeTree2(currentViewCell, viewCells); 1203 prvs.mViewCell = root; 1204 1202 1205 } 1203 1204 { 1205 1206 1206 else 1207 { 1208 prvs.mViewCell = NULL; 1209 //prvs.mPvs = root->GetPvs(); 1207 1210 } 1208 1211 } … … 1808 1811 ViewCellContainer *viewcells = &ray.mViewCells; 1809 1812 ViewCellContainer::const_iterator it; 1813 1814 if (!ray.mTerminationObject) 1815 return; 1816 1817 #if USE_KD_PVS 1818 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 1819 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 1820 Intersectable *obj = 1821 GetPreprocessor()->mKdTree-> 1822 GetOrCreateKdIntersectable(node); 1823 #else 1824 Intersectable *obj = ray.mTerminationObject; 1825 #endif 1826 1810 1827 for (it = viewcells->begin(); it != viewcells->end(); ++it) { 1811 1828 ViewCell *viewcell = *it; 1812 1829 if (viewcell->GetValid()) { 1813 1830 // if ray not outside of view space 1814 viewcell->GetPvs().AddSample( ray.mTerminationObject, ray.mPdf);1831 viewcell->GetPvs().AddSample(obj, ray.mPdf); 1815 1832 } 1816 1833 } … … 1851 1868 } 1852 1869 1870 #if USE_KD_PVS 1871 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 1872 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 1873 Intersectable *obj = 1874 GetPreprocessor()->mKdTree-> 1875 GetOrCreateKdIntersectable(node); 1876 #else 1877 Intersectable *obj = ray.mTerminationObject; 1878 #endif 1879 1880 1853 1881 ViewCellContainer::const_iterator it = viewcells.begin(); 1854 1882 1855 1883 for (; it != viewcells.end(); ++ it) 1856 1884 { … … 1862 1890 1863 1891 if (ray.mTerminationObject) 1864 { 1865 if (viewcell->GetPvs().GetSampleContribution( 1866 ray.mTerminationObject, 1867 ray.mPdf, 1868 contribution)) 1892 { 1893 1894 1895 if (viewcell->GetPvs().GetSampleContribution(obj, 1896 ray.mPdf, 1897 contribution)) 1869 1898 { 1870 1871 1899 ++ ray.mPvsContribution; 1900 ray.mRelativePvsContribution += contribution; 1872 1901 } 1873 1902 } … … 1903 1932 if (ray.mTerminationObject) 1904 1933 { 1905 viewcell->GetPvs().AddSample( ray.mTerminationObject, ray.mPdf);1934 viewcell->GetPvs().AddSample(obj, ray.mPdf); 1906 1935 } 1907 1936 #if SAMPLE_ORIGIN_OBJECTS … … 2330 2359 // now compute a new Pvs by including also objects intersecting the 2331 2360 // extended boxes of visible objects 2332 2333 2361 Intersectable::NewMail(); 2334 2362 … … 5510 5538 if (ray.mTerminationObject) 5511 5539 { 5512 // todo: maybe not correct for kd node pvs 5513 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5514 if (viewcell->GetPvs().GetSampleContribution(obj, 5515 ray.mPdf, 5516 contribution)) 5540 // todo: maybe not correct for kd node pvs 5541 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5542 5543 if (viewcell->GetPvs().GetSampleContribution(obj, 5544 ray.mPdf, 5545 contribution)) 5517 5546 { 5518 5547 ++ ray.mPvsContribution; 5519 5548 } 5520 5521 5549 5550 ray.mRelativePvsContribution += contribution; 5522 5551 } 5523 5552 5524 5553 // for directional sampling it is important to count only contributions 5525 5554 // made in one direction! -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r1585 r1594 11 11 # filename ../data/glasgow/glasgow1.x3d 12 12 # filename vienna.x3d 13 filename ../data/vienna/vienna-simple.x3d13 # filename ../data/vienna/vienna-simple.x3d 14 14 # filename ../data/vienna/vienna-buildings.x3d 15 15 # filename ../data/vienna/city1500_flat_1.x3d … … 143 143 sahUseFaces false 144 144 Termination { 145 minCost 0.95145 minCost 4 146 146 maxDepth 30 147 maxCostRatio 0.9 8147 maxCostRatio 0.99 148 148 ct_div_ci 0.5 149 maxNodes 100000149 maxNodes 300000 150 150 #500000 151 151 } … … 170 170 } 171 171 172 173 174 175 176 177 172 ViewCells { 178 173 # samples used for view cell construction … … 189 184 190 185 exportToFile true 191 loadFromFile false186 loadFromFile true 192 187 193 188 #type kdTree 194 189 #type vspKdTree 195 190 #type bspTree 196 #type vspBspTree197 type vspOspTree191 type vspBspTree 192 #type vspOspTree 198 193 #type sceneDependent 199 194 … … 243 238 Evaluation { 244 239 samplesPerPass 1000000 245 samples 1000000240 samples 5000000 246 241 statsPrefix ../scripts/viewCells 247 242 #samplingType directional … … 269 264 270 265 271 filename ../data/vienna/vsposp-seq-viewCells.xml.gz266 # filename ../data/vienna/vsposp-seq-viewCells.xml.gz 272 267 273 268 # filename ../data/atlanta/viewcells_atlanta3.xml … … 277 272 # filename ../data/vienna/vienna_simple-21-04-avs2-viewCells.xml 278 273 # filename ../data/vienna/vienna-viewcells-5000.xml 279 #filename ../data/vienna/vienna-viewcells-1000.xml.zip280 filename ../data/vienna/vsposp-seq-viewCells.xml.gz274 filename ../data/vienna/vienna-viewcells-1000.xml.zip 275 # filename ../data/vienna/vsposp-seq-viewCells.xml.gz 281 276 282 277 # filename ../data/PowerPlant/power_plant_viewcells1.xml
Note: See TracChangeset
for help on using the changeset viewer.