Changeset 85 for trunk


Ignore:
Timestamp:
05/04/05 17:58:13 (19 years ago)
Author:
mattausch
Message:

corrected bug so chc is much faster than stop and wait

Location:
trunk/VUT
Files:
23 edited

Legend:

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

    r74 r85  
    118118        DistanceQueue *mDistanceQueue; 
    119119        HierarchyNode *mSceneRoot; 
    120         //HierarchyNode *mCurrentNode; 
     120        HierarchyNode *mPreviousNode; 
    121121}; 
    122122} // namespace GtpVisibility 
  • trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp

    r74 r85  
    11#include "CoherentHierarchicalCullingManager.h" 
     2//#include <windows.h> 
    23 
    34namespace GtpVisibility { 
     
    67void CoherentHierarchicalCullingManager::RenderScene() 
    78{ 
     9        mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 
     10        //OutputDebugString("Coherent Culling\n"); 
     11 
    812        QueryQueue queryQueue; 
    9         mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 
    10  
     13         
    1114        //-- PART 1: process finished occlusion queries 
    1215        while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) 
     
    3134                                mNumQueryCulledNodes ++; 
    3235                        } 
    33                 }        
     36                } 
    3437 
    3538                //-- PART 2: hierarchical traversal 
  • trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp

    r74 r85  
    11#include "FrustumCullingManager.h" 
    2  
    3 #include <windows.h> 
     2//#include <windows.h> 
    43 
    54namespace GtpVisibility { 
     
    98{ 
    109        mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 
    11          
     10        //OutputDebugString("Frustum Culling\n"); 
     11 
    1212        while (!mHierarchyInterface->GetQueue()->empty()) 
    1313        { 
  • trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp

    r74 r85  
    88HierarchyInterface::HierarchyInterface():  
    99mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0),  
    10 mSceneRoot(0), mCurrentTestIdx(0) 
     10mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0) 
    1111{        
    1212        mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this)); 
     
    2626{ 
    2727        mFrameId ++; 
     28        mCurrentTestIdx = 0; 
    2829        mNumTraversedNodes = 0; 
    2930        mNumRenderedNodes = 0; 
  • trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp

    r74 r85  
    11#include "StopAndWaitCullingManager.h" 
     2//#include <windows.h> 
    23 
    34namespace GtpVisibility { 
     
    78{ 
    89        mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 
     10        //OutputDebugString("Stop and Wait Culling\n"); 
    911 
    1012        while (!mHierarchyInterface->GetQueue()->empty()) 
  • trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h

    r71 r85  
    7777        */ 
    7878        void RenderBoundingBox(AxisAlignedBox *box); 
    79         /** Returns one half of the bounding box. 
    80                 @param half the half index of the bouding box (0 or 1) 
     79        /** Returns pointer to current renderable half bounding box geometry 
    8180        */ 
    82         SolidHalfBoundingBox *GetSolidHalfBoundingBox(int half); 
     81        SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 
    8382 
    84         /** two halfes of an aabb.  
     83        /** one renderable half of an aabb.  
    8584        */ 
    86         SolidHalfBoundingBox *mHalfBoundingBox[2];       
     85        SolidHalfBoundingBox *mSolidHalfBoundingBox; 
    8786 
    8887        SceneManager *mSceneManager; 
     
    9190        Camera *mCamera; 
    9291        AxisAlignedBox mBox; 
    93  
     92         
    9493        std::vector<PlatformOcclusionQuery *> mOcclusionQueries; 
    9594}; 
  • trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h

    r74 r85  
    3636 
    3737        AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 
    38  
    39 protected: 
    40          
    41          
    4238}; 
    4339 
  • trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h

    r59 r85  
    1515public: 
    1616 
    17         SolidHalfBoundingBox(bool isFirstHalf); 
    18         void setupBoundingBox(const AxisAlignedBox& aabb); 
    19         /** Override this method to prevent parent transforms (rotation,translation,scale) 
    20                 and to make it public. 
     17        SolidHalfBoundingBox(); 
     18        /** Sets up the first or second half of a solid bounding box. 
     19                @param aab the axis aligned bounding box 
     20                @param isFirstHalf if it is the first or the second half 
     21        */ 
     22        void SetupBoundingBox(const AxisAlignedBox& aabb, const bool isFirstHalf); 
     23         
     24protected: 
     25    /** Builds the wireframe line list. 
     26                @param aab the axis aligned bounding box for setting up the vertices 
     27                @param first or second half of the box 
    2128    */ 
    22         void getWorldTransforms(Matrix4* xform) const; 
    23  
    24 protected: 
    25      
    26     /** Builds the wireframe line list. 
    27                 @param aab the axis aligned bounding box for setting up the list. 
    28     */ 
    29         void setupBoundingBoxVertices(const AxisAlignedBox& aab); 
     29        void SetupBoundingBoxVertices(const AxisAlignedBox& aab, const bool isFirstHalf); 
    3030        /**  
    3131                Sets the material used for occlusion queries.  
     
    3333                uses no lighting, no depth write, and no colours 
    3434        */ 
    35         void setOcclusionQueryMaterial(); 
     35        void SetOcclusionQueryMaterial(); 
    3636        /** Whether this half box is the first or the second half of the bounding box.  
    3737        */ 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r74 r85  
    140140AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    141141{ 
    142         static_cast<Octree *>(node)->_getCullBounds(&mBox); 
     142        if(node != mPreviousNode) 
     143        { 
     144                mPreviousNode = node; 
     145                static_cast<Octree *>(node)->_getCullBounds(&mBox); 
     146        } 
    143147 
    144148        return &mBox; 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r74 r85  
    1111//----------------------------------------------------------------------- 
    1212PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
    13 mSceneManager(sm), mRenderSystem(rsys) 
    14 {                
    15         mHalfBoundingBox[0] = mHalfBoundingBox[1] = NULL; 
     13mSceneManager(sm), mRenderSystem(rsys), mSolidHalfBoundingBox(NULL) 
     14{ 
    1615} 
    1716//----------------------------------------------------------------------- 
     
    1918{ 
    2019        DeleteQueries(); 
    21          
    22         if (mHalfBoundingBox[0])  
    23                 delete mHalfBoundingBox[0]; 
    2420 
    25         if (mHalfBoundingBox[1])  
    26                 delete mHalfBoundingBox[1]; 
     21        if(mSolidHalfBoundingBox) 
     22                delete mSolidHalfBoundingBox; 
    2723} 
    2824//----------------------------------------------------------------------- 
     
    3834{ 
    3935        // Render two halfes of the bounding box (using triangle fans) 
    40         for(int half = 0; half < 2; half ++) 
     36        for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 
    4137        { 
    42                 static Matrix4 xform[256]; 
    43                 //TODO: this should be full bounding box 
    44                 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(half); 
    45                 halfbox->setupBoundingBox(*box); 
    46                  
     38                //TODO: this should be the full bounding box 
     39                SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
     40                halfbox->SetupBoundingBox(*box, halfIdx == 1); 
     41                                 
    4742                mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    4843                 
     
    5045 
    5146        mSceneManager->useRenderableViewProjMode(halfbox); 
    52                 mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 
     47                mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0)); 
    5348                halfbox->getRenderOperation(ro); 
    54                 ro.srcRenderable = halfbox;  
     49                ro.srcRenderable = halfbox; 
    5550                mRenderSystem->_render(ro); 
    56                  
    57                 // matt: change this 
    58 //              mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half),  
    59 //                      getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true); 
    6051        } 
    61 } 
    62 //----------------------------------------------------------------------- 
    63 SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox(int half) 
    64 { 
    65         if(!mHalfBoundingBox[half]) 
    66                 mHalfBoundingBox[half] = new Ogre::SolidHalfBoundingBox(half == 1); 
    67  
    68         return mHalfBoundingBox[half];   
    6952} 
    7053//----------------------------------------------------------------------- 
     
    10083} 
    10184//----------------------------------------------------------------------- 
    102 bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects) 
     85bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node,  
     86                                                                                                         bool &intersects) 
    10387{ 
    10488#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     
    10993} 
    11094//----------------------------------------------------------------------- 
    111 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(GtpVisibility::HierarchyNode *node)  
     95GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 
     96        GtpVisibility::HierarchyNode *node)  
    11297{ 
    11398        // get next available test id 
     
    123108        return query; 
    124109} 
     110//----------------------------------------------------------------------- 
     111SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox() 
     112{ 
     113        if(!mSolidHalfBoundingBox) 
     114                mSolidHalfBoundingBox = new SolidHalfBoundingBox; 
     115 
     116        return mSolidHalfBoundingBox; 
     117} 
    125118 
    126119} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp

    r74 r85  
    123123AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    124124{ 
    125         SceneNode *sceneNode = static_cast<SceneNode *>(node); 
     125        if(node != mPreviousNode) 
     126        { 
     127                mPreviousNode = node; 
     128 
     129                mBox = static_cast<SceneNode *>(node)->_getWorldAABB(); 
     130        } 
     131 
    126132        return &mBox; 
    127133} 
  • trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp

    r59 r85  
    1212#define POSITION_BINDING 0 
    1313//----------------------------------------------------------------------- 
    14 SolidHalfBoundingBox::SolidHalfBoundingBox(bool isFirstHalf) 
    15         :WireBoundingBox(), mIsFirstHalf(isFirstHalf) 
     14SolidHalfBoundingBox::SolidHalfBoundingBox() 
    1615{ 
    17         setOcclusionQueryMaterial(); 
     16        SetOcclusionQueryMaterial(); 
    1817         
    1918        mRenderOp.vertexData->vertexCount = 8; 
     
    2120} 
    2221//----------------------------------------------------------------------- 
    23 void SolidHalfBoundingBox::setupBoundingBoxVertices(const AxisAlignedBox& aab) { 
    24  
     22void SolidHalfBoundingBox::SetupBoundingBoxVertices(const AxisAlignedBox& aab,  
     23                                                                                                        const bool isFirstHalf)  
     24{ 
    2525        Vector3 vmax = aab.getMaximum(); 
    2626        Vector3 vmin = aab.getMinimum(); 
    27          
    28          
     27                 
    2928        Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
    3029    mRadius = Math::Sqrt(sqLen); 
     
    3837        Real minz = vmin.z; 
    3938         
    40         // fill in the Vertex buffer: 12 lines with 2 endpoints each make up a box 
     39        // fill the vertex buffer: 12 lines with 2 endpoints each make up a box 
    4140    HardwareVertexBufferSharedPtr vbuf = 
    4241        mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);      
     
    5554 
    5655        // fan 1 
    57         if(mIsFirstHalf) 
     56        if(isFirstHalf) 
    5857        { 
    5958                *pPos++ = minx; *pPos++ = maxy; *pPos++ = maxz; //011 
     
    6665                *pPos++ = minx; *pPos++ = miny; *pPos++ = minz; //000 
    6766                *pPos++ = minx; *pPos++ = miny; *pPos++ = maxz; //001 
    68  
    6967        } 
    7068        else 
     
    8482    vbuf->unlock(); 
    8583} 
    86  
    87 void SolidHalfBoundingBox::setupBoundingBox(const AxisAlignedBox& aabb)  
     84//----------------------------------------------------------------------- 
     85void SolidHalfBoundingBox::SetupBoundingBox(const AxisAlignedBox& aabb,  
     86                                                                                        const bool isFirstHalf)  
    8887{ 
    8988        // init the vertices to the aabb 
    90         SolidHalfBoundingBox::setupBoundingBoxVertices(aabb); 
     89        SetupBoundingBoxVertices(aabb, isFirstHalf); 
    9190 
    9291    // setup the bounding box of this SimpleRenderable 
    9392        setBoundingBox(aabb); 
    9493} 
    95 // Override this method to prevent parent transforms (rotation,translation,scale) 
    96 void SolidHalfBoundingBox::getWorldTransforms( Matrix4* xform ) const 
    97 { 
    98         // return identity matrix to prevent parent transforms 
    99     *xform = Matrix4::IDENTITY; 
    100 } 
    101  
    102 void SolidHalfBoundingBox::setOcclusionQueryMaterial( void ) 
     94//----------------------------------------------------------------------- 
     95void SolidHalfBoundingBox::SetOcclusionQueryMaterial( void ) 
    10396{ 
    10497        m_pMaterial = MaterialManager::getSingleton().getByName("OcclusionQuery"); 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r74 r85  
    1919 
    2020        setVisibilityManager(visManager); 
    21         mShowBoxes = true; 
     21        //mShowBoxes = true; 
    2222        //mDisplayNodes = true; 
    23         mShowBoundingBoxes = true; 
     23        //mShowBoundingBoxes = true; 
    2424        mMaxDepth = 20; 
    2525} 
  • trunk/VUT/scripts/GtpVisibility.sln

    r78 r85  
    1717        ProjectSection(ProjectDependencies) = postProject 
    1818                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
     19                {101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900} 
    1920        EndProjectSection 
    2021EndProject 
     
    2223        ProjectSection(ProjectDependencies) = postProject 
    2324                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
     25                {101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900} 
    2426        EndProjectSection 
    2527EndProject 
  • trunk/VUT/work/TestCulling/SceneContentGenerator.cpp

    r82 r85  
    101101        mMaxPos = maxPos; 
    102102} 
    103  
     103//----------------------------------------------------------------------- 
     104int SceneContentGenerator::GetObjectCount() 
     105{ 
     106        return mCount; 
     107} 
    104108} // namespace Ogre 
  • trunk/VUT/work/TestCulling/SceneContentGenerator.h

    r82 r85  
    3434        void SetMinPos(Vector3 minPos); 
    3535        void SetMaxPos(Vector3 maxPos); 
    36          
     36        int GetObjectCount(); 
     37 
    3738protected: 
    3839 
  • trunk/VUT/work/TestCulling/TestCullingApplication.cpp

    r84 r85  
    3939}*/ 
    4040//----------------------------------------------------------------------- 
     41TestCullingApplication::~TestCullingApplication() 
     42{ 
     43        delete mSceneContentGenerator; 
     44} 
     45//----------------------------------------------------------------------- 
    4146void TestCullingApplication::createScene(void) 
    4247{ 
     
    4853        //l->setPosition(20,80,50); 
    4954 
    50         SceneContentGenerator contentGenerator(mSceneMgr); 
    51         contentGenerator.GenerateScene(330, "robot.mesh"); 
     55        mSceneContentGenerator = new SceneContentGenerator(mSceneMgr); 
     56        mSceneContentGenerator->GenerateScene(330, "robot.mesh"); 
    5257 
    5358        // Create a skybox 
     
    6065} 
    6166//----------------------------------------------------------------------- 
    62 void TestCullingApplication::setupGui( void ) 
     67void TestCullingApplication::setupGui() 
    6368{ 
    6469         mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 
     
    7479} 
    7580//----------------------------------------------------------------------- 
    76 void TestCullingApplication::createFrameListener(void) 
    77 { 
    78         mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer); 
     81void TestCullingApplication::createFrameListener() 
     82{ 
     83        mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr,  
     84                mGUIRenderer, mSceneContentGenerator); 
    7985        mFrameListener->showDebugOverlay(true); 
    8086        mRoot->addFrameListener(mFrameListener); 
     
    9197/***********************************************/ 
    9298//----------------------------------------------------------------------- 
    93 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer) 
     99MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam,  
     100                                                                           SceneManager *sceneManager,  
     101                                                                           CEGUI::Renderer *renderer, 
     102                                                                           SceneContentGenerator *sceneContentGenerator) 
    94103        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer),  
    95104                mShutdownRequested(false) 
     
    102111        mSceneMgr = sceneManager; 
    103112 
     113        mSceneContentGenerator = sceneContentGenerator; 
     114 
    104115    // Reduce move speed 
    105116        mMoveSpeed = 50; 
     
    107118 
    108119        mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
    109         mThreshold = 0; 
     120        mVisibilityThreshold = 0; 
    110121     
    111122        // Register this so that we get mouse events. 
     
    135146        mRenderedNodesInfo->setCaption(": 0"); 
    136147        mNumObjectsInfo->setCaption(": 0"); 
     148 
     149        setAlgorithm(mCurrentAlgorithm); 
    137150 
    138151    pOver->show(); 
     
    170183    if (e->getButtonID() & InputEvent::BUTTON0_MASK) 
    171184    { 
    172                 CEGUI::MouseCursor::getSingleton().show( ); 
     185                CEGUI::MouseCursor::getSingleton().show(); 
    173186        mLMouseDown = false; 
    174187    } 
     
    176189    else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 
    177190    { 
    178         CEGUI::MouseCursor::getSingleton().show( ); 
     191        CEGUI::MouseCursor::getSingleton().show(); 
    179192        mRMouseDown = false; 
    180193    } 
     
    209222        timeDelay -= evt.timeSinceLastFrame; 
    210223 
    211     KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm()); 
     224    KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 
    212225 
    213226        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
     
    222235void MouseQueryListener::changeThreshold(int incr) 
    223236{ 
    224         mThreshold += incr; if(mThreshold < 0) mThreshold = 0; 
    225          
    226         char str[100]; sprintf(str,": %d", mThreshold); 
    227  
    228         mSceneMgr->setOption("Threshold", &mThreshold);  
     237        mVisibilityThreshold += incr;  
     238        if(mVisibilityThreshold < 0) mVisibilityThreshold = 0; 
     239         
     240        char str[100]; sprintf(str,": %d", mVisibilityThreshold); 
     241 
     242        mSceneMgr->setOption("Threshold", &mVisibilityThreshold);  
    229243        mThresholdInfo->setCaption(str); 
    230244} 
    231245//----------------------------------------------------------------------- 
    232 void MouseQueryListener::changeAlgorithm() 
    233 { 
    234     mCurrentAlgorithm = ++mCurrentAlgorithm % GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 
    235  
     246void MouseQueryListener::nextAlgorithm() 
     247{ 
     248        mCurrentAlgorithm = ++mCurrentAlgorithm %  
     249                GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 
     250 
     251        setAlgorithm(mCurrentAlgorithm); 
     252} 
     253//----------------------------------------------------------------------- 
     254void MouseQueryListener::setAlgorithm(int algorithm) 
     255{ 
    236256        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
    237257        mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 
     
    258278        mRenderedNodesInfo->setCaption(str); 
    259279 
    260         sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount());  
     280        sprintf(str,": %d", mSceneContentGenerator->GetObjectCount());  
    261281        mNumObjectsInfo->setCaption(str); 
    262282} 
  • trunk/VUT/work/TestCulling/TestCullingApplication.h

    r84 r85  
    66#include "ExampleApplication.h" 
    77#include "VisibilityEnvironment.h" 
    8  
     8#include "SceneContentGenerator.h" 
    99 
    1010Real timeDelay = 0; 
     
    3030 
    3131    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
    32                         CEGUI::Renderer *renderer); 
     32                        CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator); 
    3333 
    3434 
     
    6060        void keyClicked(KeyEvent* e); 
    6161 
    62         void changeAlgorithm(); 
     62        void nextAlgorithm(); 
     63        void setAlgorithm(int algorithm); 
    6364        void changeThreshold(int incr); 
    6465        void changeStats(); 
     
    7273        bool mShutdownRequested; 
    7374        int mCurrentAlgorithm; 
    74         int mThreshold; 
     75        int mVisibilityThreshold; 
    7576 
    7677        OverlayElement *mAlgorithmInfo; 
     
    8283        OverlayElement *mRenderedNodesInfo; 
    8384        OverlayElement *mNumObjectsInfo; 
     85 
     86        SceneContentGenerator *mSceneContentGenerator; 
    8487}; 
    8588 
     
    8790class TestCullingApplication : public ExampleApplication 
    8891{ 
     92public: 
     93        ~TestCullingApplication(); 
     94 
    8995protected: 
    90         void createScene(void); 
    91         void createFrameListener(void); 
    92         void setupGui(void); 
    93         /** generates a the scene hierarchy with random values  
    94         @param number of objects to generate 
    95         */ 
    96         void GenerateScene(int numObjects); 
    97  
    98         /** generates a new scene object  
    99         @param tranlationRatio ratio between minimal and maximal possible translation 
    100         @param rotationRatio ratio between minimal and maximal possible rotation 
    101         @idx the index of the new object 
    102         @entName the name of the object entity 
    103         */ 
    104         void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio,  
    105                                                          const int idx, const String &entName); 
    106  
     96        void createScene(); 
     97        void createFrameListener(); 
     98        void setupGui(); 
     99         
    107100        //virtual void createCamera(void); 
    108101 
     
    116109        Vector3 mMaxAngle; 
    117110 
     111        SceneContentGenerator *mSceneContentGenerator; 
     112 
    118113private: 
    119114        void chooseSceneManager(void); 
  • trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp

    r84 r85  
    5353{ 
    5454        mMinPos = Vector3(0.0f, 5000.0f, 0.0f); 
    55         mMaxPos = Vector3(1000.0f, 5000.0f, 1000.0f); 
     55        mMaxPos = Vector3(3000.0f, 5000.0f, 3000.0f); 
    5656 
    5757        mMinAngle = Vector3(0.0f, 0.0f, 0.0f); 
     
    8787        mMaxHeight = maxHeight; 
    8888} 
    89 //----------------------------------------------------------------------- 
    90 int TerrainContentGenerator::GetObjectCount() 
    91 { 
    92         return mCount; 
    93 } 
    9489 
    9590} // namespace Ogre 
  • trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h

    r84 r85  
    3434 
    3535        void SetMaxHeight(Real maxHeight); 
    36         int GetObjectCount(); 
    37  
     36         
    3837protected: 
    3938        RayQueryExecutor *mRayQueryExecutor; 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r84 r85  
    8686 
    8787        // Set a nice viewpoint 
    88         mCamera->setPosition(707,2500,528); 
     88        mCamera->setPosition(707, 2500, 528); 
    8989        mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
    9090         
     
    9696 
    9797        mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 
    98         mTerrainContentGenerator->GenerateScene(300, "robot.mesh"); 
     98        mTerrainContentGenerator->GenerateScene(500, "robot.mesh"); 
    9999        // no limitations needed anymore: the user can set  
    100100        // objects also on peaks of terrain 
     
    151151        mRotateSpeed *= 2; 
    152152 
    153         mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING, 
    154         mThreshold = 0; 
     153        mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
     154        mVisibilityThreshold = 0; 
    155155     
    156156        // Register this so that we get mouse events. 
     
    182182        mRenderedNodesInfo->setCaption(": 0"); 
    183183        mNumObjectsInfo->setCaption(": 0"); 
     184 
     185        setAlgorithm(mCurrentAlgorithm); 
    184186 
    185187    pOver->show(); 
     
    287289        timeDelay -= evt.timeSinceLastFrame; 
    288290 
    289     KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm()); 
     291    KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 
    290292 
    291293        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
     
    300302void MouseQueryListener::changeThreshold(int incr) 
    301303{ 
    302         mThreshold += incr; if(mThreshold < 0) mThreshold = 0; 
    303          
    304         char str[100]; sprintf(str,": %d", mThreshold); 
    305  
    306         mSceneMgr->setOption("Threshold", &mThreshold);  
     304        mVisibilityThreshold += incr;  
     305        if(mVisibilityThreshold < 0) mVisibilityThreshold = 0; 
     306         
     307        char str[100]; sprintf(str,": %d", mVisibilityThreshold); 
     308 
     309        mSceneMgr->setOption("Threshold", &mVisibilityThreshold);  
    307310        mThresholdInfo->setCaption(str); 
    308311} 
    309312//----------------------------------------------------------------------- 
    310 void MouseQueryListener::changeAlgorithm() 
     313void MouseQueryListener::nextAlgorithm() 
    311314{ 
    312315        mCurrentAlgorithm = ++mCurrentAlgorithm %  
    313316                GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 
    314317 
     318        setAlgorithm(mCurrentAlgorithm); 
     319} 
     320//----------------------------------------------------------------------- 
     321void MouseQueryListener::setAlgorithm(int algorithm) 
     322{ 
    315323        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
    316324        mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r84 r85  
    5959        void keyClicked(KeyEvent* e); 
    6060 
    61         void changeAlgorithm(); 
     61        void nextAlgorithm(); 
     62        void setAlgorithm(int algorithm); 
    6263        void changeThreshold(int incr); 
    6364        void changeStats(); 
     
    7172        bool mShutdownRequested; 
    7273        int mCurrentAlgorithm; 
    73         int mThreshold; 
     74        int mVisibilityThreshold; 
    7475 
    7576        OverlayElement *mAlgorithmInfo; 
     
    9798 
    9899protected: 
    99         void createScene(void); 
    100         void createFrameListener(void); 
    101         void setupGui(void); 
    102         virtual void createCamera(void); 
     100        void createScene(); 
     101        void createFrameListener(); 
     102        void setupGui(); 
     103        virtual void createCamera(); 
    103104 
    104105        CEGUI::OgreCEGUIRenderer *mGUIRenderer; 
Note: See TracChangeset for help on using the changeset viewer.