Changeset 931 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 05/08/06 18:57:11 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
r925 r931 96 96 void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 97 97 QueuedRenderableCollection::OrganisationMode om); 98 void loadVisibilityConfig(const String& filename);98 99 99 /** Override standard function so octree boxes are always of equal side length. 100 100 This has advantages for CHC, because terrain tiles are in different octree nodes … … 124 124 */ 125 125 void InitVisibilityCulling(Camera *cam); 126 126 #if 0 127 127 /** Finds object corresponding to this bounding box in the scene. 128 128 */ … … 133 133 */ 134 134 void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects); 135 135 #endif 136 136 /** Loads / unloads pvs of the view cell to set the visibility in the scene. 137 137 */ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
r925 r931 180 180 Filter="h;hpp;hxx;hm;inl;inc"> 181 181 <File 182 RelativePath="..\include\OgreBoundingBoxConverter.h"> 183 </File> 184 <File 182 185 RelativePath="..\include\OgreMeshInstance.h"> 183 186 </File> … … 216 219 Name="Source Files" 217 220 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> 221 <File 222 RelativePath="..\src\OgreBoundingBoxConverter.cpp"> 223 </File> 218 224 <File 219 225 RelativePath="..\src\OgreMeshInstance.cpp"> -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r925 r931 19 19 #include "OgreMeshInstance.h" 20 20 #include "common.h" 21 #include "OgreBoundingBoxConverter.h" 21 22 22 23 // normal terrain rendering … … 998 999 else 999 1000 { 1000 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om);1001 OctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 1001 1002 } 1002 1003 } … … 1013 1014 } 1014 1015 } 1015 //-------------------------------------------------------------------------1016 void OcclusionCullingSceneManager::loadVisibilityConfig(const String& filename)1017 {1018 // TODO matt1019 // Set up the options1020 ConfigFile config;1021 String val;1022 1023 config.load(filename);1024 1025 val = config.getSetting("Algorithm");1026 1027 if (!val.empty())1028 {1029 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str());1030 }1031 1032 val = config.getSetting("UseDepthPass");1033 1034 if (!val.empty())1035 {1036 setOption("UseDepthPass", val.c_str());1037 }1038 }1039 //-------------------------------------------------------------------------1040 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box)1041 {1042 const float eps = 1e-3f;1043 const Vector3 veps(eps, eps, eps);1044 Vector3 max = box.getMaximum();1045 Vector3 min = box.getMinimum();1046 1047 return AxisAlignedBox(min - veps, max + veps);1048 }1049 //-----------------------------------------------------------------------1050 Entity *OcclusionCullingSceneManager::FindCorrespondingObject(const AxisAlignedBox &box)1051 {1052 list<SceneNode *> sceneNodeList;1053 AxisAlignedBox mybox = EnlargeBox(box);1054 //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));1055 1056 // get intersecting scene nodes1057 findNodesIn(mybox, sceneNodeList, NULL);1058 1059 1060 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();1061 1062 float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small;1063 1064 Entity *bestFittingObj = NULL;1065 float bestFit = overlap;1066 1067 // perfect fit threshold1068 const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small;1069 1070 1071 // find the bbox which is closest to the current bbox1072 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)1073 {1074 SceneNode *sn = *sit;1075 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();1076 1077 while (oit.hasMoreElements())1078 {1079 MovableObject *mo = oit.getNext();1080 1081 // we are only interested in scene entities1082 if (mo->getMovableType() != "Entity")1083 {1084 continue;1085 }1086 1087 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());1088 1089 1090 // compute measure how much aabbs overlap1091 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox),1092 OgreTypeConverter::ConvertFromOgre(bbox));1093 1094 if (overlap > bestFit)1095 {1096 bestFit = overlap;1097 1098 bestFittingObj = static_cast<Entity *>(mo);1099 1100 // perfect fit => object found, eraly exit1101 if (overlap >= thresh)1102 return bestFittingObj;1103 }1104 }1105 }1106 1107 if (0)1108 {1109 std::stringstream d;1110 if (bestFittingObj)1111 d << "best fit: " << bestFit;1112 else1113 d << "warning, objects do not fit\n" << box;1114 1115 Ogre::LogManager::getSingleton().logMessage(d.str());1116 }1117 1118 return bestFittingObj;1119 }1120 1016 //----------------------------------------------------------------------- 1121 1017 void OcclusionCullingSceneManager::LoadViewCells(string filename) … … 1124 1020 SetObjectsVisible(false); 1125 1021 1126 // identify the corresponding Ogre meshes using the bounding boxes 1127 IdentifyObjects(mObjects); 1022 const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName(); 1023 1024 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1025 OgreBoundingBoxConverter bconverter(this); 1128 1026 1129 1027 // load the view cells assigning the found objects to the pvss 1130 1028 mViewCellsManager = 1131 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects );1029 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, &bconverter); 1132 1030 1133 1031 std::stringstream d; 1134 1032 d << "view cells loaded" << endl; 1135 1033 Ogre::LogManager::getSingleton().logMessage(d.str()); 1136 }1137 //-----------------------------------------------------------------------1138 void OcclusionCullingSceneManager::IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects)1139 {1140 const string bboxesFilename = "boxes.out";1141 1142 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes;1143 mViewCellsManager->LoadBoundingBoxes(bboxesFilename, iboxes);1144 1145 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::1146 const_iterator iit, iit_end = iboxes.end();1147 1148 for (iit = iboxes.begin(); iit != iit_end; ++ iit)1149 {1150 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;1151 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);1152 1153 Entity *ent = FindCorrespondingObject(currentBox);1154 1155 // create new mesh instance1156 OgreMeshInstance *omi = new OgreMeshInstance(ent);1157 omi->SetId((*iit).first);1158 objects.push_back(omi);1159 }1160 1034 } 1161 1035 //------------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
r925 r931 20 20 //----------------------------------------------------------------------- 21 21 void OcclusionQueriesQueryManager::ComputeCameraVisibility(const Camera &camera, 22 23 24 GtpVisibility::PatchInfoContainer *visiblePatches,25 22 GtpVisibility::NodeInfoContainer *visibleNodes, 23 GtpVisibility::MeshInfoContainer *visibleGeometry, 24 GtpVisibility::PatchInfoContainer *visiblePatches, 25 bool relativeVisibility) 26 26 { 27 27 // we need access to the scene manager and the rendersystem
Note: See TracChangeset
for help on using the changeset viewer.