Changeset 93 for trunk


Ignore:
Timestamp:
05/11/05 17:51:44 (20 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT
Files:
10 edited

Legend:

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

    r92 r93  
    5050        GtpVisibility::VisibilityManager *getVisibilityManager( void ); 
    5151 
    52         //writes out into the Ogre log file 
     52        //writes out statis into the Ogre log file 
    5353        void WriteLog(); 
    5454 
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r92 r93  
    6363}; 
    6464 
    65 //}  // namespace GtpVisibility 
    6665} // namespace Ogre 
    6766 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r87 r93  
    145145} 
    146146 
    147 //} // namespace GtpVisibility 
    148147} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r92 r93  
    7878        GtpVisibility::HierarchyInterface::InitFrame(root); 
    7979        mPreviousNode = NULL; 
     80 
    8081        SetCamera(cam); 
    8182} 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r92 r93  
    145145        return mVisibilityManager; 
    146146} 
     147//----------------------------------------------------------------------- 
    147148void VisibilityOctreeSceneManager::WriteLog() 
    148149{ 
    149150        std::stringstream d; 
    150151 
    151         d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
     152        d << "Algorithm: " << mVisibilityManager->GetCullingManagerType() << ", " 
    152153          << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 
    153154          << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r87 r93  
    66#include <OgreRenderSystem.h> 
    77#include <OgreCamera.h> 
     8#include <OgreLogManager.h> 
    89 
    910#include <windows.h> 
     
    139140        return mVisibilityManager; 
    140141} 
     142//----------------------------------------------------------------------- 
     143void VisibilityTerrainSceneManager::WriteLog() 
     144{ 
     145        std::stringstream d; 
     146 
     147        d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
     148          << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 
     149          << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 
     150          << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 
     151          << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", " 
     152      << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n"; 
     153 
     154        LogManager::getSingleton().logMessage(d.str()); 
     155} 
    141156} // namespace Ogre 
  • trunk/VUT/work/TestCulling/TestCullingApplication.cpp

    r87 r93  
    105105mGUIRenderer(renderer),  
    106106mShutdownRequested(false),  
    107 mUseOptimization(false), 
    108107mLMouseDown(false), 
    109108mRMouseDown(false), 
     
    111110mVisibilityThreshold(0), 
    112111mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    113 mShowOctree(true), 
    114 mUseCulling(false) 
     112mShowOctree(false), 
     113mUseCulling(true), 
     114mUseOptimization(false), 
     115mUseCullCamera(false) 
    115116{ 
    116117    // Reduce move speed 
     
    150151 
    151152        setAlgorithm(mCurrentAlgorithm); 
    152         toggleUseOptimization(); 
     153         
     154        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
     155        mSceneMgr->setOption("UseCulling", &mUseCulling); 
     156        mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     157        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    153158 
    154159    pOver->show(); 
     
    231236        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 
    232237        KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 
    233                
     238        KEY_PRESSED(KC_V, 0.3, toggleCullCamera()); 
     239 
    234240        updateStats(); 
    235241 
     
    280286 
    281287        mSceneMgr->setOption("UseCulling", &mUseCulling); 
     288} 
     289//----------------------------------------------------------------------- 
     290void MouseQueryListener::toggleCullCamera() 
     291{ 
     292        mUseCullCamera = !mUseCullCamera; 
     293 
     294        mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
    282295} 
    283296//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCulling/TestCullingApplication.h

    r87 r93  
    6767        void toggleShowOctree(); 
    6868        void toggleUseCulling(); 
     69        void toggleCullCamera(); 
    6970 
    7071protected: 
     
    9495        bool mShowOctree; 
    9596        bool mUseCulling; 
     97        bool mUseCullCamera; 
     98 
     99        Camera *mCullCamera; 
    96100}; 
    97101 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r87 r93  
    2525TestCullingTerrainApplication::~TestCullingTerrainApplication() 
    2626{ 
    27         delete mTerrainContentGenerator; 
    28 } 
    29 //----------------------------------------------------------------------- 
    30 void TestCullingTerrainApplication::createCamera( void ) 
     27        if(mTerrainContentGenerator) 
     28                delete mTerrainContentGenerator; 
     29        //if(mCullCamera) delete mCullCamera; 
     30} 
     31//----------------------------------------------------------------------- 
     32void TestCullingTerrainApplication::createCamera() 
    3133{ 
    3234        // Create the camera 
    3335        mCamera = mSceneMgr->createCamera("PlayerCam"); 
    34  
    35         // Position it at 500 in Z direction 
    36         mCamera->setPosition(Vector3(128,25,128)); 
    37  
    38         // Look back along -Z 
    39     mCamera->lookAt(Vector3(0,0,-300)); 
    40     mCamera->setNearClipDistance(1); 
    41     mCamera->setFarClipDistance(1000); 
     36         
     37        // Set a nice viewpoint 
     38        mCamera->setPosition(707, 2500, 528); 
     39        mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
     40         
     41        //--create cull camera 
     42        mCullCamera = mSceneMgr->createCamera("CullCamera"); 
     43        mCullCamera->setPosition(707, 2500, 528); 
     44        mCullCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
     45 
     46        mCullCamera->setNearClipDistance(1); 
     47        mCamera->setNearClipDistance(1); 
     48 
     49        // Infinite far plane? 
     50        if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 
     51        { 
     52                mCullCamera->setFarClipDistance(0); 
     53                mCamera->setFarClipDistance(0); 
     54        } 
     55        else 
     56        { 
     57                 mCullCamera->setFarClipDistance(1000); 
     58                 mCamera->setFarClipDistance(1000); 
     59        } 
     60         
    4261} 
    4362//----------------------------------------------------------------------- 
     
    6079        mWindow->getViewport(0)->setBackgroundColour(fadeColour); 
    6180        //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 
     81        mWindow->addViewport(mCullCamera, 10, 0.5, 0.5, 1, 1); 
    6282 
    6383        // Create a skybox 
    64     //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 500, false); 
     84    mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 5000, false); 
    6585        //mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8, 500, false ); 
    6686 
     
    7999#endif 
    80100        mSceneMgr->setWorldGeometry(terrain_cfg); 
    81         // Infinite far plane? 
    82         if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 
    83         { 
    84                 mCamera->setFarClipDistance(0); 
    85         } 
    86  
    87         // Set a nice viewpoint 
    88         mCamera->setPosition(707, 2500, 528); 
    89         mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
    90101         
    91102        // CEGUI setup 
     
    122133{ 
    123134        mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr,  
    124                 mGUIRenderer, mTerrainContentGenerator); 
     135                mGUIRenderer, mTerrainContentGenerator, mCullCamera); 
    125136        mFrameListener->showDebugOverlay(true); 
    126137        mRoot->addFrameListener(mFrameListener); 
     
    138149                                                                           SceneManager *sceneManager,  
    139150                                                                           CEGUI::Renderer *renderer, 
    140                                                                            TerrainContentGenerator *sceneGenerator):  
     151                                                                           TerrainContentGenerator *sceneGenerator, 
     152                                                                           Camera *cullCamera):  
    141153ExampleFrameListener(win, cam, false, true),  
    142154mGUIRenderer(renderer),  
    143155mShutdownRequested(false),  
    144 mUseOptimization(false), 
    145156mLMouseDown(false), 
    146157mRMouseDown(false), 
     
    150161mVisibilityThreshold(0), 
    151162mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    152 mShowOctree(true), 
    153 mUseCulling(false) 
     163mShowOctree(false), 
     164mUseCulling(true), 
     165mUseOptimization(false), 
     166mUseCullCamera(false), 
     167mCullCamera(cullCamera) 
    154168{ 
    155169        // Reduce move speed 
     
    191205 
    192206        setAlgorithm(mCurrentAlgorithm); 
    193         toggleUseOptimization(); 
    194         toggleShowOctree(); 
    195         toggleUseCulling(); 
     207 
     208        mSceneMgr->setOption("UseOptimization", &mUseOptimization); 
     209        mSceneMgr->setOption("UseCulling", &mUseCulling); 
     210        mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     211        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    196212 
    197213    pOver->show(); 
     
    287303                        mCamera->getPosition().z); 
    288304        } 
    289          
     305 
     306        camPos = mCullCamera->getPosition(); 
     307 
     308        if(mRayQueryExecutor->executeRayQuery(&queryResult,  
     309                Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y)) 
     310        { 
     311                mCullCamera->setPosition(mCullCamera->getPosition().x, queryResult.y + 10,  
     312                        mCullCamera->getPosition().z); 
     313        } 
     314 
    290315        return ExampleFrameListener::frameStarted(evt); 
    291316} 
     
    306331        KEY_PRESSED(KC_S, 0.3, toggleShowOctree()); 
    307332        KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 
    308                
     333        KEY_PRESSED(KC_V, 0.3, toggleCullCamera()); 
     334        KEY_PRESSED(KC_X, 0.3, fixCullCamera()); 
     335 
    309336        updateStats(); 
    310337 
     
    389416        mSceneMgr->setOption("UseCulling", &mUseCulling); 
    390417} 
     418//----------------------------------------------------------------------- 
     419void MouseQueryListener::toggleCullCamera() 
     420{ 
     421        mUseCullCamera = !mUseCullCamera; 
     422        mSceneMgr->setOption("CullCamera", &mUseCullCamera); 
     423} 
     424//----------------------------------------------------------------------- 
     425void MouseQueryListener::fixCullCamera() 
     426{ 
     427        mCullCamera->setPosition(mCamera->getPosition()); 
     428        mCullCamera->setOrientation(mCamera->getOrientation()); 
     429} 
     430 
    391431//----------------------------------------------------------------------- 
    392432void MouseQueryListener::keyPressed(KeyEvent* e) 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r87 r93  
    3030 
    3131    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,  
    32                 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator); 
     32                CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *cullCamera); 
    3333 
    3434    ~MouseQueryListener(); 
     
    6666        void toggleShowOctree(); 
    6767        void toggleUseCulling(); 
     68        void toggleCullCamera(); 
     69        void fixCullCamera(); 
    6870 
    6971protected: 
     
    9799        bool mShowOctree; 
    98100        bool mUseCulling; 
     101        bool mUseCullCamera; 
     102 
     103        Camera *mCullCamera; 
    99104}; 
    100105 
     
    113118        CEGUI::OgreCEGUIRenderer *mGUIRenderer; 
    114119        CEGUI::System *mGUISystem; 
    115 //      RayQueryExecutor *mRayQueryExecutor; 
    116120 
    117121        Vector3 mMinTranslation; 
     
    123127        TerrainContentGenerator *mTerrainContentGenerator; 
    124128 
     129        Camera *mCullCamera; 
     130         
    125131private: 
    126132        void chooseSceneManager(void); 
Note: See TracChangeset for help on using the changeset viewer.