Changeset 86 for trunk/VUT


Ignore:
Timestamp:
05/06/05 01:39:32 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibility/include/HierarchyInterface.h

    r85 r86  
    3636                @returns occlusion query for this node 
    3737        */ 
    38         virtual OcclusionQuery *IssueOcclusionQuery(HierarchyNode *node) = 0; 
     38        virtual OcclusionQuery *IssueOcclusionQuery(HierarchyNode *node,  
     39                const bool wasVisible = false) = 0; 
    3940        /** Sets the root of the scene hierarchy. 
    4041                @param root the hierarchy root 
     
    105106        */ 
    106107        unsigned int GetNumRenderedNodes(); 
     108        /** Optimization when issuing occlusion test: test is done with actual geometry  
     109                rather than the bounding box 
     110                @param useOptimization if the optimization should be used 
     111        */ 
     112        void SetUseOptimization(bool useOptimization); 
    107113 
    108114protected: 
    109115         
     116        bool mUseOptimization; 
    110117        unsigned int mFrameId; 
    111118 
  • trunk/VUT/GtpVisibility/include/OcclusionQuery.h

    r59 r86  
    99{ 
    1010public: 
    11 //      OcclusionQuery(); 
    1211        virtual ~OcclusionQuery() {}; 
    1312        /** Returns the result of an occlusion query in terms of visible pixels. 
    14                 @returns number of visible pixels 
     13                @param queryResult the number of visible pixels if the result was available 
     14                @param waitForResult if we should wait for the result until available 
     15                @returns if the result was already available 
    1516        */ 
    16         virtual unsigned int GetQueryResult() const = 0; 
    17         /** Returns true if the result of the query is available, false otherwise. 
    18                 @returns if result is available 
    19         */ 
    20         virtual bool ResultAvailable() const = 0; 
     17        virtual bool GetQueryResult(unsigned int &queryResult,  
     18                const bool waitForResult) const = 0; 
    2119        /** Begins occlusion query. 
    2220                @remark the query counts the number of visible pixels between it's begin and end 
  • trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp

    r85 r86  
    11#include "CoherentHierarchicalCullingManager.h" 
    2 //#include <windows.h> 
     2#include <windows.h> 
    33 
    44namespace GtpVisibility { 
     
    88{ 
    99        mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 
    10         //OutputDebugString("Coherent Culling\n"); 
     10//      OutputDebugString("Coherent Culling\n"); 
    1111 
    1212        QueryQueue queryQueue; 
    13          
     13        unsigned int visiblePixels = 0; 
     14        bool isAvailable = false; 
     15 
    1416        //-- PART 1: process finished occlusion queries 
    1517        while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) 
    1618        { 
    1719                while (!queryQueue.empty() &&  
    18                            (queryQueue.front().second->ResultAvailable() || mHierarchyInterface->GetQueue()->empty())) 
     20                           queryQueue.front().second->GetQueryResult(visiblePixels,  
     21                                                                        mHierarchyInterface->GetQueue()->empty())) 
    1922                { 
    2023                        HierarchyNode *node = queryQueue.front().first; 
    21                                          
    22                         // wait until result available 
    23                         unsigned int visiblePixels = queryQueue.front().second->GetQueryResult(); 
    24                          
     24                                                 
    2525                        queryQueue.pop(); 
    2626 
     
    6767                                 
    6868                                // identify nodes that we cannot skip queries for 
    69                                 bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || mHierarchyInterface->IsLeaf(node); 
     69                                bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) ||  
     70                                        mHierarchyInterface->IsLeaf(node); 
    7071 
    7172                                // reset node's visibility classification  
     
    7879                                if (mustQuery) 
    7980                                { 
    80                                         queryQueue.push(QueryPair(node, mHierarchyInterface->IssueOcclusionQuery(node))); 
     81                                        queryQueue.push(QueryPair(node,  
     82                                                mHierarchyInterface->IssueOcclusionQuery(node, wasVisible))); 
    8183                                } 
    8284                                         
  • trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp

    r85 r86  
    11#include "FrustumCullingManager.h" 
    2 //#include <windows.h> 
     2#include <windows.h> 
    33 
    44namespace GtpVisibility { 
  • trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp

    r85 r86  
    88HierarchyInterface::HierarchyInterface():  
    99mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0),  
    10 mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0) 
     10mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(true) 
    1111{        
    1212        mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this)); 
     
    6464        return mNumRenderedNodes; 
    6565} 
     66 
     67void HierarchyInterface::SetUseOptimization(bool useOptimization) 
     68{ 
     69        mUseOptimization = useOptimization; 
     70} 
     71 
    6672} // namespace GtpVisibility 
  • trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp

    r85 r86  
    11#include "StopAndWaitCullingManager.h" 
    2 //#include <windows.h> 
     2#include <windows.h> 
    33 
    44namespace GtpVisibility { 
     
    3535                        } 
    3636 
     37                        unsigned int visiblePixels = 0; 
     38 
     39                        mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult(visiblePixels, true); 
     40 
    3741                        // node visible 
    38                         if (mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult() >  
    39                                 mVisibilityThreshold) 
     42                        if (visiblePixels > mVisibilityThreshold) 
    4043                        { 
    4144                                mHierarchyInterface->TraverseNode(node); 
  • trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h

    r85 r86  
    6565        /** Issue a occlusion query for this node.  
    6666                @param node the current hierarchy node 
     67                @param wasVisible if the node was visible in the last frame 
    6768                @returns occlusion query for this node 
    6869        */ 
    69         GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::HierarchyNode *node); 
     70        GtpVisibility::OcclusionQuery *IssueOcclusionQuery( 
     71                GtpVisibility::HierarchyNode *node, const bool wasVisible); 
    7072 
    7173protected: 
  • trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h

    r59 r86  
    2020        virtual ~PlatformOcclusionQuery(); 
    2121 
    22         virtual unsigned int GetQueryResult() const; 
    23         virtual bool ResultAvailable() const; 
     22        virtual bool GetQueryResult(unsigned int &queryResult, 
     23                const bool waitForResult) const; 
    2424        virtual void BeginQuery() const; 
    2525        virtual void EndQuery() const; 
  • trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h

    r85 r86  
    1616 
    1717        SolidHalfBoundingBox(); 
    18         /** Sets up the first or second half of a solid bounding box. 
     18        /** Sets up the first or second half of a the solid box. 
    1919                @param aab the axis aligned bounding box 
    2020                @param isFirstHalf if it is the first or the second half 
     
    2222        void SetupBoundingBox(const AxisAlignedBox& aabb, const bool isFirstHalf); 
    2323         
    24 protected: 
    25     /** Builds the wireframe line list. 
     24        /** Builds the wireframe line list. 
    2625                @param aab the axis aligned bounding box for setting up the vertices 
    2726                @param first or second half of the box 
    2827    */ 
    2928        void SetupBoundingBoxVertices(const AxisAlignedBox& aab, const bool isFirstHalf); 
     29 
     30protected: 
     31    
    3032        /**  
    3133                Sets the material used for occlusion queries.  
  • trunk/VUT/Ogre/resources/VisibilityDemo.overlay

    r84 r86  
    1010                top 5 
    1111                width 450 
    12                 height 55 
     12                height 60 
    1313                material Core/StatsBlockCenter 
    1414                border_size 1 1 1 1 
     
    6969                        left 155 
    7070                        top 20 
     71                        width 90 
     72                        height 30 
     73                        font_name TrebuchetMSBold 
     74                        char_height 16 
     75                        caption : 
     76                        colour_top 0.5 0.7 0.5 
     77                        colour_bottom 0.3 0.5 0.3 
     78                } 
     79                element TextArea(Example/Visibility/UseOptimization) 
     80                { 
     81                        metrics_mode pixels 
     82                        left 5 
     83                        top 35 
     84                        width 90 
     85                        height 30 
     86                        font_name TrebuchetMSBold 
     87                        char_height 16 
     88                        caption [O] Optimization 
     89                        colour_top 0.5 0.7 0.5 
     90                        colour_bottom 0.3 0.5 0.3 
     91                } 
     92                element TextArea(Example/Visibility/UseOptimizationInfo) 
     93                { 
     94                        metrics_mode pixels 
     95                        left 155 
     96                        top 35 
    7197                        width 90 
    7298                        height 30 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r85 r86  
    5757                                                                                                  GtpVisibility::HierarchyNode *node2) const 
    5858{ 
    59         // matt: change this (inefficient) 
    60         AxisAlignedBox box1, box2; 
    61  
    62         static_cast<Octree *>(node1)->_getCullBounds(&box1); 
    63         static_cast<Octree *>(node2)->_getCullBounds(&box2); 
    64  
    65         return GetSquaredViewDepth(mCamera, &box1) > GetSquaredViewDepth(mCamera, &box2); 
     59        return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) >  
     60                   GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 
    6661} 
    6762//----------------------------------------------------------------------- 
     
    7065{ 
    7166        Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 
    72         return (cam->getDerivedPosition() - mid).squaredLength();                                                                    
     67        // use nearest point rather than midpoint 
     68        Vector3 camPos = cam->getDerivedPosition(); 
     69 
     70        Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 
     71                                   camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 
     72                                   camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 
     73         
     74        return (camPos - minPos).squaredLength();                                                                    
    7375} 
    7476//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r85 r86  
    66#include "OgrePlatformHierarchyInterface.h" 
    77#include "OgrePlatformOcclusionQuery.h" 
     8#include <windows.h> 
    89 
    910namespace Ogre { 
     
    3334void PlatformHierarchyInterface::RenderBoundingBox(AxisAlignedBox *box) 
    3435{ 
     36        static RenderOperation ro; 
     37 
     38        //TODO: this should be the full bounding box 
     39        SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
     40         
     41        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
     42        mSceneManager->useRenderableViewProjMode(halfbox); 
     43    mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 
     44 
    3545        // Render two halfes of the bounding box (using triangle fans) 
    3646        for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 
    3747        { 
    38                 //TODO: this should be the full bounding box 
    39                 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
    40                 halfbox->SetupBoundingBox(*box, halfIdx == 1); 
     48                halfbox->SetupBoundingBoxVertices(*box, halfIdx == 1); 
    4149                                 
    42                 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    43                  
    44                 static RenderOperation ro; 
    45  
    46         mSceneManager->useRenderableViewProjMode(halfbox); 
    47                 mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0)); 
    4850                halfbox->getRenderOperation(ro); 
    4951                ro.srcRenderable = halfbox; 
    50                 mRenderSystem->_render(ro); 
     52                mRenderSystem->_render(ro);      
    5153        } 
    5254} 
     
    7072{ 
    7173        GtpVisibility::HierarchyInterface::InitFrame(root); 
     74        mPreviousNode = NULL; 
    7275        SetCamera(cam); 
    7376} 
     
    9497//----------------------------------------------------------------------- 
    9598GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 
    96         GtpVisibility::HierarchyNode *node)  
     99        GtpVisibility::HierarchyNode *node, const bool wasVisible)  
    97100{ 
    98101        // get next available test id 
     
    102105        query->BeginQuery(); 
    103106                         
    104         RenderBoundingBox(GetBoundingBox(node)); 
     107        // if leaf and was visible => will be rendered anyway, thus we 
     108        // can also test with the real geometry  
     109        if(mUseOptimization && wasVisible && IsLeaf(node)) 
     110        { 
     111        //      OutputDebugString("Using optimization!!\n"); 
     112                RenderNode(node); 
     113        } 
     114        else 
     115        { 
     116        //      OutputDebugString("Not optimized!!\n"); 
     117                RenderBoundingBox(GetBoundingBox(node)); 
     118        } 
    105119 
    106120        query->EndQuery(); 
  • trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp

    r59 r86  
    11#include "OgrePlatformOcclusionQuery.h" 
    2  
     2#include <windows.h> 
    33namespace Ogre { 
    44 
     
    2424} 
    2525//----------------------------------------------------------------------- 
    26 unsigned int PlatformOcclusionQuery::GetQueryResult() const 
     26bool PlatformOcclusionQuery::GetQueryResult(unsigned int &visiblePixels,  
     27                                                                                        const bool waitForResult) const 
    2728{ 
    28         unsigned int visiblePixels = 0; 
    29         // wait if result not available 
    30         mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 
    31  
    32         return visiblePixels; 
    33 } 
    34 //----------------------------------------------------------------------- 
    35 bool PlatformOcclusionQuery::ResultAvailable() const 
    36 { 
    37 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    38         return mHardwareOcclusionQuery->resultAvailable(); 
    39 #else 
    40         return true; 
    41 #endif 
     29        return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 
    4230} 
    4331 
  • trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp

    r85 r86  
    2626        Vector3 vmin = aab.getMinimum(); 
    2727                 
    28         Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
    29     mRadius = Math::Sqrt(sqLen); 
     28        //Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
     29    //mRadius = Math::Sqrt(sqLen); 
    3030         
    3131        Real maxx = vmax.x; 
     
    9090 
    9191    // setup the bounding box of this SimpleRenderable 
    92         setBoundingBox(aabb); 
     92        //setBoundingBox(aabb); 
    9393} 
    9494//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r74 r86  
    1818 
    1919        //mDisplayNodes = true; 
    20         mShowBoundingBoxes = true; 
    21         mShowBoxes = true; 
    22         //mMaxDepth = 20; 
     20        //mShowBoundingBoxes = true; 
     21        //mShowBoxes = true; 
     22        mMaxDepth = 20; 
    2323} 
    2424//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp

    r75 r86  
    2020        { 
    2121                mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val)); 
    22  
     22                return true; 
     23        } 
     24        if (key == "UseOptimization") 
     25        { 
     26                mHierarchyInterface->SetUseOptimization(*static_cast<const bool *>(val)); 
    2327                return true; 
    2428        } 
     
    5357                return true; 
    5458        } 
     59         
    5560        return false; 
    5661} 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r85 r86  
    1212//namespace GtpVisibility { 
    1313//----------------------------------------------------------------------- 
    14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager) 
    15 :mVisibilityManager(visManager) 
     14VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
     15        GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 
    1616{ 
    1717        mHierarchyInterface =  
    1818                new OctreeHierarchyInterface(this, mDestRenderSystem); 
    1919 
    20         setVisibilityManager(visManager); 
    2120        //mShowBoxes = true; 
    2221        //mDisplayNodes = true; 
  • trunk/VUT/chcdemo/HierarchyNode.h

    r10 r86  
    3434 
    3535/** This class represents a node in a k-d tree hierarchy. A 
    36 node has two children. The node can be either an interior node (i.e., left and right child 
    37 NULL) or a leaf node, which holds the actual geometry. 
     36        node has two children. The node can be either an interior node (i.e., left and right child 
     37        NULL) or a leaf node, which holds the actual geometry. 
    3838*/ 
    3939 
  • trunk/VUT/chcdemo/RenderTraverser.cpp

    r43 r86  
    5656 
    5757/** 
    58 This is the standard render traversal algorithm doing only frustum culling 
     58        This is the standard render traversal algorithm doing only frustum culling 
    5959*/ 
    6060void RenderTraverser::RenderCullFrustum() 
     
    144144        { 
    145145                while(!queryQueue.empty() &&  
    146                           (ResultAvailable(queryQueue.front()) ||       mDistanceQueue.empty())) 
     146                          (ResultAvailable(queryQueue.front()) || mDistanceQueue.empty())) 
    147147                { 
    148148                        HierarchyNode *node = queryQueue.front(); 
     
    327327} 
    328328 
    329 void RenderTraverser::IssueOcclusionQuery(HierarchyNode *node, bool wasVisible) 
     329void RenderTraverser::IssueOcclusionQuery(HierarchyNode *node, const bool wasVisible) 
    330330{ 
    331331        // get next available test id 
  • trunk/VUT/work/TestCulling/SceneContentGenerator.cpp

    r85 r86  
    2020mMaxPos(Vector3(70.0f, 70.0f, 600.0f)),  
    2121mMinAngle(Vector3(0.0f, 0.0f, 0.0f)), 
    22 mMaxAngle(Vector3(360, 360, 360)) 
     22mMaxAngle(Vector3(360, 360, 360)), 
     23mScale(0.05, 0.05, 0.05) 
    2324{ 
    2425} 
     
    6768 
    6869        currentObject->attachObject(ent); 
    69         currentObject->setScale(0.1f, 0.1f, 0.1f); 
     70        currentObject->setScale(mScale); 
    7071                 
    7172        currentObject->yaw(Degree(rotation.x)); 
     
    106107        return mCount; 
    107108} 
     109//----------------------------------------------------------------------- 
     110void SceneContentGenerator::SetScale(Vector3 scale) 
     111{ 
     112        mScale = scale; 
     113} 
    108114} // namespace Ogre 
  • trunk/VUT/work/TestCulling/SceneContentGenerator.h

    r85 r86  
    3535        void SetMaxPos(Vector3 maxPos); 
    3636        int GetObjectCount(); 
     37        void SetScale(Vector3 scale); 
    3738 
    3839protected: 
     
    4243        Vector3 mMaxPos; 
    4344        Vector3 mMinPos; 
    44          
     45        Vector3 mScale; 
     46 
    4547        SceneManager *mSceneMgr; 
    4648        int mCount;             // The number of objects on the screen 
  • trunk/VUT/work/TestCulling/TestCullingApplication.cpp

    r85 r86  
    5454 
    5555        mSceneContentGenerator = new SceneContentGenerator(mSceneMgr); 
    56         mSceneContentGenerator->GenerateScene(330, "robot.mesh"); 
     56        mSceneContentGenerator->GenerateScene(3000, "sphere.mesh"); 
    5757 
    5858        // Create a skybox 
     
    101101                                                                           CEGUI::Renderer *renderer, 
    102102                                                                           SceneContentGenerator *sceneContentGenerator) 
    103         : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer),  
    104                 mShutdownRequested(false) 
    105 { 
    106  
    107         // Setup default variables 
    108         //mOgreHead = NULL; 
    109         mLMouseDown = false; 
    110         mRMouseDown = false; 
    111         mSceneMgr = sceneManager; 
    112  
    113         mSceneContentGenerator = sceneContentGenerator; 
    114  
     103: ExampleFrameListener(win, cam, false, true), 
     104mSceneMgr(sceneManager), 
     105mGUIRenderer(renderer),  
     106mShutdownRequested(false),  
     107mUseOptimization(false), 
     108mLMouseDown(false), 
     109mRMouseDown(false), 
     110mSceneContentGenerator(sceneContentGenerator), 
     111mVisibilityThreshold(0), 
     112mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
     113{ 
    115114    // Reduce move speed 
    116115        mMoveSpeed = 50; 
    117116        mRotateSpeed *= 2; 
    118  
    119         mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
    120         mVisibilityThreshold = 0; 
    121      
     117  
    122118        // Register this so that we get mouse events. 
    123119        mEventProcessor->addMouseListener(this); 
     
    137133        mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 
    138134        mNumObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/NumObjectsInfo"); 
     135        mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo"); 
    139136 
    140137        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
     
    146143        mRenderedNodesInfo->setCaption(": 0"); 
    147144        mNumObjectsInfo->setCaption(": 0"); 
     145        mUseOptimizationInfo->setCaption(": true"); 
    148146 
    149147        setAlgorithm(mCurrentAlgorithm); 
     148        toggleUseOptimization(); 
    150149 
    151150    pOver->show(); 
     
    226225        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
    227226        KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
     227        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
    228228        //KEY_PRESSED(KC_T, 1, change); 
    229229       
     
    250250 
    251251        setAlgorithm(mCurrentAlgorithm); 
     252} 
     253//----------------------------------------------------------------------- 
     254void MouseQueryListener::toggleUseOptimization() 
     255{ 
     256        mUseOptimization = !mUseOptimization; 
     257 
     258        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
     259 
     260        if(mUseOptimization) 
     261                mUseOptimizationInfo->setCaption(": true"); 
     262        else 
     263                mUseOptimizationInfo->setCaption(": false"); 
     264} 
     265//----------------------------------------------------------------------- 
     266void MouseQueryListener::toggleShowOctree() 
     267{ 
     268        mShowOctree = !mShowOctree; 
     269 
     270        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    252271} 
    253272//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCulling/TestCullingApplication.h

    r85 r86  
    6464        void changeThreshold(int incr); 
    6565        void changeStats(); 
     66        void toggleUseOptimization(); 
     67        void toggleShowOctree(); 
    6668 
    6769protected: 
     
    8385        OverlayElement *mRenderedNodesInfo; 
    8486        OverlayElement *mNumObjectsInfo; 
     87        OverlayElement *mUseOptimizationInfo; 
    8588 
    8689        SceneContentGenerator *mSceneContentGenerator; 
     90 
     91        bool mUseOptimization; 
     92        bool mShowOctree; 
    8793}; 
    8894 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r85 r86  
    9696 
    9797        mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 
     98         
     99        mTerrainContentGenerator->GenerateScene(500, "ninja.mesh"); 
    98100        mTerrainContentGenerator->GenerateScene(500, "robot.mesh"); 
     101 
    99102        // no limitations needed anymore: the user can set  
    100103        // objects also on peaks of terrain 
     
    137140                                                                           CEGUI::Renderer *renderer, 
    138141                                                                           TerrainContentGenerator *sceneGenerator):  
    139 ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer),  
    140 mShutdownRequested(false) 
    141 { 
    142         // Setup default variables 
    143         mCurrentObject = NULL; 
    144         mLMouseDown = false; 
    145         mRMouseDown = false; 
    146         mSceneMgr = sceneManager; 
    147         mTerrainContentGenerator = sceneGenerator; 
    148  
    149     // Reduce move speed 
     142ExampleFrameListener(win, cam, false, true),  
     143mGUIRenderer(renderer),  
     144mShutdownRequested(false),  
     145mUseOptimization(false), 
     146mLMouseDown(false), 
     147mRMouseDown(false), 
     148mSceneMgr(sceneManager), 
     149mCurrentObject(NULL), 
     150mTerrainContentGenerator(sceneGenerator), 
     151mVisibilityThreshold(0), 
     152mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
     153{ 
     154        // Reduce move speed 
    150155        mMoveSpeed = 50; 
    151156        mRotateSpeed *= 2; 
    152  
    153         mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
    154         mVisibilityThreshold = 0; 
    155157     
    156158        // Register this so that we get mouse events. 
     
    173175        mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 
    174176        mNumObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/NumObjectsInfo"); 
     177        mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo"); 
    175178 
    176179        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
     
    182185        mRenderedNodesInfo->setCaption(": 0"); 
    183186        mNumObjectsInfo->setCaption(": 0"); 
     187        mUseOptimizationInfo->setCaption(": true"); 
    184188 
    185189        setAlgorithm(mCurrentAlgorithm); 
     190        toggleUseOptimization(); 
     191        toggleShowOctree(); 
    186192 
    187193    pOver->show(); 
     
    293299        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
    294300        KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
     301        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
     302        KEY_PRESSED(KC_S, 0.3, toggleShowOctree()); 
    295303        //KEY_PRESSED(KC_T, 1, change); 
    296304       
     
    321329void MouseQueryListener::setAlgorithm(int algorithm) 
    322330{ 
     331        //OutputDebugString("changing algorithm\n"); 
    323332        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
    324333        mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 
     
    347356        sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount());  
    348357        mNumObjectsInfo->setCaption(str); 
     358} 
     359//----------------------------------------------------------------------- 
     360void MouseQueryListener::toggleUseOptimization() 
     361{ 
     362        mUseOptimization = !mUseOptimization; 
     363 
     364        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
     365 
     366        if(mUseOptimization) 
     367                mUseOptimizationInfo->setCaption(": true"); 
     368        else 
     369                mUseOptimizationInfo->setCaption(": false"); 
     370} 
     371//----------------------------------------------------------------------- 
     372void MouseQueryListener::toggleShowOctree() 
     373{ 
     374        mShowOctree = !mShowOctree; 
     375 
     376        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    349377} 
    350378//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r85 r86  
    6363        void changeThreshold(int incr); 
    6464        void changeStats(); 
     65        void toggleUseOptimization(); 
     66        void toggleShowOctree(); 
    6567 
    6668protected: 
     
    8082    OverlayElement *mTraversedNodesInfo; 
    8183        OverlayElement *mHierarchyNodesInfo; 
    82         //OverlayElement *mSceneNodesInfo; 
     84        OverlayElement *mUseOptimizationInfo; 
    8385        OverlayElement *mRenderedNodesInfo; 
    8486        OverlayElement *mNumObjectsInfo; 
     
    8991        RayQueryExecutor *mRayQueryExecutor; 
    9092        TerrainContentGenerator *mTerrainContentGenerator; 
     93 
     94        bool mUseOptimization; 
     95        bool mShowOctree; 
    9196}; 
    9297 
Note: See TracChangeset for help on using the changeset viewer.