Changeset 1823 for GTP/trunk/Lib
- Timestamp:
- 11/28/06 17:23:00 (18 years ago)
- 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 239 239 240 240 bool mViewCellsGeometryLoaded; 241 242 string mViewCellsFilename; 243 string mFilename; 241 244 242 245 bool mShowTerrain; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1816 r1823 57 57 mShowViewCells(false), 58 58 mViewCellsGeometryLoaded(false), 59 mShowTerrain(false) 59 mShowTerrain(false), 60 mViewCellsFilename(""), 61 mFilename("terrain") 60 62 { 61 63 Ogre::LogManager::getSingleton(). … … 147 149 loadConfig(stream); 148 150 151 // apply parameters for file loading 152 153 // loas the scene 154 LoadScene(mFilename); 155 156 // load view cells 157 mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 158 149 159 if (mShowTerrain) 150 { 160 { 151 161 initLevelIndexes(); 152 162 153 163 // Resize the octree, allow for 1 page for now 154 164 float max_x = mOptions.scale.x * mOptions.pageSize; 155 float max_y = mOptions.scale.y; 165 float max_y = mOptions.scale.y;// * mOptions.pageSize; 156 166 float max_z = mOptions.scale.z * mOptions.pageSize; 157 167 158 168 float maxAxis = std::max(max_x, max_y); 159 169 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 162 173 setupTerrainMaterial(); 163 174 setupTerrainPages(); 164 } 175 } 165 176 } 166 177 #endif … … 168 179 void OcclusionCullingSceneManager::loadConfig(DataStreamPtr& stream) 169 180 { 170 / * Set up the options */181 // Set up the options 171 182 ConfigFile config; 172 183 String val; … … 175 186 176 187 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"); 181 190 182 191 if (!val.empty()) 183 192 { 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 190 198 if (!val.empty()) 191 199 { 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 } 197 226 } 198 227 … … 222 251 algorithm = 223 252 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 253 254 mNormalExecution = true; 224 255 } 225 256 226 257 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); 233 369 } 234 370 //----------------------------------------------------------------------- … … 530 666 //-- (e.g., the visualization mode, the shadow pass) 531 667 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)) 536 671 { 537 672 IlluminationRenderStage savedStage = mIlluminationStage; … … 619 754 mLeavePassesInQueue = 0; 620 755 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) 622 758 { 623 759 // add visible nodes found by the visibility culling algorithm … … 650 786 getRenderQueue()->clear(mDeleteQueueAfterRendering); 651 787 652 if (0)653 {654 if (!mDeleteQueueAfterRendering)655 getRenderQueue()->clear(true); // finally clear render queue656 else657 OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...658 }659 660 788 if (0) WriteLog(); // write out stats 661 789 } … … 752 880 OctreeNode::setVizScale(*static_cast<const float *>(val)); 753 881 return true; 754 }755 if (key == "LoadViewCells")756 {757 return mViewCellsLoaded;758 882 } 759 883 if (key == "UseViewCells") … … 809 933 { 810 934 mUseVisibilityFilter = *static_cast<const bool *>(val); 811 // set null =>recomputation of the pvs 935 936 // set null => recomputation of the pvs 812 937 mElementaryViewCell = NULL; 813 938 return true; 939 } 940 if (key == "ViewCellsLoaded") 941 { 942 return mViewCellsLoaded; 814 943 } 815 944 … … 840 969 { 841 970 * 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; 842 985 return true; 843 986 } … … 1283 1426 bool OcclusionCullingSceneManager::LoadViewCells(const String &filename) 1284 1427 { 1428 if (filename == "") 1429 return false; 1430 1285 1431 if (mViewCellsLoaded) 1286 1432 return true; … … 1291 1437 // load the view cells assigning the found objects to the pvss 1292 1438 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 1298 1446 // objects are set to invisible initially 1299 1447 SetObjectsVisible(false); … … 1507 1655 #endif 1508 1656 // splits strings containing multiple file names 1509 static int SplitFilenames(const std::string str, std::vector<std::string> &filenames) 1657 static int SplitFilenames(const std::string str, 1658 std::vector<std::string> &filenames) 1510 1659 { 1511 1660 int pos = 0; … … 1542 1691 if (filename == "terrain") 1543 1692 { 1693 LogManager::getSingleton().logMessage("loading terrain"); 1694 1544 1695 // terrain hack 1545 mShowTerrain = true; 1546 LogManager::getSingleton().logMessage("creating terrain"); 1547 return true; 1696 return false; 1548 1697 } 1549 1698 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/terrainCulling.cfg
r1270 r1823 3 3 # 4 4 5 #OnlineCullingAlgorithm=CHC6 OnlineCullingAlgorithm=SWC5 OnlineCullingAlgorithm=CHC 6 #OnlineCullingAlgorithm=SWC 7 7 #OnlineCullingAlgorithm=VFC 8 #OnlineCullingAlgorithm=DEFAULT 8 9 10 # 11 # Should depth first pass be used? 12 # 13 14 DepthPass=1 9 15 10 16 ###################################################################### 11 17 12 18 # 13 # Settings for vienna scene19 # Settings for iv scene (vienna) 14 20 # 15 21 … … 20 26 21 27 #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 23 30 #Scene=../../../../../resources/media/city1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv 24 25 # current view point26 ViewX=83027 ViewY=30028 ViewZ=-54029 31 30 32 # … … 32 34 # 33 35 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 43 FlushQueue=1 35 44 36 45 … … 45 54 46 55 # 47 # current view point56 # should render queue be flushed after each frame? 48 57 # 49 58 50 #ViewX=707 51 #ViewY=5000 52 #ViewZ=528 59 FlushQueue=false 60 61 UseDepthPass=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) 70 WorldTexture=terrain_texture.jpg 71 72 # The detail texture (if you wish the terrain manager to create a material for you) 73 DetailTexture=terrain_detail.jpg 74 75 #number of times the detail texture will tile in a terrain tile 76 DetailTile=3 77 78 # Heightmap source 79 PageSource=Heightmap 80 81 # Heightmap-source specific settings 82 Heightmap.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 93 PageSize=513 94 95 # How large is each tile? Must be (2^n)+1 and be smaller than PageSize 96 TileSize=65 97 98 # The maximum error allowed when determining which LOD to use 99 MaxPixelError=3 100 101 # The size of a terrain page, in world units 102 PageWorldX=5000 103 PageWorldZ=5000 104 105 # Maximum height of the terrain 106 MaxHeight=400 107 108 # Upper LOD limit 109 MaxMipMapLevel=1 110 111 #VertexNormals=yes 112 #VertexColors=yes 113 #UseTriStrips=yes 114 115 # Use vertex program to morph LODs, if available 116 VertexProgramMorph=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 121 LODMorphStart=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.