Changeset 591 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 02/05/06 03:07:32 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r590 r591 36 36 loadInitialSamples false 37 37 storeInitialSamples false 38 useViewSpaceBox true38 useViewSpaceBox false 39 39 # testBeamSampling true 40 40 } … … 181 181 182 182 #number of active view cells 183 active 169183 active 256 184 184 maxStaticMemory 40 185 185 186 186 exportToFile false 187 loadFromFile true187 loadFromFile false 188 188 189 189 #type kdTree … … 225 225 exportGeometry true 226 226 exportMergedViewCells false 227 useCuttingPlane true 228 cuttingPlaneAxis 1 227 229 } 228 230 … … 300 302 301 303 # maximal candidates for split planes 302 maxPolyCandidates 100303 #maxRayCandidates 100 304 maxPolyCandidates 0 305 304 306 305 307 # maximal tested rays for split cost heuristics … … 340 342 } 341 343 342 splitUseOnlyDrivingAxis false344 splitUseOnlyDrivingAxis true 343 345 344 346 Visualization { -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r587 r591 1330 1330 "view_cells_post_process_use_rays_for_merge=", 1331 1331 "false"); 1332 1333 RegisterOption("ViewCells.PostProcess.merge", 1334 optBool, 1335 "view_cells_post_merge=", 1336 "true"); 1332 1337 1333 1338 RegisterOption("ViewCells.Visualization.exportMergedViewCells", … … 1340 1345 "view_cells_max_static_mem=", 1341 1346 "8.0"); 1347 1348 RegisterOption("ViewCells.Visualization.useCuttingPlane", 1349 optBool, 1350 "view_cells_viz_use_cutting_plane=", 1351 "false"); 1352 1353 1354 RegisterOption("ViewCells.Visualization.cuttingPlaneAxis", 1355 optInt, 1356 "view_cells_viz_cutting_plane_axis=", 1357 "0"); 1342 1358 1343 1359 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r590 r591 54 54 environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 55 55 environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 56 environment->GetBoolValue("ViewCells.PostProcess. useRaysForMerge", mUseRaysForMerge);56 environment->GetBoolValue("ViewCells.PostProcess.e", mUseMerge); 57 57 58 58 environment->GetIntValue("ViewCells.active", mNumMergedViewCells); 59 59 environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells); 60 environment->GetBoolValue("ViewCells.Visualization.useCuttingPlane", mUseCuttingPlaneForViz); 61 62 environment->GetBoolValue("ViewCells.Visualization.", mUseCuttingPlaneForViz); 63 64 environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells); 60 65 61 66 mMinPvsSize = emptyViewCells ? 1 : 0; … … 673 678 { 674 679 mViewSpaceBox = box; 680 681 CreateCuttingPlane(); 682 675 683 mTotalAreaValid = false; 684 } 685 686 687 void ViewCellsManager::CreateCuttingPlane() 688 { 689 int axis = 0; 690 691 Vector3 point = mViewSpaceBox.Center(); 692 693 if (mUseCuttingPlaneForViz) 694 environment->GetIntValue("ViewCells.Visualization.cuttingPlaneAxis", axis); 695 696 Vector3 normal(0,0,0); 697 normal[axis] = 1; 698 699 mCuttingPlane = Plane3(normal, point); 676 700 } 677 701 … … 872 896 { 873 897 ExportColor(exporter, *it); 874 ExportViewCellGeometry(exporter, *it); 898 ExportViewCellGeometry(exporter, *it, 899 mUseCuttingPlaneForViz ? &mCuttingPlane : NULL); 875 900 } 876 901 } … … 1027 1052 // view cells tree constructed 1028 1053 if (!ViewCellsTreeConstructed()) 1029 { 1030 1054 { 1031 1055 mBspTree->CollectViewCells(mViewCells); 1032 1056 } 1033 1057 else 1034 1058 { 1035 1036 1059 // we can use the view cells tree hierarchy to get the right set 1037 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 1060 mViewCellsTree->CollectBestViewCellSet(mViewCells, 1061 mNumMergedViewCells); 1038 1062 } 1039 1063 } … … 1043 1067 { 1044 1068 // compute view cell area as subsititute for probability 1045 #if 1 1046 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 1047 #else 1048 return GetArea(viewCell) / GetAccVcArea(); 1049 #endif 1069 if (1) 1070 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 1071 else 1072 return GetArea(viewCell) / GetAccVcArea(); 1050 1073 } 1051 1074 … … 1125 1148 } 1126 1149 1127 cout << "starting post processing using " << mPostProcessSamples << " samples ... ";1128 1129 long startTime = GetTime();1130 1150 1131 VssRayContainer postProcessRays; 1132 GetRaySets(rays, mPostProcessSamples, postProcessRays); 1133 1134 //-- merge or subdivide view cells 1135 int merged = mViewCellsTree->ConstructMergeTree(rays, objects); 1136 1137 //-- stats and visualizations 1138 cout << "finished" << endl; 1139 cout << "merged " << merged << " view cells in " 1140 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 1141 1142 Debug << "Postprocessing: Merged " << merged << " view cells in " 1143 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" 1144 << "using " << (int)rays.size() << " samples" << endl << endl; 1145 1151 1152 //-- merge view cells 1153 int merged; 1154 1155 const bool mergeBspLeaves = false; 1156 if (mergeBspLeaves) 1157 { 1158 cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 1159 long startTime = GetTime(); 1160 1161 VssRayContainer postProcessRays; 1162 GetRaySets(rays, mPostProcessSamples, postProcessRays); 1163 1164 merged = mViewCellsTree->ConstructMergeTree(rays, objects); 1165 1166 //-- stats and visualizations 1167 cout << "finished" << endl; 1168 cout << "merged " << merged << " view cells in " 1169 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 1170 1171 Debug << "Postprocessing: Merged " << merged << " view cells in " 1172 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" 1173 << "using " << (int)rays.size() << " samples" << endl << endl; 1174 } 1146 1175 1147 1176 // reset view cells and stats … … 1415 1444 1416 1445 void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 1417 ViewCell *vc) const 1446 ViewCell *vc, 1447 const Plane3 *cuttingPlane) const 1418 1448 { 1419 1449 if (vc->GetMesh()) 1420 1450 { 1421 1451 exporter->ExportMesh(vc->GetMesh()); 1452 1422 1453 return; 1423 1454 } … … 1425 1456 BspNodeGeometry geom; 1426 1457 mBspTree->ConstructGeometry(vc, geom); 1427 exporter->ExportPolygons(geom.mPolys); 1458 1459 1460 if (cuttingPlane) 1461 { 1462 BspNodeGeometry front; 1463 BspNodeGeometry back; 1464 1465 geom.SplitGeometry(front, 1466 back, 1467 *cuttingPlane, 1468 mViewSpaceBox, 1469 0.005); 1470 1471 exporter->ExportPolygons(back.mPolys); 1472 } 1473 else 1474 { 1475 exporter->ExportPolygons(geom.mPolys); 1476 } 1428 1477 } 1429 1478 … … 1828 1877 1829 1878 void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 1830 ViewCell *vc) const 1879 ViewCell *vc, 1880 const Plane3 *cuttingPlane) const 1831 1881 { 1832 1882 ViewCellContainer leaves; … … 2215 2265 2216 2266 void VspKdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 2217 ViewCell *vc) const 2267 ViewCell *vc, 2268 const Plane3 *cuttingPlane) const 2218 2269 { 2219 2270 VspKdViewCell *kdVc = dynamic_cast<VspKdViewCell *>(vc); … … 2542 2593 } 2543 2594 2544 //-- merge the individual view cells 2545 MergeViewCells(postProcessRays, objects); 2546 2547 //-- refines the merged view cells 2548 if (0) 2549 RefineViewCells(postProcessRays, objects); 2550 2551 if (mCompressViewCells) 2552 { 2553 int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2554 Debug << "number of entries before compress: " << pvsEntries << endl; 2555 2556 mViewCellsTree->CompressViewCellsPvs(); 2557 2558 pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2559 Debug << "number of entries after compress: " << pvsEntries << endl; 2595 if (mMergeViewCells) 2596 { 2597 //-- merge the individual view cells 2598 MergeViewCells(postProcessRays, objects); 2599 2600 2601 //-- refines the merged view cells 2602 if (0) 2603 RefineViewCells(postProcessRays, objects); 2604 2605 if (mCompressViewCells) 2606 { 2607 int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2608 Debug << "number of entries before compress: " << pvsEntries << endl; 2609 2610 mViewCellsTree->CompressViewCellsPvs(); 2611 2612 pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2613 Debug << "number of entries after compress: " << pvsEntries << endl; 2614 } 2560 2615 } 2561 2616 … … 3005 3060 if (vcValid) 3006 3061 { 3007 m = RandomMaterial(); 3062 m.mDiffuseColor.r = RandomValue(0.3f, 1.0f); 3063 m.mDiffuseColor.g = RandomValue(0.3f, 1.0f); 3064 m.mDiffuseColor.b = RandomValue(0.3f, 1.0f); 3008 3065 } 3009 3066 else … … 3013 3070 m.mDiffuseColor.b = 0.0f; 3014 3071 } 3015 } 3016 return; 3072 3073 exporter->SetForcedMaterial(m); 3074 return; 3075 } 3076 3017 3077 case 1: // pvs 3018 3078 { … … 3051 3111 3052 3112 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 3053 ViewCell *vc) const 3113 ViewCell *vc, 3114 const Plane3 *cuttingPlane) const 3054 3115 { 3055 3116 if (vc->GetMesh()) … … 3060 3121 } 3061 3122 3062 BspNodeGeometry geom; 3063 mVspBspTree->ConstructGeometry(vc, geom); 3064 exporter->ExportPolygons(geom.mPolys); 3123 3124 if (cuttingPlane) 3125 { 3126 ViewCellContainer leaves; 3127 mViewCellsTree->CollectLeaves(vc, leaves); 3128 ViewCellContainer::const_iterator it, it_end = leaves.end(); 3129 3130 for (it = leaves.begin(); it != it_end; ++ it) 3131 { 3132 BspNodeGeometry geom; 3133 3134 BspNodeGeometry front; 3135 BspNodeGeometry back; 3136 3137 3138 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 3139 3140 mVspBspTree->ConstructGeometry(leaf, geom); 3141 3142 geom.SplitGeometry(front, 3143 back, 3144 *cuttingPlane, 3145 mViewSpaceBox, 3146 0.005); 3147 3148 exporter->ExportPolygons(back.mPolys); 3149 } 3150 } 3151 else 3152 { 3153 BspNodeGeometry geom; 3154 mVspBspTree->ConstructGeometry(vc, geom); 3155 3156 exporter->ExportPolygons(geom.mPolys); 3157 } 3065 3158 } 3066 3159 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r590 r591 93 93 @returns number of sample contributions 94 94 */ 95 virtual float ComputeSampleContributions(VssRay &ray, const bool addRays, const bool storeViewCells); 96 97 virtual void AddSampleContributions(VssRay &ray); 95 virtual float ComputeSampleContributions(VssRay &ray, 96 const bool addRays, 97 const bool storeViewCells); 98 99 virtual void AddSampleContributions(VssRay &ray); 98 100 99 101 /** Prints out statistics of the view cells. … … 318 320 /** Exports view cell geometry. 319 321 */ 320 virtual void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const = 0; 322 virtual void ExportViewCellGeometry(Exporter *exporter, 323 ViewCell *vc, 324 const Plane3 *cuttingPlane = NULL) const = 0; 321 325 322 326 virtual void FinalizeViewCells(const bool createMesh); 323 327 324 328 325 /** Loads view cells from file. The view cells manager is created with respect to the loaded326 view cells.329 /** Loads view cells from file. The view cells manager is created with 330 respect to the loaded view cells. 327 331 328 332 @returns the view cells manager if loading was successful, false otherwise 329 333 */ 330 static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 334 static ViewCellsManager *LoadViewCells(const string filename, 335 ObjectContainer *objects); 331 336 332 337 /** Evaluates statistics values on view cells. … … 351 356 protected: 352 357 358 353 359 /** 354 360 if the view cells tree was already constructed or not. … … 411 417 */ 412 418 virtual void PrepareLoadedViewCells() {}; 419 420 421 void CreateCuttingPlane(); 422 423 Plane3 mCuttingPlane; 424 bool mUseCuttingPlaneForViz; 425 413 426 414 427 /// Renders the view cells. … … 446 459 bool mExportViewCells; 447 460 461 //bool mMarchTree); 448 462 bool mOnlyValidViewCells; 449 463 … … 451 465 bool mUseRaysForMerge; 452 466 453 467 454 468 //-- visualization options 455 469 … … 507 521 void CreateMesh(ViewCell *vc); 508 522 509 void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 523 void ExportViewCellGeometry(Exporter *exporter, 524 ViewCell *vc, 525 const Plane3 *cuttingPlane = NULL) const; 510 526 511 527 void CollectMergeCandidates(const VssRayContainer &rays, … … 584 600 void CreateMesh(ViewCell *vc); 585 601 586 void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 587 588 void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 602 void ExportViewCellGeometry(Exporter *exporter, 603 ViewCell *vc, 604 const Plane3 *cuttingPlane = NULL) const; 605 606 void CollectMergeCandidates(const VssRayContainer &rays, 607 vector<MergeCandidate> &candidates); 589 608 590 609 protected: … … 647 666 void CreateMesh(ViewCell *vc); 648 667 649 void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 668 void ExportViewCellGeometry(Exporter *exporter, 669 ViewCell *vc, 670 const Plane3 *cuttingPlane = NULL) const; 650 671 651 672 void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); … … 715 736 int CastBeam(Beam &beam); 716 737 717 void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 738 void ExportViewCellGeometry(Exporter *exporter, 739 ViewCell *vc, 740 const Plane3 *cuttingPlane = NULL) const; 718 741 719 742 //float GetVolume(ViewCell *viewCell) const; … … 748 771 void PrepareLoadedViewCells(); 749 772 773 750 774 /// the view space partition BSP tree. 751 775 VspBspTree *mVspBspTree; 752 776 777 753 778 private: 754 779 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r590 r591 123 123 float GetCost() const 124 124 { 125 #if 0 126 return mPvs * mProbability; 127 #endif 125 128 #if 1 126 return mPvs * mProbability;129 return - mDepth; 127 130 #endif 128 131 #if 0
Note: See TracChangeset
for help on using the changeset viewer.