Changeset 837 for GTP/trunk/Lib
- Timestamp:
- 04/27/06 09:29:52 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r822 r837 1305 1305 1306 1306 RegisterOption("ViewCells.Evaluation.samplingType", 1307 optString,1308 "view_cells_evaluation_sampling_type=",1309 "box");1307 optString, 1308 "view_cells_evaluation_sampling_type=", 1309 "box"); 1310 1310 1311 1311 RegisterOption("ViewCells.Evaluation.samplesPerPass", … … 1318 1318 "view_cells_export_to_file=", 1319 1319 "false"); 1320 1321 RegisterOption("ViewCells.pvsExportMode", 1322 optInt, 1323 "view_cells_export_bounding_boxes=", 1324 "2"); 1320 1325 1321 1326 RegisterOption("ViewCells.PostProcess.emptyViewCellsMerge", -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r811 r837 24 24 KdPvs mKdPvs; 25 25 26 enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL };26 enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL, OGRE_MESH_INSTANCE }; 27 27 28 28 Intersectable():mMailbox(0) {} … … 38 38 39 39 void Mail() { mMailbox = sMailId; } 40 40 bool Mailed() const { return mMailbox == sMailId; } 41 41 42 42 void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } … … 65 65 Vector3 &normal, 66 66 const Vector3 &viewpoint, 67 67 const int maxTries 68 68 ) = 0; 69 69 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r752 r837 1018 1018 } 1019 1019 1020 return beam.mKdNodes.size();1021 } 1020 return (int)beam.mKdNodes.size(); 1021 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r811 r837 26 26 27 27 if (0){ 28 // form figure28 // form grrid of meshes 29 29 for (int i = 0; i < n; ++ i) 30 30 { … … 554 554 { 555 555 Vector3 origin, direction; 556 int startSize = rays.size();557 for (int i=0; rays.size() - startSize < number; i++) {556 int startSize = (int)rays.size(); 557 for (int i=0; (int)rays.size() - startSize < number; i ++) { 558 558 // now get the direction 559 559 switch (sampleType) { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r801 r837 663 663 664 664 // set merge cost to this node for priority traversal 665 //mergedVc->SetMergeCost(totalRenderCost); 666 // HACK 667 mergedVc->SetMergeCost(1.0f / (float)realNumActiveViewCells); 668 669 //if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 670 // ++ mergeStats.siblings; 665 mergedVc->SetMergeCost(totalRenderCost); 666 667 // HACK 668 //mergedVc->SetMergeCost(1.0f / (float)realNumActiveViewCells); 669 670 // check if "siblings (back and front node of the same parent) 671 if (0 && mViewCellsManager->EqualToSpatialNode(mergedVc)) 672 ++ mergeStats.siblings; 673 // set the coŽst for rendering a view cell 671 674 mergedVc->SetCost(realExpectedCost); 672 675 … … 727 730 Debug << "setting root of the merge history" << endl; 728 731 mRoot = activeViewCells[0]; 729 Debug << "volume of the root view cell: " << mRoot->GetVolume() << " " << mViewCellsManager->GetViewSpaceBox().GetVolume() << endl;730 732 } 731 733 else … … 739 741 mMergeQueue.pop(); 740 742 } 741 //hack!! 742 //mRoot->GetPvs().Clear(); 743 // TODO delete because makes no sense here 743 744 // test if voluje is equal 745 Debug << "volume of the root view cell: " << mRoot->GetVolume() << " " << mViewCellsManager->GetViewSpaceBox().GetVolume() << endl; 746 747 //hack!! 748 //mRoot->GetPvs().Clear(); 749 750 // TODO: delete because makes no sense here 744 751 mergeStats.expectedRenderCost = realExpectedCost; 745 752 mergeStats.deviation = mDeviation; … … 1952 1959 1953 1960 1954 bool ViewCellsTree::Export(ofstream &stream) 1955 { 1956 ExportViewCell(mRoot, stream); 1961 bool ViewCellsTree::Export(ofstream &stream, const int pvsType) 1962 { 1963 // export recurvivly all view cells from the root 1964 ExportViewCell(mRoot, stream, pvsType); 1957 1965 1958 1966 return true; … … 1988 1996 1989 1997 1990 void ViewCellsTree::Export ViewCell(ViewCell *viewCell, ofstream &stream)1998 void ViewCellsTree::ExportPvs(ViewCell *viewCell, ofstream &stream, const int pvsType) 1991 1999 { 1992 2000 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 1993 2001 2002 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 2003 { 2004 switch (pvsType) 2005 { 2006 case EXPORT_IDS: 2007 { 2008 stream << (*it).first->GetId() << " "; 2009 } 2010 break; 2011 case EXPORT_BBOXES: 2012 { 2013 Debug << "here24 " << pvsType << endl; 2014 MeshInstance *mi = dynamic_cast<MeshInstance *>((*it).first); 2015 AxisAlignedBox3 box = mi->GetBox(); 2016 stream << "<BoundingBox" 2017 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 2018 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 2019 } 2020 break; 2021 case EXPORT_EMPTY_PVS: 2022 default: 2023 break; 2024 } 2025 } 2026 } 2027 2028 2029 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream, const int pvsType) 2030 { 1994 2031 if (viewCell->IsLeaf()) 1995 2032 { … … 1999 2036 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2000 2037 stream << "pvs=\""; 2001 if (0)// test with empty pvs 2002 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 2003 { 2004 stream << (*it).first->GetId() << " "; 2005 } 2006 2038 2039 //-- export pvs 2040 Debug << "here66 " << pvsType << endl; 2041 ExportPvs(viewCell, stream, pvsType); 2007 2042 2008 2043 stream << "\" />" << endl; … … 2017 2052 stream << "active=\"" << viewCell->IsActive() << "\" "; 2018 2053 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2019 stream << "pvs=\""; 2020 2021 if (0)// test with empty pvs 2022 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 2023 { 2024 stream << (*it).first->GetId() << " "; 2025 } 2054 2055 //-- NOTE: do not export pvss for interior view cells because 2056 // they can be compeletely reconstructed from the leaf pvss 2057 if (0) 2058 { 2059 stream << "pvs=\""; 2060 ExportPvs(viewCell, stream, pvsType); 2061 } 2026 2062 2027 2063 stream << "\" >" << endl; 2028 2064 2065 //-- recursivly export child view cells 2029 2066 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 2030 2067 2031 2068 for (it = interior->mChildren.begin(); it != it_end; ++ it) 2032 2069 { 2033 ExportViewCell(*it, stream );2070 ExportViewCell(*it, stream, pvsType); 2034 2071 } 2035 2072 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r810 r837 384 384 void SetViewCellsStorage(int type); 385 385 386 /** pvs storage methods */ 386 /** pvs storage methods 387 */ 387 388 enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES}; 388 389 390 enum {EXPORT_EMPTY_PVS, EXPORT_IDS, EXPORT_BBOXES}; 391 389 392 /** If view cells in this tree have compressed pvs. 390 393 */ … … 403 406 void PropagatePvs(ViewCell *vc); 404 407 405 bool Export(ofstream &stream); 408 /** Exports view cells to file. 409 */ 410 bool Export(ofstream &stream, const int pvsType = EXPORT_EMPTY_PVS); 406 411 407 412 /** Export statistics of this view cell tree. … … 503 508 */ 504 509 float GetMemUsage() const; 505 506 /** 507 Exports single view cell. 510 511 /** Exports single view cell. 508 512 NOTE: should be in exporter!! 509 513 */ 510 void ExportViewCell(ViewCell *viewCell, ofstream &stream); 514 void ExportViewCell(ViewCell *viewCell, ofstream &stream, const int pvsType); 515 516 /** Exports pvs of a view cell. 517 */ 518 void ExportPvs(ViewCell *viewCell, ofstream &stream, const int pvsType); 511 519 512 520 … … 522 530 523 531 524 /** intermediate container of merged view cells. 525 */ 532 /// intermediate container of merged view cells. 526 533 ViewCellContainer mMergedViewCells; 527 534 528 535 536 /// if merged view cells are refined. 529 537 bool mRefineViewCells; 530 538 … … 537 545 float mDeviation; 538 546 float mAvgRenderCost; 539 547 /// the area is used for pvs heuristics 540 548 int mUseAreaForPvs; 541 549 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r827 r837 92 92 environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 93 93 environment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType); 94 95 environment->GetIntValue("ViewCells.pvsExportMode", mPvsExportMode); 94 96 95 97 char buf[100]; … … 1149 1151 { 1150 1152 if (!ViewCellsConstructed()) 1151 return mViewSpaceBox.IsInside(viewPoint); 1152 else { 1153 if (!mViewSpaceBox.IsInside(viewPoint)) 1154 return false; 1155 ViewCell *viewcell = GetViewCell(viewPoint); 1156 if (!viewcell || !viewcell->GetValid()) 1157 return false; 1153 return mViewSpaceBox.IsInside(viewPoint); 1154 else 1155 { 1156 if (!mViewSpaceBox.IsInside(viewPoint)) 1157 return false; 1158 1159 ViewCell *viewcell = GetViewCell(viewPoint); 1160 1161 if (!viewcell || !viewcell->GetValid()) 1162 return false; 1158 1163 } 1164 1159 1165 return true; 1160 1166 } … … 2576 2582 stream << "<ViewCells>" << endl; 2577 2583 2578 #if 0 2579 2580 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 2581 2582 for (it = mViewCells.begin(); it != it_end; ++ it) 2583 ExportViewCell(*it, stream); 2584 #else 2585 mViewCellsTree->Export(stream); 2586 #endif 2584 mViewCellsTree->Export(stream, mPvsExportMode); 2587 2585 2588 2586 stream << "</ViewCells>" << endl; … … 3725 3723 int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 3726 3724 const VssRayContainer &rays) 3727 { 3725 {Debug << "here8773" << endl; 3728 3726 if (!ViewCellsConstructed()) 3729 3727 { … … 3824 3822 3825 3823 3824 Debug << "here3" << endl; 3826 3825 // write view cells to disc 3827 3826 if (mExportViewCells) 3828 3827 { 3828 Debug << "here4" << endl; 3829 3829 char buff[100]; 3830 3830 environment->GetStringValue("ViewCells.filename", buff); … … 3950 3950 { 3951 3951 interior->mPvs = pvs; 3952 //cout << "here233" << endl;3953 3952 } 3954 3953 … … 4571 4570 stream << "<Hierarchy name=\"vspBspTree\" />" << endl; 4572 4571 4573 //-- loadthe view cells itself, i.e., the ids and the pvs4572 //-- export the view cells itself, i.e., the ids and the pvs 4574 4573 stream << "<ViewCells>" << endl; 4575 4576 #if 0 4577 4578 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 4579 4580 for (it = mViewCells.begin(); it != it_end; ++ it) 4581 ExportViewCell(*it, stream); 4582 #else 4583 mViewCellsTree->Export(stream); 4584 #endif 4574 Debug << "**************************** mode: " << mPvsExportMode << endl; 4575 mViewCellsTree->Export(stream, mPvsExportMode); 4585 4576 4586 4577 stream << "</ViewCells>" << endl; 4587 4578 4588 //-- loadthe hierarchy4579 //-- export the hierarchy 4589 4580 stream << "<Hierarchy>" << endl; 4590 4581 mVspBspTree->Export(stream); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r810 r837 499 499 500 500 501 int mPvsExportMode; 501 502 502 503 Plane3 mClipPlane; 504 503 505 bool mUseClipPlaneForViz; 504 506 … … 843 845 void CreateMesh(ViewCell *vc); 844 846 845 //bool LoadViewCellsGeometry(const string filename, ObjectContainer *objects);846 847 bool ExportViewCells(const string filename); 847 848 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r822 r837 1247 1247 1248 1248 // the relative cost ratio 1249 float ratio = /*Limits::Infinity;*/99999999.0 ;1249 float ratio = /*Limits::Infinity;*/99999999.0f; 1250 1250 bool splitPlaneFound = false; 1251 1251 … … 1430 1430 int bestAxis; 1431 1431 1432 // if max cost ratio is exceeded, take split along longest axis instead 1433 const float maxCostRatioForArbitraryAxis = 0.9f; 1434 1432 1435 if (mUseDrivingAxisForMaxCost) 1433 1436 bestAxis = box.Size().DrivingAxis(); … … 1437 1440 // mximum cost ratio for axis to be valid: 1438 1441 // if exceeded, spatial mid split is used instead 1439 const float maxCostRatio = 0.9f; 1440 1441 // hack : subdivide along driving axis up to certain depth 1442 int maxDepthForDrivingAxis = 0; 1443 const maxCostRatioForHeur = 0.99; 1444 1445 const bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis || 1446 mCirculatingAxis; 1442 //const maxCostRatioForHeur = 0.99f; 1443 1444 1445 const bool useSpecialAxis = 1446 mOnlyDrivingAxis || mUseRandomAxis || mCirculatingAxis; 1447 1447 1448 1448 … … 1476 1476 1477 1477 //-- split plane position is spatial median 1478 //-- use median split if cost ratio very low as 1479 //-- there are not enough visibility cues 1480 1481 else //if (!mUseCostHeuristics || (nCostRatio[axis] > maxCostRatioForHeur)) 1478 1479 1480 // also use median split if cost ratio very low as 1481 // there are not enough visibility cues 1482 //if (!mUseCostHeuristics || (nCostRatio[axis] > maxCostRatioForHeur)) 1483 else 1482 1484 { 1483 1485 … … 1541 1543 { 1542 1544 // NOTE: takes longest axis split if cost ratio exceeds threshold 1543 if (nCostRatio[axis] < min(maxCostRatio , nCostRatio[bestAxis]))1545 if (nCostRatio[axis] < min(maxCostRatioForArbitraryAxis, nCostRatio[bestAxis])) 1544 1546 { 1545 1547 bestAxis = axis; 1546 1548 } 1547 //else if (nCostRatio[axis] < nCostRatio[bestAxis])1548 // Debug << "warning!! different path taken: " << axis << " " << bestAxis<< endl;1549 else if (nCostRatio[axis] < nCostRatio[bestAxis]) 1550 Debug << "taking split along longest axis (" << bestAxis << ") instead of (" << axis << ")" << endl; 1549 1551 1550 1552 }
Note: See TracChangeset
for help on using the changeset viewer.