Changeset 1823 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 11/28/06 17:23:00 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 2 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
Note: See TracChangeset
for help on using the changeset viewer.