Changeset 863 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Timestamp:
- 04/29/06 19:11:23 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r860 r863 1 1 #include "OgreOcclusionCullingSceneManager.h" 2 2 #include "OgreVisibilityOptionsManager.h" 3 #include "OgreTypeConverter.h" 3 4 #include <OgreMath.h> 4 5 #include <OgreIteratorWrappers.h> … … 9 10 #include <OgreEntity.h> 10 11 #include <OgreSubEntity.h> 12 #include <OgreIteratorWrappers.h> 11 13 #include "VspBspTree.h" 12 #include <OgreIteratorWrappers.h> 14 #include "Containers.h" 15 #include "ViewCellsManager.h" 13 16 14 17 namespace Ogre { … … 38 41 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 39 42 40 //mDisplayNodes = true; 41 //mShowBoundingBoxes = true; 42 //mShowBoxes = true; 43 //std::stringstream d; d << "here555"; 44 //mDummyLog.open(""); 45 43 #if 0 44 mDisplayNodes = true; 45 mShowBoundingBoxes = true; 46 mShowBoxes = true; 47 #endif 46 48 // TODO: set maxdepth to reasonable value 47 49 mMaxDepth = 50; … … 836 838 } 837 839 838 /*bool OcclusionCullingSceneManager::CompareBoundingBoxes(const AxisAlignedBox &boxa, 839 const AxisAlignedBox &boxb) 840 { 841 } 842 */ 843 void OcclusionCullingSceneManager::LoadViewCells(string filename) 844 { 845 ObjectContainer objects; 846 mViewCellsManager->LoadViewCells(filename, &objects); 847 848 AxisAlignedBox box; 840 841 MovableObject *OcclusionCullingSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 842 { 849 843 list<SceneNode *> sceneNodeList; 850 844 … … 853 847 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 854 848 855 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 849 bool overlap = false; 850 851 MovableObject *bestFittingObj = NULL; 852 float bestFit = 0.0; 853 854 // find the bbox which is closest to the current bbox 855 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(), !overlap; ++ sit) 856 856 { 857 857 SceneNode *sn = *sit; 858 858 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 859 859 860 861 860 while (oit.hasMoreElements()) 861 { 862 862 MovableObject *mo = oit.getNext(); 863 AxisAlignedBox bbox = mo->getWorldBoundingBox(); 864 // CompareBoundingBoxes(*oit, box); 865 } 863 const AxisAlignedBox bbox = mo->getWorldBoundingBox(); 864 865 const float overlap = GtpVisibilityPreprocessor::FactorOfOverlap( 866 OgreTypeConverter::ConvertFromOgre(bbox), 867 OgreTypeConverter::ConvertFromOgre(box)); 868 869 if (overlap > bestFit) 870 { 871 bestFit = overlap; 872 bestFittingObj = mo; 873 874 // perfect fit => object found 875 if (overlap > (1.0 - GtpVisibilityPreprocessor::Limits::Small)) 876 break; 877 } 878 } 879 } 880 881 return bestFittingObj; 882 } 883 884 885 void OcclusionCullingSceneManager::LoadViewCells(string filename) 886 { 887 GtpVisibilityPreprocessor::ObjectContainer objects; 888 // identify the corresponding Ogre meshes using the bounding boxes 889 IdentifyObjects(objects); 890 891 // load the view cells assigning the found objects to the pvss 892 mViewCellsManager->LoadViewCells(filename, &objects); 893 } 894 895 896 void OcclusionCullingSceneManager::IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects) 897 { 898 const string bboxesFilename = "boxes.out"; 899 900 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 901 mViewCellsManager->LoadBoundingBoxes(bboxesFilename, iboxes); 902 903 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: 904 const_iterator iit, iit_end = iboxes.end(); 905 906 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 907 { 908 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 909 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 910 911 MovableObject *mo = FindCorrespondingObject(currentBox); 912 913 //objects.push_back(mi); 866 914 } 867 915 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp
r860 r863 2 2 3 3 4 GtpVisibilityPreprocessor::AxisAlignedBox3 Ogre::OgreTypeConverter::ConvertFromOgre(const Ogre::AxisAlignedBox &box) 4 namespace Ogre 5 5 { 6 7 GtpVisibilityPreprocessor::AxisAlignedBox3 OgreTypeConverter::ConvertFromOgre(const AxisAlignedBox &box) 8 { 9 const GtpVisibilityPreprocessor::Vector3 bmin = ConvertFromOgre(box.getMinimum()); 10 const GtpVisibilityPreprocessor::Vector3 bmax = ConvertFromOgre(box.getMaximum()); 11 12 return GtpVisibilityPreprocessor::AxisAlignedBox3(bmin, bmax); 6 13 } 7 14 8 GtpVisibilityPreprocessor::Vector3 Ogre ::OgreTypeConverter::ConvertFromOgre(const Ogre::Vector3 &v)15 GtpVisibilityPreprocessor::Vector3 OgreTypeConverter::ConvertFromOgre(const Vector3 &v) 9 16 { 17 return GtpVisibilityPreprocessor::Vector3(v.x, v.y, v.z); 10 18 } 11 19 12 Ogre::AxisAlignedBox Ogre::OgreTypeConverter::ConvertToOgre(const GtpVibilityPreprocessor::AxisAlignedBox3 &box)20 AxisAlignedBox OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::AxisAlignedBox3 &box) 13 21 { 22 const Vector3 bmin = ConvertToOgre(box.Min()); 23 const Vector3 bmax = ConvertToOgre(box.Max()); 24 25 return AxisAlignedBox(bmin, bmax); 14 26 } 15 27 16 Ogre::Vector3 Ogre::OgreTypeConverter::ConvertToOgre(const GtpVibilityPreprocessor::Vector3 &v)28 Vector3 OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v) 17 29 { 30 return Vector3(v.getX(), v.getY(), v.getZ()); 18 31 } 32 }
Note: See TracChangeset
for help on using the changeset viewer.