Changeset 99 for trunk/VUT/work


Ignore:
Timestamp:
05/15/05 04:08:02 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/work
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCulling/TestCullingApplication.cpp

    r94 r99  
    111111mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    112112mShowOctree(false), 
    113 mUseCulling(true), 
     113mUseVisibilityCulling(true), 
    114114mUseOptimization(true), 
    115 mUseCullCamera(false) 
     115mShowVisualization(false) 
    116116{ 
    117117    // Reduce move speed 
     
    153153         
    154154        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
    155         mSceneMgr->setOption("UseCulling", &mUseCulling); 
    156         mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     155        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 
     156        mSceneMgr->setOption("ShowVizualisation", &mShowVisualization); 
    157157        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    158158 
     
    235235        KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
    236236        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
    237         KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 
    238         KEY_PRESSED(KC_V, 0.3, toggleCullCamera()); 
     237        KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling()); 
     238        KEY_PRESSED(KC_V, 0.3, toggleShowViz()); 
    239239 
    240240        updateStats(); 
     
    281281} 
    282282//----------------------------------------------------------------------- 
    283 void MouseQueryListener::toggleUseCulling() 
    284 { 
    285         mUseCulling = !mUseCulling; 
    286  
    287         mSceneMgr->setOption("UseCulling", &mUseCulling); 
    288 } 
    289 //----------------------------------------------------------------------- 
    290 void MouseQueryListener::toggleCullCamera() 
    291 { 
    292         mUseCullCamera = !mUseCullCamera; 
    293  
    294         mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     283void MouseQueryListener::toggleUseVisibilityCulling() 
     284{ 
     285        mUseVisibilityCulling = !mUseVisibilityCulling; 
     286 
     287        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 
     288} 
     289//----------------------------------------------------------------------- 
     290void MouseQueryListener::toggleShowViz() 
     291{ 
     292        mShowVisualization = !mShowVisualization; 
     293 
     294        mSceneMgr->setOption("CullCamera", &mShowVisualization); 
    295295} 
    296296//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCulling/TestCullingApplication.h

    r94 r99  
    6666        void toggleUseOptimization(); 
    6767        void toggleShowOctree(); 
    68         void toggleUseCulling(); 
    69         void toggleCullCamera(); 
     68        void toggleUseVisibilityCulling(); 
     69        void toggleShowViz(); 
    7070 
    7171protected: 
     
    9494        bool mUseOptimization; 
    9595        bool mShowOctree; 
    96         bool mUseCulling; 
    97         bool mUseCullCamera; 
     96        bool mUseVisibilityCulling; 
     97        bool mShowVisualization; 
    9898 
    9999        Camera *mVisualizationCamera; 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r98 r99  
    2727        if(mTerrainContentGenerator) 
    2828                delete mTerrainContentGenerator; 
     29        //if(mRenderTargetListener)     delete mRenderTargetListener; 
    2930} 
    3031//----------------------------------------------------------------------- 
    3132void TestCullingTerrainApplication::createCamera() 
    3233{ 
    33         // Create the camera 
    34         mCamera = mSceneMgr->createCamera("CullCamera"); 
    35          
    36         // Set a nice viewpoint 
     34        // create the camera 
     35        mCamera = mSceneMgr->createCamera("PlayerCam"); 
     36         
     37        // set a nice viewpoint 
    3738        mCamera->setPosition(707, 2500, 528); 
    3839        mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
    3940         
    40         //--create cull camera 
    41         mVisualizationCamera = mSceneMgr->createCamera("VisualizationCamera"); 
    42         mVisualizationCamera->setPosition(707, 2500, 528); 
    43         mVisualizationCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
     41        //--create visualization camera 
     42        mVisualizationCamera = mSceneMgr->createCamera("VizCam"); 
     43        mVisualizationCamera->setPosition(mCamera->getPosition()); 
     44        mVisualizationCamera->setOrientation(mCamera->getOrientation()); 
    4445 
    4546        mVisualizationCamera->setNearClipDistance(1); 
    4647        mCamera->setNearClipDistance(1); 
    4748 
    48         // Infinite far plane? 
     49        // infinite far plane? 
    4950        if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 
    5051        { 
     
    5657                 mVisualizationCamera->setFarClipDistance(1000); 
    5758                 mCamera->setFarClipDistance(1000); 
    58         } 
    59          
     59        }        
     60} 
     61 
     62//----------------------------------------------------------------------- 
     63bool TestCullingTerrainApplication::setup() 
     64{ 
     65        bool result = ExampleApplication::setup(); 
     66 
     67        createRenderTargetListener(); 
     68 
     69        return result; 
     70} 
     71//----------------------------------------------------------------------- 
     72void TestCullingTerrainApplication::createRenderTargetListener() 
     73{ 
     74        mWindow->addListener(new VisualizationRenderTargetListener(mSceneMgr)); 
    6075} 
    6176//----------------------------------------------------------------------- 
     
    152167mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    153168mShowOctree(false), 
    154 mUseCulling(true), 
     169mUseVisibilityCulling(true), 
    155170mUseOptimization(true), 
    156 mUseCullCamera(false), 
    157171mVisualizationCamera(vizCamera) 
    158172{ 
     
    197211 
    198212        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
    199         mSceneMgr->setOption("UseCulling", &mUseCulling); 
    200         mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     213        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 
    201214        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    202  
     215         
    203216    pOver->show(); 
    204217}  
     
    241254     } // else if 
    242255} // mousePressed 
    243  
    244  //----------------------------------------------------------------------- 
     256//----------------------------------------------------------------------- 
    245257void MouseQueryListener::mouseReleased(MouseEvent* e) 
    246258{ 
     
    316328        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
    317329        KEY_PRESSED(KC_Y, 0.3, toggleShowOctree()); 
    318         KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 
    319         KEY_PRESSED(KC_V, 0.3, toggleCullCamera()); 
     330        KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling()); 
     331        KEY_PRESSED(KC_V, 0.3, toggleShowViz()); 
    320332        KEY_PRESSED(KC_X, 0.3, FixVizCamera()); 
    321333 
     
    397409} 
    398410//----------------------------------------------------------------------- 
    399 void MouseQueryListener::toggleUseCulling() 
    400 { 
    401         mUseCulling = !mUseCulling; 
    402  
    403         mSceneMgr->setOption("UseCulling", &mUseCulling); 
    404 } 
    405 //----------------------------------------------------------------------- 
    406 void MouseQueryListener::toggleCullCamera() 
    407 { 
    408         mUseCullCamera = !mUseCullCamera; 
    409  
    410         if(mUseCullCamera) 
     411void MouseQueryListener::toggleUseVisibilityCulling() 
     412{ 
     413        mUseVisibilityCulling = !mUseVisibilityCulling; 
     414 
     415        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 
     416} 
     417//----------------------------------------------------------------------- 
     418void MouseQueryListener::toggleShowViz() 
     419{ 
     420        mShowVisualization = !mShowVisualization; 
     421 
     422        // create viewport with priority 10: will be rendered over standard viewport 
     423        if(mShowVisualization) 
    411424        {        
    412425                mWindow->addViewport(mVisualizationCamera, 10, 0.5, 0.5, 1, 1); 
     
    414427        } 
    415428        else 
     429        { 
    416430                mWindow->removeViewport(10); 
    417  
    418         mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     431        } 
    419432} 
    420433//----------------------------------------------------------------------- 
     
    451464        // Do nothing 
    452465        e->consume(); 
     466} 
     467/**************************************************************/ 
     468/*      VisualizationRenderTargetListener implementation      */ 
     469/**************************************************************/ 
     470VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr) 
     471:RenderTargetListener(), mSceneMgr(sceneMgr) 
     472{ 
     473} 
     474//----------------------------------------------------------------------- 
     475void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt) 
     476{ 
     477        const bool b = evt.source->getZOrder() == 10; // visualization viewport 
     478                         
     479        mSceneMgr->setOption("ShowVisualization", &b); 
     480         
     481        RenderTargetListener::preViewportUpdate(evt); 
     482} 
     483//----------------------------------------------------------------------- 
     484void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt) 
     485{ 
     486        RenderTargetListener::postRenderTargetUpdate(evt); 
    453487} 
    454488//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r94 r99  
    77#include "TerrainContentGenerator.h" 
    88#include "VisibilityEnvironment.h" 
     9#include <OgreRenderTargetListener.h> 
    910 
    1011Real timeDelay = 0; 
     
    2324        "Stop and Wait Culling",  
    2425        "Coherent Hierarchical Culling" 
     26}; 
     27 
     28class VisualizationRenderTargetListener: public RenderTargetListener 
     29{ 
     30public: 
     31        VisualizationRenderTargetListener(SceneManager *sceneMgr); 
     32 
     33protected: 
     34        void preViewportUpdate (const RenderTargetViewportEvent &evt); 
     35        void postRenderTargetUpdate (const RenderTargetEvent &evt); 
     36 
     37        SceneManager *mSceneMgr; 
    2538}; 
    2639 
     
    6578        void toggleUseOptimization(); 
    6679        void toggleShowOctree(); 
    67         void toggleUseCulling(); 
    68         void toggleCullCamera(); 
     80        void toggleUseVisibilityCulling(); 
     81        void toggleShowViz(); 
    6982        void FixVizCamera(); 
    7083 
     
    100113        bool mUseOptimization; 
    101114        bool mShowOctree; 
    102         bool mUseCulling; 
    103         bool mUseCullCamera; 
     115        bool mUseVisibilityCulling; 
     116        bool mShowVisualization; 
    104117 
    105118        Camera *mVisualizationCamera; 
     
    113126 
    114127protected: 
     128        //-- inherited from ExampleApplication 
     129        bool setup(); 
    115130        void createScene(); 
    116131        void createFrameListener(); 
     132        void createCamera(); 
     133        //void createViewports(); 
     134         
     135        virtual void createRenderTargetListener(); 
     136 
     137        /** cegui setup */ 
    117138        void setupGui(); 
    118         virtual void createCamera(); 
    119139 
    120140        CEGUI::OgreCEGUIRenderer *mGUIRenderer; 
     
    128148 
    129149        TerrainContentGenerator *mTerrainContentGenerator; 
     150         
     151        Camera *mVisualizationCamera; 
     152        VisualizationRenderTargetListener *mRenderTargetListener; 
    130153 
    131         Camera *mVisualizationCamera; 
    132          
    133154private: 
    134155        void chooseSceneManager(void); 
    135156}; 
    136  
  • trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp

    r61 r99  
    41784178    } 
    41794179} 
    4180 #ifdef OGRE_COHERENT_OCCLUSION_CULLING 
     4180#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    41814181//----------------------------------------------------------------------- 
    41824182void SceneManager::_renderSceneNode( Camera *cam, SceneNode *node ) 
     
    41934193        RenderQueue::QueueGroupIterator queueIt = getRenderQueue()->_getQueueGroupIterator(); 
    41944194 
     4195        // find currently processed queue groups and delelete them from render queue 
    41954196        while (queueIt.hasMoreElements()) 
    41964197        { 
     
    41984199                RenderQueueGroup* pGroup = queueIt.getNext(); 
    41994200 
    4200                 // delete this queue group if already processed 
    42014201                if (isRenderQueueToBeProcessed(qId)) 
    42024202                        pGroup->clear(); 
     
    42064206        // Pass::processPendingPassUpdates(); 
    42074207} 
    4208 #endif //OGRE_COHERENT_OCCLUSION_CULLING 
    4209 } 
     4208#endif //GTP_VISIBILITY_MODIFIED_OGRE 
     4209} 
  • trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp

    r61 r99  
    316316 
    317317    mOctree = new Octree( 0 ); 
    318 #ifdef OGRE_COHERENT_OCCLUSION_CULLING 
     318#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    319319        mNumOctreeNodes = 1; 
    320 #endif // OGRE_COHERENT_OCCLUSION_CULLING 
     320#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    321321    mMaxDepth = depth; 
    322322    mBox = box; 
     
    461461        { 
    462462            octant -> mChildren[ x ][ y ][ z ] = new Octree( octant ); 
    463 #ifdef OGRE_COHERENT_OCCLUSION_CULLING 
     463#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    464464        mNumOctreeNodes ++; 
    465 #endif // OGRE_COHERENT_OCCLUSION_CULLING 
     465#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    466466 
    467467            const Vector3 *corners = octant -> mBox.getAllCorners(); 
     
    10281028 
    10291029    mOctree = new Octree( 0 ); 
    1030 #ifdef OGRE_COHERENT_OCCLUSION_CULLING 
     1030#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    10311031        mNumOctreeNodes = 1; 
    1032 #endif // OGRE_COHERENT_OCCLUSION_CULLING 
     1032#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    10331033    mOctree->mBox = box; 
    10341034 
     
    11661166    return q; 
    11671167} 
    1168 #ifdef OGRE_COHERENT_OCCLUSION_CULLING 
     1168#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    11691169//----------------------------------------------------------------------- 
    11701170void OctreeSceneManager::_renderOctant(Camera *cam, Octree *octant) 
     
    11771177                OctreeNode *sn = *it; 
    11781178 
    1179         mNumObjects++; 
     1179        ++mNumObjects; 
    11801180 
    11811181                // check bounding box visibility of scene nodes 
     
    11871187 
    11881188                        if (mDisplayNodes) 
     1189                        { 
    11891190                                getRenderQueue()->addRenderable(sn); 
     1191                        } 
    11901192 
    11911193                        // check if the scene manager or this node wants the bounding box shown. 
    11921194                        if (sn->getShowBoundingBox() || mShowBoundingBoxes) 
     1195                        { 
    11931196                                sn->_addBoundingBoxToQueue(getRenderQueue()); 
    1194  
    1195                         if (mShowBoxes) 
    1196                                 getRenderQueue()->addRenderable(octant->getWireBoundingBox()); 
     1197                        } 
    11971198                } 
    11981199        ++it; 
    11991200        } 
    12001201 
     1202        if (mShowBoxes) 
     1203        { 
     1204                getRenderQueue()->addRenderable(octant->getWireBoundingBox()); 
     1205                ++mNumObjects; 
     1206        } 
     1207 
    12011208        SceneManager::_renderVisibleObjects(); 
    12021209 
    1203         // delete all rendered objects from renderqueue 
     1210        // delete all rendered objects from the render queue 
    12041211        _deleteRenderedQueueGroups(); 
    12051212} 
    1206 #endif // OGRE_COHERENT_OCCLUSION_CULLING 
    1207 } 
     1213#endif // GTP_VISIBILITY_MODIFIED_OGRE 
     1214} 
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r97 r99  
    161161 
    162162        // Check for hardware occlusion support 
    163     // if( glDeleteOcclusionQueriesNV_ptr != 0 )        // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
    164         if( glDeleteQueriesARB_ptr != 0 ) 
     163    if ( glDeleteOcclusionQueriesNV_ptr != 0 )  // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
     164        //if ( glDeleteQueriesARB_ptr != 0 ) 
    165165        { 
    166166                m_bHWOcclusionSupport = true; 
     
    171171        } 
    172172 
    173         if( m_bHWOcclusionSupport ) 
    174         { 
    175                 //glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );         
    176                 glGenQueriesARB_ptr(1, m_uintQuery); 
     173        if ( m_bHWOcclusionSupport ) 
     174        { 
     175                glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );   
     176                //glGenQueriesARB_ptr(1, m_uintQuery); 
    177177        } 
    178178} 
     
    182182GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery()  
    183183{  
    184         if( m_bHWOcclusionSupport ) 
    185         { 
    186                 //glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );   
    187                 glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 
     184        if ( m_bHWOcclusionSupport ) 
     185        { 
     186                glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );   
     187                //glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 
    188188        }        
    189189} 
     
    192192void GLHardwareOcclusionQuery::beginOcclusionQuery()  
    193193{  
    194         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     194        if ( m_bHWOcclusionSupport )    // Make it fail silently if hardware occlusion isn't supported 
    195195        { 
    196196                // do the actual occlusion query for this node 
    197                 //glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
    198                 glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 
     197                glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     198                //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 
    199199        } 
    200200} 
     
    202202void GLHardwareOcclusionQuery::endOcclusionQuery()  
    203203{  
    204         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    205         { 
    206                 //glEndOcclusionQueryNV_ptr(); 
    207                 glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
     204        if ( m_bHWOcclusionSupport )    // Make it fail silently if hardware occlusion isn't supported 
     205        { 
     206                glEndOcclusionQueryNV_ptr(); 
     207                //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
    208208        } 
    209209} 
     
    211211bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
    212212{ 
    213         //unsigned int isAvailable = GL_TRUE; 
    214         int isAvailable = GL_TRUE; 
     213        unsigned int isAvailable = GL_TRUE; 
     214        //int isAvailable = GL_TRUE; 
    215215 
    216216        if( m_bHWOcclusionSupport )      
    217217        { 
    218                 if(!waitForResult) 
    219                 { 
    220                         //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
    221                         glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
    222                 } 
    223  
    224                 if(isAvailable == GL_TRUE) 
    225                 { 
    226                         glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 
    227                         //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     218                if (!waitForResult) 
     219                { 
     220                        glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
     221                        //glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     222                } 
     223 
     224                if (isAvailable == GL_TRUE) 
     225                { 
     226                        glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     227                        //glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 
    228228                } 
    229229        }  
Note: See TracChangeset for help on using the changeset viewer.