Ignore:
Timestamp:
10/13/06 10:49:29 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h

    r1621 r1623  
    6666        } 
    6767         
     68        //------------------------------------------------------------------------- 
     69        inline static AxisAlignedBox ScaleBox(const AxisAlignedBox &box) 
     70        { 
     71                const float scale = 1.5f; 
     72        Vector3 max = box.getMaximum(); 
     73        Vector3 min = box.getMinimum(); 
     74                Vector3 size = max - min; 
     75                Vector3 newSize = size*(scale*0.5f); 
     76                Vector3 center = 0.5f * (min + max);  
     77 
     78                Vector3 min = center - newSize; 
     79                Vector3 max = center + newSize; 
     80 
     81                return AxisAlignedBox(min, max); 
     82        } 
    6883        /** find object which fits best to this bounding box 
    6984        */ 
     
    89104{ 
    90105        list<SceneNode *> sceneNodeList; 
     106        AxisAlignedBox3 enlargedBox =  
    91107        AxisAlignedBox mybox = EnlargeBox(box); 
    92108                 
     
    154170} 
    155171//----------------------------------------------------------------------- 
    156 template<typename T> 
     172/*template<typename T> 
    157173void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box, 
    158174                                                                                                                          EntityContainer &objects) const 
     
    161177                         
    162178        // get intersecting scene nodes (= candidates) 
    163         //AxisAlignedBox mybox = EnlargeBox(box); 
    164         //mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 
    165         mSceneMgr->findNodesIn(box, sceneNodeList, NULL); 
     179        AxisAlignedBox mybox = EnlargeBox(box); 
     180        mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 
     181        //mSceneMgr->findNodesIn(box, sceneNodeList, NULL); 
    166182 
    167183        list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
    168184 
    169         //GtpVisibilityPreprocessor::AxisAlignedBox nodeBox = OgreTypeConverter::ConvertFromOgre(mybox); 
    170         GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box); 
     185        GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(mybox); 
     186        //GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box); 
    171187 
    172188        // find really intersecting objects 
     
    201217        } 
    202218} 
    203  
     219*/ 
     220template<typename T> 
     221void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box, 
     222                                                                                                                          EntityContainer &objects) const 
     223{//return; 
     224        list<SceneNode *> sceneNodeList; 
     225                         
     226        // get intersecting scene nodes (= candidates) 
     227        AxisAlignedBox mybox = EnlargeBox(box); 
     228        //mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 
     229        mSceneMgr->findNodesIn(box, sceneNodeList, NULL); 
     230 
     231        list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
     232 
     233        //GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(mybox); 
     234        GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box); 
     235 
     236        // find really intersecting objects 
     237        for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 
     238        { 
     239                SceneNode *sn = *sit; 
     240                SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 
     241 
     242        while (oit.hasMoreElements()) 
     243                { 
     244                        MovableObject *mo = oit.getNext(); 
     245 
     246                        // we are only interested in scene entities 
     247                        if (mo->getMovableType() != "Entity") 
     248                        { 
     249                                continue; 
     250                        } 
     251                          
     252                        //const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 
     253                        const AxisAlignedBox bbox = mo->getWorldBoundingBox(); 
     254 
     255                        const bool overlaps = Overlap(nodeBox, 
     256                                                                                  OgreTypeConverter::ConvertFromOgre(bbox) 
     257                                                                                  ); 
     258                                                                                  //,0.00001); 
     259         
     260                         if (overlaps) 
     261                         { 
     262                                 objects.push_back(static_cast<Entity *>(mo)); 
     263                         } 
     264                } 
     265        } 
     266} 
    204267#if USE_KD_PVS 
    205268//------------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r1622 r1623  
    703703                        SetObjectsVisible(!mUseViewCells); 
    704704 
    705                         /*MovableObjectIterator movit = getMovableObjectIterator("Entity"); 
     705                        MovableObjectIterator movit = getMovableObjectIterator("Entity"); 
    706706                        while (movit.hasMoreElements()) 
    707707                        { 
    708708                                Entity *ent = static_cast<Entity *>(movit.getNext()); 
    709709                                ent->setVisible(!mUseViewCells); 
    710                         }*/ 
     710                        } 
    711711                } 
    712712 
Note: See TracChangeset for help on using the changeset viewer.