- Timestamp:
- 01/11/06 18:13:07 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r513 r517 13 13 #;../data/vienna/vienna-plane.x3d 14 14 # filename ../data/vienna/viewcells-25-sel.x3d 15 filename ../data/atlanta/atlanta2.x3d15 # filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 17 filename ../data/soda/soda5.dat … … 28 28 29 29 VssPreprocessor { 30 samplesPerPass 50000031 initialSamples 20000032 vssSamples 20000030 samplesPerPass 100000 31 initialSamples 300000 32 vssSamples 500000 33 33 vssSamplesPerPass 100000 34 34 useImportanceSampling true … … 169 169 170 170 ViewCells { 171 loadFromFile false172 exportToFile true171 loadFromFile true 172 exportToFile false 173 173 #type kdTree 174 174 #type vspKdTree … … 179 179 180 180 height 5.0 181 maxViewCells 500181 maxViewCells 100 182 182 #percentage of total visible objects where pvs is considered invalid 183 maxPvsRatio 0.1 183 maxPvsRatio 1 184 185 delayedConstruction true 186 184 187 185 188 PostProcess { … … 203 206 # filename ../data/vienna/viewcells-25.x3d 204 207 # filename ../data/vienna/viewcells-large-sel.x3d 205 filename ../scripts/viewcells .xml208 filename ../scripts/viewcells_soda.xml 206 209 } 207 210 … … 266 269 # pvs = 1024 267 270 268 splitPlaneStrategy 102 6271 splitPlaneStrategy 1024 269 272 270 273 # maximal candidates for split planes 271 274 maxPolyCandidates 100 272 maxRayCandidates 100275 #maxRayCandidates 100 273 276 274 277 # maximal tested rays for split cost heuristics … … 284 287 Termination { 285 288 # parameters used for autopartition 286 minRays 500289 minRays 900 287 290 minPolygons -1 288 291 maxDepth 30 289 minPvs 20292 minPvs 10 290 293 minArea 0.0001 291 294 #minArea 0.000 292 maxRayContribution 0. 5293 maxCostRatio 0.9 5294 missTolerance 5295 maxRayContribution 0.4 296 maxCostRatio 0.93 297 missTolerance 3 295 298 #maxAccRayLength 100 296 299 … … 301 304 302 305 AxisAligned { 303 minRays 2000 306 minRays 200000 304 307 maxRayContribution 0.5 305 308 } … … 315 318 PostProcess { 316 319 maxCostRatio 0.1 317 minViewCells 200320 minViewCells 100 318 321 maxPvsSize 1000 319 322 useRaysForMerge true -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r516 r517 1246 1246 RegisterOption("ViewCells.Visualization.colorCode", 1247 1247 optString, 1248 "-view_cells_visualization .color_code",1248 "-view_cells_visualization_color_code", 1249 1249 "PVS"); 1250 1250 1251 1251 RegisterOption("ViewCells.Visualization.exportRays", 1252 1252 optBool, 1253 "-bsp_visualization.export_rays", 1253 "-view_cells_delayed_construction", 1254 "false"); 1255 1256 RegisterOption("ViewCells.delayedConstruction", 1257 optBool, 1258 "-view_cells_delayed_construction", 1254 1259 "false"); 1255 1260 1256 1261 RegisterOption("ViewCells.Visualization.exportGeometry", 1257 1262 optBool, 1258 "- bsp_visualization.export_geometry",1263 "-view_cells_visualization_export_geometry", 1259 1264 "false"); 1260 1265 … … 1826 1831 "vsp_bsp_max_static_mem=", 1827 1832 "8.0"); 1833 1828 1834 ////////////////////////////////////////////////////////////////////////////////// 1829 1835 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r516 r517 48 48 GlRenderer::~GlRenderer() 49 49 { 50 } 51 52 53 static void handleCgError() 54 { 55 fprintf(stderr, "Cg error: %s\n", cgGetErrorString(cgGetError())); 56 exit(1); 50 57 } 51 58 … … 147 154 148 155 // cg initialization 156 cgSetErrorCallback(handleCgError); 149 157 sCgContext = cgCreateContext(); 150 158 … … 406 414 { 407 415 static int glList = -1; 408 if (glList == -1) { 416 if (glList != -1) { 417 glCallList(glList); 418 } else { 409 419 glList = glGenLists(1); 410 glNewList(glList, GL_COMPILE );420 glNewList(glList, GL_COMPILE_AND_EXECUTE); 411 421 ObjectContainer::const_iterator oi = mObjects.begin(); 412 422 for (; oi != mObjects.end(); oi++) … … 414 424 glEndList(); 415 425 } 416 glCallList(glList);417 426 return true; 418 427 } … … 570 579 Beam &beam, 571 580 const int desiredSamples, 572 GlRendererBuffer::BeamSampleStatistics &stat)581 BeamSampleStatistics &stat) 573 582 { 574 583 // TODO: should not be done every time here -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r508 r517 13 13 #include "ViewCellsParser.h" 14 14 15 15 16 ViewCellsManager::ViewCellsManager(): 16 17 mRenderer(NULL), … … 19 20 mVisualizationSamples(0), 20 21 mTotalAreaValid(false), 21 mTotalArea(0.0f) 22 mTotalArea(0.0f), 23 mViewCellsFinished(false) 22 24 { 23 25 mSceneBox.Initialize(); 24 26 ParseEnvironment(); 25 27 } 28 26 29 27 30 ViewCellsManager::ViewCellsManager(int constructionSamples): … … 29 32 mRenderer(NULL), 30 33 mPostProcessSamples(0), 31 mVisualizationSamples(0) 34 mVisualizationSamples(0), 35 mViewCellsFinished(false) 32 36 { 33 37 mSceneBox.Initialize(); 34 38 ParseEnvironment(); 35 39 } 40 36 41 37 42 void ViewCellsManager::ParseEnvironment() … … 348 353 termination, 349 354 viewcells); 350 355 //Debug << "constribution: " << (int)viewcells.size() << endl; 351 356 // copy viewcells memory efficiently 352 357 const bool storeViewcells = false; … … 462 467 463 468 464 void ViewCellsManager::CreateViewCell sMeshes()469 void ViewCellsManager::CreateViewCellMeshes() 465 470 { 466 471 // convert to meshes … … 469 474 for (it = mViewCells.begin(); it != it_end; ++ it) 470 475 { 471 CreateMesh(*it); 476 if (!(*it)->GetMesh()) 477 CreateMesh(*it); 472 478 } 473 479 } … … 1860 1866 startTime = GetTime(); 1861 1867 1862 //-- merge the individual view cells: Should be done here because it makes1863 MergeViewCells(rays, objects);1864 //-- refines the merged view cells1865 RefineViewCells(rays);1866 // collapse sibling leaves that share the same view cell1867 mVspBspTree->CollapseTree();1868 1869 1868 // reset view cells and stats 1870 1869 ResetViewCells(); … … 1891 1890 int pvsSize = 0; 1892 1891 1893 VssRayContainer postProcessRays;1894 GetRaySets(rays, mPostProcessSamples, postProcessRays);1895 1896 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl;1897 EvaluateViewCellsStats();1898 Debug << "\noriginal view cell partition:\n" << mViewCellsStats << endl << endl;1899 1900 1892 mRenderer->RenderScene(); 1901 1893 SimulationStatistics ss; … … 1910 1902 1911 1903 // TODO: should be done BEFORE the ray casting 1912 merged = mVspBspTree->MergeViewCells( postProcessRays);1904 merged = mVspBspTree->MergeViewCells(rays); 1913 1905 1914 1906 //-- stats and visualizations … … 1978 1970 } 1979 1971 1972 1980 1973 int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 1981 1974 const VssRayContainer &rays) … … 1983 1976 if (!ViewCellsConstructed()) 1984 1977 { 1985 Debug << " view cells notconstructed" << endl;1978 Debug << "postprocess error: no view cells constructed" << endl; 1986 1979 return 0; 1987 1980 } 1981 // view cells already finished 1982 else if (mViewCellsFinished) 1983 return 0; 1984 1985 VssRayContainer postProcessRays; 1986 GetRaySets(rays, mPostProcessSamples, postProcessRays); 1987 1988 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 1989 EvaluateViewCellsStats(); 1990 Debug << "\nview cell partition after sampling:\n" << mViewCellsStats << endl << endl; 1991 1992 1993 //-- merge the individual view cells: Should be done here because it makes 1994 MergeViewCells(postProcessRays, objects); 1995 //-- refines the merged view cells 1996 RefineViewCells(postProcessRays); 1997 // collapse sibling leaves that share the same view cell 1998 mVspBspTree->CollapseTree(); 1988 1999 1989 2000 // real meshes are only contructed only at this stage 1990 CreateViewCellsMeshes(); 2001 CreateViewCellMeshes(); 2002 1991 2003 // write view cells to disc 1992 2004 if (mExportViewCells) 1993 2005 { 1994 ExportViewCells("viewcells.xml"); 2006 char buff[100]; 2007 environment->GetStringValue("ViewCells.filename", buff); 2008 string vcFilename(buff); 2009 2010 ExportViewCells(buff); 1995 2011 } 1996 2012 … … 2371 2387 bool success = parser.ParseFile(filename, mVspBspTree, this, objects); 2372 2388 ResetViewCells(); 2373 2389 CreateViewCellMeshes(); 2390 2374 2391 Debug << (int)mViewCells.size() << " view cells loaded" << endl; 2392 2393 mViewCellsFinished = true; 2375 2394 2376 2395 return success; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r508 r517 277 277 /** Creates meshes from the view cells. 278 278 */ 279 void CreateViewCell sMeshes();279 void CreateViewCellMeshes(); 280 280 281 281 /** … … 320 320 bool mExportGeometry; 321 321 bool mExportRays; 322 323 bool mViewCellsFinished; 322 324 }; 323 325 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r511 r517 88 88 environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 89 89 90 environment->Get IntValue("ViewCells.pvsInvalid", mMaxPvsRatio);90 environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 91 91 92 92 //-- termination criteria for axis aligned split … … 311 311 312 312 mMaxPvs = (int)(mMaxPvsRatio * (float)numObj); 313 313 Debug << "maximal pvs where view cell is valid: " << mMaxPvs << endl; 314 314 //-- store rays 315 315 for (rit = sampleRays.begin(); rit != rit_end; ++ rit) … … 938 938 Plane3 plane; 939 939 float lowestCost = MAX_FLOAT; 940 940 941 // decides if the first few splits should be only axisAligned 941 942 const bool onlyAxisAligned = 942 943 (mSplitPlaneStrategy & AXIS_ALIGNED) && … … 944 945 ((int)data.GetAvgRayContribution() < mTermMaxRayContriForAxisAligned); 945 946 946 // split polygons if no axis aligned splits947 947 const int limit = onlyAxisAligned ? 0 : 948 948 Min((int)data.mPolygons->size(), mMaxPolyCandidates); … … 2084 2084 if (leaf->GetParent()) 2085 2085 leaf->GetParent()->ReplaceChildLink(node, leaf); 2086 2086 else 2087 mRoot = leaf; 2088 2087 2089 ++ collapsed; 2088 2090 delete interior; … … 2099 2101 { 2100 2102 int collapsed = 0; 2103 2101 2104 (void)CollapseTree(mRoot, collapsed); 2105 2102 2106 // revalidate leaves 2103 RepairV cLeafLists();2107 RepairViewCellsLeafLists(); 2104 2108 2105 2109 return collapsed; … … 2107 2111 2108 2112 2109 void VspBspTree::RepairV cLeafLists()2113 void VspBspTree::RepairViewCellsLeafLists() 2110 2114 { 2111 2115 // list not valid anymore => clear -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r511 r517 336 336 /** Helper function revalidating the view cell leaf list after merge. 337 337 */ 338 void RepairV cLeafLists();338 void RepairViewCellsLeafLists(); 339 339 340 340 /** Evaluates tree stats in the BSP tree leafs. … … 692 692 int mMaxPvs; 693 693 694 int mMaxPvsRatio;694 float mMaxPvsRatio; 695 695 696 696 /// View cell corresponding to the space outside the valid view space … … 704 704 /// maximal tree memory 705 705 float mMaxMemory; 706 706 /// the tree is out of memory 707 707 bool mOutOfMemory; 708 708 709 private: 709 710 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r503 r517 2360 2360 2361 2361 2362 void VspKdTree::RepairV cLeafLists()2362 void VspKdTree::RepairViewCellsLeafLists() 2363 2363 { 2364 2364 // list not valid anymore => clear … … 2446 2446 CollapseTree(mRoot, collapsed); 2447 2447 // revalidate leaves 2448 RepairV cLeafLists();2448 RepairViewCellsLeafLists(); 2449 2449 2450 2450 return collapsed; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r501 r517 790 790 /** Helper function revalidating the view cell leaf list after merge. 791 791 */ 792 void RepairV cLeafLists();792 void RepairViewCellsLeafLists(); 793 793 794 794 /** Shuffles the leaves, i.e., tests if exchanging -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r508 r517 25 25 environment->GetIntValue("VssPreprocessor.vssSamplesPerPass", mVssSamplesPerPass); 26 26 environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling); 27 environment->GetBoolValue("ViewCells.delayedConstruction", mDelayedViewCellsConstruction); 27 28 28 29 environment->GetBoolValue("VssPreprocessor.loadInitialSamples", mLoadInitialSamples); … … 498 499 499 500 // construct view cells 500 mViewCellsManager->Construct(mObjects, mVssRays); 501 501 if (!mDelayedViewCellsConstruction) 502 mViewCellsManager->Construct(mObjects, mVssRays); 503 502 504 vssTree = new VssTree; 503 505 // viewcells = Construct(mVssRays); … … 536 538 int pass = 0; 537 539 538 /// Rays used for post processing and visualizations539 RayContainer storedRays;540 540 // cast view cell samples 541 541 while (1) { … … 570 570 cout<<"Average PVS size = "<<avgPvs<<endl; 571 571 572 //Debug << "samples: " << samples << " construction samples " << mViewCellsManager->GetConstructionSamples() << endl; 573 // construct view cells after vss 574 if (!mViewCellsManager->ViewCellsConstructed() && 575 (samples + mInitialSamples > mViewCellsManager->GetConstructionSamples())) 576 { 577 VssRayContainer constructionRays; 578 vssTree->CollectRays(constructionRays, 579 mViewCellsManager->GetConstructionSamples()); 580 mViewCellsManager->Construct(mObjects, constructionRays); 581 } 582 583 /// compute view cell contribution of rays 584 mViewCellsManager->ComputeSampleContributions(vssRays); 585 572 586 if (numExportRays) { 573 587 char filename[64]; … … 579 593 ExportRays(filename, vssRays, numExportRays); 580 594 } 581 582 //-- prepare traversal rays for view cell intersections583 /// compute view cell contribution of rays584 mViewCellsManager->ComputeSampleContributions(vssRays);585 595 586 596 samples+=num; … … 596 606 597 607 598 { 599 VssRayContainer storedRays; 600 vssTree->CollectRays(storedRays, Max( 601 mViewCellsManager->GetPostProcessSamples(), 602 mViewCellsManager->GetVisualizationSamples())); 603 604 //-- post process view cells 605 mViewCellsManager->PostProcess(mObjects, storedRays); 606 607 //-- several visualizations and statistics 608 Debug << "\nview cells after post processing: " << endl; 609 mViewCellsManager->PrintStatistics(Debug); 610 611 mViewCellsManager->Visualize(mObjects, storedRays); 612 } 613 608 VssRayContainer viewCellRays; 609 610 // compute rays used for view cells construction 611 int numRays = Max(mViewCellsManager->GetPostProcessSamples(), 612 mViewCellsManager->GetVisualizationSamples()); 613 614 vssTree->CollectRays(viewCellRays, numRays); 615 616 //-- post process view cells 617 mViewCellsManager->PostProcess(mObjects, viewCellRays); 618 619 //-- several visualizations and statistics 620 Debug << "\nview cells after post processing: " << endl; 621 mViewCellsManager->PrintStatistics(Debug); 622 623 mViewCellsManager->Visualize(mObjects, viewCellRays); 624 614 625 //-- render simulation after merge 615 626 cout << "\nevaluating bsp view cells render time after merge ... "; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r501 r517 37 37 VssRayContainer mVssRays; 38 38 39 bool mDelayedViewCellsConstruction; 40 39 41 VssPreprocessor(); 40 42 ~VssPreprocessor();
Note: See TracChangeset
for help on using the changeset viewer.