Changeset 1027 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 06/21/06 09:44:39 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1022 r1027 181 181 182 182 183 Debug << "*********** View Cells options ****************" << endl;183 Debug << "************ View Cells options ***************" << endl; 184 184 Debug << "color code: " << mColorCode << endl; 185 185 … … 417 417 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 418 418 419 //return 0; 419 420 420 // take post processing time 421 421 startTime = GetTime(); … … 1727 1727 { 1728 1728 mViewSpaceBox = box; 1729 1729 Debug << "here111 " << mViewSpaceBox << endl; 1730 // hack: create clip plane relative to new view space box 1730 1731 CreateClipPlane(); 1731 1732 // the total area of the view space has changed 1732 1733 mTotalAreaValid = false; 1733 1734 } … … 2928 2929 const Plane3 *clipPlane) const 2929 2930 { 2931 // export mesh if available 2930 2932 if (vc->GetMesh()) 2931 2933 { 2932 2934 exporter->ExportMesh(vc->GetMesh()); 2933 2934 2935 return; 2935 2936 } 2936 2937 2937 // otherwise construct from leaves 2938 2938 if (clipPlane) 2939 2939 { … … 4787 4787 ViewCellsManager(), mVspTree(vspTree), mOspTree(ospTree) 4788 4788 { 4789 Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 4789 mHierarchyManager = new HierarchyManager(*vspTree, *ospTree); 4790 Environment::GetSingleton()->GetIntValue("VspTree.Construction.samples", mInitialSamples); 4790 4791 mVspTree->SetViewCellsManager(this); 4791 4792 mVspTree->mViewCellsTree = mViewCellsTree; … … 4795 4796 VspOspViewCellsManager::~VspOspViewCellsManager() 4796 4797 { 4798 DEL_PTR(mHierarchyManager); 4797 4799 } 4798 4800 … … 4835 4837 mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 4836 4838 4839 Debug << "here125 view space box " << mViewSpaceBox << endl; 4840 4837 4841 // if view cells were already constructed 4838 4842 if (ViewCellsConstructed()) … … 4858 4862 long startTime; 4859 4863 4860 #if TODO 4861 if (1) 4862 mVspTree->Construct(constructionRays, &mViewSpaceBox); 4863 else 4864 mVspTree->Construct(rays, &mViewSpaceBox); 4865 #endif 4866 // collapse invalid regions 4867 cout << "collapsing invalid tree regions ... "; 4868 startTime = GetTime(); 4869 const int collapsedLeaves = mVspTree->CollapseTree(); 4870 Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3 4871 << " seconds" << endl; 4872 4873 cout << "finished" << endl; 4874 4864 mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4865 4866 4875 4867 //-- stats 4876 4868 Debug << mVspTree->GetStatistics() << endl; … … 4917 4909 4918 4910 4919 // view cells already finished before post processing step 4920 // (i.e. because they were loaded) 4911 // take this step only if 4912 // view cells already constructed before post processing step 4913 // (e.g., because they were loaded) 4921 4914 if (mViewCellsFinished) 4922 4915 { … … 5154 5147 5155 5148 5149 void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 5150 ViewCell *vc, 5151 const Plane3 *clipPlane) const 5152 { 5153 ViewCellContainer leaves; 5154 5155 mViewCellsTree->CollectLeaves(vc, leaves); 5156 ViewCellContainer::const_iterator it, it_end = leaves.end(); 5157 5158 for (it = leaves.begin(); it != it_end; ++ it) 5159 { 5160 VspViewCell *vspVc = dynamic_cast<VspViewCell *>(*it); 5161 VspLeaf *l = vspVc->mLeaf; 5162 5163 const AxisAlignedBox3 box = mVspTree->GetBBox(vspVc->mLeaf); 5164 5165 if (!clipPlane || !box.Side(*clipPlane)) 5166 exporter->ExportBox(box); 5167 } 5168 } 5169 5170 5156 5171 bool VspOspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 5157 5172 { … … 5161 5176 5162 5177 // return mViewSpaceBox.IsInside(viewPoint) && 5163 // mVsp BspTree->ViewPointValid(viewPoint);5178 // mVspTree->ViewPointValid(viewPoint); 5164 5179 } 5165 5180 … … 5170 5185 if (!ViewCellsConstructed()) 5171 5186 return; 5172 #if TODO 5187 5173 5188 VssRayContainer visRays; 5174 5189 GetRaySets(sampleRays, mVisualizationSamples, visRays); … … 5208 5223 5209 5224 // HACK: export without clip plane 5210 const bool b = mUseClipPlaneForViz;5211 mUseClipPlaneForViz = false;5225 //const bool b = mUseClipPlaneForViz; 5226 //mUseClipPlaneForViz = false; 5212 5227 5213 5228 ExportViewCellsForViz(exporter); 5214 5229 5215 mUseClipPlaneForViz = b;5230 //mUseClipPlaneForViz = b; 5216 5231 delete exporter; 5217 5232 … … 5220 5235 5221 5236 mColorCode = savedColorCode; 5222 }5223 5224 5225 if (0)5226 {5227 cout << "exporting depth map ... ";5228 5229 Exporter *exporter = Exporter::GetExporter("depth_map.x3d");5230 if (exporter)5231 {5232 if (1)5233 {5234 exporter->SetWireframe();5235 exporter->ExportBox(mViewSpaceBox);5236 exporter->SetFilled();5237 }5238 5239 if (mExportGeometry)5240 {5241 exporter->ExportGeometry(objects);5242 }5243 5244 const int maxDepth = mVspBspTree->mBspStats.maxDepth;5245 5246 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end();5247 5248 for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit)5249 {5250 ViewCell *vc = *vit;5251 5252 ViewCellContainer leaves;5253 mViewCellsTree->CollectLeaves(vc, leaves);5254 5255 ViewCellContainer::const_iterator lit, lit_end = leaves.end();5256 5257 for (lit = leaves.begin(); lit != lit_end; ++ lit)5258 {5259 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*lit)->mLeaf;5260 5261 Material m;5262 5263 float relDepth = (float)leaf->GetDepth() / (float)maxDepth;5264 m.mDiffuseColor.r = relDepth;5265 m.mDiffuseColor.g = 0.0f;5266 m.mDiffuseColor.b = 1.0f - relDepth;5267 5268 exporter->SetForcedMaterial(m);5269 5270 5271 BspNodeGeometry geom;5272 mVspBspTree->ConstructGeometry(leaf, geom);5273 exporter->ExportPolygons(geom.GetPolys());5274 }5275 }5276 5277 delete exporter;5278 }5279 5280 5281 cout << "finished" << endl;5282 }5283 5284 //-- visualization of the BSP splits5285 5286 bool exportSplits = false;5287 Environment::GetSingleton()->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits);5288 5289 if (exportSplits)5290 {5291 cout << "exporting splits ... ";5292 ExportSplits(objects, visRays);5293 cout << "finished" << endl;5294 5237 } 5295 5238 5296 5239 //-- export single view cells 5297 5240 ExportBspPvs(objects, visRays); 5298 #endif5299 5241 } 5300 5242 … … 5482 5424 5483 5425 5484 void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter,5485 ViewCell *vc,5486 const Plane3 *clipPlane) const5487 {5488 // matt: TODO5489 }5490 5491 5492 5426 bool VspOspViewCellsManager::ExportViewCells(const string filename, 5493 5427 const bool exportPvs, … … 5537 5471 5538 5472 //-- export the view cells and the pvs 5539 stream << "<HierarchyType name=\"vsp BspTree\" />" << endl;5473 stream << "<HierarchyType name=\"vspTree\" />" << endl; 5540 5474 5541 5475 const int numViewCells = mCurrentViewCellsStats.viewCells; … … 5566 5500 5567 5501 5568 ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point, const bool active) const 5502 ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point, 5503 const bool active) const 5569 5504 { 5570 5505 if (!ViewCellsConstructed()) … … 5582 5517 // matt: TODO 5583 5518 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 5519 5520 ViewCellContainer leaves; 5521 mViewCellsTree->CollectLeaves(vc, leaves); 5522 5523 ViewCellContainer::const_iterator it, it_end = leaves.end(); 5524 5525 for (it = leaves.begin(); it != it_end; ++ it) 5526 { 5527 VspLeaf *leaf = dynamic_cast<VspViewCell *>(*it)->mLeaf; 5528 const AxisAlignedBox3 box = mVspTree->GetBBox(leaf); 5529 5530 IncludeBoxInMesh(box, *mesh); 5531 } 5532 5584 5533 vc->SetMesh(mesh); 5585 5534 } … … 5596 5545 const bool createMesh) 5597 5546 { 5598 #if TODO5599 5547 float area = 0; 5600 5548 float volume = 0; … … 5607 5555 for (it = leaves.begin(); it != it_end; ++ it) 5608 5556 { 5609 BspNodeGeometry geom;5610 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf;5611 mVspBspTree->ConstructGeometry(leaf, geom);5612 5613 const float lVol = geom.GetVolume();5614 const float lArea = geom.GetArea();5557 VspLeaf *leaf = dynamic_cast<VspViewCell *>(*it)->mLeaf; 5558 5559 const AxisAlignedBox3 box = mVspTree->GetBBox(leaf); 5560 5561 const float lVol = box.GetVolume(); 5562 const float lArea = box.SurfaceArea(); 5615 5563 5616 5564 //(*it)->SetVolume(vol); … … 5625 5573 viewCell->SetVolume(volume); 5626 5574 viewCell->SetArea(area); 5627 #endif5628 5575 } 5629 5576
Note: See TracChangeset
for help on using the changeset viewer.