Changeset 2097 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 02/06/07 20:33:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r2069 r2097 180 180 { 181 181 list<SceneNode *> sceneNodeList; 182 182 183 183 // find intersecting scene nodes to get candidates for intersection 184 184 // note: this function has to be provided by scene manager 185 185 186 #if ENLARGE_NODE_BBOX 186 187 // make search radius larger 187 AxisAlignedBox mybox = EnlargeBox(box);188 mSceneMgr->findNodesIn( mybox, sceneNodeList, NULL);188 AxisAlignedBox largebox = EnlargeBox(box); 189 mSceneMgr->findNodesIn(largebox, sceneNodeList, NULL); 189 190 190 191 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 191 192 192 193 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = 193 OgreTypeConverter::ConvertFromOgre( mybox);194 OgreTypeConverter::ConvertFromOgre(largebox); 194 195 #else 195 196 … … 201 202 OgreTypeConverter::ConvertFromOgre(box); 202 203 #endif 203 204 204 205 // loop through the intersected scene nodes 205 206 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) … … 233 234 } 234 235 } 236 235 237 #if USE_KD_PVS 236 238 //------------------------------------------------------------------------- … … 255 257 EngineIntersectable *entry = 256 258 new EngineIntersectable(entryObjects); 259 257 260 entry->SetId((*iit).first); 258 261 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r2066 r2097 364 364 else if (strKey == "UseViewCells") 365 365 { 366 Ogre::LogManager::getSingleton().logMessage("here44"); 366 367 if (mViewCellsLoaded) 367 368 { 369 Ogre::LogManager::getSingleton().logMessage("here99"); 368 370 mUseViewCells = *static_cast<const bool *>(pValue); 369 371 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2067 r2097 136 136 const String& typeName) 137 137 { 138 138 // Clear out any existing world resources (if not default) 139 139 if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() != 140 140 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) … … 150 150 loadConfig(stream); 151 151 152 // apply parameters for file loading 153 154 // loas the scene 152 ////////////// 153 // file loading 154 155 // load the scene 155 156 LoadScene(mFilename); 156 157 157 158 // load view cells 158 mViewCellsLoaded = LoadViewCells(mViewCellsFilename);159 //mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 159 160 160 161 if (mShowTerrain) … … 170 171 maxAxis = std::max(maxAxis, max_z); 171 172 //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 )); 173 174 174 175 setupTerrainMaterial(); … … 177 178 } 178 179 #endif 180 179 181 //------------------------------------------------------------------------- 180 182 void OcclusionCullingSceneManager::loadConfig(DataStreamPtr& stream) … … 211 213 { 212 214 mShowTerrain = true; 213 LogManager::getSingleton().logMessage(" creating terrain");215 LogManager::getSingleton().logMessage("loading terrain"); 214 216 } 215 217 } … … 221 223 if (!val.empty()) 222 224 { 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 229 229 val = config.getSetting("OnlineCullingAlgorithm"); 230 230 … … 262 262 } 263 263 264 ///////////// ////////////////////////////264 ///////////// 265 265 // terrain options 266 266 … … 268 268 return; 269 269 270 val = config.getSetting( "DetailTile");271 if ( !val.empty())270 val = config.getSetting("DetailTile"); 271 if (!val.empty()) 272 272 setDetailTextureRepeat(atoi(val.c_str())); 273 273 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())); 282 282 else 283 283 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSize'", … … 285 285 286 286 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())); 290 290 else 291 291 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'TileSize'", … … 472 472 for (eit = entries->begin(); eit != eit_end; ++ eit) 473 473 { 474 //OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*eit);474 475 475 Entity *ent = *eit; 476 476 Any newAny = ent->getUserAny(); 477 477 478 478 int flt = any_cast<int>(newAny); 479 //std::stringstream d; d << "any: " << flt << " "; 480 //Ogre::LogManager::getSingleton().logMessage(d.str()); 479 481 480 if (any_cast<int>(newAny) == 0) 482 481 { … … 485 484 } 486 485 487 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;488 486 } 489 487 } … … 883 881 } 884 882 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 886 893 // 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); 893 899 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 913 918 return true; 914 919 } … … 1422 1427 bool OcclusionCullingSceneManager::LoadViewCells(const String &filename) 1423 1428 { 1429 // no filename specified 1424 1430 if (filename == "") 1425 1431 return false; 1426 1432 1433 // view cells already loaded 1427 1434 if (mViewCellsLoaded) 1428 1435 return true; … … 1432 1439 1433 1440 // load the view cells assigning the found objects to the pvss 1434 const bool finalizeViewCells = true;1441 const bool finalizeViewCells = false; 1435 1442 1436 1443 mViewCellsManager = GtpVisibilityPreprocessor:: … … 1439 1446 true, 1440 1447 &bconverter); 1448 1449 Ogre::LogManager::getSingleton().logMessage("*******************"); 1441 1450 1442 1451 // objects are set to invisible initially … … 1453 1462 void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1454 1463 const bool load) 1455 { // NOTE: should not encounter NULL view cell, 1464 { 1465 // NOTE: should not encounter NULL view cell, 1456 1466 // rather apply view cell representing unbounded space then 1457 1467 if (!vc) 1458 1468 { 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? 1460 1471 //SetObjectsVisible(true); 1461 1472 SetObjectsVisible(false); … … 1467 1478 //////////// 1468 1479 //-- 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()); 1469 1483 1470 1484 while (pit.HasMoreEntries()) … … 1482 1496 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 1483 1497 omi->GetEntity()->setVisible(load); 1484 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1485 } 1498 } 1486 1499 break; 1487 1500 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 1488 1501 { 1489 //GtpVisibilityPreprocessor::EngineIntersectable *oi =1490 // static_cast<GtpVisibilityPreprocessor::EngineIntersectable *>(entry);1491 1502 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 1492 1503 1493 //GtpVisibilityPreprocessor::ObjectContainer *entries = oi->GetItem();1494 1504 EntityContainer *entries = oi->GetItem(); 1495 1505 … … 1498 1508 for (eit = entries->begin(); eit != eit_end; ++ eit) 1499 1509 { 1500 //OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*eit);1501 //omi->GetEntity()->setVisible(load);1502 1510 Entity *ent = *eit; 1503 1511 ent->setVisible(load); 1504 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;1505 1512 } 1506 1513 } … … 1520 1527 OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 1521 1528 1529 //std::stringstream d; d << "vp: " << viewPoint; 1530 //LogManager::getSingleton().logMessage(d.str()); 1531 1522 1532 GtpVisibilityPreprocessor::ViewCell *newElementary = 1523 1533 mViewCellsManager->GetViewCell(viewPoint); 1524 1534 1525 // elementary view cell did not change => apply same pvs1535 // elementary view cell did not change => don't change pvs 1526 1536 if (mElementaryViewCell == newElementary) 1527 1537 return; … … 1557 1567 ApplyViewCellPvs(viewCell, true); 1558 1568 1559 // store pvs1560 1569 if (viewCell) 1561 1570 { 1571 // store current view cell 1562 1572 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1563 1573 mCurrentViewCell->SetMesh(viewCell->GetMesh()); … … 1691 1701 return false; 1692 1702 } 1693 1703 /* 1694 1704 for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i) 1695 1705 { … … 1709 1719 result = true; 1710 1720 } 1711 1721 */ result=true; 1712 1722 return result; 1713 1723 } … … 1771 1781 const String& instanceName) 1772 1782 { 1773 OcclusionCullingSceneManager* tsm = new OcclusionCullingSceneManager(instanceName, visManager); 1783 OcclusionCullingSceneManager* tsm = 1784 new OcclusionCullingSceneManager(instanceName, visManager); 1774 1785 1775 1786 // Create & register default sources (one per manager)
Note: See TracChangeset
for help on using the changeset viewer.