Ignore:
Timestamp:
04/29/06 19:11:23 (19 years ago)
Author:
mattausch
Message:

working on preprocessor integration
added iv stuff

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  
    11#include "OgreOcclusionCullingSceneManager.h" 
    22#include "OgreVisibilityOptionsManager.h" 
     3#include "OgreTypeConverter.h" 
    34#include <OgreMath.h> 
    45#include <OgreIteratorWrappers.h> 
     
    910#include <OgreEntity.h> 
    1011#include <OgreSubEntity.h> 
     12#include <OgreIteratorWrappers.h> 
    1113#include "VspBspTree.h" 
    12 #include <OgreIteratorWrappers.h> 
     14#include "Containers.h" 
     15#include "ViewCellsManager.h" 
    1316 
    1417namespace Ogre { 
     
    3841        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
    3942         
    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 
    4648        // TODO: set maxdepth to reasonable value 
    4749        mMaxDepth = 50; 
     
    836838} 
    837839 
    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 
     841MovableObject *OcclusionCullingSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 
     842{ 
    849843        list<SceneNode *> sceneNodeList; 
    850844 
     
    853847        list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
    854848 
    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) 
    856856        { 
    857857                SceneNode *sn = *sit; 
    858858                SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 
    859859 
    860                 while (oit.hasMoreElements()) 
    861                  { 
     860        while (oit.hasMoreElements()) 
     861                { 
    862862                         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 
     885void 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 
     896void 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); 
    866914        } 
    867915} 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp

    r860 r863  
    22 
    33 
    4 GtpVisibilityPreprocessor::AxisAlignedBox3 Ogre::OgreTypeConverter::ConvertFromOgre(const Ogre::AxisAlignedBox &box) 
     4namespace Ogre 
    55{ 
     6 
     7GtpVisibilityPreprocessor::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); 
    613} 
    714 
    8 GtpVisibilityPreprocessor::Vector3 Ogre::OgreTypeConverter::ConvertFromOgre(const Ogre::Vector3 &v) 
     15GtpVisibilityPreprocessor::Vector3 OgreTypeConverter::ConvertFromOgre(const Vector3 &v) 
    916{ 
     17    return GtpVisibilityPreprocessor::Vector3(v.x, v.y, v.z); 
    1018} 
    1119         
    12 Ogre::AxisAlignedBox Ogre::OgreTypeConverter::ConvertToOgre(const GtpVibilityPreprocessor::AxisAlignedBox3 &box) 
     20AxisAlignedBox OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::AxisAlignedBox3 &box) 
    1321{ 
     22        const Vector3 bmin = ConvertToOgre(box.Min()); 
     23        const Vector3 bmax = ConvertToOgre(box.Max()); 
     24 
     25        return AxisAlignedBox(bmin, bmax); 
    1426} 
    1527 
    16 Ogre::Vector3 Ogre::OgreTypeConverter::ConvertToOgre(const GtpVibilityPreprocessor::Vector3 &v) 
     28Vector3 OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v) 
    1729{ 
     30        return Vector3(v.getX(), v.getY(), v.getZ()); 
    1831} 
     32} 
Note: See TracChangeset for help on using the changeset viewer.