Changeset 1593 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 10/09/06 22:38:07 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h
r1028 r1593 13 13 { 14 14 public: 15 15 /** The default constructor taking an entity into account. 16 */ 16 17 OgreMeshInstance(Entity *ent); 17 18 18 19 /** Returns 'mesh' associated with this instance. 19 20 */ 20 Entity *Get Mesh() const;21 Entity *GetEntity() const; 21 22 22 23 /** See get. 23 24 */ 24 void Set Mesh(Entity *mesh);25 void SetEntity(Entity *entity); 25 26 26 27 28 ///////////////////////////// 27 29 //-- inherited functions from Intersectable 28 30 … … 51 53 protected: 52 54 53 Entity *m Mesh;55 Entity *mEntity; 54 56 }; 55 57 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
r1276 r1593 16 16 namespace Ogre { 17 17 18 18 19 /** 19 20 This class extends the terrain scene manager, … … 126 127 /** Loads / unloads pvs of the view cell to set the visibility in the scene. 127 128 */ 128 void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);129 void ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load); 129 130 130 131 /** updates pvs in current frame. 131 132 */ 132 void updatePvs(Camera *cam);133 void UpdatePvs(Camera *cam); 133 134 134 135 /** Sets all objects invisible. … … 136 137 void SetObjectsVisible(const bool visible); 137 138 138 139 /** Creates view cells geometry from the loaded view cells. 140 */ 141 void CreateViewCellsGeometry(); 142 143 139 144 ////////////////////////////////////////// 140 145 141 146 /// the interface to the scene hierarchy. 142 147 OctreeHierarchyInterface *mHierarchyInterface; 148 143 149 /// manages all visibility options 144 150 GtpVisibility::VisibilityManager *mVisibilityManager; … … 175 181 /// the depth pass (no lighting, just filling the depth buffer) 176 182 Pass *mDepthPass; 183 /// the pass for item buffer setting a color id 177 184 Pass *mItemBufferPass; 178 185 179 int mCurrentEntityId;180 186 /// flag for passes which should not be deleted from queue during first traversal 181 187 int mLeavePassesInQueue; 182 183 188 184 189 /// if transparent object are considered for item buffer visibility … … 190 195 bool mIsHierarchicalCulling; 191 196 197 /// do we use preprocessed visibility 192 198 bool mViewCellsLoaded; 199 200 /// the view cells manager handling the preprocesor stuff 193 201 GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 194 202 … … 210 218 // normal terrain rendering 211 219 bool mNormalExecution; 220 221 // helper variable to provide sequential numbering for sub-entities 222 int mCurrentEntityId; 223 224 typedef map<int, MovableObject *> MovableObjectsMap; 225 226 /// hash table for view cells geometry 227 MovableObjectsMap mViewCellsGeometry; 212 228 }; 213 229 214 /// Factory for VisibilityOctreeSceneManager 230 231 /** Factory for VisibilityOctreeSceneManager. 232 */ 215 233 class OcclusionCullingSceneManagerFactory : public SceneManagerFactory 216 234 { -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreTypeConverter.h
r863 r1593 5 5 #include "AxisAlignedBox3.h" 6 6 #include "Vector3.h" 7 //#include "ManualObject.h" 7 8 8 9 9 10 namespace Ogre { 10 11 12 class SceneManager; 13 11 14 /** 12 15 Class which converts preprocessor types to OGRE types … … 27 30 */ 28 31 static Vector3 ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v); 32 33 /** The Ogre object will be created from the mesh. 34 */ 35 static ManualObject *ConvertToOgre(GtpVisibilityPreprocessor::Mesh *mesh, SceneManager *sceneMgr); 29 36 }; 30 37 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
r1320 r1593 1307 1307 { 1308 1308 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 1309 Entity *ent = omi->Get Mesh();1309 Entity *ent = omi->GetEntity(); 1310 1310 1311 1311 ent->setVisible(visible); … … 1354 1354 1355 1355 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first); 1356 omi->Get Mesh()->setVisible(load);1356 omi->GetEntity()->setVisible(load); 1357 1357 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1358 1358 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1344 r1593 1696 1696 1697 1697 if (showBoxes) 1698 { 1698 1699 if (mLevel == mOwner->getHiLiteLevel() || mOwner->getShowAllBoxes()) 1699 1700 queue->addRenderable(getWireBoundingBox()); 1701 } 1700 1702 } 1701 1703 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1495 r1593 1307 1307 { 1308 1308 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 1309 Entity *ent = omi->Get Mesh();1309 Entity *ent = omi->GetEntity(); 1310 1310 1311 1311 ent->setVisible(visible); … … 1351 1351 1352 1352 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first); 1353 omi->Get Mesh()->setVisible(load);1353 omi->GetEntity()->setVisible(load); 1354 1354 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1355 1355 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp
r1028 r1593 6 6 7 7 OgreMeshInstance::OgreMeshInstance(Entity *ent): 8 GtpVisibilityPreprocessor::Intersectable(), m Mesh(ent)8 GtpVisibilityPreprocessor::Intersectable(), mEntity(ent) 9 9 { 10 10 } 11 11 12 void OgreMeshInstance::Set Mesh(Entity *mesh)12 void OgreMeshInstance::SetEntity(Entity *entity) 13 13 { 14 m Mesh = mesh;14 mEntity = entity; 15 15 } 16 16 17 Entity *OgreMeshInstance::Get Mesh() const17 Entity *OgreMeshInstance::GetEntity() const 18 18 { 19 return m Mesh;19 return mEntity; 20 20 } 21 21 22 22 GtpVisibilityPreprocessor::AxisAlignedBox3 OgreMeshInstance::GetBox() const 23 23 { 24 return OgreTypeConverter::ConvertFromOgre(m Mesh->getWorldBoundingBox());24 return OgreTypeConverter::ConvertFromOgre(mEntity->getWorldBoundingBox()); 25 25 } 26 26 … … 71 71 ostream &OgreMeshInstance::Describe(ostream &s) 72 72 { 73 s << m Mesh;73 s << mEntity; 74 74 return s; 75 75 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1304 r1593 20 20 #include "common.h" 21 21 #include "OgreBoundingBoxConverter.h" 22 #include <OgreManualObject.h> 22 23 23 24 … … 173 174 getRenderQueue()->addRenderable(*it); 174 175 } 175 176 177 MovableObjectsMap::const_iterator mit, mit_end = mViewCellsGeometry.end(); 178 /* 179 for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit) 180 { 181 (*mit).second->_updateRenderQueue(getRenderQueue()); 182 } 183 */ 184 176 185 if (mRenderNodesForViz || mRenderNodesContentForViz) 177 186 { … … 198 207 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 199 208 } 209 200 210 // add renderables itself 201 211 if (mRenderNodesContentForViz) … … 292 302 } 293 303 294 295 //-- show visible scene nodes and octree bounding boxes from last frame296 304 if (mShowVisualization) 297 305 { 306 ////////////// 307 //-- show visible scene nodes and octree bounding boxes from last frame 308 298 309 PrepareVisualization(cam); 299 310 } … … 314 325 if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 315 326 316 327 /////////// 317 328 //-- apply view cell pvs 318 updatePvs(cam); 319 } 320 321 329 UpdatePvs(cam); 330 } 331 322 332 // lists only used for visualization 323 333 mVisible.clear(); … … 329 339 if (mNormalExecution) 330 340 { 341 // the standard octree rendering mode 331 342 OctreeSceneManager::_renderVisibleObjects(); 332 343 return; … … 339 350 ColourValue savedAmbient = mAmbientLight; 340 351 341 //-- apply standard rendering for some modes (e.g., visualization, shadow pass) 352 //////////////////// 353 //-- apply standard rendering for some modes 354 //-- (e.g., the visualization mode, the shadow pass) 342 355 343 356 if (mShowVisualization || … … 363 376 mDestRenderSystem -> setLightingEnabled(false); 364 377 365 // don't render backgrounds for item buffer366 378 if (mUseItemBuffer) 367 379 { 380 // don't render backgrounds for item buffer 368 381 clearSpecialCaseRenderQueues(); 369 382 getRenderQueue()->clear(); 370 383 } 371 384 385 //////////////////// 372 386 //-- hierarchical culling 387 373 388 // the objects of different layers (e.g., background, scene, 374 389 // overlay) must be identified and rendered one after another 375 390 376 // --render all early skies391 // first render all early skies 377 392 clearSpecialCaseRenderQueues(); 378 393 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); … … 387 402 #endif 388 403 404 /////////////////// 389 405 //-- prepare queue for visible objects (i.e., all but overlay and skies late) 406 390 407 clearSpecialCaseRenderQueues(); 391 408 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); … … 394 411 // exclude this queues from hierarchical rendering 395 412 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 396 397 413 398 414 // set all necessary parameters for … … 416 432 #endif 417 433 434 ///////////// 418 435 //-- reset parameters needed for special rendering 419 436 … … 425 442 mLeavePassesInQueue = 0; 426 443 427 // add visible nodes found by the visibility culling algorithm428 if (mUseDepthPass)429 {444 if (mUseDepthPass) // the shaded geometry is rendered in a second pass 445 { 446 // add visible nodes found by the visibility culling algorithm 430 447 NodeList::const_iterator it, it_end = mVisible.end(); 431 448 … … 436 453 } 437 454 } 455 456 ///////////// 438 457 //-- now we can render all remaining queue objects 439 458 //-- used for depth pass, transparents, overlay … … 453 472 getRenderQueue()->clear(mDeleteQueueAfterRendering); 454 473 455 //if (!mDeleteQueueAfterRendering) 456 // getRenderQueue()->clear(true); // finally clear render queue 457 //else 458 // OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 474 if (0) 475 { 476 if (!mDeleteQueueAfterRendering) 477 getRenderQueue()->clear(true); // finally clear render queue 478 else 479 OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 480 } 459 481 460 482 if (0) WriteLog(); // write out stats … … 573 595 574 596 if (mUseViewCells) 597 { 575 598 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 599 } 576 600 577 601 mElementaryViewCell = NULL; … … 683 707 renderObjects(pPriorityGrp->getSolidsBasic(), om, true); 684 708 685 // for correct rendering, transparents must be rendered after hierarchical culling686 // => do nothing687 688 // Do transparents (always descending)689 if (mNormalExecution || !mSkipTransparents)690 {709 // for correct rendering, transparents must be rendered 710 // after hierarchical culling => don't render them now 711 712 if (mNormalExecution || !mSkipTransparents) 713 { 714 // Do transparents (always descending) 691 715 renderObjects(pPriorityGrp->getTransparents(), 692 716 QueuedRenderableCollection::OM_SORT_DESCENDING, true); … … 694 718 695 719 696 } // for each priority720 } // for each priority 697 721 } 698 722 … … 770 794 if (0) 771 795 { 772 std::stringstream d; d << "itembuffer, pass name: " <<773 ipass->first->getParent()->getParent()->getName();774 775 LogManager::getSingleton().logMessage(d.str());796 std::stringstream d; d << "itembuffer, pass name: " << 797 ipass->first->getParent()->getParent()->getName(); 798 799 LogManager::getSingleton().logMessage(d.str()); 776 800 } 777 801 … … 1023 1047 { 1024 1048 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 1025 Entity *ent = omi->Get Mesh();1049 Entity *ent = omi->GetEntity(); 1026 1050 1027 1051 ent->setVisible(visible); … … 1034 1058 SetObjectsVisible(false); 1035 1059 1036 const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName();1037 1038 1060 // converter between view cell ids and Ogre entites 1039 1061 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; … … 1041 1063 1042 1064 // load the view cells assigning the found objects to the pvss 1065 const bool finalizeViewCells = true; 1043 1066 mViewCellsManager = 1044 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter); 1067 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, true, &bconverter); 1068 1069 if (finalizeViewCells) 1070 { 1071 CreateViewCellsGeometry(); 1072 } 1045 1073 1046 1074 return (mViewCellsManager != NULL); 1047 1075 } 1048 1076 //------------------------------------------------------------------------- 1049 void OcclusionCullingSceneManager:: applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,1077 void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1050 1078 const bool load) 1051 { // NOTE: should not happen, rather apply view cell representing unbounded space then 1079 { // NOTE: should not encounter NULL view cell, 1080 // rather apply view cell representing unbounded space then 1052 1081 if (!vc) 1053 1082 { 1054 // set everything visible for savety1083 // if no there is no view cell, set everything visible 1055 1084 SetObjectsVisible(true); 1056 1057 1085 return; 1058 1086 } … … 1061 1089 oit_end = vc->GetPvs().mEntries.end(); 1062 1090 1063 //-- PVS of view cell 1091 //////////// 1092 //-- set PVS of view cell to visible 1093 1064 1094 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1065 1095 { … … 1067 1097 1068 1098 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first); 1069 omi->Get Mesh()->setVisible(load);1099 omi->GetEntity()->setVisible(load); 1070 1100 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1071 1101 } 1072 1102 } 1073 1103 //------------------------------------------------------------------------- 1074 void OcclusionCullingSceneManager:: updatePvs(Camera *cam)1104 void OcclusionCullingSceneManager::UpdatePvs(Camera *cam) 1075 1105 { 1076 1106 if (!(mViewCellsLoaded && mUseViewCells)) … … 1088 1118 1089 1119 mElementaryViewCell = newElementary; 1090 //LogManager::getSingleton().logMessage("unloading"); 1120 LogManager::getSingleton().logMessage("unloading"); 1121 1122 std::stringstream d; 1123 d << "here2 " << mViewCellsGeometry.size(); 1124 LogManager::getSingleton().logMessage(d.str()); 1125 1126 ////////////// 1091 1127 //-- unload old pvs 1092 applyViewCellPvs(mCurrentViewCell, false); 1093 1094 1095 //-- the new view cell 1096 1128 1129 ApplyViewCellPvs(mCurrentViewCell, false); 1130 1131 // set old view cell geometry to invisible 1132 if (mCurrentViewCell && mCurrentViewCell->GetMesh()) 1133 { 1134 const int id = mCurrentViewCell->GetId(); 1135 1136 std::stringstream str; 1137 str << "id : " << id << " of " << mViewCellsGeometry.size(); 1138 LogManager::getSingleton().logMessage(str.str()); 1139 1140 mViewCellsGeometry[id]->setVisible(false); 1141 } 1142 1143 // the new view cell 1097 1144 GtpVisibilityPreprocessor::ViewCell *viewCell; 1098 1099 1145 1100 1146 if (mUseVisibilityFilter) 1101 { 1147 { 1148 //////////// 1102 1149 //-- compute new filtered cell 1150 1103 1151 GtpVisibilityPreprocessor::PrVs prvs; 1104 1152 mViewCellsManager->GetPrVS(viewPoint, prvs, 5); … … 1107 1155 else 1108 1156 { 1109 viewCell = newElementary; 1110 } 1111 //LogManager::getSingleton().logMessage("loading"); 1157 viewCell = newElementary;LogManager::getSingleton().logMessage("here55"); 1158 } 1159 1160 /////////////// 1112 1161 //-- load new pvs 1113 applyViewCellPvs(viewCell, true); 1162 1163 // set new view cell geometry to invisible 1164 if (viewCell && viewCell->GetMesh()) 1165 { 1166 const int id = viewCell->GetId(); 1167 1168 std::stringstream str; 1169 str << "id : " << id << " of " << mViewCellsGeometry.size(); 1170 LogManager::getSingleton().logMessage(str.str()); 1171 1172 mViewCellsGeometry[id]->setVisible(false); 1173 } 1174 1175 ApplyViewCellPvs(viewCell, true); 1114 1176 1115 1177 // store pvs 1116 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1117 1118 // delete merge tree of filtered view cell 1119 if (mUseVisibilityFilter) 1120 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1121 } 1178 if (viewCell) 1179 { 1180 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1181 mCurrentViewCell->SetMesh(viewCell->GetMesh()); 1182 mCurrentViewCell->SetId(viewCell->GetId()); 1183 1184 // delete merge tree of filtered view cell 1185 if (mUseVisibilityFilter) 1186 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1187 } 1188 } 1189 //------------------------------------------------------------------------- 1190 void OcclusionCullingSceneManager::CreateViewCellsGeometry() 1191 { 1192 LogManager::getSingleton().logMessage("creating view cells geometry"); 1193 1194 GtpVisibilityPreprocessor::ViewCellContainer viewCells = mViewCellsManager->GetViewCells(); 1195 1196 GtpVisibilityPreprocessor::ViewCellContainer::const_iterator it, it_end = viewCells.end(); 1197 for (it = viewCells.begin(); it != it_end; ++ it) 1198 { 1199 GtpVisibilityPreprocessor::ViewCell *viewCell = *it; 1200 1201 std::stringstream str; 1202 str << "id : " << viewCell->GetId(); 1203 1204 ManualObject *manual = OgreTypeConverter::ConvertToOgre(viewCell->GetMesh(), this); 1205 mViewCellsGeometry[viewCell->GetId()] = manual; 1206 1207 // attach to scene node 1208 getRootSceneNode()->createChildSceneNode()->attachObject(manual); 1209 1210 // initialy set to invisible 1211 manual->setVisible(false); 1212 } 1213 } 1214 1122 1215 #if 0 1123 1216 //------------------------------------------------------------------------- … … 1135 1228 // first test for scene node, then for octant (part of the hierarchy) 1136 1229 if (!octant->mVisibleChildren) 1230 { 1137 1231 octant->setVisible(false); 1232 } 1138 1233 } 1139 1234 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp
r863 r1593 1 1 #include "OgreTypeConverter.h" 2 #include "Mesh.h" 3 #include <OgreManualObject.h> 4 #include <OgreSceneManager.h> 2 5 3 6 … … 13 16 } 14 17 18 15 19 GtpVisibilityPreprocessor::Vector3 OgreTypeConverter::ConvertFromOgre(const Vector3 &v) 16 20 { 17 21 return GtpVisibilityPreprocessor::Vector3(v.x, v.y, v.z); 18 22 } 19 23 24 20 25 AxisAlignedBox OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::AxisAlignedBox3 &box) 21 26 { … … 26 31 } 27 32 33 28 34 Vector3 OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v) 29 35 { 30 36 return Vector3(v.getX(), v.getY(), v.getZ()); 31 37 } 38 39 40 ManualObject *OgreTypeConverter::ConvertToOgre(GtpVisibilityPreprocessor::Mesh *mesh, SceneManager *sceneMgr) 41 { 42 char name[100]; 43 sprintf(name, "mesh%04d", mesh->GetId()); 44 45 ManualObject* manual = sceneMgr->createManualObject(name); 46 manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP); 47 48 // create vertices 49 GtpVisibilityPreprocessor::VertexContainer::const_iterator vit, 50 vit_end = mesh->mVertices.end(); 51 52 for (vit = mesh->mVertices.begin(); vit != vit_end; ++ vit) 53 { 54 const GtpVisibilityPreprocessor::Vector3 vtx = *vit; 55 manual->position(vtx.x, vtx.y, vtx.z); 56 } 57 58 // create faces indices 59 GtpVisibilityPreprocessor::FaceContainer::const_iterator fit, fit_end = mesh->mFaces.end(); 60 61 for (fit = mesh->mFaces.begin(); fit != fit_end; ++ fit) 62 { 63 GtpVisibilityPreprocessor::Face *face = *fit; 64 GtpVisibilityPreprocessor::VertexIndexContainer::const_iterator 65 iit, iit_end = face->mVertexIndices.end(); 66 //GtpVisibilityPreprocessor::VertexIndexContainer::const_reverse_iterator 67 // iit, iit_end = face->mVertexIndices.rend(); 68 69 for (iit = face->mVertexIndices.begin(); iit != iit_end; ++ iit) 70 { 71 const int index = *iit; 72 manual->index(index); 73 } 74 } 75 76 manual->end(); 77 //mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual); 78 79 return manual; 32 80 } 81 82 83 }
Note: See TracChangeset
for help on using the changeset viewer.