Changeset 938 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 05/10/06 08:05:24 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
r931 r938 108 108 /** Loads view cells for this particular scene. 109 109 */ 110 void LoadViewCells(std::stringfilename);110 bool LoadViewCells(const String &filename); 111 111 112 112 protected: … … 210 210 bool mUseViewCells; 211 211 212 213 212 /// if the view cells are filtered 214 213 bool mUseVisibilityFilter; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformHierarchyInterface.h
r897 r938 20 20 @remark also provides methods for using occlusion queries on the hierarchy nodes 21 21 */ 22 typedef std::vector<PlatformOcclusionQuery *> OcclusionQueryContainer; 23 22 24 class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface 23 25 { … … 151 153 AxisAlignedBox mBox; 152 154 153 std::vector<PlatformOcclusionQuery *>mOcclusionQueries;155 OcclusionQueryContainer mOcclusionQueries; 154 156 155 157 Vector3 mCameraPosition; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp
r933 r938 19 19 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: 20 20 const_iterator iit, iit_end = iboxes.end(); 21 21 std::stringstream d; d << "here75557\n"; 22 LogManager::getSingleton().logMessage(d.str()); 22 23 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 23 24 { 24 25 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 25 26 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 26 27 std::stringstream d; d << "here77\n"; 28 LogManager::getSingleton().logMessage(d.str()); 27 29 Entity *ent = FindCorrespondingObject(currentBox); 28 30 … … 51 53 AxisAlignedBox mybox = EnlargeBox(box); 52 54 //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000)); 53 55 std::stringstream d; d << "here3 idenbtiy 8888\n"; 56 LogManager::getSingleton().logMessage(d.str()); 54 57 //-- get intersecting scene nodes 55 58 mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); … … 58 61 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 59 62 60 float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small; 63 // minimal overlap 64 float overlap = 0;//1e-6; 61 65 62 66 Entity *bestFittingObj = NULL; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r931 r938 66 66 // TODO: set maxdepth to reasonable value 67 67 mMaxDepth = 50; 68 69 //loadVisibilityConfig("GtpVisibility.cfg");70 //LoadViewCells("");71 //mViewCellsLoaded = true;72 68 } 73 69 //----------------------------------------------------------------------- … … 137 133 mTerrainPages.clear(); 138 134 // Load the configuration 139 loadConfig( stream);135 loadConfig(stream); 140 136 initLevelIndexes(); 141 137 … … 555 551 if (!mViewCellsLoaded) 556 552 { 557 LoadViewCells(static_cast<const char *>(val));558 mViewCellsLoaded = true;559 } 560 561 return true;553 String filename(static_cast<const char *>(val)); 554 mViewCellsLoaded = LoadViewCells(filename); 555 } 556 557 return mViewCellsLoaded; 562 558 } 563 559 if (key == "UseViewCells") 564 560 { 565 mUseViewCells = *static_cast<const bool *>(val); 566 567 // reset view cell 568 OGRE_DELETE(mCurrentViewCell); 569 if (mUseViewCells) 570 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 571 mElementaryViewCell = NULL; 572 // if using view cells, all objects are set to false initially 573 SetObjectsVisible(!mUseViewCells); 574 561 if (mViewCellsLoaded) 562 { 563 LogManager::getSingleton().logMessage("here3"); 564 mUseViewCells = *static_cast<const bool *>(val); 565 566 // reset view cell 567 OGRE_DELETE(mCurrentViewCell); 568 569 if (mUseViewCells) 570 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 571 572 mElementaryViewCell = NULL; 573 574 // if using view cells, all objects are set to false initially 575 SetObjectsVisible(!mUseViewCells); 576 } 577 575 578 return true; 576 579 } … … 1011 1014 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 1012 1015 Entity *ent = omi->GetMesh(); 1016 LogManager::getSingleton().logMessage("here999"); 1013 1017 ent->setVisible(visible); 1014 1018 } 1015 1019 } 1016 1020 //----------------------------------------------------------------------- 1017 void OcclusionCullingSceneManager::LoadViewCells(stringfilename)1018 { 1019 // the objects are set to invisible a prioriy1021 bool OcclusionCullingSceneManager::LoadViewCells(const String &filename) 1022 { 1023 // objects are set to invisible initially 1020 1024 SetObjectsVisible(false); 1021 1025 1022 1026 const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName(); 1023 1027 1028 // converter between view cell ids and Ogre entites 1024 1029 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1025 1030 OgreBoundingBoxConverter bconverter(this); 1026 1031 1032 1033 GtpVisibilityPreprocessor::Environment *env = 1034 mVisibilityManager->GetVisibilityEnvironment()->GetPreprocessorEnvironment(); 1035 1027 1036 // load the view cells assigning the found objects to the pvss 1028 1037 mViewCellsManager = 1029 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, &bconverter); 1030 1031 std::stringstream d; 1032 d << "view cells loaded" << endl; 1033 Ogre::LogManager::getSingleton().logMessage(d.str()); 1038 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, env, &bconverter); 1039 1040 if (!mViewCellsManager) 1041 { 1042 std::stringstream d; 1043 d << "error loading view cells" << endl; 1044 LogManager::getSingleton().logMessage(d.str()); 1045 } 1046 1047 return (mViewCellsManager != NULL); 1034 1048 } 1035 1049 //------------------------------------------------------------------------- … … 1041 1055 // set everything visible for savety 1042 1056 SetObjectsVisible(true); 1043 1057 LogManager::getSingleton().logMessage("here7"); 1044 1058 return; 1045 1059 } 1046 1060 LogManager::getSingleton().logMessage("here8"); 1047 1061 GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit, 1048 1062 oit_end = vc->GetPvs().mEntries.end(); … … 1055 1069 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first); 1056 1070 omi->GetMesh()->setVisible(load); 1057 //GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl;1071 GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 1058 1072 } 1059 1073 } … … 1061 1075 void OcclusionCullingSceneManager::updatePvs(Camera *cam) 1062 1076 { 1063 if (mViewCellsLoaded && mUseViewCells) 1064 { 1065 const GtpVisibilityPreprocessor::Vector3 viewPoint = 1066 OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 1067 1068 GtpVisibilityPreprocessor::ViewCell *newElementary = 1069 mViewCellsManager->GetViewCell(viewPoint); 1070 1071 // elementary view cell did not change => apply same pvs 1072 if (mElementaryViewCell == newElementary) 1073 return; 1074 1075 mElementaryViewCell = newElementary; 1076 1077 //-- unload old pvs 1078 applyViewCellPvs(mCurrentViewCell, false); 1079 1080 1081 //-- the new view cell 1077 if (!(mViewCellsLoaded && mUseViewCells)) 1078 return; 1079 1080 const GtpVisibilityPreprocessor::Vector3 viewPoint = 1081 OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 1082 1083 GtpVisibilityPreprocessor::ViewCell *newElementary = 1084 mViewCellsManager->GetViewCell(viewPoint); 1085 1086 // elementary view cell did not change => apply same pvs 1087 if (mElementaryViewCell == newElementary) 1088 return; 1089 1090 mElementaryViewCell = newElementary; 1091 LogManager::getSingleton().logMessage("unloading"); 1092 //-- unload old pvs 1093 applyViewCellPvs(mCurrentViewCell, false); 1094 1095 1096 //-- the new view cell 1082 1097 1083 1098 GtpVisibilityPreprocessor::ViewCell *viewCell; 1084 1099 1085 1100 1086 if (mUseVisibilityFilter) 1087 { 1088 //-- compute new filtered cell 1089 GtpVisibilityPreprocessor::PrVs prvs; 1090 mViewCellsManager->GetPrVS(viewPoint, prvs, 5); 1091 viewCell = prvs.mViewCell; 1092 } 1093 else 1094 { 1095 viewCell = newElementary; 1096 } 1097 1098 //-- load new pvs 1099 applyViewCellPvs(viewCell, true); 1100 1101 // store pvs 1102 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1103 1104 // delete merge tree of filtered view cell 1105 if (mUseVisibilityFilter) 1106 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1107 } 1101 if (mUseVisibilityFilter) 1102 { 1103 //-- compute new filtered cell 1104 GtpVisibilityPreprocessor::PrVs prvs; 1105 mViewCellsManager->GetPrVS(viewPoint, prvs, 5); 1106 viewCell = prvs.mViewCell; 1107 } 1108 else 1109 { 1110 viewCell = newElementary; 1111 } 1112 LogManager::getSingleton().logMessage("loading"); 1113 //-- load new pvs 1114 if (0)applyViewCellPvs(viewCell, true); 1115 1116 // store pvs 1117 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1118 1119 // delete merge tree of filtered view cell 1120 if (mUseVisibilityFilter) 1121 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1108 1122 } 1109 1123 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
r925 r938 112 112 octant->setLastRendered(mFrameId); 113 113 OctreeSceneManager *ocm = 114 //dynamic_cast<OctreeSceneManager *>(mSceneManager);115 114 dynamic_cast<OctreeSceneManager *>(mSceneManager); 115 116 116 ocm->_renderOctant(mCamera, octant, mOnlyShadowCasters, mLeavePassesInQueue); 117 117 … … 144 144 // reuse box if node is the same 145 145 // only create renderable bounding box for new node 146 if ( 1 || (node != mSavedNode))146 if (node != mSavedNode) 147 147 { 148 148 mSavedNode = node; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r925 r938 81 81 void PlatformHierarchyInterface::ResetQueries() 82 82 { 83 for (int i = 0; i < (int)mOcclusionQueries.size(); ++ i) OGRE_DELETE(mOcclusionQueries[i]); 83 OcclusionQueryContainer::iterator it, it_end = mOcclusionQueries.end(); 84 for (it = mOcclusionQueries.begin(); it != it_end; ++ it) 85 { 86 PlatformOcclusionQuery *query = *it; 87 OGRE_DELETE(query); 88 } 84 89 85 90 mCurrentTestIdx = 0; … … 121 126 { 122 127 // create new query if there is no query left 123 if (mCurrentTestIdx >= (int)mOcclusionQueries.size()) 124 { 125 mCurrentTestIdx = (int)mOcclusionQueries.size(); 128 if (mCurrentTestIdx == mOcclusionQueries.size()) 129 { 126 130 mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); 127 131 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp
r925 r938 35 35 { 36 36 isAvailable = !mHardwareOcclusionQuery->isStillOutstanding(); 37 //std::stringstream d; d << "available: " << isAvailable;38 //Ogre::LogManager::getSingleton().logMessage(d.str());39 37 } 38 39 //std::stringstream d; d << mHardwareOcclusionQuery << ", available: " << isAvailable << ", waitforresult: " << waitForResult; 40 // Ogre::LogManager::getSingleton().logMessage(d.str()); 40 41 41 42 if (isAvailable) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
r925 r938 47 47 extern "C" void __declspec(dllexport) dllStartPlugin(void) 48 48 { 49 // load visibility environment 49 50 visEnv = new GtpVisibility::VisibilityEnvironment(); 50 visEnv->LoadEnvironment("simple.env");51 //visEnv->LoadEnvironment("simple.env"); 51 52 visManager = new GtpVisibility::VisibilityManager(visEnv); 52 53
Note: See TracChangeset
for help on using the changeset viewer.