Ignore:
Timestamp:
06/21/06 09:44:39 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1022 r1027  
    181181 
    182182 
    183         Debug << "***********View Cells options ****************" << endl; 
     183        Debug << "************ View Cells options ***************" << endl; 
    184184        Debug << "color code: " << mColorCode << endl; 
    185185 
     
    417417                  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    418418 
    419 //return 0; 
     419 
    420420        // take post processing time 
    421421        startTime = GetTime(); 
     
    17271727{ 
    17281728        mViewSpaceBox = box; 
    1729  
     1729        Debug << "here111 " << mViewSpaceBox << endl; 
     1730        // hack: create clip plane relative to new view space box 
    17301731        CreateClipPlane(); 
    1731          
     1732        // the total area of the view space has changed 
    17321733        mTotalAreaValid = false; 
    17331734} 
     
    29282929                                                                                                 const Plane3 *clipPlane) const 
    29292930{ 
     2931        // export mesh if available 
    29302932        if (vc->GetMesh()) 
    29312933        { 
    29322934                exporter->ExportMesh(vc->GetMesh()); 
    2933          
    29342935                return; 
    29352936        } 
    2936  
    2937          
     2937        // otherwise construct from leaves 
    29382938        if (clipPlane) 
    29392939        { 
     
    47874787ViewCellsManager(), mVspTree(vspTree), mOspTree(ospTree) 
    47884788{ 
    4789         Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 
     4789        mHierarchyManager = new HierarchyManager(*vspTree, *ospTree); 
     4790        Environment::GetSingleton()->GetIntValue("VspTree.Construction.samples", mInitialSamples); 
    47904791        mVspTree->SetViewCellsManager(this); 
    47914792        mVspTree->mViewCellsTree = mViewCellsTree; 
     
    47954796VspOspViewCellsManager::~VspOspViewCellsManager() 
    47964797{ 
     4798        DEL_PTR(mHierarchyManager); 
    47974799} 
    47984800 
     
    48354837        mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 
    48364838 
     4839        Debug << "here125 view space box " << mViewSpaceBox << endl; 
     4840 
    48374841        // if view cells were already constructed 
    48384842        if (ViewCellsConstructed()) 
     
    48584862        long startTime; 
    48594863 
    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         
    48754867        //-- stats 
    48764868        Debug << mVspTree->GetStatistics() << endl; 
     
    49174909 
    49184910 
    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) 
    49214914        if (mViewCellsFinished) 
    49224915        { 
     
    51545147 
    51555148 
     5149void 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 
    51565171bool VspOspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    51575172{ 
     
    51615176 
    51625177  //    return mViewSpaceBox.IsInside(viewPoint) && 
    5163   //               mVspBspTree->ViewPointValid(viewPoint); 
     5178  //               mVspTree->ViewPointValid(viewPoint); 
    51645179} 
    51655180 
     
    51705185        if (!ViewCellsConstructed()) 
    51715186                return; 
    5172 #if TODO 
     5187 
    51735188        VssRayContainer visRays; 
    51745189        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
     
    52085223 
    52095224                        // HACK: export without clip plane 
    5210                         const bool b = mUseClipPlaneForViz; 
    5211                         mUseClipPlaneForViz = false; 
     5225                        //const bool b = mUseClipPlaneForViz; 
     5226                        //mUseClipPlaneForViz = false; 
    52125227 
    52135228                        ExportViewCellsForViz(exporter); 
    52145229                         
    5215                         mUseClipPlaneForViz = b; 
     5230                        //mUseClipPlaneForViz = b; 
    52165231                        delete exporter; 
    52175232 
     
    52205235 
    52215236                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 splits 
    5285  
    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; 
    52945237        } 
    52955238 
    52965239        //-- export single view cells 
    52975240        ExportBspPvs(objects, visRays); 
    5298 #endif 
    52995241} 
    53005242 
     
    54825424 
    54835425 
    5484 void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    5485                                                     ViewCell *vc, 
    5486                                                                                                         const Plane3 *clipPlane) const 
    5487 { 
    5488         // matt: TODO 
    5489 } 
    5490  
    5491  
    54925426bool VspOspViewCellsManager::ExportViewCells(const string filename,  
    54935427                                                                                         const bool exportPvs,  
     
    55375471 
    55385472        //-- export the view cells and the pvs 
    5539         stream << "<HierarchyType name=\"vspBspTree\" />" << endl; 
     5473        stream << "<HierarchyType name=\"vspTree\" />" << endl; 
    55405474 
    55415475        const int numViewCells = mCurrentViewCellsStats.viewCells; 
     
    55665500 
    55675501 
    5568 ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point, const bool active) const 
     5502ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point,  
     5503                                                                                          const bool active) const 
    55695504{ 
    55705505        if (!ViewCellsConstructed()) 
     
    55825517        // matt: TODO 
    55835518        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 
    55845533        vc->SetMesh(mesh); 
    55855534} 
     
    55965545                                                                          const bool createMesh) 
    55975546{ 
    5598 #if TODO 
    55995547        float area = 0; 
    56005548        float volume = 0; 
     
    56075555    for (it = leaves.begin(); it != it_end; ++ it) 
    56085556        { 
    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(); 
    56155563 
    56165564                //(*it)->SetVolume(vol); 
     
    56255573        viewCell->SetVolume(volume); 
    56265574        viewCell->SetArea(area); 
    5627 #endif 
    56285575} 
    56295576         
Note: See TracChangeset for help on using the changeset viewer.