Changeset 130 for trunk/VUT/work


Ignore:
Timestamp:
06/14/05 02:50:05 (19 years ago)
Author:
mattausch
Message:

added visibility queries

Location:
trunk/VUT/work
Files:
5 edited

Legend:

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

    r115 r130  
    161161}  
    162162//----------------------------------------------------------------------- 
    163 TerrainMouseQueryListener::~TerrainMouseQueryListener( ) 
    164 { 
    165 } 
    166 //----------------------------------------------------------------------- 
    167 void TerrainMouseQueryListener::mouseMoved (MouseEvent *e) 
     163TerrainMouseQueryListener::~TerrainMouseQueryListener() 
     164{ 
     165} 
     166//----------------------------------------------------------------------- 
     167void TerrainMouseQueryListener::mouseMoved(MouseEvent *e) 
    168168{ 
    169169        // Update CEGUI with the mouse motion 
    170     CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 
     170    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() *  
     171                mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 
    171172} 
    172173//----------------------------------------------------------------------- 
  • trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp

    r122 r130  
    66#include <OgreMemoryMacros.h> 
    77#include "TerrainMouseQueryListener.h" 
     8#include "OgrePlatformQueryManager.h" 
     9#include "OgreVisibilityTerrainSceneManager.h" 
     10#include "VisibilityInfo.h" 
    811 
    912// output file for frame info 
     
    5457mTerrainContentGenerator(sceneGenerator), 
    5558mVisibilityThreshold(0), 
    56 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    57 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 
     59mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
     60//mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 
    5861mNodeVizMode(NODEVIZ_NONE), 
    5962mVizCameraHeight(Real(2500.0)), 
     
    8184mSunLight(sunLight) 
    8285{ 
    83         mInputDevice = PlatformManager::getSingleton().createInputReader(); 
    84         mInputDevice->initialise(win, true, true); 
    85  
    86         /* 
     86        //mInputDevice = PlatformManager::getSingleton().createInputReader(); 
     87         
     88        //mInputDevice->initialise(win, true, true); 
     89        mEventProcessor = new EventProcessor(); 
     90         
     91        mEventProcessor->initialise(win); 
     92        mEventProcessor->startProcessingEvents(); 
    8793        mEventProcessor->addMouseListener(this); 
    8894        mEventProcessor->addMouseMotionListener(this); 
    89         mEventProcessor->addKeyListener(this); 
    90         */ 
     95 
     96        //mEventProcessor->addKeyListener(this); 
     97        mInputDevice = mEventProcessor->getInputReader(); 
     98         
    9199 
    92100        // create ray query executor, used to place objects in terrain 
     
    145153        mSceneMgr->setOption("CullCamera", &mCullCamera); 
    146154        mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 
     155 
     156        mVisibilityManager =  
     157                dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->GetVisibilityManager(); 
     158 
     159        dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> 
     160                SetViewport(mWindow->getViewport(0)); 
    147161}  
    148162//----------------------------------------------------------------------- 
    149163TerrainMouseQueryListener::~TerrainMouseQueryListener() 
    150164{ 
    151         PlatformManager::getSingleton().destroyInputReader(mInputDevice); 
     165        //PlatformManager::getSingleton().destroyInputReader(mInputDevice); 
    152166     
    153167        delete mRayQueryExecutor; 
     168        delete mEventProcessor; 
    154169} 
    155170//----------------------------------------------------------------------- 
     
    170185                 // Setup the ray scene query 
    171186         Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 
    172    
    173                  Vector3 queryResult; 
     187                 
     188                 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 
    174189                  
    175190                 // Get results, create a node/entity on the position 
    176191                 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 
    177                          mouseRay.getOrigin(), Vector3(0,0,0), "robot"); 
     192                         mouseRay.getOrigin(), Vector3::ZERO, "robot", false); 
    178193                 
    179194         mLMouseDown = true;  
     
    231246bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 
    232247{ 
    233         LogManager::getSingleton().logMessage("frame started"); 
    234248        if (mWindow->isClosed()) 
     249        { 
    235250        return false; 
    236  
    237          mInputDevice->capture(); 
    238                   
    239          //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 
    240          int terrainLevelIdx = 0; 
    241          mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 
    242  
    243          //-- setup what is needed for immediate mouse/key movement 
    244          if (mTimeDelay >= 0)  
    245                  mTimeDelay -= evt.timeSinceLastFrame; 
    246  
    247          // If this is the first frame, pick a speed 
    248          if (evt.timeSinceLastFrame == 0) 
    249          { 
    250                  mMoveScale = 1; 
    251                  mRotScale = 0.1; 
    252          } 
    253          // Otherwise scale movement units by time passed since last frame 
    254          else 
    255          { 
    256                  // Move about 100 units per second, 
    257                  mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 
    258                  // Take about 10 seconds for full rotation 
    259                  mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 
    260          } 
    261  
    262          mRotX = 0; 
    263          mRotY = 0; 
    264          mTranslateVector = Vector3::ZERO; 
    265  
    266          if (!processUnbufferedKeyInput(evt)) 
    267          { 
    268                  return false; 
    269          } 
    270          if (!processUnbufferedMouseInput(evt)) 
    271          { 
    272                  return false; 
    273          } 
    274  
    275          if (mShowVisualization) 
    276          { 
     251        } 
     252 
     253//      mInputDevice->capture(); 
     254 
     255        //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 
     256        int terrainLevelIdx = 0; 
     257        mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 
     258 
     259        //-- setup what is needed for immediate mouse/key movement 
     260        if (mTimeDelay >= 0)  
     261        { 
     262                mTimeDelay -= evt.timeSinceLastFrame; 
     263        } 
     264 
     265        // If this is the first frame, pick a speed 
     266        if (evt.timeSinceLastFrame == 0) 
     267        { 
     268                mMoveScale = 1; 
     269                mRotScale = 0.1; 
     270        } 
     271        // Otherwise scale movement units by time passed since last frame 
     272        else 
     273        { 
     274                // Move about 100 units per second, 
     275                mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 
     276                // Take about 10 seconds for full rotation 
     277                mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 
     278        } 
     279 
     280        mRotX = 0; 
     281        mRotY = 0; 
     282        mTranslateVector = Vector3::ZERO; 
     283 
     284        if (!processUnbufferedKeyInput(evt)) 
     285        { 
     286                return false; 
     287        } 
     288/*      if (!processUnbufferedMouseInput(evt)) 
     289        { 
     290                return false; 
     291        }*/ 
     292        // --- set parameters for visualization 
     293        if (mShowVisualization) 
     294        { 
    277295                // important for visualization => draw octree bounding boxes 
    278296                mSceneMgr->setOption("ShowOctree", &mShowVisualization); 
    279                 // also render nodew content? 
    280                 //mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
    281  
    282                 // -- setup visualization camera 
     297                 
     298                // ---- setup visualization camera 
     299 
    283300                mVizCamera->setPosition(0, 0, 0); 
    284301                mVizCamera->setOrientation(Quaternion::IDENTITY); 
     
    289306                // point down -Z axis 
    290307                mVizCamera->pitch(Radian(Degree(270.0))); 
    291          
     308 
    292309                // rotation arounnd X axis 
    293310                mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x,  
     
    298315        } 
    299316 
     317        //-- set application state 
    300318        switch (mAppState) 
    301319        { 
     
    312330                                StringConverter::toString(mFrameInfo.size() - 1)); 
    313331                }        
    314          
    315                  moveCamera(); 
    316                  Clamp2Terrain(); 
    317  
    318                  break; 
     332 
     333                moveCamera(); 
     334                Clamp2Terrain(); 
     335 
     336                break; 
    319337        default: 
    320338                break; 
    321339        };       
    322          
     340 
    323341        return true; 
     342} 
     343//----------------------------------------------------------------------- 
     344void TerrainMouseQueryListener::ApplyVisibilityQuery() 
     345{ 
     346        InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 
     347        InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 
     348 
     349    mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 
     350                            &visibleNodes, &visibleGeometry, false); 
     351 
     352        for (int i=0; i < visibleGeometry.size(); ++i) 
     353        { 
     354                std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibiliy(); 
     355                LogManager::getSingleton().logMessage(d.str()); 
     356        } 
     357        for (int i=0; i < visibleNodes.size(); ++i) 
     358        { 
     359                std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibiliy(); 
     360                LogManager::getSingleton().logMessage(d.str()); 
     361        } 
     362 
    324363} 
    325364//----------------------------------------------------------------------- 
     
    365404        { 
    366405                ofstr << StringConverter::toString((*it).position) << " "  
    367                         << StringConverter::toString((*it).orientation) << " " 
    368                         << StringConverter::toString((*it).timeElapsed) << "\n"; 
     406                          << StringConverter::toString((*it).orientation) << " " 
     407                          << StringConverter::toString((*it).timeElapsed) << "\n"; 
    369408        } 
    370409        ofstr.close(); 
     
    390429                mFrameInfo.push_back(info); 
    391430                 
    392                 /* 
    393                 std::stringstream d; 
     431                /*      std::stringstream d; 
    394432                d << StringConverter::toString(info.position) << " " << StringConverter::toString(info.orientation); 
    395                 LogManager::getSingleton().logMessage(d.str()); 
    396                 */ 
     433                LogManager::getSingleton().logMessage(d.str());         */ 
    397434        } 
    398435        ifstr.close(); 
     
    791828        KEY_PRESSED(KC_F3, 0.3, nextAppState()); 
    792829        KEY_PRESSED(KC_F4, 0.3, toggleRecord()); 
     830        KEY_PRESSED(KC_F5, 0.3, ApplyVisibilityQuery()); 
    793831 
    794832        KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); 
  • trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.h

    r121 r130  
    99#include <OgreException.h> 
    1010#include "VisibilityEnvironment.h" 
     11#include "VisibilityManager.h" 
    1112#include "OgreTerrainContentGenerator.h" 
    1213 
     
    113114        void toggleRecord(); 
    114115 
     116        void ApplyVisibilityQuery(); 
     117 
     118        void switchMouseMode()  
     119        { 
     120        mUseBufferedInputMouse = !mUseBufferedInputMouse; 
     121                mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse); 
     122        } 
    115123protected: 
    116124 
     
    201209 
    202210        Light *mSunLight; 
     211        GtpVisibility::VisibilityManager *mVisibilityManager; 
     212        EventProcessor* mEventProcessor; 
     213         
     214        bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
     215         
    203216}; 
    204217 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj

    r115 r130  
    7575                                PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE" 
    7676                                RuntimeLibrary="2" 
     77                                RuntimeTypeInfo="TRUE" 
    7778                                UsePrecompiledHeader="0" 
    7879                                WarningLevel="3" 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r115 r130  
    5757 
    5858        TerrainMouseQueryListener *mTerrainFrameListener; 
    59  
     59         
    6060private: 
    6161        void chooseSceneManager(void); 
Note: See TracChangeset for help on using the changeset viewer.