Changeset 1177


Ignore:
Timestamp:
08/02/06 15:22:19 (18 years ago)
Author:
szydlowski
Message:
 
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h

    r1170 r1177  
    215215                String rm; 
    216216                if (mSceneMgr->getOption("RenderMethod", &rm)) 
    217                         value = " " + rm; 
     217                { 
     218                        if (rm == "INT") 
     219                                value = " Internal Frustum Culling"; 
     220                        else if (rm == "VFC") 
     221                                value = " View Frustum Culling"; 
     222                        else if (rm == "SWC") 
     223                                value = " Stop and Wait Culling"; 
     224                        else if (rm == "CHC") 
     225                                value = " Coherent Hierarchical Culling"; 
     226                        else 
     227                                value = na; 
     228                } 
    218229                else 
    219230                        value = na; 
     
    278289 
    279290                // stuff for the kdtree overlay 
     291                static String sRM = "[SPACE] Algorithm: "; 
     292                static String sBM = "[X] Build Method: "; 
    280293                static String sMaxDepth = "[1][2] Max Tree Depth: "; 
    281294                static String sHL = "[3][4] Highlight: "; 
    282295                static String sKT = "[5][6] KT: "; 
    283296                static String sKI = "[7][8] KI: "; 
    284                 static String sBM = "[Y] Build Method: "; 
    285                 static String sRM = "[X] Render Method: "; 
    286297                static String sMov = "[Q] Movement: "; 
    287298 
     
    291302 
    292303                //static String rmOptions[] = { "Recursive", "Stack", "StopAndWait", "CHC" }; 
    293                 static String rmOptions[] = { "Recursive", "Stack" }; 
     304                static String rmOptions[] = { "INT", "VFC", "SWC", "CHC" }; 
     305                static String rmOptionCaptions[] = 
     306                { 
     307                        "Internal Frustum Culling", 
     308                        "View Frustum Culling",  
     309                        "Stop and Wait Culling", 
     310                        "Coherent Hierarchical Culling" 
     311                }; 
    294312                static int rmOptionsSize = sizeof(rmOptions) / sizeof (String); 
    295313                static int rmCurrent = 0; 
     
    400418                } 
    401419 
    402                 if (mInputDevice->isKeyDown(KC_Z) && mTimeUntilNextToggle <= 0) 
     420                if (mInputDevice->isKeyDown(KC_X) && mTimeUntilNextToggle <= 0) 
    403421                { 
    404422                        String bm; 
     
    417435                } 
    418436 
    419                 if (mInputDevice->isKeyDown(KC_X) && mTimeUntilNextToggle <= 0) 
     437                if (mInputDevice->isKeyDown(KC_SPACE) && mTimeUntilNextToggle <= 0) 
    420438                { 
    421439                        String rm; 
     
    424442                                rmCurrent = (rmCurrent + 1) % rmOptionsSize; 
    425443                                if (mSceneMgr->setOption("RenderMethod", &rmOptions[rmCurrent])) 
    426                                         OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM + rmOptions[rmCurrent]); 
     444                                        OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM + rmOptionCaptions[rmCurrent]); 
    427445                        } 
    428446                        else 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj

    r1163 r1177  
    103103                                LinkIncremental="1" 
    104104                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;" 
    105                                 GenerateDebugInformation="FALSE" 
     105                                GenerateDebugInformation="TRUE" 
    106106                                SubSystem="2" 
    107107                                OptimizeReferences="2" 
  • 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        { 
  • OGRE/trunk/resources/overlays/TestKdTree.overlay

    r1172 r1177  
    1111                top 5 
    1212                // width 220 
    13                 width 300 
     13                width 430 
    1414                height 120 
    1515                material Core/StatsBlockCenter 
     
    3434//                      material Core/StatsBreak 
    3535//              } 
    36                      
     36 
     37                element TextArea(KdTree/RenderMethod) 
     38                { 
     39                        metrics_mode pixels 
     40                        left 5 
     41                        top 5 
     42                        width 90 
     43                        height 30 
     44                        font_name TrebuchetMSBold 
     45                        char_height 16 
     46                        caption [SPACE] Algorithm: 
     47                        colour_top 0.5 0.7 0.5 
     48                        colour_bottom 0.3 0.5 0.3 
     49                } 
     50                element TextArea(KdTree/BuildMethod) 
     51                { 
     52                        metrics_mode pixels 
     53                        left 5 
     54                        top 20 
     55                        width 90 
     56                        height 30 
     57                        font_name TrebuchetMSBold 
     58                        char_height 16 
     59                        caption [X] Build Method: 
     60                        colour_top 0.5 0.7 0.5 
     61                        colour_bottom 0.3 0.5 0.3 
     62                } 
    3763                element TextArea(KdTree/Depth) 
    3864                { 
    3965                        metrics_mode pixels 
    4066                        left 5 
    41                         top 5 
     67                        top 35 
    4268                        width 90 
    4369                        height 30 
     
    5480                        metrics_mode pixels 
    5581                        left 5 
    56                         top 20 
     82                        top 50 
    5783                        width 90 
    5884                        height 30 
     
    6793                        metrics_mode pixels 
    6894                        left 5 
    69                         top 35 
     95                        top 65 
    7096                        width 90 
    7197                        height 30 
     
    80106                        metrics_mode pixels 
    81107                        left 5 
    82                         top 50 
     108                        top 80 
    83109                        width 90 
    84110                        height 30 
     
    86112                        char_height 16 
    87113                        caption [7][8] KI: 
    88                         colour_top 0.5 0.7 0.5 
    89                         colour_bottom 0.3 0.5 0.3 
    90                 } 
    91                 element TextArea(KdTree/BuildMethod) 
    92                 { 
    93                         metrics_mode pixels 
    94                         left 5 
    95                         top 65 
    96                         width 90 
    97                         height 30 
    98                         font_name TrebuchetMSBold 
    99                         char_height 16 
    100                         caption [Y] Build Method: 
    101                         colour_top 0.5 0.7 0.5 
    102                         colour_bottom 0.3 0.5 0.3 
    103                 } 
    104                 element TextArea(KdTree/RenderMethod) 
    105                 { 
    106                         metrics_mode pixels 
    107                         left 5 
    108                         top 80 
    109                         width 90 
    110                         height 30 
    111                         font_name TrebuchetMSBold 
    112                         char_height 16 
    113                         caption [X] Render Method: 
    114114                        colour_top 0.5 0.7 0.5 
    115115                        colour_bottom 0.3 0.5 0.3 
Note: See TracChangeset for help on using the changeset viewer.