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/work/TestCulling
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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); 
Note: See TracChangeset for help on using the changeset viewer.