Ignore:
Timestamp:
11/28/06 17:23:00 (18 years ago)
Author:
mattausch
Message:

changed occlusion culling scene manager
the configuration goes to the scene manager directly (only terrainculling.cfg)

File:
1 edited

Legend:

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

    r1816 r1823  
    5757mShowViewCells(false), 
    5858mViewCellsGeometryLoaded(false), 
    59 mShowTerrain(false) 
     59mShowTerrain(false), 
     60mViewCellsFilename(""), 
     61mFilename("terrain") 
    6062{ 
    6163        Ogre::LogManager::getSingleton(). 
     
    147149    loadConfig(stream); 
    148150 
     151        // apply parameters for file loading 
     152 
     153        // loas the scene 
     154        LoadScene(mFilename); 
     155 
     156        // load view cells 
     157        mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 
     158 
    149159        if (mShowTerrain) 
    150         { 
     160        {        
    151161                initLevelIndexes(); 
    152162 
    153163                // Resize the octree, allow for 1 page for now 
    154164                float max_x = mOptions.scale.x * mOptions.pageSize; 
    155                 float max_y = mOptions.scale.y; 
     165                float max_y = mOptions.scale.y;// * mOptions.pageSize; 
    156166                float max_z = mOptions.scale.z * mOptions.pageSize; 
    157167 
    158168                float maxAxis = std::max(max_x, max_y); 
    159169                maxAxis = std::max(maxAxis, max_z); 
    160                 resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) ); 
    161      
     170                //resize(AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis)); 
     171                resize( AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z ) ); 
     172 
    162173                setupTerrainMaterial(); 
    163174                setupTerrainPages(); 
    164         } 
     175        }        
    165176 } 
    166177#endif 
     
    168179void OcclusionCullingSceneManager::loadConfig(DataStreamPtr& stream) 
    169180{ 
    170         /* Set up the options */ 
     181        // Set up the options 
    171182        ConfigFile config; 
    172183        String val; 
     
    175186 
    176187        std::stringstream d;  
    177         //d << "reading the config file from: " << filename; 
    178         //LogManager::getSingleton().logMessage(d.str()); 
    179  
    180         val = config.getSetting("Scene"); 
     188                 
     189        val = config.getSetting("DepthPass"); 
    181190 
    182191    if (!val.empty()) 
    183192        { 
    184                  string filename = val.c_str(); 
    185                  LoadScene(filename); 
    186         } 
    187  
    188         val = config.getSetting("ViewCells"); 
    189  
     193                mUseDepthPass = atoi(val.c_str()); 
     194        } 
     195 
     196        val = config.getSetting("FlushQueue"); 
     197         
    190198        if (!val.empty()) 
    191199        { 
    192                  string viewCellsFilename = val.c_str(); 
    193                  std::stringstream d; d << "view cells file name: " << viewCellsFilename; 
    194                  LogManager::getSingleton().logMessage(d.str()); 
    195  
    196                  mViewCellsLoaded = LoadViewCells(viewCellsFilename); 
     200                mDeleteQueueAfterRendering = atoi(val.c_str()); 
     201        } 
     202 
     203        val = config.getSetting("Scene"); 
     204 
     205    if (!val.empty()) 
     206        { 
     207                mFilename = val.c_str(); 
     208                 
     209                if (mFilename == "terrain") 
     210                { 
     211                        mShowTerrain = true; 
     212                        LogManager::getSingleton().logMessage("creating terrain"); 
     213                } 
     214        } 
     215 
     216        if (!mShowTerrain) 
     217        { 
     218                val = config.getSetting("ViewCells"); 
     219 
     220                if (!val.empty()) 
     221                { 
     222                        mViewCellsFilename = val.c_str(); 
     223                        d << "view cells file name: " << mViewCellsFilename; 
     224                        LogManager::getSingleton().logMessage(d.str()); 
     225                } 
    197226        } 
    198227         
     
    222251                         algorithm =  
    223252                                 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 
     253 
     254                         mNormalExecution = true; 
    224255                 } 
    225256 
    226257                 mVisibilityManager->SetCullingManager(algorithm); 
    227         } 
    228  
    229         if (mShowTerrain) 
    230         { 
    231                 TerrainSceneManager::loadConfig(stream); 
    232         } 
     258 
     259                 d << "setting algorithm to: " << algorithm; 
     260                 LogManager::getSingleton().logMessage(d.str()); 
     261        } 
     262 
     263        ///////////////////////////////////////// 
     264        // terrain options 
     265 
     266        if (!mShowTerrain) 
     267                return; 
     268 
     269        val = config.getSetting( "DetailTile" ); 
     270        if ( !val.empty() ) 
     271                setDetailTextureRepeat(atoi(val.c_str())); 
     272 
     273        val = config.getSetting( "MaxMipMapLevel" ); 
     274        if ( !val.empty() ) 
     275                setMaxGeoMipMapLevel(atoi( val.c_str() )); 
     276 
     277 
     278        val = config.getSetting( "PageSize" ); 
     279        if ( !val.empty() ) 
     280                setPageSize(atoi( val.c_str() )); 
     281        else 
     282                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSize'", 
     283                "TerrainSceneManager::loadConfig"); 
     284 
     285 
     286        val = config.getSetting( "TileSize" ); 
     287        if ( !val.empty() ) 
     288                setTileSize(atoi( val.c_str() )); 
     289        else 
     290                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'TileSize'", 
     291                "TerrainSceneManager::loadConfig"); 
     292 
     293        Vector3 v = Vector3::UNIT_SCALE; 
     294 
     295        val = config.getSetting( "PageWorldX" ); 
     296        if ( !val.empty() ) 
     297                v.x = atof( val.c_str() ); 
     298 
     299        val = config.getSetting( "MaxHeight" ); 
     300        if ( !val.empty() ) 
     301                v.y = atof( val.c_str() ); 
     302 
     303        val = config.getSetting( "PageWorldZ" ); 
     304        if ( !val.empty() ) 
     305                v.z = atof( val.c_str() ); 
     306 
     307        // Scale x/z relative to pagesize 
     308        v.x /= mOptions.pageSize; 
     309        v.z /= mOptions.pageSize; 
     310        setScale(v); 
     311 
     312        val = config.getSetting( "MaxPixelError" ); 
     313        if ( !val.empty() ) 
     314                setMaxPixelError(atoi( val.c_str() )); 
     315 
     316        mDetailTextureName = config.getSetting( "DetailTexture" ); 
     317 
     318        mWorldTextureName = config.getSetting( "WorldTexture" ); 
     319 
     320        if ( config.getSetting( "VertexColours" ) == "yes" ) 
     321                mOptions.coloured = true; 
     322 
     323        if ( config.getSetting( "VertexNormals" ) == "yes" ) 
     324                mOptions.lit = true; 
     325 
     326        if ( config.getSetting( "UseTriStrips" ) == "yes" ) 
     327                setUseTriStrips(true); 
     328 
     329        if ( config.getSetting( "VertexProgramMorph" ) == "yes" ) 
     330                setUseLODMorph(true); 
     331 
     332        val = config.getSetting( "LODMorphStart"); 
     333        if ( !val.empty() ) 
     334                setLODMorphStart(atof(val.c_str())); 
     335 
     336        val = config.getSetting( "CustomMaterialName" ); 
     337        if ( !val.empty() ) 
     338                setCustomMaterial(val); 
     339 
     340        val = config.getSetting( "MorphLODFactorParamName" ); 
     341        if ( !val.empty() ) 
     342                setCustomMaterialMorphFactorParam(val); 
     343 
     344        val = config.getSetting( "MorphLODFactorParamIndex" ); 
     345        if ( !val.empty() ) 
     346                setCustomMaterialMorphFactorParam(atoi(val.c_str())); 
     347 
     348        // Now scan through the remaining settings, looking for any PageSource 
     349        // prefixed items 
     350        String pageSourceName = config.getSetting("PageSource"); 
     351        if (pageSourceName == "") 
     352        { 
     353                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSource'", 
     354                        "TerrainSceneManager::loadConfig"); 
     355        } 
     356        TerrainPageSourceOptionList optlist; 
     357        ConfigFile::SettingsIterator setIt = config.getSettingsIterator(); 
     358        while (setIt.hasMoreElements()) 
     359        { 
     360                String name = setIt.peekNextKey(); 
     361                String value = setIt.getNext(); 
     362                if (StringUtil::startsWith(name, pageSourceName, false)) 
     363                { 
     364                        optlist.push_back(TerrainPageSourceOption(name, value)); 
     365                } 
     366        } 
     367        // set the page source 
     368        selectPageSource(pageSourceName, optlist); 
    233369} 
    234370//----------------------------------------------------------------------- 
     
    530666        //-- (e.g., the visualization mode, the shadow pass) 
    531667 
    532         if ( 
    533                 mShowVisualization || 
    534            (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
    535             mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
     668        if (mShowVisualization || 
     669            (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     670             mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
    536671        {        
    537672                IlluminationRenderStage savedStage = mIlluminationStage;  
     
    619754                mLeavePassesInQueue = 0; 
    620755                 
    621                 if (mUseDepthPass) // the shaded geometry is rendered in a second pass 
     756                 // the shaded geometry is rendered in a second pass 
     757                if (mUseDepthPass) 
    622758                { 
    623759                        // add visible nodes found by the visibility culling algorithm 
     
    650786        getRenderQueue()->clear(mDeleteQueueAfterRendering); 
    651787 
    652         if (0) 
    653         { 
    654                 if (!mDeleteQueueAfterRendering) 
    655                         getRenderQueue()->clear(true); // finally clear render queue 
    656                 else 
    657                         OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 
    658         } 
    659  
    660788        if (0) WriteLog(); // write out stats 
    661789} 
     
    752880                OctreeNode::setVizScale(*static_cast<const float *>(val)); 
    753881                return true; 
    754         } 
    755         if (key == "LoadViewCells") 
    756         {  
    757                 return mViewCellsLoaded; 
    758882        } 
    759883        if (key == "UseViewCells") 
     
    809933        { 
    810934                mUseVisibilityFilter = *static_cast<const bool *>(val); 
    811                 // set null =>recomputation of the pvs 
     935 
     936                // set null => recomputation of the pvs 
    812937        mElementaryViewCell = NULL; 
    813938                return true; 
     939        } 
     940        if (key == "ViewCellsLoaded") 
     941        {  
     942                return mViewCellsLoaded; 
    814943        } 
    815944 
     
    840969        { 
    841970                * static_cast<bool *>(val) = (bool *)mShowTerrain; 
     971                return true; 
     972        } 
     973        if (key == "UseDepthPass") 
     974        { 
     975                * static_cast<bool *>(val) = (bool *)mUseDepthPass; 
     976                return true; 
     977        } 
     978        if (key == "AlgorithmType") 
     979        { 
     980                GtpVisibility::VisibilityEnvironment::CullingManagerType algorithm = 
     981                        mVisibilityManager->GetCullingManagerType(); 
     982 
     983                * static_cast<unsigned int *>(val) =  
     984                        (unsigned int)algorithm; 
    842985                return true; 
    843986        } 
     
    12831426bool OcclusionCullingSceneManager::LoadViewCells(const String &filename) 
    12841427{ 
     1428        if (filename == "") 
     1429                return false; 
     1430 
    12851431        if (mViewCellsLoaded)  
    12861432                return true; 
     
    12911437        // load the view cells assigning the found objects to the pvss 
    12921438        const bool finalizeViewCells = true; 
    1293         mViewCellsManager =  
    1294                 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, true, &bconverter); 
    1295  
    1296         //Ogre::LogManager().getSingleton().logMessage("view cells loaded"); 
    1297         //Ogre::LogManager().getSingleton().flush(); 
     1439 
     1440        mViewCellsManager = GtpVisibilityPreprocessor:: 
     1441                ViewCellsManager::LoadViewCells(filename,  
     1442                                                                                &mObjects,  
     1443                                                                                true,  
     1444                                                                                &bconverter); 
     1445 
    12981446        // objects are set to invisible initially 
    12991447        SetObjectsVisible(false); 
     
    15071655#endif 
    15081656// splits strings containing multiple file names 
    1509 static int SplitFilenames(const std::string str, std::vector<std::string> &filenames) 
     1657static int SplitFilenames(const std::string str,  
     1658                                                  std::vector<std::string> &filenames) 
    15101659{ 
    15111660        int pos = 0; 
     
    15421691        if (filename == "terrain") 
    15431692        { 
     1693                LogManager::getSingleton().logMessage("loading terrain"); 
     1694 
    15441695                // terrain hack 
    1545                 mShowTerrain = true; 
    1546                 LogManager::getSingleton().logMessage("creating terrain"); 
    1547                 return true; 
     1696                return false; 
    15481697        } 
    15491698 
Note: See TracChangeset for help on using the changeset viewer.