Ignore:
Timestamp:
08/02/06 15:22:19 (18 years ago)
Author:
szydlowski
Message:
 
Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
Files:
4 edited

Legend:

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

    r1173 r1177  
    429429                enum RenderMethod 
    430430                { 
    431                         KDRM_RECURSE, 
    432                         KDRM_STACK, 
    433                         KDRM_SAW, 
    434                         KDRM_CHC 
     431                        KDRM_INTERNAL, 
     432                        KDRM_GTP_VFC, 
     433                        KDRM_GTP_SWC, 
     434                        KDRM_GTP_CHC 
     435 
    435436                }; 
    436437 
     
    488489                void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame,  
    489490                        Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 
    490                 // stack based rendering function 
    491                 void stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame,  
    492                         Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 
    493491 
    494492                // the root node of the kdtree 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h

    r1175 r1177  
    3232                virtual const String& getTypeName(void) const; 
    3333 
     34                /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 
     35                */ 
    3436                virtual SceneNode* createSceneNode(void); 
     37                /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 
     38                */ 
    3539                virtual SceneNode* createSceneNode(const String& name); 
     40 
    3641                /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 
    3742                */ 
     
    4247                virtual void _updateNode(KdTreeSceneNode *node); // TODO:  
    4348 
    44                 //virtual void _updateSceneGraph(Camera* cam); 
     49                /** Override from scene manager to st up culling manager 
     50                */ 
     51                virtual void _updateSceneGraph(Camera* cam); 
     52                /** Override from Scenemanager, employ kd-tree based culling 
     53                        or CHC 
     54                */ 
    4555                virtual void _findVisibleObjects(Camera *cam, bool onlyShadowCasters); 
    4656                //virtual void _renderVisibleObjects(); 
    4757 
     58                /** Render a list of scenenodes 
     59                */ 
    4860                virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam, 
    4961                        bool onlyShadowCasters, int leavePassesInQueue); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp

    r1173 r1177  
    12781278                if (mKdRoot) 
    12791279                { 
    1280                         //if (renderMethod == KdTree::KDRM_STACK) 
    1281                         //{ 
    1282                         //      stackQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(),  
    1283                         //              cam, queue, onlyShadowCasters, showBoxes); 
    1284                         //} 
    1285                         //else 
    1286                         //{ 
    1287                                 recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
    1288                                         cam, queue, onlyShadowCasters, showBoxes); 
    1289                         //} 
     1280                        recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
     1281                                cam, queue, onlyShadowCasters, showBoxes); 
    12901282                } 
    12911283        } 
     
    13431335        } 
    13441336 
    1345         void KdTree::stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame, Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
    1346         { 
    1347                 static NodeStack nodestack; 
    1348                 if (!nodestack.empty()) OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,  
    1349                         "Stuff left in stack from previos frame", "KdTree::stackQueueVisibleObjects"); 
    1350  
    1351                 nodestack.push(root); 
    1352  
    1353                 while (!nodestack.empty()) 
    1354                 { 
    1355                         KdTree::Node * node = nodestack.top(); 
    1356                         nodestack.pop(); 
    1357  
    1358                         // test visibility 
    1359                         if (cam->isVisible(node->mAABB)) 
    1360                         { 
    1361         #ifdef KDTREE_DEBUG 
    1362                                 WireBoundingBox * wbb = 0; 
    1363                                 if (showBoxes) 
    1364                                         wbb = node->getWireBoundingBox(); 
    1365         #endif 
    1366  
    1367                                 if (node->isLeaf()) 
    1368                                 { 
    1369                                         KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 
    1370                                         KdRenderableList::iterator it  = leaf->mKdRenderables.begin(); 
    1371                                         KdRenderableList::iterator end = leaf->mKdRenderables.end(); 
    1372                                         while (it != end) 
    1373                                         {                        
    1374                                                 if (!(*it)->isQueued(currentFrame, cam)) 
    1375                                                 { 
    1376                                                         (*it)->queueObjects(cam, queue, onlyShadowCasters); 
    1377                                                 } 
    1378                                                 it++; 
    1379                                         } 
    1380         #ifdef KDTREE_DEBUG 
    1381                                         if (wbb) 
    1382                                                 queue->addRenderable(wbb); 
    1383         #else 
    1384                                         if (showBoxes) 
    1385                                                 queue->addRenderable(leaf->getWireBoundingBox()); 
    1386         #endif 
    1387                                 } 
    1388                                 else 
    1389                                 { 
    1390                                         KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
    1391         #ifdef KDTREE_DEBUG 
    1392                                         if (wbb) 
    1393                                                 queue->addRenderable(wbb); 
    1394         #else 
    1395                                         if (showBoxes) 
    1396                                                 queue->addRenderable(branch->getWireBoundingBox()); 
    1397         #endif 
    1398  
    1399                                         if (branch->mLeft) 
    1400                                                 nodestack.push(branch->mLeft); 
    1401                                         if (branch->mRight) 
    1402                                                 nodestack.push(branch->mRight); 
    1403                                 } 
    1404                         } 
    1405                 } 
    1406         } 
    1407  
    14081337        void KdTree::dump() 
    14091338        { 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r1175 r1177  
    1414#include "OgreKdTree.h" 
    1515#include "OgreVisibilityOptionsManager.h" 
     16#include <VisibilityEnvironment.h> 
    1617 
    1718#include <OgreLogManager.h> 
     
    3132#endif 
    3233                mBuildMethod(KdTree::KDBM_PRIORITYQUEUE), 
    33                 mRenderMethod(KdTree::KDRM_RECURSE), 
     34                mRenderMethod(KdTree::KDRM_INTERNAL), 
    3435                mLeavePassesInQueue(0), 
    3536                mCurrentEntityId(1) 
     
    164165                { 
    165166                        String rm = *static_cast<const String *>(pValue); 
    166                         if (rm == "Recursive") 
    167                         { 
    168                                 mRenderMethod = KdTree::KDRM_RECURSE; 
    169                                 return true; 
    170                         } 
    171                         else if (rm == "Stack") 
    172                         { 
    173                                 mRenderMethod = KdTree::KDRM_STACK; 
    174                                 return true; 
    175                         } 
    176                         else if (rm == "StopAndWait") 
    177                         { 
    178                                 mRenderMethod = KdTree::KDRM_SAW; 
    179                                 return true; 
     167                        if (rm == "INT") 
     168                        { 
     169                                mRenderMethod = KdTree::KDRM_INTERNAL; 
     170                                return true; 
     171                        } 
     172                        else if (rm == "VFC") 
     173                        { 
     174                                mRenderMethod = KdTree::KDRM_GTP_VFC; 
     175                                int cmt = GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING; 
     176                                return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 
     177                                        .setOption("Algorithm", &cmt); 
     178                        } 
     179                        else if (rm == "SWC") 
     180                        { 
     181                                mRenderMethod = KdTree::KDRM_GTP_SWC; 
     182                                int cmt = GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING; 
     183                                return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 
     184                                        .setOption("Algorithm", &cmt); 
    180185                        } 
    181186                        else if (rm == "CHC") 
    182187                        { 
    183                                 mRenderMethod = KdTree::KDRM_CHC; 
    184                                 return true; 
    185                         } 
    186                         else 
    187                         { 
    188                                 return false; 
    189                         } 
     188                                mRenderMethod = KdTree::KDRM_GTP_CHC; 
     189                                int cmt = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
     190                                return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 
     191                                        .setOption("Algorithm", &cmt); 
     192                        } 
     193                        else 
     194                        { 
     195                                return false; 
     196                        } 
     197                } 
     198                // little hack in case someone uses "Algorithm" option from VisOptMan directly 
     199                else if (strKey == "Algorithm") 
     200                { 
     201                        bool success = VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 
     202                                .setOption(strKey, pValue); 
     203                        // change setting only if change in VisOptMan was successful 
     204                        if (success) 
     205                        { 
     206                                int val = *static_cast<const int *>(pValue); 
     207                                if (val == GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING) 
     208                                        mRenderMethod = KdTree::KDRM_GTP_VFC; 
     209                                else if (val == GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING) 
     210                                        mRenderMethod = KdTree::KDRM_GTP_SWC; 
     211                                else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
     212                                        mRenderMethod = KdTree::KDRM_GTP_CHC; 
     213                                // default, should never happen 
     214                                else 
     215                                        mRenderMethod = KdTree::KDRM_INTERNAL; 
     216                        } 
     217                        return success; 
    190218                } 
    191219                else if (strKey == "ShowKdTree") 
     
    243271                else if (strKey == "RenderMethod") 
    244272                { 
    245                         if (mRenderMethod == KdTree::KDRM_RECURSE) 
    246                         { 
    247                                 *static_cast<String *>(pDestValue) = "Recursive"; 
    248                         } 
    249                         else if (mRenderMethod == KdTree::KDRM_STACK) 
    250                         { 
    251                                 *static_cast<String *>(pDestValue) = "Stack"; 
    252                         } 
    253                         else if (mRenderMethod == KdTree::KDRM_SAW) 
    254                         { 
    255                                 *static_cast<String *>(pDestValue) = "StopAndWait"; 
    256                         } 
    257                         else if (mRenderMethod == KdTree::KDRM_CHC) 
    258                         { 
    259                                 *static_cast<String *>(pDestValue) = "CHC"; 
     273                        if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     274                        { 
     275                                *static_cast<String *>(pDestValue) = "INT"; 
     276                        } 
     277                        else if (mRenderMethod == KdTree::KDRM_GTP_VFC) 
     278                        { 
     279                                        *static_cast<String *>(pDestValue) = "VFC"; 
     280                        } 
     281                        else if (mRenderMethod == KdTree::KDRM_GTP_SWC) 
     282                        { 
     283                                        *static_cast<String *>(pDestValue) = "SWC"; 
     284                        } 
     285                        else if (mRenderMethod == KdTree::KDRM_GTP_CHC) 
     286                        { 
     287                                        *static_cast<String *>(pDestValue) = "CHC"; 
     288                        } 
     289                        else 
     290                        { 
     291                                return false; 
    260292                        } 
    261293                        return true; 
     
    343375        { 
    344376                Entity *ent = SceneManager::createEntity(entityName, meshName); 
    345  
     377#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    346378                for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
    347379                { 
     
    351383                // increase counter of entity id values 
    352384                ++ mCurrentEntityId; 
    353  
     385#endif 
    354386                return ent; 
    355387        } 
     
    398430        } 
    399431 
     432        void KdTreeSceneManager::_updateSceneGraph(Camera* cam) 
     433        { 
     434                mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 
     435                mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 
     436 
     437                SceneManager::_updateSceneGraph(cam); 
     438        } 
     439 
    400440        void KdTreeSceneManager::_findVisibleObjects(Camera *cam, bool onlyShadowCasters) 
    401441        { 
Note: See TracChangeset for help on using the changeset viewer.