Changeset 1416 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 09/19/06 09:41:23 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1415 r1416 356 356 357 357 ResetViewCells(); 358 if (0) Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl;359 360 //-- optionally export initial view cell partition361 if (0) 362 { 358 359 if (0) //-- optionally export initial view cell partition 360 { 361 Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 362 363 363 const string filename("viewcells.wrl"); 364 364 Exporter *exporter = Exporter::GetExporter(filename.c_str()); … … 374 374 375 375 exporter->SetWireframe(); 376 ExportViewCellsForViz(exporter );376 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 377 377 378 378 delete exporter; … … 429 429 430 430 #if 0 431 /////////////// /////////////////////////////////432 //-- get stats after the additional sampling step431 /////////////// 432 //-- Get stats after the additional sampling step 433 433 //-- and before the bottom-up merge step 434 434 … … 445 445 446 446 447 //////////////////// ///////////////////////////447 //////////////////// 448 448 // 449 449 //-- post processing of the initial construction … … 476 476 477 477 478 //////////////// //////////////////////////////////////////////478 //////////////// 479 479 //-- Evaluation of the resulting view cell partition. 480 480 //-- We cast a number of new samples and measure the render cost … … 486 486 487 487 488 ///////////////// //////////////////488 ///////////////// 489 489 //-- Finally, we do some visualization 490 490 … … 508 508 509 509 return numSamples; 510 } 511 512 513 AxisAlignedPlane * ViewCellsManager::GetClipPlane() 514 { 515 return mUseClipPlaneForViz ? &mClipPlaneForViz : NULL; 510 516 } 511 517 … … 1692 1698 1693 1699 Environment::GetSingleton()->GetFloatValue("ViewCells.Visualization.clipPlanePos", pos); 1694 1695 Vector3 point = mViewSpaceBox.Min() + mViewSpaceBox.Size() * pos; 1696 1697 if (mUseClipPlaneForViz) 1698 Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 1699 1700 mClipPlane = AxisAlignedPlane(axis, point[axis]); 1700 Vector3 absPos = mViewSpaceBox.Min() + mViewSpaceBox.Size() * pos; 1701 1702 Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 1703 1704 mClipPlaneForViz = AxisAlignedPlane(axis, absPos[axis]); 1701 1705 } 1702 1706 … … 1946 1950 } 1947 1951 1948 // matt: todo 1949 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter) const 1952 1953 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter, 1954 const AxisAlignedBox3 *sceneBox, 1955 const AxisAlignedPlane *clipPlane 1956 ) const 1950 1957 { 1951 1958 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); … … 1956 1963 { 1957 1964 ExportColor(exporter, *it); 1958 1959 ExportViewCellGeometry(exporter, *it, 1960 mUseClipPlaneForViz ? &mClipPlane : NULL); 1965 ExportViewCellGeometry(exporter, *it, sceneBox, clipPlane); 1961 1966 } 1962 1967 } … … 2670 2675 const int savedColorCode = mColorCode; 2671 2676 2672 //BspLeaf::NewMail();2673 2677 if (1) // export merged view cells 2674 2678 { 2675 mColorCode = 0; 2676 2679 mColorCode = 0; // hack color code 2677 2680 Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 2678 2681 … … 2683 2686 { 2684 2687 if (mExportGeometry) 2688 { 2685 2689 exporter->ExportGeometry(objects); 2686 2687 //exporter->SetWireframe(); 2690 } 2691 2688 2692 exporter->SetFilled(); 2689 ExportViewCellsForViz(exporter); 2690 2693 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 2691 2694 2692 2695 delete exporter; … … 2695 2698 } 2696 2699 2697 if (1) // export merged view cells using pvs color coding 2698 { 2700 if (1) 2701 { 2702 // export merged view cells using pvs color coding 2699 2703 mColorCode = 1; 2700 2704 2701 2705 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 2702 2703 2706 cout << "exporting view cells after merge (pvs size) ... "; 2704 2707 2705 2708 if (exporter) 2706 2709 { 2707 //exporter->SetWireframe();2708 //exporter->SetForcedMaterial(RandomMaterial());2709 2710 2710 if (mExportGeometry) 2711 { 2711 2712 exporter->ExportGeometry(objects); 2712 2713 //exporter->SetWireframe();2713 } 2714 2714 2715 exporter->SetFilled(); 2715 ExportViewCellsForViz(exporter );2716 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 2716 2717 2717 2718 delete exporter; … … 2769 2770 if (exporter) 2770 2771 { 2771 //exporter->SetWireframe();2772 2773 2772 if (mExportGeometry) 2773 { 2774 2774 exporter->ExportGeometry(objects); 2775 2776 //exporter->SetFilled(); 2777 const bool b = mUseClipPlaneForViz; 2778 mUseClipPlaneForViz = false; 2779 2780 ExportViewCellsForViz(exporter); 2781 2782 mUseClipPlaneForViz = b; 2775 } 2776 2777 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 2783 2778 delete exporter; 2784 2779 } … … 2788 2783 mColorCode = savedColorCode; 2789 2784 2785 2786 ////////////////// 2790 2787 //-- visualization of the BSP splits 2788 2791 2789 bool exportSplits = false; 2792 2790 Environment::GetSingleton()->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); … … 2890 2888 exporter->SetForcedMaterial(m); 2891 2889 2892 ExportViewCellGeometry(exporter, vc );2890 ExportViewCellGeometry(exporter, vc, NULL, NULL); 2893 2891 2894 2892 // export rays piercing this view cell … … 2962 2960 void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 2963 2961 ViewCell *vc, 2964 const AxisAlignedPlane *clipPlane) const 2962 const AxisAlignedBox3 *sceneBox, 2963 const AxisAlignedPlane *clipPlane 2964 ) const 2965 2965 { 2966 2966 // export mesh if available … … 3437 3437 void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 3438 3438 ViewCell *vc, 3439 const AxisAlignedPlane *clipPlane) const 3439 const AxisAlignedBox3 *sceneBox, 3440 const AxisAlignedPlane *clipPlane 3441 ) const 3440 3442 { 3441 3443 ViewCellContainer leaves; 3442 3443 3444 mViewCellsTree->CollectLeaves(vc, leaves); 3444 3445 ViewCellContainer::const_iterator it, it_end = leaves.end(); … … 3447 3448 { 3448 3449 KdViewCell *kdVc = dynamic_cast<KdViewCell *>(*it); 3449 3450 3450 exporter->ExportBox(mKdTree->GetBox(kdVc->mLeaf)); 3451 3451 } … … 3718 3718 exporter->SetFilled(); 3719 3719 3720 ExportViewCellsForViz(exporter );3720 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 3721 3721 3722 3722 if (mExportGeometry) … … 3737 3737 if (1) 3738 3738 { 3739 mColorCode = 1; // export merged view cells using pvs coding 3739 // use pvs size for color coding 3740 mColorCode = 1; 3740 3741 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 3741 3742 … … 3744 3745 if (exporter) 3745 3746 { 3746 if (0) 3747 exporter->SetWireframe(); 3748 else 3749 exporter->SetFilled(); 3750 3751 ExportViewCellsForViz(exporter); 3747 exporter->SetFilled(); 3748 3749 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 3752 3750 3753 3751 if (mExportGeometry) … … 4033 4031 GetRaySets(sampleRays, mVisualizationSamples, visRays); 4034 4032 4035 //-- export final view cell partition 4036 4033 4037 4034 if (0) 4038 4035 { 4039 // hack pvs 4040 //const int savedColorCode = mColorCode; 4041 //mColorCode = 1; 4042 4036 ////////////////// 4037 //-- export final view cell partition 4038 4043 4039 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 4044 4040 … … 4074 4070 } 4075 4071 4076 //exporter->SetFilled(); 4077 4078 // HACK: export without clip plane 4079 const bool b = mUseClipPlaneForViz; 4080 //mUseClipPlaneForViz = false; 4081 4082 ExportViewCellsForViz(exporter); 4083 4084 mUseClipPlaneForViz = b; 4072 ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 4073 4085 4074 delete exporter; 4086 4087 4075 cout << "finished" << endl; 4088 4076 } 4089 4090 //mColorCode = savedColorCode; 4091 } 4092 4077 } 4093 4078 4094 4079 if (0) … … 4316 4301 } 4317 4302 4318 4303 //////////////// 4319 4304 //-- export view cell geometry 4305 4320 4306 exporter->SetWireframe(); 4321 4307 … … 4324 4310 exporter->SetForcedMaterial(m); 4325 4311 4326 ExportViewCellGeometry(exporter, vc); 4327 4312 ExportViewCellGeometry(exporter, vc, NULL, NULL); 4328 4313 exporter->SetFilled(); 4329 4314 4330 4331 //-- export pvs4332 4315 if (1) 4333 4316 { 4317 //////// 4318 //-- export pvs 4334 4319 ObjectPvsMap::const_iterator oit, 4335 4320 oit_end = pvs.mEntries.end(); … … 4396 4381 4397 4382 exporter->SetForcedMaterial(RgbColor(0,1,0)); 4398 ExportViewCellGeometry(exporter, GetViewCell(viewPoint) );4383 ExportViewCellGeometry(exporter, GetViewCell(viewPoint), NULL, NULL); 4399 4384 4400 4385 //exporter->ResetForcedMaterial(); 4401 4386 exporter->SetForcedMaterial(RgbColor(0,0,1)); 4402 ExportViewCellGeometry(exporter, testPrVs.mViewCell );4387 ExportViewCellGeometry(exporter, testPrVs.mViewCell, NULL, NULL); 4403 4388 4404 4389 exporter->SetForcedMaterial(RgbColor(1,0,0)); … … 4491 4476 m.mDiffuseColor.b = 1.0f; 4492 4477 //exporter->SetForcedMaterial(m); 4493 //ExportViewCellGeometry(exporter, vc, mClipPlane );4478 //ExportViewCellGeometry(exporter, vc, mClipPlaneForViz); 4494 4479 4495 4480 /* // counting the pvss … … 4510 4495 4511 4496 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 4512 ViewCell *vc, 4513 const AxisAlignedPlane *clipPlane) const 4497 ViewCell *vc, 4498 const AxisAlignedBox3 *sceneBox, 4499 const AxisAlignedPlane *clipPlane 4500 ) const 4514 4501 { 4515 4502 if (clipPlane) … … 5013 5000 void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 5014 5001 ViewCell *vc, 5015 const AxisAlignedPlane *clipPlane) const 5002 const AxisAlignedBox3 *sceneBox, 5003 const AxisAlignedPlane *clipPlane 5004 ) const 5016 5005 { 5017 5006 ViewCellContainer leaves; … … 5021 5010 5022 5011 Plane3 plane; 5023 5012 5024 5013 if (clipPlane) 5025 {5026 5014 plane = clipPlane->GetPlane(); 5027 }5028 5029 AxisAlignedBox3 bbox = GetViewSpaceBox();5030 bbox.Scale(Vector3(0.5, 1, 0.5));5031 5015 5032 5016 for (it = leaves.begin(); it != it_end; ++ it) … … 5035 5019 VspLeaf *l = vspVc->mLeaf; 5036 5020 5037 const AxisAlignedBox3 box = mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 5021 const AxisAlignedBox3 box = 5022 mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 5038 5023 5039 if (!Overlap( box, bbox))5024 if (!Overlap(*sceneBox, box)) 5040 5025 continue; 5041 5026 … … 5049 5034 { 5050 5035 AxisAlignedBox3 fbox, bbox; 5051 b ox.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox);5036 bbox.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox); 5052 5037 5053 5038 exporter->ExportBox(bbox); … … 5084 5069 if (1) 5085 5070 { 5086 //////////// /////////////////5071 //////////// 5087 5072 //-- export final view cells 5088 5073 … … 5098 5083 cout << "exporting final view cells (after initial construction + post process) ... "; 5099 5084 5085 // matt: hack 5086 AxisAlignedBox3 bbox = mHierarchyManager->GetViewSpaceBox(); 5087 bbox.Scale(Vector3(0.5, 1, 0.5)); 5088 5100 5089 if (mExportGeometry) 5101 5090 { 5102 exporter->ExportGeometry(objects, true );5091 exporter->ExportGeometry(objects, true, &bbox); 5103 5092 } 5104 5093 … … 5109 5098 } 5110 5099 5111 // HACK: export without clip plane 5112 const bool b = mUseClipPlaneForViz; 5113 if (0) mUseClipPlaneForViz = false; 5114 5115 ExportViewCellsForViz(exporter); 5116 5117 mUseClipPlaneForViz = b; 5100 ExportViewCellsForViz(exporter, &bbox, GetClipPlane()); 5101 5118 5102 delete exporter; 5119 5120 5103 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5121 5104 } … … 5132 5115 { 5133 5116 const long starttime = GetTime(); 5117 5118 // matt: hack 5119 AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 5120 bbox.Scale(Vector3(0.5, 1, 0.5)); 5134 5121 5135 5122 cout << "exporting object space hierarchy ... "; 5136 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects );5123 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox); 5137 5124 5138 5125 delete exporter; … … 5187 5174 mViewCellsTree->GetPvs(vc, pvs); 5188 5175 5189 //bspLeaves[j]->Mail();5190 5176 char s[64]; sprintf(s, "bsp-pvs%04d.wrl", i); 5191 5177 Exporter *exporter = Exporter::GetExporter(s); … … 5266 5252 exporter->SetWireframe(); 5267 5253 5268 Material m; //= RandomMaterial();5254 Material m; 5269 5255 m.mDiffuseColor = RgbColor(0, 1, 0); 5270 5256 exporter->SetForcedMaterial(m); 5271 5257 5272 ExportViewCellGeometry(exporter, vc); 5273 5258 ExportViewCellGeometry(exporter, vc, NULL, NULL); 5274 5259 exporter->SetFilled(); 5275 5260
Note: See TracChangeset
for help on using the changeset viewer.