Changeset 837


Ignore:
Timestamp:
04/27/06 09:29:52 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
9 edited

Legend:

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

    r822 r837  
    13051305 
    13061306        RegisterOption("ViewCells.Evaluation.samplingType", 
    1307                         optString, 
    1308                         "view_cells_evaluation_sampling_type=", 
    1309                         "box"); 
     1307                                        optString, 
     1308                                        "view_cells_evaluation_sampling_type=", 
     1309                                        "box"); 
    13101310 
    13111311        RegisterOption("ViewCells.Evaluation.samplesPerPass", 
     
    13181318                                        "view_cells_export_to_file=", 
    13191319                                        "false"); 
     1320 
     1321        RegisterOption("ViewCells.pvsExportMode", 
     1322                                        optInt, 
     1323                                        "view_cells_export_bounding_boxes=", 
     1324                                        "2"); 
    13201325 
    13211326        RegisterOption("ViewCells.PostProcess.emptyViewCellsMerge", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r811 r837  
    2424  KdPvs mKdPvs; 
    2525   
    26   enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL }; 
     26  enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL, OGRE_MESH_INSTANCE }; 
    2727   
    2828  Intersectable():mMailbox(0) {} 
     
    3838         
    3939        void Mail() { mMailbox = sMailId; } 
    40   bool Mailed() const { return mMailbox == sMailId; } 
     40        bool Mailed() const { return mMailbox == sMailId; } 
    4141 
    4242        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
     
    6565                                                           Vector3 &normal, 
    6666                                                           const Vector3 &viewpoint, 
    67                                                                                                                         const int maxTries 
     67                                                          const int maxTries 
    6868                                                           ) = 0; 
    6969   
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r752 r837  
    10181018  } 
    10191019 
    1020   return beam.mKdNodes.size(); 
    1021 } 
     1020  return (int)beam.mKdNodes.size(); 
     1021} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r811 r837  
    2626 
    2727        if (0){ 
    28         // form figure 
     28        // form grrid of meshes 
    2929        for (int i = 0; i < n; ++ i) 
    3030        { 
     
    554554{ 
    555555  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 ++) { 
    558558        // now get the direction 
    559559        switch (sampleType) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r801 r837  
    663663         
    664664                        // 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 
    671674                        mergedVc->SetCost(realExpectedCost); 
    672675 
     
    727730                Debug << "setting root of the merge history" << endl; 
    728731                mRoot = activeViewCells[0]; 
    729                 Debug << "volume of the root view cell: " << mRoot->GetVolume() << " " << mViewCellsManager->GetViewSpaceBox().GetVolume() << endl; 
    730732        } 
    731733        else 
     
    739741                mMergeQueue.pop(); 
    740742        } 
    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 
    744751        mergeStats.expectedRenderCost = realExpectedCost; 
    745752        mergeStats.deviation = mDeviation; 
     
    19521959 
    19531960 
    1954 bool ViewCellsTree::Export(ofstream &stream) 
    1955 { 
    1956         ExportViewCell(mRoot, stream); 
     1961bool ViewCellsTree::Export(ofstream &stream, const int pvsType) 
     1962{ 
     1963        // export recurvivly all view cells from the root 
     1964        ExportViewCell(mRoot, stream, pvsType); 
    19571965 
    19581966        return true; 
     
    19881996 
    19891997 
    1990 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream) 
     1998void ViewCellsTree::ExportPvs(ViewCell *viewCell, ofstream &stream, const int pvsType) 
    19911999{ 
    19922000        ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 
    19932001 
     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 
     2029void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream, const int pvsType) 
     2030{ 
    19942031        if (viewCell->IsLeaf()) 
    19952032        { 
     
    19992036                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
    20002037                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); 
    20072042         
    20082043                stream << "\" />" << endl; 
     
    20172052                stream << "active=\"" << viewCell->IsActive() << "\" "; 
    20182053                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                } 
    20262062 
    20272063                stream << "\" >" << endl; 
    20282064 
     2065                //-- recursivly export child view cells 
    20292066                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    20302067 
    20312068                for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    20322069                { 
    2033                         ExportViewCell(*it, stream); 
     2070                        ExportViewCell(*it, stream, pvsType); 
    20342071                } 
    20352072 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r810 r837  
    384384        void SetViewCellsStorage(int type); 
    385385 
    386         /** pvs storage methods */ 
     386        /** pvs storage methods  
     387        */ 
    387388        enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES}; 
    388389 
     390        enum {EXPORT_EMPTY_PVS, EXPORT_IDS, EXPORT_BBOXES}; 
     391 
    389392        /** If view cells in this tree have compressed pvs. 
    390393        */ 
     
    403406        void PropagatePvs(ViewCell *vc); 
    404407 
    405         bool Export(ofstream &stream); 
     408        /** Exports view cells to file. 
     409        */ 
     410    bool Export(ofstream &stream, const int pvsType = EXPORT_EMPTY_PVS); 
    406411 
    407412        /** Export statistics of this view cell tree. 
     
    503508        */ 
    504509        float GetMemUsage() const; 
    505          
    506         /** 
    507                 Exports single view cell. 
     510 
     511        /**     Exports single view cell. 
    508512                NOTE: should be in exporter!! 
    509513        */ 
    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); 
    511519 
    512520 
     
    522530 
    523531         
    524         /** intermediate container of merged view cells. 
    525 */ 
     532        /// intermediate container of merged view cells. 
    526533        ViewCellContainer mMergedViewCells; 
    527534         
    528535 
     536        /// if merged view cells are refined. 
    529537        bool mRefineViewCells; 
    530538 
     
    537545    float mDeviation; 
    538546        float mAvgRenderCost; 
    539  
     547        /// the area is used for pvs heuristics 
    540548        int mUseAreaForPvs; 
    541549 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r827 r837  
    9292        environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 
    9393        environment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType); 
     94 
     95        environment->GetIntValue("ViewCells.pvsExportMode", mPvsExportMode); 
    9496 
    9597        char buf[100]; 
     
    11491151{ 
    11501152  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; 
    11581163  } 
     1164 
    11591165  return true; 
    11601166} 
     
    25762582        stream << "<ViewCells>" << endl; 
    25772583 
    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); 
    25872585 
    25882586        stream << "</ViewCells>" << endl; 
     
    37253723int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 
    37263724                                                                                const VssRayContainer &rays) 
    3727 { 
     3725{Debug << "here8773" << endl; 
    37283726        if (!ViewCellsConstructed()) 
    37293727        { 
     
    38243822 
    38253823 
     3824        Debug << "here3" << endl; 
    38263825        // write view cells to disc 
    38273826        if (mExportViewCells) 
    38283827        { 
     3828        Debug << "here4" << endl; 
    38293829                char buff[100]; 
    38303830                environment->GetStringValue("ViewCells.filename", buff); 
     
    39503950        { 
    39513951                interior->mPvs = pvs; 
    3952                 //cout << "here233" << endl; 
    39533952        } 
    39543953         
     
    45714570        stream << "<Hierarchy name=\"vspBspTree\" />" << endl; 
    45724571 
    4573         //-- load the view cells itself, i.e., the ids and the pvs 
     4572        //-- export the view cells itself, i.e., the ids and the pvs 
    45744573        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); 
    45854576 
    45864577        stream << "</ViewCells>" << endl; 
    45874578 
    4588         //-- load the hierarchy 
     4579        //-- export the hierarchy 
    45894580        stream << "<Hierarchy>" << endl; 
    45904581        mVspBspTree->Export(stream); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r810 r837  
    499499 
    500500 
     501        int mPvsExportMode; 
    501502 
    502503        Plane3 mClipPlane; 
     504 
    503505        bool mUseClipPlaneForViz; 
    504506 
     
    843845        void CreateMesh(ViewCell *vc); 
    844846 
    845         //bool LoadViewCellsGeometry(const string filename, ObjectContainer *objects); 
    846847        bool ExportViewCells(const string filename); 
    847848 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r822 r837  
    12471247         
    12481248        // the relative cost ratio 
    1249         float ratio = /*Limits::Infinity;*/99999999.0; 
     1249        float ratio = /*Limits::Infinity;*/99999999.0f; 
    12501250        bool splitPlaneFound = false; 
    12511251 
     
    14301430        int bestAxis; 
    14311431 
     1432        // if max cost ratio is exceeded, take split along longest axis instead 
     1433        const float maxCostRatioForArbitraryAxis = 0.9f; 
     1434 
    14321435        if (mUseDrivingAxisForMaxCost) 
    14331436                bestAxis = box.Size().DrivingAxis(); 
     
    14371440        // mximum cost ratio for axis to be valid: 
    14381441        // 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; 
    14471447 
    14481448 
     
    14761476                         
    14771477                        //-- 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  
    14821484                        { 
    14831485 
     
    15411543                        { 
    15421544                                 // 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])) 
    15441546                                { 
    15451547                                        bestAxis = axis; 
    15461548                                } 
    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; 
    15491551                                 
    15501552                        } 
Note: See TracChangeset for help on using the changeset viewer.