Changeset 133


Ignore:
Timestamp:
06/15/05 01:18:51 (20 years ago)
Author:
mattausch
Message:

fixed some bugs

Location:
trunk/VUT
Files:
2 added
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r130 r133  
    7272        void renderQueueGroupObjects(RenderQueueGroup* pGroup); 
    7373 
    74         /** Override from SceneManager so that sub entities can be assigned an id for item buffer */ 
     74        /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 
     75        */ 
    7576        Entity* createEntity(const String& entityName, const String& meshName); 
    7677 
    77         /** Returns pointer to visibility manager */ 
     78        /** Returns pointer to visibility manager. 
     79        */ 
    7880        GtpVisibility::VisibilityManager *GetVisibilityManager(); 
    7981 
    8082protected: 
    8183         
    82         /** Creates material for depth pass, e.g., a pass that only fills the depth buffer. */ 
     84        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.  
     85        */ 
    8386        void InitDepthPass(); 
    84         /** Creates material for item buffer. */ 
     87        /** Creates material for item buffer.  
     88        */ 
    8589        void InitItemBufferPass(); 
    86         /** Fills render queue so that a visualization can be rendered. */ 
     90        /** Fills render queue so that a visualization can be rendered.  
     91        */ 
    8792        void ShowVisualization(Camera *cam); 
    8893 
     
    100105        bool mRenderDepthPass; 
    101106        bool mRenderItemBuffer; 
     107        bool mEnableDepthWrite; 
    102108 
    103109        Pass *mDepthPass; 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r130 r133  
    188188        else 
    189189        { 
     190                // used by the scene manager, because bounding box rendering must be handled 
     191                // differently 
    190192                mIsBoundingBoxQuery = true; 
    191193 
  • trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp

    r121 r133  
    4646 
    4747//----------------------------------------------------------------------- 
    48 extern "C" void dllStartPlugin(void) 
     48extern "C" void __declspec(dllexport) dllStartPlugin(void) 
    4949{ 
    5050        visEnv = new GtpVisibility::VisibilityEnvironment(); 
     
    6666} 
    6767//----------------------------------------------------------------------- 
    68 extern "C" void dllStopPlugin() 
     68extern "C" void __declspec(dllexport) dllShutdownPlugin() 
     69{ 
     70        visibilityTerrainPlugin->shutdown(); 
     71        heightmapTerrainPageSource->shutdown(); 
     72} 
     73//----------------------------------------------------------------------- 
     74extern "C" void __declspec(dllexport) dllStopPlugin() 
    6975{ 
    7076        delete heightmapTerrainPageSource; 
     
    7783        delete visEnv; 
    7884} 
    79 //----------------------------------------------------------------------- 
    80 extern "C" void dllShutdownPlugin() 
    81 { 
    82         visibilityTerrainPlugin->shutdown(); 
    83         heightmapTerrainPageSource->shutdown(); 
    84 } 
     85 
    8586 
    8687} //namespace Ogre 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r130 r133  
    2525mUseDepthPass(false), 
    2626mRenderItemBuffer(false), 
    27 mCurrentEntityId(0) 
     27mCurrentEntityId(0), 
     28mEnableDepthWrite(true) 
    2829{ 
    2930        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    145146         
    146147        // set depth fill pass only if depth write enabled 
    147         Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ? mDepthPass : pass); 
     148        Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ?  
     149                                          mDepthPass : pass); 
    148150                 
    149151        IlluminationRenderStage savedStage = mIlluminationStage;  
     
    158160        if (mRenderDepthPass) 
    159161        { 
    160                 // set vertex program of current pass 
     162                // --- set vertex program of current pass so z-buffer is updated correctly 
    161163        if (pass->hasVertexProgram()) 
    162164                { 
     
    178180                } 
    179181        } 
     182 
     183        bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 
     184        // global option which enables / disables depth writes 
     185        if (!mEnableDepthWrite) 
     186        { 
     187                usedPass->setDepthWriteEnabled(false); 
     188        } 
     189 
    180190        //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 
    181191         
    182192        Pass *result = SceneManager::setPass(usedPass); 
     193 
     194        // reset depth write 
     195        if (!mEnableDepthWrite) 
     196        { 
     197                usedPass->setDepthWriteEnabled(IsDepthWrite); 
     198        } 
    183199 
    184200        // reset illumination stage 
     
    191207{ 
    192208        // needs full ambient lighting for item colors to be exact 
    193         if (mRenderItemBuffer) 
    194         { 
    195                 setAmbientLight(ColourValue(1,1,1,1)); 
    196         } 
    197         //getRenderQueue()->clear(); 
    198  
     209        /*if (mRenderItemBuffer) 
     210        {       setAmbientLight(ColourValue(1,1,1,1)); }*/ 
     211         
    199212        //-- show visible scene nodes and octree bounding boxes from last frame 
    200213        if (mShowVisualization) 
     
    374387        { 
    375388                TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 
     389                return true; 
     390        } 
     391        if (key == "DepthCheck") 
     392        { 
     393                mEnableDepthWrite = (*static_cast<const bool *>(val)); 
    376394                return true; 
    377395        } 
     
    508526        } 
    509527 
    510         // ----- TRANSPARENT LOOP: must be handlet differently altough we don't really 
    511         // care about transparents for the item buffer 
     528        // ----- TRANSPARENT LOOP: must be handled differently  
     529        // although we don't really     care about transparents for the item buffer 
    512530        // TODO: HOW TO HANDLE OCCLUDED OBJECTS ???? 
    513531        RenderPriorityGroup::TransparentRenderablePassList 
  • trunk/VUT/work/TestCulling/TestCullingApplication.cpp

    r130 r133  
    8181void TestCullingApplication::createFrameListener() 
    8282{ 
    83         mFrameListener= new TerrainMouseQueryListener(mWindow, mCamera, mSceneMgr,  
     83        mFrameListener= new TerrainFrameListener(mWindow, mCamera, mSceneMgr,  
    8484                mGUIRenderer, mSceneContentGenerator); 
    8585        mFrameListener->showDebugOverlay(true); 
     
    9494 
    9595/***********************************************/ 
    96 /* TerrainMouseQueryListener implementation           */ 
     96/* TerrainFrameListener implementation           */ 
    9797/***********************************************/ 
    9898//----------------------------------------------------------------------- 
    99 TerrainMouseQueryListener::TerrainMouseQueryListener(RenderWindow* win, Camera* cam,  
     99TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam,  
    100100                                                                           SceneManager *sceneManager,  
    101101                                                                           CEGUI::Renderer *renderer, 
     
    161161}  
    162162//----------------------------------------------------------------------- 
    163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 
    164 { 
    165 } 
    166 //----------------------------------------------------------------------- 
    167 void TerrainMouseQueryListener::mouseMoved(MouseEvent *e) 
     163TerrainFrameListener::~TerrainFrameListener() 
     164{ 
     165} 
     166//----------------------------------------------------------------------- 
     167void TerrainFrameListener::mouseMoved(MouseEvent *e) 
    168168{ 
    169169        // Update CEGUI with the mouse motion 
     
    172172} 
    173173//----------------------------------------------------------------------- 
    174 void TerrainMouseQueryListener::mousePressed(MouseEvent* e) 
     174void TerrainFrameListener::mousePressed(MouseEvent* e) 
    175175{ 
    176176     // Left mouse button down 
     
    188188 
    189189 //----------------------------------------------------------------------- 
    190 void TerrainMouseQueryListener::mouseReleased(MouseEvent* e) 
     190void TerrainFrameListener::mouseReleased(MouseEvent* e) 
    191191{ 
    192192    // Left mouse button up 
     
    204204}  
    205205//----------------------------------------------------------------------- 
    206 void TerrainMouseQueryListener::mouseDragged (MouseEvent *e) 
     206void TerrainFrameListener::mouseDragged (MouseEvent *e) 
    207207 { 
    208208         // If we are dragging the left mouse button.             
     
    219219} 
    220220//----------------------------------------------------------------------- 
    221 bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 
     221bool TerrainFrameListener::frameStarted(const FrameEvent &evt) 
    222222{         
    223223        return ExampleFrameListener::frameStarted(evt); 
    224224} 
    225225//----------------------------------------------------------------------- 
    226 bool TerrainMouseQueryListener::frameEnded(const FrameEvent& evt) 
     226bool TerrainFrameListener::frameEnded(const FrameEvent& evt) 
    227227{ 
    228228        if (mShutdownRequested) 
     
    245245} 
    246246//----------------------------------------------------------------------- 
    247 void TerrainMouseQueryListener::changeThreshold(int incr) 
     247void TerrainFrameListener::changeThreshold(int incr) 
    248248{ 
    249249        mVisibilityThreshold += incr;  
     
    256256} 
    257257//----------------------------------------------------------------------- 
    258 void TerrainMouseQueryListener::nextAlgorithm() 
     258void TerrainFrameListener::nextAlgorithm() 
    259259{ 
    260260        mCurrentAlgorithm = ++mCurrentAlgorithm %  
     
    264264} 
    265265//----------------------------------------------------------------------- 
    266 void TerrainMouseQueryListener::toggleUseOptimization() 
     266void TerrainFrameListener::toggleUseOptimization() 
    267267{ 
    268268        mUseOptimization = !mUseOptimization; 
     
    276276} 
    277277//----------------------------------------------------------------------- 
    278 void TerrainMouseQueryListener::toggleShowOctree() 
     278void TerrainFrameListener::toggleShowOctree() 
    279279{ 
    280280        mShowOctree = !mShowOctree; 
     
    283283} 
    284284//----------------------------------------------------------------------- 
    285 void TerrainMouseQueryListener::toggleUseDepthPass() 
     285void TerrainFrameListener::toggleUseDepthPass() 
    286286{ 
    287287        mUseDepthPass = !mUseDepthPass; 
     
    290290} 
    291291//----------------------------------------------------------------------- 
    292 void TerrainMouseQueryListener::toggleShowViz() 
     292void TerrainFrameListener::toggleShowViz() 
    293293{ 
    294294        mShowVisualization = !mShowVisualization; 
     
    298298} 
    299299//----------------------------------------------------------------------- 
    300 void TerrainMouseQueryListener::setAlgorithm(int algorithm) 
     300void TerrainFrameListener::setAlgorithm(int algorithm) 
    301301{ 
    302302        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
     
    304304} 
    305305//----------------------------------------------------------------------- 
    306 void TerrainMouseQueryListener::updateStats() 
     306void TerrainFrameListener::updateStats() 
    307307{ 
    308308        unsigned int opt = 0; 
     
    331331} 
    332332//----------------------------------------------------------------------- 
    333 void TerrainMouseQueryListener::keyPressed(KeyEvent* e) 
     333void TerrainFrameListener::keyPressed(KeyEvent* e) 
    334334{ 
    335335        if(e->getKey() == KC_ESCAPE) 
     
    345345} 
    346346//----------------------------------------------------------------------- 
    347 void TerrainMouseQueryListener::keyReleased(KeyEvent* e) 
     347void TerrainFrameListener::keyReleased(KeyEvent* e) 
    348348{ 
    349349        CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 
     
    351351} 
    352352//----------------------------------------------------------------------- 
    353 void TerrainMouseQueryListener::keyClicked(KeyEvent* e)  
     353void TerrainFrameListener::keyClicked(KeyEvent* e)  
    354354{ 
    355355        // Do nothing 
  • trunk/VUT/work/TestCulling/TestCullingApplication.h

    r115 r133  
    2525}; 
    2626 
    27 class TerrainMouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener 
     27class TerrainFrameListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener 
    2828{ 
    2929public: 
    3030 
    31     TerrainMouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
     31    TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
    3232                        CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator); 
    3333 
    3434 
    35     ~TerrainMouseQueryListener( ); 
     35    ~TerrainFrameListener( ); 
    3636 
    3737        bool frameStarted(const FrameEvent& evt); 
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp

    r130 r133  
    55#include <../CEGUIRenderer/include/OgreCEGUITexture.h> 
    66#include <OgreMemoryMacros.h> 
    7 #include "TerrainMouseQueryListener.h" 
     7#include "TerrainFrameListener.h" 
    88#include "OgrePlatformQueryManager.h" 
    99#include "OgreVisibilityTerrainSceneManager.h" 
     
    1616 
    1717 
    18 #define KEY_PRESSED(_key, _timeDelay, _macro) \ 
    19 { \ 
    20     if (mInputDevice->isKeyDown(_key) && mTimeDelay <= 0) \ 
    21 { \ 
    22     mTimeDelay = _timeDelay; \ 
    23     _macro ; \ 
    24 } \ 
    25 } 
    26  
    27  
    2818String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =  
    2919{ 
     
    3525 
    3626//----------------------------------------------------------------------- 
    37 TerrainMouseQueryListener::TerrainMouseQueryListener(RenderWindow* win, Camera* cam,  
     27TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam,  
    3828                                                                           SceneManager *sceneManager,  
    3929                                                                           CEGUI::Renderer *renderer, 
     
    8272mDisplayCameraDetails(false), 
    8373mVisualizeCulledNodes(false), 
    84 mSunLight(sunLight) 
     74mSunLight(sunLight), 
     75mShiftPressed(false) 
    8576{ 
    8677        //mInputDevice = PlatformManager::getSingleton().createInputReader(); 
     
    9384        mEventProcessor->addMouseListener(this); 
    9485        mEventProcessor->addMouseMotionListener(this); 
    95  
    96         //mEventProcessor->addKeyListener(this); 
     86        mEventProcessor->addKeyListener(this); 
     87 
    9788        mInputDevice = mEventProcessor->getInputReader(); 
    9889         
     
    154145        mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 
    155146 
    156         mVisibilityManager =  
    157                 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->GetVisibilityManager(); 
     147        // TODO: change this 
     148        mVisibilityManager = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)-> 
     149                GetVisibilityManager(); 
    158150 
    159151        dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> 
     
    161153}  
    162154//----------------------------------------------------------------------- 
    163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 
     155TerrainFrameListener::~TerrainFrameListener() 
    164156{ 
    165157        //PlatformManager::getSingleton().destroyInputReader(mInputDevice); 
     
    169161} 
    170162//----------------------------------------------------------------------- 
    171 void TerrainMouseQueryListener::mouseMoved(MouseEvent *e) 
     163void TerrainFrameListener::mouseMoved(MouseEvent *e) 
    172164{ 
    173165        // Update CEGUI with the mouse motion 
     
    176168} 
    177169//----------------------------------------------------------------------- 
    178 void TerrainMouseQueryListener::mousePressed(MouseEvent* e) 
     170void TerrainFrameListener::mousePressed(MouseEvent* e) 
    179171{ 
    180172     // Left mouse button down 
     
    200192         mRMouseDown = true; 
    201193     } 
    202 } // mousePressed 
    203 //----------------------------------------------------------------------- 
    204 void TerrainMouseQueryListener::mouseReleased(MouseEvent* e) 
     194}  
     195//----------------------------------------------------------------------- 
     196void TerrainFrameListener::mouseReleased(MouseEvent* e) 
    205197{ 
    206198    // Left mouse button up 
     
    218210}  
    219211//----------------------------------------------------------------------- 
    220 void TerrainMouseQueryListener::mouseDragged(MouseEvent *e) 
     212void TerrainFrameListener::mouseDragged(MouseEvent *e) 
    221213 { 
    222214         // If we are dragging the left mouse button.             
     
    244236} 
    245237//----------------------------------------------------------------------- 
    246 bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 
     238bool TerrainFrameListener::frameStarted(const FrameEvent &evt) 
    247239{ 
    248240        if (mWindow->isClosed()) 
     
    287279        } 
    288280/*      if (!processUnbufferedMouseInput(evt)) 
    289         { 
    290                 return false; 
    291         }*/ 
     281        {       return false;   }*/ 
     282 
    292283        // --- set parameters for visualization 
    293284        if (mShowVisualization) 
     
    330321                                StringConverter::toString(mFrameInfo.size() - 1)); 
    331322                }        
    332  
     323                // move camera according to input 
    333324                moveCamera(); 
     325                // clamp camera so we always walk along the terrain 
    334326                Clamp2Terrain(); 
    335  
    336                 break; 
     327                break; 
     328 
    337329        default: 
    338330                break; 
     
    342334} 
    343335//----------------------------------------------------------------------- 
    344 void TerrainMouseQueryListener::ApplyVisibilityQuery() 
     336void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility) 
    345337{ 
    346338        InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 
    347339        InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 
    348340 
    349     mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 
    350                             &visibleNodes, &visibleGeometry, false); 
     341        if (fromPoint) 
     342        { 
     343        } 
     344        else 
     345        { 
     346                mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 
     347                            &visibleNodes, &visibleGeometry, relativeVisibility); 
     348        } 
    351349 
    352350        for (int i=0; i < visibleGeometry.size(); ++i) 
     
    363361} 
    364362//----------------------------------------------------------------------- 
    365 void TerrainMouseQueryListener::Clamp2Terrain() 
     363void TerrainFrameListener::Clamp2Terrain() 
    366364{ 
    367365        // clamp to terrain 
     
    376374} 
    377375//----------------------------------------------------------------------- 
    378 bool TerrainMouseQueryListener::frameEnded(const FrameEvent& evt) 
     376bool TerrainFrameListener::frameEnded(const FrameEvent& evt) 
    379377{ 
    380378        if (mShutdownRequested) 
     
    386384} 
    387385//----------------------------------------------------------------------- 
    388 void TerrainMouseQueryListener::moveCamera() 
     386void TerrainFrameListener::moveCamera() 
    389387{ 
    390388        // move node rather than camera so orientation is right in the visualization 
     
    394392} 
    395393//----------------------------------------------------------------------- 
    396 void TerrainMouseQueryListener::writeFrames() 
     394void TerrainFrameListener::writeFrames() 
    397395{ 
    398396        std::ofstream ofstr(frames_out_filename); 
     
    410408} 
    411409//----------------------------------------------------------------------- 
    412 void TerrainMouseQueryListener::loadFrames() 
     410void TerrainFrameListener::loadFrames() 
    413411{ 
    414412        std::ifstream ifstr(frames_out_filename); 
     
    436434} 
    437435//----------------------------------------------------------------------- 
    438 void TerrainMouseQueryListener::nextAppState() 
     436void TerrainFrameListener::nextAppState() 
    439437{ 
    440438        mCurrentFrame = 0; 
     
    496494} 
    497495//----------------------------------------------------------------------- 
    498 void TerrainMouseQueryListener::toggleRecord() 
     496void TerrainFrameListener::toggleRecord() 
    499497{ 
    500498        mRecord = !mRecord; 
     
    507505} 
    508506//----------------------------------------------------------------------- 
    509 void TerrainMouseQueryListener::changeThreshold(int incr) 
     507void TerrainFrameListener::changeThreshold(int incr) 
    510508{ 
    511509        mVisibilityThreshold += incr;  
     
    518516} 
    519517//----------------------------------------------------------------------- 
    520 void TerrainMouseQueryListener::zoomVizCamera(int zoom) 
     518void TerrainFrameListener::zoomVizCamera(int zoom) 
    521519{ 
    522520        mVizCameraHeight += zoom;  
     
    524522} 
    525523//----------------------------------------------------------------------- 
    526 void TerrainMouseQueryListener::nextAlgorithm() 
     524void TerrainFrameListener::nextAlgorithm() 
    527525{ 
    528526        mCurrentAlgorithm = (mCurrentAlgorithm + 1) %  
     
    532530} 
    533531//----------------------------------------------------------------------- 
    534 void TerrainMouseQueryListener::setAlgorithm(int algorithm) 
     532void TerrainFrameListener::setAlgorithm(int algorithm) 
    535533{ 
    536534        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 
     
    538536} 
    539537//----------------------------------------------------------------------- 
    540 void TerrainMouseQueryListener::updateStats() 
     538void TerrainFrameListener::updateStats() 
    541539{ 
    542540        unsigned int opt = 0; 
     
    599597} 
    600598//----------------------------------------------------------------------- 
    601 void TerrainMouseQueryListener::toggleUseOptimization() 
     599void TerrainFrameListener::toggleUseOptimization() 
    602600{ 
    603601        mUseOptimization = !mUseOptimization; 
    604  
    605602        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
    606         // delayed rendering (i.e., render transparents afterwards) allows  
    607         // no optimization which tests geometry instead of aabb 
     603         
     604        // disable optimization which tests geometry instead of aabb 
     605        // for delayed rendering (i.e., render transparents after all the solids) 
     606        // because otherwise visible transparents could be skipped 
    608607        bool delayedRendering = !mUseOptimization; 
    609608        mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering); 
    610609 
    611610        if (mUseOptimization) 
     611        { 
    612612                mUseOptimizationInfo->setCaption(": true"); 
     613        } 
    613614        else 
     615        { 
    614616                mUseOptimizationInfo->setCaption(": false"); 
    615 } 
    616 //----------------------------------------------------------------------- 
    617 void TerrainMouseQueryListener::toggleShowOctree() 
     617        } 
     618} 
     619//----------------------------------------------------------------------- 
     620void TerrainFrameListener::toggleShowOctree() 
    618621{ 
    619622        mShowOctree = !mShowOctree; 
     
    622625} 
    623626//----------------------------------------------------------------------- 
    624 void TerrainMouseQueryListener::toggleUseDepthPass() 
     627void TerrainFrameListener::toggleUseDepthPass() 
    625628{ 
    626629        mUseDepthPass = !mUseDepthPass; 
     
    638641} 
    639642//----------------------------------------------------------------------- 
    640 void TerrainMouseQueryListener::toggleShowViz() 
     643void TerrainFrameListener::toggleShowViz() 
    641644{ 
    642645        mShowVisualization = !mShowVisualization; 
     
    677680} 
    678681//----------------------------------------------------------------------- 
    679 void TerrainMouseQueryListener::toggleUseShadows() 
     682void TerrainFrameListener::toggleUseShadows() 
    680683{ 
    681684        mUseShadows = !mUseShadows; 
     
    694697} 
    695698//----------------------------------------------------------------------- 
    696 void TerrainMouseQueryListener::nextNodeVizMode() 
     699void TerrainFrameListener::nextNodeVizMode() 
    697700{ 
    698701        mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM; 
     
    707710} 
    708711//----------------------------------------------------------------------- 
    709 void TerrainMouseQueryListener::keyPressed(KeyEvent* e) 
    710 { 
    711         if(e->getKey() == KC_ESCAPE) 
    712     { 
     712void TerrainFrameListener::keyPressed(KeyEvent* e) 
     713{ 
     714        switch(e->getKey()) 
     715        { 
     716        case KC_ESCAPE: 
    713717                mShutdownRequested = true; 
    714718                e->consume(); 
    715719                return; 
    716         } 
    717  
    718         CEGUI::System::getSingleton().injectKeyDown(e->getKey()); 
    719         CEGUI::System::getSingleton().injectChar(e->getKeyChar()); 
    720         e->consume(); 
    721 } 
    722 //----------------------------------------------------------------------- 
    723 void TerrainMouseQueryListener::keyReleased(KeyEvent* e) 
    724 { 
    725         CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 
    726         e->consume(); 
    727 } 
    728 //----------------------------------------------------------------------- 
    729 void TerrainMouseQueryListener::keyClicked(KeyEvent* e)  
    730 { 
    731         // Do nothing 
    732         e->consume(); 
    733 } 
    734 //----------------------------------------------------------------------- 
    735 void TerrainMouseQueryListener::addFrameInfo(SceneNode *camNode, Real timeElapsed) 
    736 { 
    737         frame_info info; 
    738         info.orientation = mCamNode->getOrientation(); 
    739         info.position = mCamNode->getPosition(); 
    740         info.timeElapsed = timeElapsed; 
    741  
    742         mFrameInfo.push_back(info); 
    743 } 
    744 //----------------------------------------------------------------------- 
    745 void TerrainMouseQueryListener::setCurrentFrameInfo(Real timeElapsed) 
    746 { 
    747         //-- find current frame relative to elapsed frame time           
    748         mTimeElapsed -= timeElapsed; 
    749  
    750         while ((mTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1)) 
    751         { 
    752                 mTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed; 
    753         } 
    754  
    755         frame_info new_frame = mFrameInfo[mCurrentFrame]; 
    756         frame_info old_frame = mFrameInfo[mCurrentFrame - 1]; 
    757                  
    758         //-- interpolate frames 
    759         Real factor = 1; 
    760  
    761         if (old_frame.timeElapsed > 0) 
    762                 factor = mTimeElapsed / old_frame.timeElapsed; 
    763  
    764         Vector3 camPos = old_frame.position + factor * (new_frame.position - old_frame.position); 
    765         Quaternion camOrienation = Quaternion::Slerp(factor, old_frame.orientation,  
    766                 new_frame.orientation, true); 
    767  
    768         mCamNode->setPosition(camPos); 
    769         mCamNode->setOrientation(camOrienation); 
    770          
    771         // stop replay after a full walkthrough 
    772         if (mCurrentFrame == (int)mFrameInfo.size() - 1) 
    773         { 
     720 
     721        case KC_SPACE: 
     722                nextAlgorithm(); 
     723                break; 
     724         
     725        case KC_F: 
     726                nextFilter(); 
     727                break; 
     728        case KC_R: 
     729                nextSceneDetailLevel(); 
     730                break; 
     731        case KC_P: 
     732                toggleDisplayCameraDetails(); 
     733                break; 
     734        case KC_O: 
     735                toggleUseOptimization(); 
     736                break; 
     737        case KC_T: 
     738                toggleShowOctree(); 
     739                break; 
     740        case KC_X: 
     741                toggleUseDepthPass(); 
     742                break; 
     743        case KC_S: 
     744                toggleUseShadows(); 
     745                break; 
     746 
     747        case KC_SUBTRACT: 
     748                changeThreshold(-10); 
     749                break; 
     750        case KC_ADD: 
     751                changeThreshold(10); 
     752                break; 
     753 
     754        //-- visualization 
     755        case KC_1: 
     756                toggleShowViz(); 
     757                break; 
     758        case KC_2: 
     759                nextNodeVizMode(); 
     760                break; 
     761 
     762        case KC_F1: 
     763                toggleShowHelp(); 
     764                break; 
     765        case KC_F2: 
     766                toggleShowStats(); 
     767                break; 
     768        case KC_F3: 
    774769                nextAppState(); 
    775         } 
    776 } 
    777 //-----------------------------------------------------------------------     
    778 bool TerrainMouseQueryListener::processUnbufferedKeyInput(const FrameEvent& evt) 
    779 { 
    780         if (mInputDevice->isKeyDown(KC_ESCAPE)) 
    781     {             
    782         return false; 
    783     } 
    784  
    785         /* Move camera forward by keypress. */ 
    786     if (mInputDevice->isKeyDown(KC_UP)) 
    787         { 
    788                 mTranslateVector.z = -mMoveScale; 
    789         } 
    790  
    791     /* Move camera backward by keypress. */ 
    792     if (mInputDevice->isKeyDown(KC_DOWN)) 
    793     { 
    794                 mTranslateVector.z = mMoveScale; 
    795     } 
    796  
    797     if (mInputDevice->isKeyDown(KC_RIGHT)) 
    798     { 
    799         mCamNode->yaw(-mRotScale); 
    800     } 
    801          
    802     if (mInputDevice->isKeyDown(KC_LEFT)) 
    803     { 
    804         mCamNode->yaw(mRotScale); 
    805     } 
    806  
    807         KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 
    808         KEY_PRESSED(KC_F, 0.3, nextFilter()); 
    809         KEY_PRESSED(KC_R, 0.3, nextSceneDetailLevel()); 
    810  
    811         KEY_PRESSED(KC_P, 0.3, toggleDisplayCameraDetails()); 
    812         KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
    813         KEY_PRESSED(KC_T, 0.3, toggleShowOctree()); 
    814         KEY_PRESSED(KC_X, 0.3, toggleUseDepthPass()); 
    815         KEY_PRESSED(KC_S, 0.3, toggleUseShadows()); 
    816  
    817         KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
    818         KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
    819          
    820         //-- visualization 
    821         KEY_PRESSED(KC_1, 0.3, toggleShowViz()); 
    822         KEY_PRESSED(KC_2, 0.3, nextNodeVizMode()); 
    823         KEY_PRESSED(KC_3, 0, zoomVizCamera(50)); 
    824         KEY_PRESSED(KC_4, 0, zoomVizCamera(-50)); 
    825  
    826         KEY_PRESSED(KC_F1, 0.3, toggleShowHelp()); 
    827         KEY_PRESSED(KC_F2, 0.3, toggleShowStats()); 
    828         KEY_PRESSED(KC_F3, 0.3, nextAppState()); 
    829         KEY_PRESSED(KC_F4, 0.3, toggleRecord()); 
    830         KEY_PRESSED(KC_F5, 0.3, ApplyVisibilityQuery()); 
    831  
    832         KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); 
    833         KEY_PRESSED(KC_F12, 0.3, mTerrainContentGenerator->WriteObjects(objects_out_filename)); 
     770                break; 
     771        case KC_F4: 
     772                toggleRecord(); 
     773                break; 
     774        case KC_F5: 
     775                ApplyVisibilityQuery(false, mShiftPressed); 
     776                break; 
     777        case KC_F6: 
     778                ApplyVisibilityQuery(true, mShiftPressed); 
     779                break; 
     780 
     781        case KC_F11: 
     782                takeScreenShot(); 
     783                break; 
     784        case KC_F12: 
     785                mTerrainContentGenerator->WriteObjects(objects_out_filename); 
     786                break; 
     787 
     788        case KC_LSHIFT: 
     789                mShiftPressed = !mShiftPressed; 
     790                break; 
    834791        //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 
    835792        //KEY_PRESSED(KC_F4, 0.3, loadFrames()); 
     793        default: 
     794                break; 
     795        } 
    836796 
    837797        if (mDisplayCameraDetails) 
     
    842802    } 
    843803 
     804        CEGUI::System::getSingleton().injectKeyDown(e->getKey()); 
     805        CEGUI::System::getSingleton().injectChar(e->getKeyChar()); 
     806        e->consume(); 
     807} 
     808//----------------------------------------------------------------------- 
     809void TerrainFrameListener::keyReleased(KeyEvent* e) 
     810{ 
     811        CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 
     812        e->consume(); 
     813} 
     814//----------------------------------------------------------------------- 
     815void TerrainFrameListener::keyClicked(KeyEvent* e)  
     816{ 
     817        // Do nothing 
     818        e->consume(); 
     819} 
     820//----------------------------------------------------------------------- 
     821void TerrainFrameListener::addFrameInfo(SceneNode *camNode, Real timeElapsed) 
     822{ 
     823        frame_info info; 
     824        info.orientation = mCamNode->getOrientation(); 
     825        info.position = mCamNode->getPosition(); 
     826        info.timeElapsed = timeElapsed; 
     827 
     828        mFrameInfo.push_back(info); 
     829} 
     830//----------------------------------------------------------------------- 
     831void TerrainFrameListener::setCurrentFrameInfo(Real timeElapsed) 
     832{ 
     833        //-- find current frame relative to elapsed frame time           
     834        mTimeElapsed -= timeElapsed; 
     835 
     836        while ((mTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1)) 
     837        { 
     838                mTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed; 
     839        } 
     840 
     841        frame_info new_frame = mFrameInfo[mCurrentFrame]; 
     842        frame_info old_frame = mFrameInfo[mCurrentFrame - 1]; 
     843                 
     844        //-- interpolate frames 
     845        Real factor = 1; 
     846 
     847        if (old_frame.timeElapsed > 0) 
     848        { 
     849                factor = mTimeElapsed / old_frame.timeElapsed; 
     850        } 
     851 
     852        Vector3 camPos = old_frame.position + factor  
     853                * (new_frame.position - old_frame.position); 
     854        Quaternion camOrienation = Quaternion::Slerp(factor, old_frame.orientation,  
     855                new_frame.orientation, true); 
     856 
     857        mCamNode->setPosition(camPos); 
     858        mCamNode->setOrientation(camOrienation); 
     859         
     860        // stop replay after a full walkthrough 
     861        if (mCurrentFrame == (int)mFrameInfo.size() - 1) 
     862        { 
     863                nextAppState(); 
     864        } 
     865} 
     866//-----------------------------------------------------------------------     
     867bool TerrainFrameListener::processUnbufferedKeyInput(const FrameEvent& evt) 
     868{ 
     869        /*if (mInputDevice->isKeyDown(KC_ESCAPE)) 
     870    {             
     871        return false; 
     872    }*/ 
     873 
     874        /* Move camera forward by keypress. */ 
     875    if (mInputDevice->isKeyDown(KC_UP)) 
     876        { 
     877                mTranslateVector.z = -mMoveScale; 
     878        } 
     879 
     880    /* Move camera backward by keypress. */ 
     881    if (mInputDevice->isKeyDown(KC_DOWN)) 
     882    { 
     883                mTranslateVector.z = mMoveScale; 
     884    } 
     885 
     886    if (mInputDevice->isKeyDown(KC_RIGHT)) 
     887    { 
     888        mCamNode->yaw(-mRotScale); 
     889    } 
     890         
     891    if (mInputDevice->isKeyDown(KC_LEFT)) 
     892    { 
     893        mCamNode->yaw(mRotScale); 
     894    } 
     895        // visualization camera 
     896        if (mInputDevice->isKeyDown(KC_3)) 
     897        { 
     898                zoomVizCamera(50); 
     899        } 
     900        if (mInputDevice->isKeyDown(KC_4)) 
     901        { 
     902                zoomVizCamera(-50); 
     903        } 
     904 
     905 
    844906    // Return true to continue rendering 
    845907    return true; 
    846908} 
    847909//----------------------------------------------------------------------- 
    848 void TerrainMouseQueryListener::nextFilter() 
    849 { 
    850         switch(mFiltering) 
     910void TerrainFrameListener::nextFilter() 
     911{ 
     912        switch (mFiltering) 
    851913        { 
    852914        case TFO_BILINEAR: 
     
    869931    MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 
    870932 
     933        // reload stats 
    871934    showStats(mStatsOn); 
    872935} 
    873936//----------------------------------------------------------------------- 
    874 void TerrainMouseQueryListener::nextSceneDetailLevel() 
    875 { 
    876         mSceneDetailIndex = (mSceneDetailIndex+1)%3 ; 
    877         switch(mSceneDetailIndex)  
    878         { 
    879                 case 0 : mCamera->setDetailLevel(SDL_SOLID) ; break ; 
    880                 case 1 : mCamera->setDetailLevel(SDL_WIREFRAME) ; break ; 
    881                 case 2 : mCamera->setDetailLevel(SDL_POINTS) ; break ; 
    882         } 
    883 } 
    884 //----------------------------------------------------------------------- 
    885 void TerrainMouseQueryListener::takeScreenShot() 
     937void TerrainFrameListener::nextSceneDetailLevel() 
     938{ 
     939        mSceneDetailIndex = (mSceneDetailIndex + 1) % 3; 
     940        switch (mSceneDetailIndex)  
     941        { 
     942                case 0:  
     943                        mCamera->setDetailLevel(SDL_SOLID);  
     944                        break; 
     945                case 1:  
     946                        mCamera->setDetailLevel(SDL_WIREFRAME);  
     947                        break; 
     948                case 2:  
     949                        mCamera->setDetailLevel(SDL_POINTS);  
     950                        break; 
     951        } 
     952} 
     953//----------------------------------------------------------------------- 
     954void TerrainFrameListener::takeScreenShot() 
    886955{ 
    887956        char tmp[20]; 
     
    891960} 
    892961//----------------------------------------------------------------------- 
    893 void TerrainMouseQueryListener::toggleDisplayCameraDetails() 
     962void TerrainFrameListener::toggleDisplayCameraDetails() 
    894963{ 
    895964        mDisplayCameraDetails = !mDisplayCameraDetails; 
    896965         
    897966    if (!mDisplayCameraDetails) 
     967        { 
    898968                mWindow->setDebugText(""); 
    899 } 
    900 //----------------------------------------------------------------------- 
    901 bool TerrainMouseQueryListener::processUnbufferedMouseInput(const FrameEvent& evt) 
    902 { 
    903         /* Rotation factors, may not be used if the second mouse button is pressed. */ 
    904  
    905         /* If the second mouse button is pressed, then the mouse movement results in  
    906         sliding the camera, otherwise we rotate. */ 
    907         if(mInputDevice->getMouseButton(1)) 
    908         { 
    909                 mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13; 
    910                 mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13; 
    911         } 
    912     else 
    913     { 
    914                 mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13); 
    915                 mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13); 
    916     } 
    917  
    918  
    919         return true; 
    920 } 
    921 //----------------------------------------------------------------------- 
    922 void TerrainMouseQueryListener::showStats(bool show) 
     969        } 
     970} 
     971//----------------------------------------------------------------------- 
     972void TerrainFrameListener::showStats(bool show) 
    923973{ 
    924974        if (mDebugOverlay && mCullStatsOverlay) 
     
    937987} 
    938988//----------------------------------------------------------------------- 
    939 void TerrainMouseQueryListener::toggleShowStats() 
     989void TerrainFrameListener::toggleShowStats() 
    940990{ 
    941991        mStatsOn = !mStatsOn; 
     
    944994} 
    945995//----------------------------------------------------------------------- 
    946 void TerrainMouseQueryListener::toggleShowHelp() 
     996void TerrainFrameListener::toggleShowHelp() 
    947997{ 
    948998        mShowHelp = !mShowHelp; 
     
    9571007        } 
    9581008} 
    959  
    960          
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h

    r130 r133  
    1 #ifndef _TerrainMouseQueryListener_H__ 
    2 #define _TerrainMouseQueryListener_H__ 
     1#ifndef _TerrainFrameListener_H__ 
     2#define _TerrainFrameListener_H__ 
    33 
    44#include "CEGUIForwardRefs.h" 
     
    2020/** Mouse query listener for terrain  
    2121*/ 
    22 class TerrainMouseQueryListener: public FrameListener, public MouseListener, public MouseMotionListener 
     22class TerrainFrameListener: public FrameListener, public MouseListener, public MouseMotionListener, public KeyListener 
    2323{ 
    2424public: 
    2525         
    26    TerrainMouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
     26   TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
    2727                CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera, 
    2828                SceneNode *camNode, Light *sunLight); 
    2929 
    30    ~TerrainMouseQueryListener(); 
     30   ~TerrainFrameListener(); 
    3131 
    3232 
     
    114114        void toggleRecord(); 
    115115 
    116         void ApplyVisibilityQuery(); 
    117  
    118         void switchMouseMode()  
    119         { 
    120         mUseBufferedInputMouse = !mUseBufferedInputMouse; 
    121                 mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse); 
    122         } 
     116        /** Applies visibility query. Collects the visible objects  
     117                and their visibility information. 
     118                @param fromnPoint if query should be from point or from camera 
     119                @param relativeVisibility if query should return number of visible pixels or the ratio 
     120                visible pixels / projected pixels. 
     121        */ 
     122        void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility); 
     123 
    123124protected: 
    124125 
     
    212213        EventProcessor* mEventProcessor; 
    213214         
    214         bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
    215          
     215        bool mShiftPressed; 
     216        //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
    216217}; 
    217218 
    218219 
    219 #endif //_TerrainMouseQueryListener_H__ 
     220#endif //_TerrainFrameListener_H__ 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj

    r130 r133  
    123123                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 
    124124                        <File 
    125                                 RelativePath=".\TerrainMouseQueryListener.cpp"> 
     125                                RelativePath=".\TerrainFrameListener.cpp"> 
    126126                        </File> 
    127127                        <File 
     
    134134                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
    135135                        <File 
    136                                 RelativePath=".\TerrainMouseQueryListener.h"> 
     136                                RelativePath=".\TerrainFrameListener.h"> 
    137137                        </File> 
    138138                        <File 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r122 r133  
    187187     CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme"); 
    188188     CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow"); 
    189          mGUISystem->setDefaultMouseCursor( 
    190                 (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); 
     189         mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook",  
     190                                                                          (CEGUI::utf8*)"MouseArrow"); 
    191191 
    192192         CEGUI::MouseCursor::getSingleton().show(); 
     
    195195void TestCullingTerrainApplication::createFrameListener() 
    196196{ 
    197         mTerrainFrameListener = new TerrainMouseQueryListener(mWindow, mCamera, mSceneMgr,  
     197        mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr,  
    198198                mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight); 
    199199         
     
    218218void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt) 
    219219{ 
    220         const bool showViz = evt.source->getZOrder() == VIZ_VIEWPORT_Z_ORDER; // visualization viewport 
     220        // visualization viewport 
     221        const bool showViz = evt.source->getZOrder() == VIZ_VIEWPORT_Z_ORDER; 
    221222        const bool nShowViz = !showViz; 
    222223 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r130 r133  
    77 
    88#include <OgreRenderTargetListener.h> 
    9 #include "TerrainMouseQueryListener.h" 
     9#include "TerrainFrameListener.h" 
    1010 
    1111class VisualizationRenderTargetListener: public RenderTargetListener 
     
    5656        VisualizationRenderTargetListener *mRenderTargetListener; 
    5757 
    58         TerrainMouseQueryListener *mTerrainFrameListener; 
     58        TerrainFrameListener *mTerrainFrameListener; 
    5959         
    6060private: 
Note: See TracChangeset for help on using the changeset viewer.