Changeset 870


Ignore:
Timestamp:
05/02/06 10:26:43 (18 years ago)
Author:
mattausch
Message:

added pvs

Location:
GTP/trunk/Lib/Vis
Files:
3 added
20 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivmanualmeshloader.cpp

    r187 r870  
    146146                 
    147147        AxisAlignedBox bb(data->boundingBox->getMinimum() - translation, data->boundingBox->getMaximum() - translation); 
     148        //AxisAlignedBox bb(data->boundingBox->getMinimum(), data->boundingBox->getMaximum()); 
    148149        pMesh->_setBounds(bb);  
    149150        Real radius = data->boundingBox->getMinimum().length(); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h

    r868 r870  
    123123        /** Finds object corresponding to this bounding box in the scene. 
    124124        */ 
    125         MovableObject *FindCorrespondingObject(const AxisAlignedBox &box); 
     125        Entity *FindCorrespondingObject(const AxisAlignedBox &box); 
    126126 
    127127        /** Identifies objects in the scene and gives them unique ids that 
     
    129129        */ 
    130130        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects); 
     131 
     132        /** Loads / unloads pvs of the view cell to set the visibility in the scene. 
     133        */ 
     134        void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load); 
     135 
     136        /** updates pvs in current frame. 
     137        */ 
     138        void updatePvs(Camera *cam); 
     139 
     140        /** Sets all objects invisible. 
     141        */ 
     142        void SetObjectsVisible(const bool visible); 
    131143 
    132144        /// the interface to the scene hierarchy. 
     
    183195        bool mViewCellsLoaded; 
    184196        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 
     197 
     198        /** Used to assign Ogre meshes to view cell entries. 
     199        */ 
     200        GtpVisibilityPreprocessor::ObjectContainer mObjects; 
     201 
     202        GtpVisibilityPreprocessor::ViewCell *mOldViewCell; 
     203        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 
     204 
     205        /** If view cells are used. 
     206        */ 
     207        bool mUseViewCells; 
    185208}; 
    186209 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp

    r868 r870  
    1515#include <OgreConfigFile.h> 
    1616#include "OgreTypeConverter.h" 
     17#include "OgreMeshInstance.h" 
     18#include "common.h" 
    1719 
    1820// normal terrain rendering 
     
    4244mExecuteVertexProgramForAllPasses(true), 
    4345mIsHierarchicalCulling(false), 
    44 mViewCellsLoaded(false) 
     46mViewCellsLoaded(false), 
     47mCurrentViewCell(NULL), 
     48mOldViewCell(NULL), 
     49mUseViewCells(false) 
    4550{ 
    4651        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    8590{ 
    8691        OGRE_DELETE(mHierarchyInterface); 
     92        CLEAR_CONTAINER(mObjects); 
    8793} 
    8894//----------------------------------------------------------------------- 
     
    127133    } 
    128134        // add bounding boxes of rendered objects 
     135        if (0) 
    129136        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    130137{ 
     
    145152                        { 
    146153                                // render the leaf nodes 
    147                                 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) &&  
    148                                          (*it)->getAttachedObject(0)->getMovableType() == "Entity") 
     154                                if ((*it)->numAttachedObjects() &&  
     155                                        !(*it)->numChildren() &&  
     156                                        ((*it)->getAttachedObject(0)->getMovableType() == "Entity") && 
     157                                        (*it)->getAttachedObject(0)->isVisible()) 
    149158                                { 
    150159                                        getRenderQueue()->addRenderable((*it)); 
    151                                         std::stringstream d; 
    152                                         d << "here 223 " <<  (*it)->getAttachedObject(0)->getWorldBoundingBox(); 
    153                                         Ogre::LogManager::getSingleton().logMessage(d.str()); 
    154160                                } 
    155  
    156                                 // addbounding boxes instead of node itself 
    157                                 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 
    158161                        } 
    159162                        // add renderables itself 
     
    247250                return; 
    248251        } 
     252         
    249253 
    250254        //-- show visible scene nodes and octree bounding boxes from last frame 
     
    265269                        OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    266270                } 
     271 
    267272                // only shadow casters will be rendered in shadow texture pass 
    268273                if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     274 
     275 
     276                //-- apply view cell pvs 
     277                updatePvs(cam); 
    269278        } 
    270279         
     
    311320        else //-- the hierarchical culling algorithm 
    312321        {        
    313                 // this is also called in TerrainSceneManager: really 
    314                 // nexessary? 
     322                // this is also called in TerrainSceneManager: really necessary? 
    315323                //mDestRenderSystem -> setLightingEnabled(false); 
    316324 
     
    498506                if (!mViewCellsLoaded) 
    499507                { 
    500                         LoadViewCells(""); 
    501                         mViewCellsLoaded = true; 
    502                 } 
    503  
    504                 return true; 
    505         } 
    506  
     508                        LoadViewCells(static_cast<const char *>(val)); 
     509                        mViewCellsLoaded = true;         
     510                } 
     511 
     512                return true; 
     513        } 
     514        if (key == "UseViewCells") 
     515        {  
     516                if (mViewCellsLoaded) 
     517                { 
     518                        mUseViewCells = *static_cast<const bool *>(val); 
     519                         
     520                        if (mUseViewCells) 
     521                        { 
     522                                SetObjectsVisible(false); 
     523                                mCurrentViewCell = mOldViewCell = NULL; 
     524                        } 
     525                        else 
     526                        { 
     527                                SetObjectsVisible(true); 
     528                        } 
     529                } 
     530 
     531                return true; 
     532        } 
    507533        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    508534                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
     
    876902   } 
    877903} 
    878 //----------------------------------------------------------------------- 
    879 MovableObject *VisibilityOctreeSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 
     904 
     905inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 
     906{ 
     907        const float eps = 1e-3f; 
     908        const Vector3 veps(eps, eps, eps); 
     909        Vector3 max = box.getMaximum(); 
     910        Vector3 min = box.getMinimum(); 
     911 
     912        return AxisAlignedBox(min - veps, max + veps); 
     913} 
     914//----------------------------------------------------------------------- 
     915Entity *VisibilityOctreeSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 
    880916{ 
    881917        list<SceneNode *> sceneNodeList; 
    882  
    883         findNodesIn(box, sceneNodeList, NULL); 
    884         std::stringstream d;  
    885         d << "\n*******************"; 
    886         Ogre::LogManager::getSingleton().logMessage(d.str()); 
     918        AxisAlignedBox mybox = EnlargeBox(box); 
     919        //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000)); 
     920         
     921        // get intersecting scene nodes 
     922        findNodesIn(mybox, sceneNodeList, NULL); 
     923         
     924 
    887925        list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
    888926 
    889         float overlap = GtpVisibilityPreprocessor::Limits::Small; 
    890  
    891          
    892         d << "here23 " << box; 
    893         Ogre::LogManager::getSingleton().logMessage(d.str()); 
    894  
    895         MovableObject *bestFittingObj = NULL; 
     927        float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small; 
     928 
     929        Entity *bestFittingObj = NULL; 
    896930        float bestFit = overlap; 
    897931 
     
    908942        while (oit.hasMoreElements()) 
    909943                { 
    910                          MovableObject *mo = oit.getNext(); 
    911                          const AxisAlignedBox bbox = mo->getWorldBoundingBox(true); 
    912                          
    913                          overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(box), 
    914                                                                           OgreTypeConverter::ConvertFromOgre(bbox)); 
     944                        MovableObject *mo = oit.getNext(); 
     945 
     946                        // we are only interested in scene entities 
     947                        if (mo->getMovableType() != "Entity") 
     948                        { 
     949                                continue; 
     950                        } 
     951                          
     952                        const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 
     953                                         
     954 
     955                        // compute measure how much aabbs overlap 
     956                        overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox), 
     957                                                                         OgreTypeConverter::ConvertFromOgre(bbox)); 
     958         
    915959                         if (overlap > bestFit) 
    916960                         { 
    917961                                 bestFit = overlap; 
    918                                  bestFittingObj = mo; 
    919                                 d << "new bestfit " << bestFit << endl;Ogre::LogManager::getSingleton().logMessage(d.str()); 
    920                                  // perfect fit => object found 
     962                         
     963                                 bestFittingObj = static_cast<Entity *>(mo); 
     964 
     965                                 // perfect fit => object found, eraly exit 
    921966                                 if (overlap >= thresh) 
    922                                  { 
    923                                          std::stringstream d2;  
    924          
    925                         d2 << "!!best fit " << bestFittingObj->getWorldBoundingBox(true); 
    926         Ogre::LogManager::getSingleton().logMessage(d2.str()); 
    927                                         return bestFittingObj; 
    928                                         } 
     967                                         return bestFittingObj;                          
    929968                         } 
    930969                } 
    931970        } 
    932971 
    933         std::stringstream d2;  
    934         if (bestFittingObj) 
    935         { 
    936                 d2 << "best fit " << bestFittingObj->getWorldBoundingBox(true); 
    937         } 
    938         else 
    939         { 
    940                 d2 << "warning, no best fitting objects"; 
    941         } 
    942  
    943         Ogre::LogManager::getSingleton().logMessage(d2.str()); 
     972        if (0) 
     973        { 
     974                std::stringstream d;  
     975                if (bestFittingObj) 
     976                        d << "best fit: " << bestFit;      
     977                else 
     978                        d << "warning, objects do not fit\n" << box; 
     979         
     980                Ogre::LogManager::getSingleton().logMessage(d.str()); 
     981        } 
    944982 
    945983        return bestFittingObj; 
     
    948986void VisibilityOctreeSceneManager::LoadViewCells(string filename) 
    949987{ 
    950         GtpVisibilityPreprocessor::ObjectContainer objects; 
     988        // the objects are set to invisible a prioriy 
     989        SetObjectsVisible(false); 
     990 
    951991        // identify the corresponding Ogre meshes using the bounding boxes 
    952         IdentifyObjects(objects); 
     992        IdentifyObjects(mObjects); 
    953993 
    954994        // load the view cells assigning the found objects to the pvss 
    955         //mViewCellsManager->LoadViewCells(filename, &objects); 
     995        mViewCellsManager =  
     996                GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects); 
     997 
     998        std::stringstream d; 
     999        d << "view cells loaded" << endl; 
     1000        Ogre::LogManager::getSingleton().logMessage(d.str()); 
    9561001} 
    9571002//----------------------------------------------------------------------- 
     
    9701015                  const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 
    9711016                  const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 
    972                    
    973                   MovableObject *mo = FindCorrespondingObject(currentBox); 
    974  
    975                   //objects.push_back(mi); 
    976         } 
    977 } 
    978  
     1017                  
     1018                  Entity *ent = FindCorrespondingObject(currentBox); 
     1019 
     1020                  // create new mesh instance 
     1021                  OgreMeshInstance *omi = new OgreMeshInstance(ent); 
     1022                  omi->SetId((*iit).first); 
     1023                  objects.push_back(omi); 
     1024        } 
     1025} 
    9791026//------------------------------------------------------------------------- 
    980 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename) 
    981 { 
    982         /// Set up the options 
     1027void VisibilityOctreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
     1028                                                                                                        const bool load) 
     1029{       GtpVisibilityPreprocessor::Debug << "here9 " << endl; 
     1030        // NOTE: should not happen, rather apply view cell representing unbounded space then 
     1031        if (!vc) return; 
     1032 
     1033        GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit, 
     1034                        oit_end = vc->GetPvs().mEntries.end(); 
     1035 
     1036        //-- PVS of view cell 
     1037        for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1038        { 
     1039                if (!(*oit).first) continue; 
     1040 
     1041                OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first); 
     1042                omi->GetMesh()->setVisible(load); 
     1043                GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 
     1044        } 
     1045} 
     1046//------------------------------------------------------------------------- 
     1047void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible) 
     1048{ 
     1049        // for OGRE 1.2 
     1050#ifdef OGRE12 
     1051        MovableObjectIterator mit = getMovableObjectIterator("Entity"); 
     1052#else 
     1053        EntityIterator eit = getEntityIterator(); 
     1054 
     1055        // set all objects to invisible (initially); 
     1056        while (eit.hasMoreElements()) 
     1057        { 
     1058                Entity *ent = eit.getNext(); 
     1059                ent->setVisible(visible); 
     1060        } 
     1061 
     1062#endif 
     1063} 
     1064//------------------------------------------------------------------------- 
     1065void VisibilityOctreeSceneManager::loadVisibilityConfig(const String &filename) 
     1066{ 
     1067        // TODO matt 
     1068        // Set up the options 
    9831069        ConfigFile config; 
    9841070        String val; 
     
    10001086        } 
    10011087} 
     1088//------------------------------------------------------------------------- 
     1089void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 
     1090{ 
     1091        Ogre::LogManager::getSingleton().logMessage("here196"); 
     1092        if (mViewCellsLoaded && mUseViewCells) 
     1093        { 
     1094                GtpVisibilityPreprocessor::ViewCell *vc =  
     1095                        mViewCellsManager->GetViewCell(OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition())); 
     1096 
     1097                std::stringstream d; d << "pos " << cam->getDerivedPosition() << "vc: " << vc; 
     1098                Ogre::LogManager::getSingleton().logMessage(d.str()); 
     1099 
     1100                // view cell changed => unload old objects and load new objects 
     1101                if (vc != mCurrentViewCell) 
     1102                { 
     1103                        //-- unload old pvs 
     1104                        if (mOldViewCell) 
     1105                        { 
     1106                                const bool load = false; 
     1107 
     1108                                applyViewCellPvs(mOldViewCell, load); 
     1109                                Ogre::LogManager::getSingleton().logMessage("here16"); 
     1110                        } 
     1111 
     1112                        mOldViewCell = mCurrentViewCell; 
     1113 
     1114                        //-- load new pvs 
     1115                        mCurrentViewCell = vc; 
     1116                        const bool load = true; 
     1117 
     1118                        applyViewCellPvs(mCurrentViewCell, load); 
     1119                        Ogre::LogManager::getSingleton().logMessage("here106"); 
     1120                } 
     1121        } 
     1122} 
     1123 
    10021124}  // namespace Ogre 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp

    r657 r870  
    4949{ 
    5050        visEnv = new GtpVisibility::VisibilityEnvironment(); 
     51        visEnv->LoadEnvironment("vienna_simple.env"); 
    5152        visManager = new GtpVisibility::VisibilityManager(visEnv); 
    5253 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h

    r254 r870  
    11#ifndef _VisibilityEnvironment_H__ 
    22#define _VisibilityEnvironment_H__ 
     3 
     4#include <string> 
    35 
    46namespace GtpVisibility { 
     
    1012public: 
    1113    VisibilityEnvironment(); 
    12          
     14        ~VisibilityEnvironment(); 
    1315        /** Different types of occlusion culling algorithms  
    1416        */ 
     
    2022        /** Loads an environment from disk. 
    2123        */ 
    22         void LoadEnvironment(); 
     24        void LoadEnvironment(std::string filename); 
    2325}; 
    2426} // namespace GtpVisibility 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj

    r827 r870  
    6363                                Name="VCCLCompilerTool" 
    6464                                OptimizeForWindowsApplication="TRUE" 
    65                                 AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;" 
     65                                AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src" 
    6666                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 
    6767                                RuntimeLibrary="2" 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp

    r100 r870  
    11#include "VisibilityEnvironment.h" 
     2#include "common.h" 
     3#include "Environment.h" 
     4 
    25 
    36namespace GtpVisibility { 
     
    69VisibilityEnvironment::VisibilityEnvironment() 
    710{ 
     11        // load debug stream 
     12        GtpVisibilityPreprocessor::Debug.open("debug.log"); 
     13          
     14} 
     15VisibilityEnvironment::~VisibilityEnvironment() 
     16{ 
     17        // load debug stream 
     18        DEL_PTR(GtpVisibilityPreprocessor::environment); 
     19          
    820} 
    921//----------------------------------------------------------------------- 
    10 void VisibilityEnvironment::LoadEnvironment() 
     22void VisibilityEnvironment::LoadEnvironment(string filename) 
    1123{ 
     24        // todo matt: 
     25        GtpVisibilityPreprocessor::environment = new GtpVisibilityPreprocessor::Environment; 
     26         
     27        char argc = 2; 
     28        char *argv[2]; 
     29        argv[0] = ""; 
     30         
     31        char fname[200]; 
     32        sprintf(fname, "%s", filename.c_str()); 
     33        argv[1] = fname; 
     34 
     35        GtpVisibilityPreprocessor::Debug << "filename: " << argv[1] << endl; 
     36 
     37        GtpVisibilityPreprocessor::environment->Parse(argc, argv, false); 
     38        //MeshKdTree::ParseEnvironment(); 
    1239} 
    1340 
     41 
    1442} // namespace GtpVisibility 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r863 r870  
    142142        between 0 (no overlap) and 1 (same box). 
    143143  */ 
    144   friend inline float FactorOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 
     144  friend inline float RatioOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 
    145145 
    146146  /** Includes returns true if a includes b (completely) 
     
    540540} 
    541541 
    542 inline float FactorOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 
    543 { 
    544         const AxisAlignedBox3 isect = Intersect(box1, box2); 
    545         return isect.GetVolume() / box1.GetVolume(); 
     542inline float RatioOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 
     543{ 
     544        // return ratio of intersection to union 
     545        const AxisAlignedBox3 bisect = Intersect(box1, box2); 
     546        const AxisAlignedBox3 bunion = Union(box1, box2); 
     547 
     548        return bisect.GetVolume() / bunion.GetVolume(); 
    546549} 
    547550 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r860 r870  
    4949 
    5050    virtual AxisAlignedBox3 GetBox() = 0; 
    51         virtual int CastRay(Ray &ray) = 0; 
     51        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0; 
    5252         
    5353        virtual bool IsConvex() = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r863 r870  
    6969Mesh::Preprocess() 
    7070{ 
    71  Cleanup(); 
     71        Cleanup(); 
    7272    
    73    ComputeBoundingBox(); 
     73        ComputeBoundingBox(); 
    7474    
    75   /** true if it is a watertight convex mesh */ 
    76   mIsConvex = false; 
    77    
    78   if (mFaces.size() > MeshKdTree::mTermMinCost) { 
    79     mKdTree = new MeshKdTree(this); 
    80     MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 
    81     for (int i = 0; i < mFaces.size(); i++) 
    82       root->mFaces.push_back(i); 
    83     cout<<"KD"; 
    84     mKdTree->Construct(); 
    85          
    86     if (mKdTree->GetRoot()->IsLeaf()) { 
    87       cout<<"d"; 
    88       delete mKdTree; 
    89           mKdTree = NULL; 
    90     } 
    91   } 
     75        /** true if it is a watertight convex mesh  
     76        */ 
     77        mIsConvex = false; 
     78 
     79        if (mFaces.size() > MeshKdTree::mTermMinCost)  
     80        { 
     81                mKdTree = new MeshKdTree(this); 
     82                MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 
     83                 
     84                for (int i = 0; i < mFaces.size(); i++) 
     85                        root->mFaces.push_back(i); 
     86                 
     87                cout<<"KD"; 
     88                mKdTree->Construct(); 
     89 
     90                if (mKdTree->GetRoot()->IsLeaf())  
     91                { 
     92                        cout<<"d"; 
     93                        delete mKdTree; 
     94                        mKdTree = NULL; 
     95                } 
     96        } 
    9297} 
    9398 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r863 r870  
    2222 
    2323/// vertex index container 
    24 typedef std::vector<short> VertexIndexContainer; 
    25  
     24//typedef std::vector<short> VertexIndexContainer; 
     25typedef std::vector<int> VertexIndexContainer; 
    2626 
    2727/** Patch used as an element of the mesh */ 
     
    5858/// default vertex container for Mesh 
    5959typedef vector<Vector3> VertexContainer; 
    60  
    61 /// vertex index container 
    62 typedef vector<short> VertexIndexContainer; 
    6360 
    6461/// default patch container for Mesh 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r863 r870  
    374374                Debug << "view cell type: VspBsp" << endl; 
    375375 
    376                 mVspBspTree = new VspBspTree(); 
     376                mVspBspTree = new VspBspTree(environment); 
    377377                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    378378        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r863 r870  
    20332033                stream << "active=\"" << viewCell->IsActive() << "\" "; 
    20342034                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
     2035                stream << "pvs=\""; 
     2036 
     2037                //-- NOTE: do not export pvss for interior view cells because 
     2038                // they can be completely reconstructed from the leaf pvss 
     2039                if (0) 
     2040                        ExportPvs(viewCell, stream); 
    20352041                 
    2036                 //-- NOTE: do not export pvss for interior view cells because 
    2037                 // they can be compeletely reconstructed from the leaf pvss 
    2038                 if (0) 
    2039                 { 
    2040                         stream << "pvs=\""; 
    2041                         ExportPvs(viewCell, stream); 
    2042                 } 
    2043  
    20442042                stream << "\" >" << endl; 
    20452043 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r863 r870  
    46834683        ViewCellsManager *vm = NULL; 
    46844684 
     4685        Debug << "vc filename: " << filename << endl; 
     4686 
    46854687        if (parser.ParseFile(filename, &vm, objects)) 
    46864688        { 
     
    46994701        else 
    47004702        { 
    4701                 Debug << "failed loading view cells" << endl; 
     4703                Debug << "Error: loading view cells failed!" << endl; 
    47024704                DEL_PTR(vm); 
    47034705        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r860 r870  
    362362        virtual void FinalizeViewCells(const bool createMesh); 
    363363 
    364  
    365         /** Loads view cells from file. The view cells manager is created with  
    366                 respect to the loaded view cells. 
    367  
    368                 @returns the view cells manager if loading was successful, false otherwise 
    369         */ 
    370         static ViewCellsManager *LoadViewCells(const string filename,  
    371                                                                                    ObjectContainer *objects); 
    372  
    373364        /** Evaluates statistics values on view cells. 
    374365        */ 
     
    432423                                ); 
    433424 
    434   AxisAlignedBox3 
    435   GetViewCellBox(ViewCell *vc); 
     425        /** Returns bounding box of a view cell. 
     426        */ 
     427        AxisAlignedBox3 GetViewCellBox(ViewCell *vc); 
    436428 
    437429        /** Exports bounding boxes of objects to file. 
     
    442434        */ 
    443435        bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 
     436 
     437 
     438        /** Loads view cells from file. The view cells manager is created with  
     439                respect to the loaded view cells. 
     440 
     441                @returns the view cells manager if loading was successful, false otherwise 
     442        */ 
     443        static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 
    444444 
    445445protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r863 r870  
    117117        // go one up in the tree 
    118118        if (mCurrentBspNode->GetParent()) 
    119         {       cout << "]"; 
     119        {       Debug << "]"; 
    120120                mCurrentBspNode = mCurrentBspNode->GetParent(); 
    121121        } 
     
    127127        // go one up in the tree 
    128128        if (mCurrentViewCell->GetParent()) 
    129         {       cout << "]"; 
     129        {       Debug << "]"; 
    130130                mCurrentViewCell = mCurrentViewCell->GetParent(); 
    131131        } 
     
    160160                        const char *ptr = attrValue.LocalForm(); 
    161161                         
     162                        //-- the view cells manager is created here 
    162163                        CreateViewCellsManager(ptr); 
    163164                } 
     
    171172        if (element == "Interior")  
    172173        { 
    173                 cout << "["; 
     174                Debug << "["; 
    174175                StartBspInterior(attributes); 
    175176        } 
     
    177178        if (element == "Leaf")  
    178179        { 
    179                 cout << "l"; 
     180                Debug << "l"; 
    180181                Debug << "leaf" << endl; 
    181182                StartBspLeaf(attributes); 
     
    189190        StrX lname(name); 
    190191        string element(lname.LocalForm()); 
    191  
     192         
    192193        // decides the used view cell hierarchy 
    193194        if (element == "ViewCells") 
    194195        { 
    195                 cout << "parsing view cells" << endl; 
     196                Debug << "parsing view cells" << endl; 
    196197                mParseViewCells = true; 
    197198        } 
     
    199200        if (element == "Hierarchy") 
    200201        { 
    201                 cout << "parsing spatial hierarchy" << endl; 
     202                Debug << "parsing spatial hierarchy" << endl; 
    202203                mParseViewCells = false; 
    203204                StartHierarchy(attributes); 
     
    207208        if (element == "ViewSpaceBox") 
    208209        { 
    209                 cout << "b"; 
     210                Debug << "b"; 
    210211                StartViewSpaceBox(attributes); 
    211212        } 
     
    234235                if (element == "Interior")  
    235236                { 
    236                         cout << "["; 
     237                        Debug << "["; 
    237238                        StartViewCellInterior(attributes); 
    238239                } 
     
    240241                if (element == "Leaf")  
    241242                { 
    242                         cout << "l"; 
     243                        Debug << "l"; 
    243244                        StartViewCellLeaf(attributes); 
    244245                } 
     
    306307                                  // to sumof pdfs, i.e. its relative visibility 
    307308                                  // temporarily set to 1.0f 
    308                                         viewCell->GetPvs().AddSample(obj, 1.0f); 
     309                                        viewCell->GetPvs().AddSample(obj, 1.0f);                                 
    309310                                } 
    310311                                else 
     
    559560                mVspBspTree = new VspBspTree(); 
    560561                //mCurrentBspNode = mVspBspTree->GetRoot(); 
    561  
    562562                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    563563 
     
    573573        else 
    574574        { 
    575                 cerr<<"Wrong view cells type " << name << "!!!" << endl; 
     575                cerr << "Wrong view cells type: " << name << endl; 
    576576                exit(1); 
    577577        } 
     
    700700    catch (const XMLException& e) 
    701701      { 
    702         XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 
     702                        XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 
    703703                                  << StrX(e.getMessage()) 
    704704                                  << "\n" << XERCES_STD_QUALIFIER endl; 
    705         errorCount = 1; 
    706         return false; 
     705                        errorCount = 1; 
     706                        return false; 
    707707      } 
    708708 
     
    710710    // Print out the stats that we collected and time taken 
    711711    if (!errorCount) { 
    712       XERCES_STD_QUALIFIER cout << filename << ": " << duration << " ms (" 
     712                XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 
    713713                                << handler.GetElementCount() << " elems, " 
    714714                                << handler.GetAttrCount() << " attrs, " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r863 r870  
    5555 
    5656 
    57 VspBspTree::VspBspTree(): 
     57VspBspTree::VspBspTree(Environment *env): 
    5858mRoot(NULL), 
    5959mUseAreaForPvs(false), 
     
    6767{ 
    6868        bool randomize = false; 
    69         environment->GetBoolValue("VspBspTree.Construction.randomize", randomize); 
     69        env->GetBoolValue("VspBspTree.Construction.randomize", randomize); 
    7070        if (randomize) 
    7171                Randomize(); // initialise random generator for heuristics 
    7272 
    7373        //-- termination criteria for autopartition 
    74         environment->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 
    75         environment->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 
    76         environment->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 
    77         environment->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 
    78         environment->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 
    79         environment->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 
    80         environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    81         environment->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 
    82         environment->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
     74        env->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 
     75        env->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 
     76        env->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 
     77        env->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 
     78        env->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 
     79        env->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 
     80        env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
     81        env->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 
     82        env->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
    8383 
    8484        //-- max cost ratio for early tree termination 
    85         environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    86  
    87         environment->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
    88         environment->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
     85        env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
     86 
     87        env->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
     88        env->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    8989 
    9090        // HACK//mTermMinPolygons = 25; 
    9191 
    9292        //-- factors for bsp tree split plane heuristics 
    93         environment->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 
    94         environment->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 
     93        env->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 
     94        env->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 
    9595 
    9696 
    9797        //-- partition criteria 
    98         environment->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 
    99         environment->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 
    100         environment->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 
    101  
    102         environment->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 
    103         environment->GetIntValue("VspBspTree.maxTests", mMaxTests); 
     98        env->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 
     99        env->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 
     100        env->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 
     101 
     102        env->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 
     103        env->GetIntValue("VspBspTree.maxTests", mMaxTests); 
    104104 
    105105        // if only the driving axis is used for axis aligned split 
    106         environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
     106        env->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    107107         
    108108        //-- termination criteria for axis aligned split 
    109         environment->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
     109        env->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
    110110                                                                mTermMaxRayContriForAxisAligned); 
    111         environment->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 
     111        env->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 
    112112                                                         mTermMinRaysForAxisAligned); 
    113113 
    114         //environment->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 
    115         environment->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 
    116  
    117         environment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 
    118         environment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 
    119  
    120         environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
    121         environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
    122         environment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 
    123         environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 
    124         environment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 
    125  
    126         environment->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 
     114        //env->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 
     115        env->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 
     116 
     117        env->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 
     118        env->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 
     119 
     120        env->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
     121        env->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
     122        env->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 
     123        env->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 
     124        env->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 
     125 
     126        env->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 
    127127         
    128128        char subdivisionStatsLog[100]; 
    129         environment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 
     129        env->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 
    130130        mSubdivisionStats.open(subdivisionStatsLog); 
    131131 
    132         environment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 
    133         environment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 
    134         environment->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 
     132        env->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 
     133        env->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 
     134        env->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 
    135135 
    136136        //-- debug output 
     
    199199} 
    200200 
     201VspBspTree::VspBspTree(): 
     202mRoot(NULL), 
     203mUseAreaForPvs(false), 
     204mCostNormalizer(Limits::Small), 
     205mViewCellsManager(NULL), 
     206mOutOfBoundsCell(NULL), 
     207mStoreRays(false), 
     208mRenderCostWeight(0.5), 
     209mUseRandomAxis(false), 
     210mTimeStamp(1), 
     211mEpsilon(1e-6f) 
     212{ 
     213} 
    201214 
    202215BspViewCell *VspBspTree::GetOutOfBoundsCell() 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r863 r870  
    2626class Beam; 
    2727class ViewCellsTree; 
    28  
     28class Environment; 
    2929 
    3030/** 
     
    199199        VspBspTree(); 
    200200 
     201         
     202        /** Constructor creating an empty tree. Loads parameters  
     203                from an environment file. 
     204        */  
     205        VspBspTree(Environment *env); 
     206 
    201207        /** Default destructor. 
    202208        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r863 r870  
    219219        if (mLoadPolygonsAsMeshes) 
    220220        { 
    221                  
    222                 /*vector<VertexIndexContainer>::const_iterator it,  
    223                         it_end = mCurrentVertexIndices.end(); 
    224  
    225                 for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it) 
    226                 { 
    227                         // only one face per mesh 
    228                         Mesh *mesh = new Mesh(); 
    229  
    230                         VertexIndexContainer vc; 
    231  
    232                         // add vertices 
    233                         for (int i = 0; i < (int)(*it).size(); ++ i) 
    234                         { 
    235                                 mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 
    236                                 vc.push_back(i); 
    237                         } 
    238                          
    239                         mesh->mFaces.push_back(new Face(vc)); 
    240                          
    241                         // NOTE: should rather be written into trafo of mesh instance 
    242                         ApplyTransformations(mTransformations, mesh); 
    243  
    244                         mesh->Preprocess(); 
    245                         // make an instance of this mesh 
    246                         MeshInstance *mi = new MeshInstance(mesh); 
    247                         mCurrentNode->mGeometry.push_back(mi); 
    248  
    249                 }*/ 
    250  
    251221                //if (mCurrentMesh->mFaces.empty())     cout << "error!" << endl; 
    252222 
Note: See TracChangeset for help on using the changeset viewer.