Changeset 1823 for GTP/trunk


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)

Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h

    r1816 r1823  
    239239 
    240240        bool mViewCellsGeometryLoaded; 
     241 
     242        string mViewCellsFilename; 
     243        string mFilename; 
    241244 
    242245        bool mShowTerrain; 
  • 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 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/terrainCulling.cfg

    r1270 r1823  
    33# 
    44 
    5 #OnlineCullingAlgorithm=CHC 
    6 OnlineCullingAlgorithm=SWC 
     5OnlineCullingAlgorithm=CHC 
     6#OnlineCullingAlgorithm=SWC 
    77#OnlineCullingAlgorithm=VFC 
     8#OnlineCullingAlgorithm=DEFAULT 
    89 
     10# 
     11# Should depth first pass be used? 
     12# 
     13 
     14DepthPass=1 
    915 
    1016###################################################################### 
    1117 
    1218# 
    13 #  Settings for vienna scene 
     19#  Settings for iv scene (vienna) 
    1420# 
    1521 
     
    2026 
    2127#Scene=../../../../../resources/media/house_test1.iv 
    22 Scene=../../../../../resources/media/city1500_flat_1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv 
     28#Scene=../../../../../resources/media/city1500_flat_1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv 
     29#Scene=../../../../../resources/media/city1500_flat_1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv;../../../../../resources/media/CityPlane60.iv 
    2330#Scene=../../../../../resources/media/city1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv 
    24  
    25 # current view point 
    26 ViewX=830 
    27 ViewY=300 
    28 ViewZ=-540 
    2931 
    3032# 
     
    3234# 
    3335 
    34 ViewCells=../../../../../../../GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna-visibility.xml.zip 
     36#ViewCells=../../../../../../../GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna-visibility.xml.zip 
     37 
     38 
     39# 
     40# should render queue be flushed after each frame? 
     41# 
     42 
     43FlushQueue=1 
    3544 
    3645 
     
    4554 
    4655# 
    47 # current view point 
     56# should render queue be flushed after each frame? 
    4857# 
    4958 
    50 #ViewX=707 
    51 #ViewY=5000 
    52 #ViewZ=528 
     59FlushQueue=false 
     60 
     61UseDepthPass=false 
     62 
     63########################################### 
     64# 
     65# Terrain scene manager settings 
     66# 
     67######################################### 
     68 
     69# The main world texture (if you wish the terrain manager to create a material for you) 
     70WorldTexture=terrain_texture.jpg 
     71 
     72# The detail texture (if you wish the terrain manager to create a material for you) 
     73DetailTexture=terrain_detail.jpg 
     74 
     75#number of times the detail texture will tile in a terrain tile 
     76DetailTile=3 
     77 
     78# Heightmap source 
     79PageSource=Heightmap 
     80 
     81# Heightmap-source specific settings 
     82Heightmap.image=terrain.png 
     83 
     84# If you use RAW, fill in the below too 
     85# RAW-specific setting - size (horizontal/vertical) 
     86#Heightmap.raw.size=513 
     87# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit) 
     88#Heightmap.raw.bpp=2 
     89# Use this if you want to flip the terrain (eg Terragen exports raw upside down) 
     90#Heightmap.flip=true 
     91 
     92# How large is a page of tiles (in vertices)? Must be (2^n)+1 
     93PageSize=513 
     94 
     95# How large is each tile? Must be (2^n)+1 and be smaller than PageSize 
     96TileSize=65 
     97 
     98# The maximum error allowed when determining which LOD to use 
     99MaxPixelError=3 
     100 
     101# The size of a terrain page, in world units 
     102PageWorldX=5000 
     103PageWorldZ=5000 
     104 
     105# Maximum height of the terrain  
     106MaxHeight=400 
     107 
     108# Upper LOD limit 
     109MaxMipMapLevel=1 
     110 
     111#VertexNormals=yes 
     112#VertexColors=yes 
     113#UseTriStrips=yes 
     114 
     115# Use vertex program to morph LODs, if available 
     116VertexProgramMorph=no 
     117 
     118# The proportional distance range at which the LOD morph starts to take effect 
     119# This is as a proportion of the distance between the current LODs effective range, 
     120# and the effective range of the next lower LOD 
     121LODMorphStart=0.2 
     122 
     123# This following section is for if you want to provide your own terrain shading routine 
     124# Note that since you define your textures within the material this makes the  
     125# WorldTexture and DetailTexture settings redundant 
     126 
     127# The name of the vertex program parameter you wish to bind the morph LOD factor to 
     128# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely 
     129# to the same position as the next lower LOD 
     130# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING 
     131#MorphLODFactorParamName=morphFactor 
     132 
     133# The index of the vertex program parameter you wish to bind the morph LOD factor to 
     134# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely 
     135# to the same position as the next lower LOD 
     136# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING 
     137#MorphLODFactorParamIndex=4 
     138 
     139# The name of the material you will define to shade the terrain 
     140#CustomMaterialName=TestTerrainMaterial 
Note: See TracChangeset for help on using the changeset viewer.