Changeset 1595 for GTP/trunk/Lib
- Timestamp:
- 10/10/06 01:27:11 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r1296 r1595 1 #ifndef _ OgreBoundingBoxConverter_H__2 #define _ OgreBoundingBoxConverter_H__1 #ifndef _PlatFormBoundingBoxConverter_H__ 2 #define _PlatFormBoundingBoxConverter_H__ 3 3 4 4 #include "OgreAxisAlignedBox.h" … … 13 13 class OctreeSceneManager; 14 14 class KdTreeSceneManager; 15 class BvHierarchySceneManager; 16 15 17 16 18 /** Class which converts preprocessor types to OGRE types 17 19 */ 18 class __declspec(dllexport) OgreBoundingBoxConverter: public GtpVisibilityPreprocessor::BoundingBoxConverter 20 template<typename T> 21 class __declspec(dllexport) PlatFormBoundingBoxConverter: public GtpVisibilityPreprocessor::BoundingBoxConverter 19 22 { 20 23 public: 21 OgreBoundingBoxConverter(OctreeSceneManager *sm); 22 OgreBoundingBoxConverter(KdTreeSceneManager *sm); 23 24 PlatFormBoundingBoxConverter(T *sm); 25 24 26 bool IdentifyObjects(const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes, 25 27 GtpVisibilityPreprocessor::ObjectContainer &objects) const; … … 28 30 protected: 29 31 30 Entity *FindCorrespondingObject(const AxisAlignedBox &box) const; 32 //------------------------------------------------------------------------- 33 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 34 { 35 const float eps = 1e-3f; 36 const Vector3 veps(eps, eps, eps); 37 38 Vector3 max = box.getMaximum(); 39 Vector3 min = box.getMinimum(); 31 40 32 OctreeSceneManager *mOctSceneMgr; 33 KdTreeSceneManager *mKdSceneMgr; 41 return AxisAlignedBox(min - veps, max + veps); 42 } 43 44 Entity *FindBestFittingObject(const AxisAlignedBox &box) const; 45 46 T *mSceneMgr; 34 47 }; 48 49 //------------------------------------------------------------------------- 50 template<typename T> 51 PlatFormBoundingBoxConverter<T>::PlatFormBoundingBoxConverter(T *sm): 52 mSceneMgr(sm) 53 { 54 } 55 //----------------------------------------------------------------------- 56 template<typename T> 57 Entity *PlatFormBoundingBoxConverter<T>::FindBestFittingObject(const AxisAlignedBox &box) const 58 { 59 list<SceneNode *> sceneNodeList; 60 AxisAlignedBox mybox = EnlargeBox(box); 61 62 // get intersecting scene nodes 63 mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 64 65 // minimal overlap 66 float overlap = 0;//1e-6; 67 68 Entity *bestFittingObj = NULL; 69 float bestFit = overlap; 70 71 // perfect fit threshold 72 const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small; 73 74 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 75 // find the bbox which is closest to the current bbox 76 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 77 { 78 SceneNode *sn = *sit; 79 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 80 81 while (oit.hasMoreElements()) 82 { 83 MovableObject *mo = oit.getNext(); 84 85 // we are only interested in scene entities 86 if (mo->getMovableType() != "Entity") 87 { 88 continue; 89 } 90 91 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 92 93 // compute measure how much aabbs overlap 94 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox), 95 OgreTypeConverter::ConvertFromOgre(bbox)); 96 97 if (overlap > bestFit) 98 { 99 bestFit = overlap; 100 bestFittingObj = static_cast<Entity *>(mo); 101 102 // perfect fit => object found, early exit 103 if (overlap >= thresh) 104 { 105 return bestFittingObj; 106 } 107 } 108 } 109 } 110 111 if (0) 112 { 113 std::stringstream d; 114 if (bestFittingObj) 115 d << "best fit: " << bestFit; 116 else 117 d << "warning, no best fitting object\n" << box; 118 119 Ogre::LogManager::getSingleton().logMessage(d.str()); 120 } 121 122 return bestFittingObj; 123 } 124 //------------------------------------------------------------------------- 125 template<typename T> 126 bool PlatFormBoundingBoxConverter<T>::IdentifyObjects( 127 const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes, 128 GtpVisibilityPreprocessor::ObjectContainer &objects) const 129 { 130 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: 131 const_iterator iit, iit_end = iboxes.end(); 132 133 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 134 { 135 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 136 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 137 138 Entity *ent = FindBestFittingObject(currentBox); 139 140 // create new mesh instance 141 if (ent) 142 { 143 OgreMeshInstance *omi = new OgreMeshInstance(ent); 144 omi->SetId((*iit).first); 145 objects.push_back(omi); 146 } 147 } 148 149 return true; 150 } 151 152 153 typedef PlatFormBoundingBoxConverter<OctreeSceneManager> OctreeBoundingBoxConverter; 154 typedef PlatFormBoundingBoxConverter<BvHierarchySceneManager> BvhBoundingBoxConverter; 155 typedef PlatFormBoundingBoxConverter<KdTreeSceneManager> KdTreeBoundingBoxConverter; 35 156 36 157 } // namespace Ogre 37 158 38 #endif // OgreBoundingBoxConverter159 #endif // PlatFormBoundingBoxConverter -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneManager.h
r1320 r1595 271 271 bool mDeleteQueueAfterRendering; 272 272 273 274 273 // remember visited scene nodes for viz 275 274 BvHierarchy::NodeList mVisibleNodes; 276 275 277 /************************************************************************/ 278 /* Kd-Tree specific options & members */ 279 /************************************************************************/ 276 277 /************************************************************************/ 278 /* Bvh specific options & members */ 279 /************************************************************************/ 280 281 280 282 // maximum depth of the BvHierarchy 281 283 int mMaxDepth; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp
r1296 r1595 9 9 namespace Ogre 10 10 { 11 //-------------------------------------------------------------------------12 OgreBoundingBoxConverter::OgreBoundingBoxConverter(OctreeSceneManager *sm):13 mOctSceneMgr(sm), mKdSceneMgr(0)14 {15 }16 //-------------------------------------------------------------------------17 OgreBoundingBoxConverter::OgreBoundingBoxConverter(KdTreeSceneManager *sm):18 mOctSceneMgr(0), mKdSceneMgr(sm)19 {20 }21 //-------------------------------------------------------------------------22 bool OgreBoundingBoxConverter::IdentifyObjects(const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes,23 GtpVisibilityPreprocessor::ObjectContainer &objects) const24 {25 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::26 const_iterator iit, iit_end = iboxes.end();27 28 for (iit = iboxes.begin(); iit != iit_end; ++ iit)29 {30 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;31 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);32 33 Entity *ent = FindCorrespondingObject(currentBox);34 35 // create new mesh instance36 OgreMeshInstance *omi = new OgreMeshInstance(ent);37 omi->SetId((*iit).first);38 objects.push_back(omi);39 }40 41 return true;42 }43 //-------------------------------------------------------------------------44 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box)45 {46 const float eps = 1e-3f;47 const Vector3 veps(eps, eps, eps);48 49 Vector3 max = box.getMaximum();50 Vector3 min = box.getMinimum();51 52 return AxisAlignedBox(min - veps, max + veps);53 }54 //-----------------------------------------------------------------------55 Entity *OgreBoundingBoxConverter::FindCorrespondingObject(const AxisAlignedBox &box) const56 {57 list<SceneNode *> sceneNodeList;58 AxisAlignedBox mybox = EnlargeBox(box);59 //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));60 61 // get intersecting scene nodes62 if (mOctSceneMgr)63 mOctSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);64 else if (mKdSceneMgr)65 mKdSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);66 else67 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Bounding Box Converter cannot "68 "find appropriate scene manager.", "OgreBoundingBoxConverter::FindCorrespondingObject");69 70 71 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();72 73 // minimal overlap74 float overlap = 0;//1e-6;75 76 Entity *bestFittingObj = NULL;77 float bestFit = overlap;78 79 // perfect fit threshold80 const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small;81 11 82 12 83 // find the bbox which is closest to the current bbox84 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)85 {86 SceneNode *sn = *sit;87 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();88 89 while (oit.hasMoreElements())90 {91 MovableObject *mo = oit.getNext();92 93 // we are only interested in scene entities94 if (mo->getMovableType() != "Entity")95 {96 continue;97 }98 99 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());100 101 102 // compute measure how much aabbs overlap103 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox),104 OgreTypeConverter::ConvertFromOgre(bbox));105 106 if (overlap > bestFit)107 {108 bestFit = overlap;109 110 bestFittingObj = static_cast<Entity *>(mo);111 112 // perfect fit => object found, early exit113 if (overlap >= thresh)114 return bestFittingObj;115 }116 }117 }118 119 if (0)120 {121 std::stringstream d;122 if (bestFittingObj)123 d << "best fit: " << bestFit;124 else125 d << "warning, objects do not fit\n" << box;126 127 Ogre::LogManager::getSingleton().logMessage(d.str());128 }129 130 return bestFittingObj;131 }132 13 133 14 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
r1593 r1595 27 27 { 28 28 29 BvHierarchySceneManager::BvHierarchySceneManager(const String& name, GtpVisibility::VisibilityManager *vm): 29 BvHierarchySceneManager::BvHierarchySceneManager(const String& name, 30 GtpVisibility::VisibilityManager *vm): 30 31 SceneManager(name), 31 32 mVisibilityManager(vm), … … 1323 1324 // converter between view cell ids and Ogre entites 1324 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1325 #if 0 1326 OgreBoundingBoxConverter bconverter(this); 1327 1328 // load the view cells assigning the found objects to the pvss1326 BvhBoundingBoxConverter bconverter(this); 1327 1328 // load the view cells and assigns the objects in the pvs to 1329 // the scene objects using the bounding boxes 1329 1330 mViewCellsManager = 1330 1331 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter); 1331 1332 1332 1333 return (mViewCellsManager != NULL); 1333 #endif1334 1334 } 1335 1335 //------------------------------------------------------------------------- 1336 1336 void BvHierarchySceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1337 1337 const bool load) 1338 { // NOTE: should not happen, rather apply view cell representing unbounded space then 1338 { // NOTE: should not happen, rather apply view cell 1339 // representing unbounded space then 1339 1340 if (!vc) 1340 { 1341 // set everything visible for savety 1341 { // set everything visible for savety 1342 1342 SetObjectsVisible(true); 1343 1344 1343 return; 1345 1344 } … … 1348 1347 oit_end = vc->GetPvs().mEntries.end(); 1349 1348 1349 ////////////// 1350 1350 //-- PVS of view cell 1351 1351 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1593 r1595 1322 1322 // converter between view cell ids and Ogre entites 1323 1323 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1324 OgreBoundingBoxConverter bconverter(this);1324 KdTreeBoundingBoxConverter bconverter(this); 1325 1325 1326 1326 // load the view cells assigning the found objects to the pvss -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1593 r1595 593 593 // reset view cell 594 594 OGRE_DELETE(mCurrentViewCell); 595 595 596 596 if (mUseViewCells) 597 597 { … … 601 601 mElementaryViewCell = NULL; 602 602 603 // if usingview cells, all objects are set to false initially603 // if we use view cells, all objects are set to false initially 604 604 SetObjectsVisible(!mUseViewCells); 605 605 } … … 1060 1060 // converter between view cell ids and Ogre entites 1061 1061 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1062 O greBoundingBoxConverter bconverter(this);1062 OctreeBoundingBoxConverter bconverter(this); 1063 1063 1064 1064 // load the view cells assigning the found objects to the pvss -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r1495 r1595 125 125 { 126 126 // create new query if there is no query left 127 if (mCurrentTestIdx == mOcclusionQueries.size())127 if (mCurrentTestIdx == (int)mOcclusionQueries.size()) 128 128 { 129 129 mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); 130 } 131 132 std::stringstream d;133 d << "resizing queries: " << (int)mOcclusionQueries.size() << std::endl;134 LogManager::getSingleton().logMessage(d.str());130 131 std::stringstream d; 132 d << "resizing queries: " << (int)mOcclusionQueries.size() << std::endl; 133 LogManager::getSingleton().logMessage(d.str()); 134 } 135 135 136 136 return mOcclusionQueries[mCurrentTestIdx ++]; -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1580 r1595 270 270 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 271 271 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 272 { cout << "z";272 { 273 273 (*rit)->mFlags |= VssRay::BorderSample; 274 //(*rit)->mOriginObject = currentRay.mTerminationObject;275 } 274 } 275 276 276 // add to ray queue 277 277 EnqueueRays(vssRays); … … 280 280 int castRays = (int)vssRays.size(); 281 281 282 283 #if 0284 282 // recursivly subdivide each edge 285 for (int i = 0; i < n; ++ i)283 for (int i = 0; 1 && (i < n); ++ i) 286 284 { 287 285 castRays += SubdivideEdge( … … 293 291 currentRay); 294 292 } 295 #endif296 293 297 294 mBorderSamples += castRays; … … 348 345 { 349 346 const long startTime = GetTime(); 350 //cout << "here8"<<endl; 347 351 348 // generate simple rays 352 349 SimpleRayContainer simpleRays; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1586 r1595 274 274 275 275 if (mBoundingBoxConverter) 276 { 276 277 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects); 278 } 277 279 278 280 Debug << "\nconverted bounding boxes to objects in " -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1581 r1595 129 129 char internKdTree[100]; 130 130 Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", internKdTree); 131 // string internKdTree = ReplaceSuffic(filename, ".x3d", ".kd");131 //const string internKdTree = ReplaceSuffic(filename, ".x3d", ".kd"); 132 132 133 133 //-- initialize external ray casters
Note: See TracChangeset
for help on using the changeset viewer.