Ignore:
Timestamp:
02/06/07 20:33:48 (17 years ago)
Author:
mattausch
Message:

revived ogre engine pvs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2067 r2097  
    136136                                                                                                        const String& typeName) 
    137137{ 
    138     // Clear out any existing world resources (if not default) 
     138        // Clear out any existing world resources (if not default) 
    139139    if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() !=  
    140140        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) 
     
    150150    loadConfig(stream); 
    151151 
    152         // apply parameters for file loading 
    153  
    154         // loas the scene 
     152        ////////////// 
     153        // file loading 
     154 
     155        // load the scene 
    155156        LoadScene(mFilename); 
    156  
     157         
    157158        // load view cells 
    158         mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 
     159        //mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 
    159160 
    160161        if (mShowTerrain) 
     
    170171                maxAxis = std::max(maxAxis, max_z); 
    171172                //resize(AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis)); 
    172                 resize( AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z ) ); 
     173                resize(AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z )); 
    173174 
    174175                setupTerrainMaterial(); 
     
    177178 } 
    178179#endif 
     180 
    179181//------------------------------------------------------------------------- 
    180182void OcclusionCullingSceneManager::loadConfig(DataStreamPtr& stream) 
     
    211213                { 
    212214                        mShowTerrain = true; 
    213                         LogManager::getSingleton().logMessage("creating terrain"); 
     215                        LogManager::getSingleton().logMessage("loading terrain"); 
    214216                } 
    215217        } 
     
    221223                if (!val.empty()) 
    222224                { 
    223                         mViewCellsFilename = val.c_str(); 
    224                         d << "view cells file name: " << mViewCellsFilename; 
    225                         LogManager::getSingleton().logMessage(d.str()); 
    226                 } 
    227         } 
    228          
     225                        mViewCellsFilename = val; 
     226                } 
     227        } 
     228 
    229229        val = config.getSetting("OnlineCullingAlgorithm"); 
    230230                 
     
    262262        } 
    263263 
    264         ///////////////////////////////////////// 
     264        ///////////// 
    265265        // terrain options 
    266266 
     
    268268                return; 
    269269 
    270         val = config.getSetting( "DetailTile" ); 
    271         if ( !val.empty() ) 
     270        val = config.getSetting("DetailTile"); 
     271        if (!val.empty()) 
    272272                setDetailTextureRepeat(atoi(val.c_str())); 
    273273 
    274         val = config.getSetting( "MaxMipMapLevel" ); 
    275         if ( !val.empty() ) 
    276                 setMaxGeoMipMapLevel(atoi( val.c_str() )); 
    277  
    278  
    279         val = config.getSetting( "PageSize" ); 
    280         if ( !val.empty() ) 
    281                 setPageSize(atoi( val.c_str() )); 
     274        val = config.getSetting("MaxMipMapLevel"); 
     275        if (!val.empty()) 
     276                setMaxGeoMipMapLevel(atoi(val.c_str())); 
     277 
     278 
     279        val = config.getSetting("PageSize"); 
     280        if (!val.empty()) 
     281                setPageSize(atoi(val.c_str())); 
    282282        else 
    283283                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSize'", 
     
    285285 
    286286 
    287         val = config.getSetting( "TileSize" ); 
    288         if ( !val.empty() ) 
    289                 setTileSize(atoi( val.c_str() )); 
     287        val = config.getSetting("TileSize"); 
     288        if (!val.empty()) 
     289                setTileSize(atoi(val.c_str())); 
    290290        else 
    291291                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'TileSize'", 
     
    472472                                        for (eit = entries->begin(); eit != eit_end; ++ eit) 
    473473                                        { 
    474                                                 //OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*eit); 
     474                                         
    475475                                                Entity *ent = *eit; 
    476476                                                Any newAny = ent->getUserAny(); 
    477477 
    478478                                                int flt = any_cast<int>(newAny); 
    479                                                 //std::stringstream d; d << "any: " << flt << " "; 
    480                                                 //Ogre::LogManager::getSingleton().logMessage(d.str()); 
     479                                         
    481480                                                if (any_cast<int>(newAny) == 0) 
    482481                                                { 
     
    485484                                                } 
    486485 
    487                                                 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 
    488486                                        } 
    489487                                } 
     
    883881        } 
    884882        if (key == "UseViewCells") 
    885         {  
     883        {        
     884                if (!mViewCellsLoaded) 
     885                { 
     886                        // try ro loaded view cells 
     887                        mViewCellsLoaded = LoadViewCells(mViewCellsFilename);    
     888                } 
     889 
     890                if (!mViewCellsLoaded) 
     891                        return false; 
     892                 
    886893                // only use this option if view cells are available 
    887                 if (mViewCellsLoaded) 
    888                 { 
    889                         mUseViewCells = *static_cast<const bool *>(val); 
    890  
    891                         // reset view cell 
    892                         OGRE_DELETE(mCurrentViewCell); 
     894 
     895                mUseViewCells = *static_cast<const bool *>(val); 
     896 
     897                // reset view cell 
     898                OGRE_DELETE(mCurrentViewCell); 
    893899                         
    894                         if (mUseViewCells) 
    895                         { 
    896                                 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 
    897                         } 
    898                         // view cell corresponding to leaf in the view cell hierarchy 
    899                         mElementaryViewCell = NULL; 
    900  
    901                         // if we decide use view cells 
    902                         // all objects are set to invisible per default 
    903                         SetObjectsVisible(!mUseViewCells); 
    904  
    905                         MovableObjectIterator movit = getMovableObjectIterator("Entity"); 
    906                         while (movit.hasMoreElements()) 
    907                         { 
    908                                 Entity *ent = static_cast<Entity *>(movit.getNext()); 
    909                                 ent->setVisible(!mUseViewCells); 
    910                         } 
    911                 } 
    912  
     900                if (mUseViewCells) 
     901                { 
     902                        mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 
     903                } 
     904                 
     905                // view cell corresponding to leaf in the view cell hierarchy 
     906                mElementaryViewCell = NULL; 
     907 
     908                // with view cells all objects are set to invisible per default 
     909                SetObjectsVisible(!mUseViewCells); 
     910 
     911                MovableObjectIterator movit = getMovableObjectIterator("Entity"); 
     912                while (movit.hasMoreElements()) 
     913                { 
     914                        Entity *ent = static_cast<Entity *>(movit.getNext()); 
     915                        ent->setVisible(!mUseViewCells); 
     916                } 
     917                 
    913918                return true; 
    914919        } 
     
    14221427bool OcclusionCullingSceneManager::LoadViewCells(const String &filename) 
    14231428{ 
     1429        // no filename specified 
    14241430        if (filename == "") 
    14251431                return false; 
    14261432 
     1433        // view cells already loaded 
    14271434        if (mViewCellsLoaded)  
    14281435                return true; 
     
    14321439 
    14331440        // load the view cells assigning the found objects to the pvss 
    1434         const bool finalizeViewCells = true; 
     1441        const bool finalizeViewCells = false; 
    14351442 
    14361443        mViewCellsManager = GtpVisibilityPreprocessor:: 
     
    14391446                                                                                true,  
    14401447                                                                                &bconverter); 
     1448         
     1449        Ogre::LogManager::getSingleton().logMessage("*******************"); 
    14411450 
    14421451        // objects are set to invisible initially 
     
    14531462void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
    14541463                                                                                                        const bool load) 
    1455 {       // NOTE: should not encounter NULL view cell,  
     1464{        
     1465        // NOTE: should not encounter NULL view cell,  
    14561466        // rather apply view cell representing unbounded space then 
    14571467        if (!vc)  
    14581468        {        
    1459                 // if no there is no view cell, set everything visible 
     1469                LogManager::getSingleton().logMessage("error: should not come here"); 
     1470                // question: if no view cell, set everything visible? 
    14601471                //SetObjectsVisible(true); 
    14611472                SetObjectsVisible(false); 
     
    14671478        //////////// 
    14681479        //-- set PVS of view cell to visible 
     1480 
     1481        std::stringstream d; d << "appying new view cell pvs: " << vc->GetPvs().GetSize(); 
     1482        LogManager::getSingleton().logMessage(d.str()); 
    14691483 
    14701484        while (pit.HasMoreEntries()) 
     
    14821496                                        OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 
    14831497                                        omi->GetEntity()->setVisible(load); 
    1484                                         //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 
    1485                                 } 
     1498                                }                                
    14861499                                break; 
    14871500                        case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 
    14881501                                { 
    1489                                         //GtpVisibilityPreprocessor::EngineIntersectable *oi =  
    1490                                         //      static_cast<GtpVisibilityPreprocessor::EngineIntersectable *>(entry); 
    14911502                                        EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 
    14921503 
    1493                                         //GtpVisibilityPreprocessor::ObjectContainer *entries = oi->GetItem(); 
    14941504                                        EntityContainer *entries = oi->GetItem(); 
    14951505 
     
    14981508                                        for (eit = entries->begin(); eit != eit_end; ++ eit) 
    14991509                                        { 
    1500                                                 //OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*eit); 
    1501                                                 //omi->GetEntity()->setVisible(load); 
    15021510                                                Entity *ent = *eit; 
    15031511                                                ent->setVisible(load);                                   
    1504                                                 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 
    15051512                                        } 
    15061513                                } 
     
    15201527                OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 
    15211528 
     1529        //std::stringstream d; d << "vp: " << viewPoint; 
     1530        //LogManager::getSingleton().logMessage(d.str()); 
     1531 
    15221532        GtpVisibilityPreprocessor::ViewCell *newElementary =  
    15231533                mViewCellsManager->GetViewCell(viewPoint); 
    15241534 
    1525         // elementary view cell did not change => apply same pvs 
     1535        // elementary view cell did not change => don't change pvs 
    15261536        if (mElementaryViewCell == newElementary) 
    15271537                return; 
     
    15571567        ApplyViewCellPvs(viewCell, true); 
    15581568 
    1559         // store pvs 
    15601569        if (viewCell) 
    15611570        { 
     1571                // store current view cell 
    15621572                mCurrentViewCell->SetPvs(viewCell->GetPvs()); 
    15631573                mCurrentViewCell->SetMesh(viewCell->GetMesh()); 
     
    16911701                return false; 
    16921702        } 
    1693  
     1703/* 
    16941704        for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i) 
    16951705        { 
     
    17091719                result = true; 
    17101720        } 
    1711          
     1721*/      result=true; 
    17121722        return result; 
    17131723} 
     
    17711781                const String& instanceName) 
    17721782{ 
    1773         OcclusionCullingSceneManager* tsm = new OcclusionCullingSceneManager(instanceName, visManager); 
     1783        OcclusionCullingSceneManager* tsm =  
     1784                new OcclusionCullingSceneManager(instanceName, visManager); 
    17741785         
    17751786        // Create & register default sources (one per manager) 
Note: See TracChangeset for help on using the changeset viewer.