Changeset 133
- Timestamp:
- 06/15/05 01:18:51 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 2 added
- 9 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r130 r133 72 72 void renderQueueGroupObjects(RenderQueueGroup* pGroup); 73 73 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 */ 75 76 Entity* createEntity(const String& entityName, const String& meshName); 76 77 77 /** Returns pointer to visibility manager */ 78 /** Returns pointer to visibility manager. 79 */ 78 80 GtpVisibility::VisibilityManager *GetVisibilityManager(); 79 81 80 82 protected: 81 83 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 */ 83 86 void InitDepthPass(); 84 /** Creates material for item buffer. */ 87 /** Creates material for item buffer. 88 */ 85 89 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 */ 87 92 void ShowVisualization(Camera *cam); 88 93 … … 100 105 bool mRenderDepthPass; 101 106 bool mRenderItemBuffer; 107 bool mEnableDepthWrite; 102 108 103 109 Pass *mDepthPass; -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r130 r133 188 188 else 189 189 { 190 // used by the scene manager, because bounding box rendering must be handled 191 // differently 190 192 mIsBoundingBoxQuery = true; 191 193 -
trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp
r121 r133 46 46 47 47 //----------------------------------------------------------------------- 48 extern "C" void dllStartPlugin(void)48 extern "C" void __declspec(dllexport) dllStartPlugin(void) 49 49 { 50 50 visEnv = new GtpVisibility::VisibilityEnvironment(); … … 66 66 } 67 67 //----------------------------------------------------------------------- 68 extern "C" void dllStopPlugin() 68 extern "C" void __declspec(dllexport) dllShutdownPlugin() 69 { 70 visibilityTerrainPlugin->shutdown(); 71 heightmapTerrainPageSource->shutdown(); 72 } 73 //----------------------------------------------------------------------- 74 extern "C" void __declspec(dllexport) dllStopPlugin() 69 75 { 70 76 delete heightmapTerrainPageSource; … … 77 83 delete visEnv; 78 84 } 79 //----------------------------------------------------------------------- 80 extern "C" void dllShutdownPlugin() 81 { 82 visibilityTerrainPlugin->shutdown(); 83 heightmapTerrainPageSource->shutdown(); 84 } 85 85 86 86 87 } //namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r130 r133 25 25 mUseDepthPass(false), 26 26 mRenderItemBuffer(false), 27 mCurrentEntityId(0) 27 mCurrentEntityId(0), 28 mEnableDepthWrite(true) 28 29 { 29 30 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 145 146 146 147 // 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); 148 150 149 151 IlluminationRenderStage savedStage = mIlluminationStage; … … 158 160 if (mRenderDepthPass) 159 161 { 160 // set vertex program of current pass162 // --- set vertex program of current pass so z-buffer is updated correctly 161 163 if (pass->hasVertexProgram()) 162 164 { … … 178 180 } 179 181 } 182 183 bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 184 // global option which enables / disables depth writes 185 if (!mEnableDepthWrite) 186 { 187 usedPass->setDepthWriteEnabled(false); 188 } 189 180 190 //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 181 191 182 192 Pass *result = SceneManager::setPass(usedPass); 193 194 // reset depth write 195 if (!mEnableDepthWrite) 196 { 197 usedPass->setDepthWriteEnabled(IsDepthWrite); 198 } 183 199 184 200 // reset illumination stage … … 191 207 { 192 208 // 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 199 212 //-- show visible scene nodes and octree bounding boxes from last frame 200 213 if (mShowVisualization) … … 374 387 { 375 388 TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 389 return true; 390 } 391 if (key == "DepthCheck") 392 { 393 mEnableDepthWrite = (*static_cast<const bool *>(val)); 376 394 return true; 377 395 } … … 508 526 } 509 527 510 // ----- TRANSPARENT LOOP: must be handle t differently altough we don't really511 // care about transparents for the item buffer528 // ----- TRANSPARENT LOOP: must be handled differently 529 // although we don't really care about transparents for the item buffer 512 530 // TODO: HOW TO HANDLE OCCLUDED OBJECTS ???? 513 531 RenderPriorityGroup::TransparentRenderablePassList -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r130 r133 81 81 void TestCullingApplication::createFrameListener() 82 82 { 83 mFrameListener= new Terrain MouseQueryListener(mWindow, mCamera, mSceneMgr,83 mFrameListener= new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 84 84 mGUIRenderer, mSceneContentGenerator); 85 85 mFrameListener->showDebugOverlay(true); … … 94 94 95 95 /***********************************************/ 96 /* Terrain MouseQueryListener implementation */96 /* TerrainFrameListener implementation */ 97 97 /***********************************************/ 98 98 //----------------------------------------------------------------------- 99 Terrain MouseQueryListener::TerrainMouseQueryListener(RenderWindow* win, Camera* cam,99 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, 100 100 SceneManager *sceneManager, 101 101 CEGUI::Renderer *renderer, … … 161 161 } 162 162 //----------------------------------------------------------------------- 163 Terrain MouseQueryListener::~TerrainMouseQueryListener()164 { 165 } 166 //----------------------------------------------------------------------- 167 void Terrain MouseQueryListener::mouseMoved(MouseEvent *e)163 TerrainFrameListener::~TerrainFrameListener() 164 { 165 } 166 //----------------------------------------------------------------------- 167 void TerrainFrameListener::mouseMoved(MouseEvent *e) 168 168 { 169 169 // Update CEGUI with the mouse motion … … 172 172 } 173 173 //----------------------------------------------------------------------- 174 void Terrain MouseQueryListener::mousePressed(MouseEvent* e)174 void TerrainFrameListener::mousePressed(MouseEvent* e) 175 175 { 176 176 // Left mouse button down … … 188 188 189 189 //----------------------------------------------------------------------- 190 void Terrain MouseQueryListener::mouseReleased(MouseEvent* e)190 void TerrainFrameListener::mouseReleased(MouseEvent* e) 191 191 { 192 192 // Left mouse button up … … 204 204 } 205 205 //----------------------------------------------------------------------- 206 void Terrain MouseQueryListener::mouseDragged (MouseEvent *e)206 void TerrainFrameListener::mouseDragged (MouseEvent *e) 207 207 { 208 208 // If we are dragging the left mouse button. … … 219 219 } 220 220 //----------------------------------------------------------------------- 221 bool Terrain MouseQueryListener::frameStarted(const FrameEvent &evt)221 bool TerrainFrameListener::frameStarted(const FrameEvent &evt) 222 222 { 223 223 return ExampleFrameListener::frameStarted(evt); 224 224 } 225 225 //----------------------------------------------------------------------- 226 bool Terrain MouseQueryListener::frameEnded(const FrameEvent& evt)226 bool TerrainFrameListener::frameEnded(const FrameEvent& evt) 227 227 { 228 228 if (mShutdownRequested) … … 245 245 } 246 246 //----------------------------------------------------------------------- 247 void Terrain MouseQueryListener::changeThreshold(int incr)247 void TerrainFrameListener::changeThreshold(int incr) 248 248 { 249 249 mVisibilityThreshold += incr; … … 256 256 } 257 257 //----------------------------------------------------------------------- 258 void Terrain MouseQueryListener::nextAlgorithm()258 void TerrainFrameListener::nextAlgorithm() 259 259 { 260 260 mCurrentAlgorithm = ++mCurrentAlgorithm % … … 264 264 } 265 265 //----------------------------------------------------------------------- 266 void Terrain MouseQueryListener::toggleUseOptimization()266 void TerrainFrameListener::toggleUseOptimization() 267 267 { 268 268 mUseOptimization = !mUseOptimization; … … 276 276 } 277 277 //----------------------------------------------------------------------- 278 void Terrain MouseQueryListener::toggleShowOctree()278 void TerrainFrameListener::toggleShowOctree() 279 279 { 280 280 mShowOctree = !mShowOctree; … … 283 283 } 284 284 //----------------------------------------------------------------------- 285 void Terrain MouseQueryListener::toggleUseDepthPass()285 void TerrainFrameListener::toggleUseDepthPass() 286 286 { 287 287 mUseDepthPass = !mUseDepthPass; … … 290 290 } 291 291 //----------------------------------------------------------------------- 292 void Terrain MouseQueryListener::toggleShowViz()292 void TerrainFrameListener::toggleShowViz() 293 293 { 294 294 mShowVisualization = !mShowVisualization; … … 298 298 } 299 299 //----------------------------------------------------------------------- 300 void Terrain MouseQueryListener::setAlgorithm(int algorithm)300 void TerrainFrameListener::setAlgorithm(int algorithm) 301 301 { 302 302 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 304 304 } 305 305 //----------------------------------------------------------------------- 306 void Terrain MouseQueryListener::updateStats()306 void TerrainFrameListener::updateStats() 307 307 { 308 308 unsigned int opt = 0; … … 331 331 } 332 332 //----------------------------------------------------------------------- 333 void Terrain MouseQueryListener::keyPressed(KeyEvent* e)333 void TerrainFrameListener::keyPressed(KeyEvent* e) 334 334 { 335 335 if(e->getKey() == KC_ESCAPE) … … 345 345 } 346 346 //----------------------------------------------------------------------- 347 void Terrain MouseQueryListener::keyReleased(KeyEvent* e)347 void TerrainFrameListener::keyReleased(KeyEvent* e) 348 348 { 349 349 CEGUI::System::getSingleton().injectKeyUp(e->getKey()); … … 351 351 } 352 352 //----------------------------------------------------------------------- 353 void Terrain MouseQueryListener::keyClicked(KeyEvent* e)353 void TerrainFrameListener::keyClicked(KeyEvent* e) 354 354 { 355 355 // Do nothing -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r115 r133 25 25 }; 26 26 27 class Terrain MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener27 class TerrainFrameListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener 28 28 { 29 29 public: 30 30 31 Terrain MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,31 TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 32 32 CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator); 33 33 34 34 35 ~Terrain MouseQueryListener( );35 ~TerrainFrameListener( ); 36 36 37 37 bool frameStarted(const FrameEvent& evt); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r130 r133 5 5 #include <../CEGUIRenderer/include/OgreCEGUITexture.h> 6 6 #include <OgreMemoryMacros.h> 7 #include "Terrain MouseQueryListener.h"7 #include "TerrainFrameListener.h" 8 8 #include "OgrePlatformQueryManager.h" 9 9 #include "OgreVisibilityTerrainSceneManager.h" … … 16 16 17 17 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 28 18 String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] = 29 19 { … … 35 25 36 26 //----------------------------------------------------------------------- 37 Terrain MouseQueryListener::TerrainMouseQueryListener(RenderWindow* win, Camera* cam,27 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, 38 28 SceneManager *sceneManager, 39 29 CEGUI::Renderer *renderer, … … 82 72 mDisplayCameraDetails(false), 83 73 mVisualizeCulledNodes(false), 84 mSunLight(sunLight) 74 mSunLight(sunLight), 75 mShiftPressed(false) 85 76 { 86 77 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 93 84 mEventProcessor->addMouseListener(this); 94 85 mEventProcessor->addMouseMotionListener(this); 95 96 //mEventProcessor->addKeyListener(this); 86 mEventProcessor->addKeyListener(this); 87 97 88 mInputDevice = mEventProcessor->getInputReader(); 98 89 … … 154 145 mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 155 146 156 mVisibilityManager = 157 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->GetVisibilityManager(); 147 // TODO: change this 148 mVisibilityManager = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)-> 149 GetVisibilityManager(); 158 150 159 151 dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> … … 161 153 } 162 154 //----------------------------------------------------------------------- 163 Terrain MouseQueryListener::~TerrainMouseQueryListener()155 TerrainFrameListener::~TerrainFrameListener() 164 156 { 165 157 //PlatformManager::getSingleton().destroyInputReader(mInputDevice); … … 169 161 } 170 162 //----------------------------------------------------------------------- 171 void Terrain MouseQueryListener::mouseMoved(MouseEvent *e)163 void TerrainFrameListener::mouseMoved(MouseEvent *e) 172 164 { 173 165 // Update CEGUI with the mouse motion … … 176 168 } 177 169 //----------------------------------------------------------------------- 178 void Terrain MouseQueryListener::mousePressed(MouseEvent* e)170 void TerrainFrameListener::mousePressed(MouseEvent* e) 179 171 { 180 172 // Left mouse button down … … 200 192 mRMouseDown = true; 201 193 } 202 } // mousePressed203 //----------------------------------------------------------------------- 204 void Terrain MouseQueryListener::mouseReleased(MouseEvent* e)194 } 195 //----------------------------------------------------------------------- 196 void TerrainFrameListener::mouseReleased(MouseEvent* e) 205 197 { 206 198 // Left mouse button up … … 218 210 } 219 211 //----------------------------------------------------------------------- 220 void Terrain MouseQueryListener::mouseDragged(MouseEvent *e)212 void TerrainFrameListener::mouseDragged(MouseEvent *e) 221 213 { 222 214 // If we are dragging the left mouse button. … … 244 236 } 245 237 //----------------------------------------------------------------------- 246 bool Terrain MouseQueryListener::frameStarted(const FrameEvent &evt)238 bool TerrainFrameListener::frameStarted(const FrameEvent &evt) 247 239 { 248 240 if (mWindow->isClosed()) … … 287 279 } 288 280 /* if (!processUnbufferedMouseInput(evt)) 289 { 290 return false; 291 }*/ 281 { return false; }*/ 282 292 283 // --- set parameters for visualization 293 284 if (mShowVisualization) … … 330 321 StringConverter::toString(mFrameInfo.size() - 1)); 331 322 } 332 323 // move camera according to input 333 324 moveCamera(); 325 // clamp camera so we always walk along the terrain 334 326 Clamp2Terrain(); 335 336 break; 327 break; 328 337 329 default: 338 330 break; … … 342 334 } 343 335 //----------------------------------------------------------------------- 344 void Terrain MouseQueryListener::ApplyVisibilityQuery()336 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility) 345 337 { 346 338 InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 347 339 InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 348 340 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 } 351 349 352 350 for (int i=0; i < visibleGeometry.size(); ++i) … … 363 361 } 364 362 //----------------------------------------------------------------------- 365 void Terrain MouseQueryListener::Clamp2Terrain()363 void TerrainFrameListener::Clamp2Terrain() 366 364 { 367 365 // clamp to terrain … … 376 374 } 377 375 //----------------------------------------------------------------------- 378 bool Terrain MouseQueryListener::frameEnded(const FrameEvent& evt)376 bool TerrainFrameListener::frameEnded(const FrameEvent& evt) 379 377 { 380 378 if (mShutdownRequested) … … 386 384 } 387 385 //----------------------------------------------------------------------- 388 void Terrain MouseQueryListener::moveCamera()386 void TerrainFrameListener::moveCamera() 389 387 { 390 388 // move node rather than camera so orientation is right in the visualization … … 394 392 } 395 393 //----------------------------------------------------------------------- 396 void Terrain MouseQueryListener::writeFrames()394 void TerrainFrameListener::writeFrames() 397 395 { 398 396 std::ofstream ofstr(frames_out_filename); … … 410 408 } 411 409 //----------------------------------------------------------------------- 412 void Terrain MouseQueryListener::loadFrames()410 void TerrainFrameListener::loadFrames() 413 411 { 414 412 std::ifstream ifstr(frames_out_filename); … … 436 434 } 437 435 //----------------------------------------------------------------------- 438 void Terrain MouseQueryListener::nextAppState()436 void TerrainFrameListener::nextAppState() 439 437 { 440 438 mCurrentFrame = 0; … … 496 494 } 497 495 //----------------------------------------------------------------------- 498 void Terrain MouseQueryListener::toggleRecord()496 void TerrainFrameListener::toggleRecord() 499 497 { 500 498 mRecord = !mRecord; … … 507 505 } 508 506 //----------------------------------------------------------------------- 509 void Terrain MouseQueryListener::changeThreshold(int incr)507 void TerrainFrameListener::changeThreshold(int incr) 510 508 { 511 509 mVisibilityThreshold += incr; … … 518 516 } 519 517 //----------------------------------------------------------------------- 520 void Terrain MouseQueryListener::zoomVizCamera(int zoom)518 void TerrainFrameListener::zoomVizCamera(int zoom) 521 519 { 522 520 mVizCameraHeight += zoom; … … 524 522 } 525 523 //----------------------------------------------------------------------- 526 void Terrain MouseQueryListener::nextAlgorithm()524 void TerrainFrameListener::nextAlgorithm() 527 525 { 528 526 mCurrentAlgorithm = (mCurrentAlgorithm + 1) % … … 532 530 } 533 531 //----------------------------------------------------------------------- 534 void Terrain MouseQueryListener::setAlgorithm(int algorithm)532 void TerrainFrameListener::setAlgorithm(int algorithm) 535 533 { 536 534 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 538 536 } 539 537 //----------------------------------------------------------------------- 540 void Terrain MouseQueryListener::updateStats()538 void TerrainFrameListener::updateStats() 541 539 { 542 540 unsigned int opt = 0; … … 599 597 } 600 598 //----------------------------------------------------------------------- 601 void Terrain MouseQueryListener::toggleUseOptimization()599 void TerrainFrameListener::toggleUseOptimization() 602 600 { 603 601 mUseOptimization = !mUseOptimization; 604 605 602 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 608 607 bool delayedRendering = !mUseOptimization; 609 608 mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering); 610 609 611 610 if (mUseOptimization) 611 { 612 612 mUseOptimizationInfo->setCaption(": true"); 613 } 613 614 else 615 { 614 616 mUseOptimizationInfo->setCaption(": false"); 615 } 616 //----------------------------------------------------------------------- 617 void TerrainMouseQueryListener::toggleShowOctree() 617 } 618 } 619 //----------------------------------------------------------------------- 620 void TerrainFrameListener::toggleShowOctree() 618 621 { 619 622 mShowOctree = !mShowOctree; … … 622 625 } 623 626 //----------------------------------------------------------------------- 624 void Terrain MouseQueryListener::toggleUseDepthPass()627 void TerrainFrameListener::toggleUseDepthPass() 625 628 { 626 629 mUseDepthPass = !mUseDepthPass; … … 638 641 } 639 642 //----------------------------------------------------------------------- 640 void Terrain MouseQueryListener::toggleShowViz()643 void TerrainFrameListener::toggleShowViz() 641 644 { 642 645 mShowVisualization = !mShowVisualization; … … 677 680 } 678 681 //----------------------------------------------------------------------- 679 void Terrain MouseQueryListener::toggleUseShadows()682 void TerrainFrameListener::toggleUseShadows() 680 683 { 681 684 mUseShadows = !mUseShadows; … … 694 697 } 695 698 //----------------------------------------------------------------------- 696 void Terrain MouseQueryListener::nextNodeVizMode()699 void TerrainFrameListener::nextNodeVizMode() 697 700 { 698 701 mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM; … … 707 710 } 708 711 //----------------------------------------------------------------------- 709 void TerrainMouseQueryListener::keyPressed(KeyEvent* e) 710 { 711 if(e->getKey() == KC_ESCAPE) 712 { 712 void TerrainFrameListener::keyPressed(KeyEvent* e) 713 { 714 switch(e->getKey()) 715 { 716 case KC_ESCAPE: 713 717 mShutdownRequested = true; 714 718 e->consume(); 715 719 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: 774 769 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; 834 791 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 835 792 //KEY_PRESSED(KC_F4, 0.3, loadFrames()); 793 default: 794 break; 795 } 836 796 837 797 if (mDisplayCameraDetails) … … 842 802 } 843 803 804 CEGUI::System::getSingleton().injectKeyDown(e->getKey()); 805 CEGUI::System::getSingleton().injectChar(e->getKeyChar()); 806 e->consume(); 807 } 808 //----------------------------------------------------------------------- 809 void TerrainFrameListener::keyReleased(KeyEvent* e) 810 { 811 CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 812 e->consume(); 813 } 814 //----------------------------------------------------------------------- 815 void TerrainFrameListener::keyClicked(KeyEvent* e) 816 { 817 // Do nothing 818 e->consume(); 819 } 820 //----------------------------------------------------------------------- 821 void 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 //----------------------------------------------------------------------- 831 void 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 //----------------------------------------------------------------------- 867 bool 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 844 906 // Return true to continue rendering 845 907 return true; 846 908 } 847 909 //----------------------------------------------------------------------- 848 void Terrain MouseQueryListener::nextFilter()849 { 850 switch (mFiltering)910 void TerrainFrameListener::nextFilter() 911 { 912 switch (mFiltering) 851 913 { 852 914 case TFO_BILINEAR: … … 869 931 MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 870 932 933 // reload stats 871 934 showStats(mStatsOn); 872 935 } 873 936 //----------------------------------------------------------------------- 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() 937 void 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 //----------------------------------------------------------------------- 954 void TerrainFrameListener::takeScreenShot() 886 955 { 887 956 char tmp[20]; … … 891 960 } 892 961 //----------------------------------------------------------------------- 893 void Terrain MouseQueryListener::toggleDisplayCameraDetails()962 void TerrainFrameListener::toggleDisplayCameraDetails() 894 963 { 895 964 mDisplayCameraDetails = !mDisplayCameraDetails; 896 965 897 966 if (!mDisplayCameraDetails) 967 { 898 968 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 //----------------------------------------------------------------------- 972 void TerrainFrameListener::showStats(bool show) 923 973 { 924 974 if (mDebugOverlay && mCullStatsOverlay) … … 937 987 } 938 988 //----------------------------------------------------------------------- 939 void Terrain MouseQueryListener::toggleShowStats()989 void TerrainFrameListener::toggleShowStats() 940 990 { 941 991 mStatsOn = !mStatsOn; … … 944 994 } 945 995 //----------------------------------------------------------------------- 946 void Terrain MouseQueryListener::toggleShowHelp()996 void TerrainFrameListener::toggleShowHelp() 947 997 { 948 998 mShowHelp = !mShowHelp; … … 957 1007 } 958 1008 } 959 960 -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r130 r133 1 #ifndef _Terrain MouseQueryListener_H__2 #define _Terrain MouseQueryListener_H__1 #ifndef _TerrainFrameListener_H__ 2 #define _TerrainFrameListener_H__ 3 3 4 4 #include "CEGUIForwardRefs.h" … … 20 20 /** Mouse query listener for terrain 21 21 */ 22 class Terrain MouseQueryListener: public FrameListener, public MouseListener, public MouseMotionListener22 class TerrainFrameListener: public FrameListener, public MouseListener, public MouseMotionListener, public KeyListener 23 23 { 24 24 public: 25 25 26 Terrain MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,26 TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 27 27 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera, 28 28 SceneNode *camNode, Light *sunLight); 29 29 30 ~Terrain MouseQueryListener();30 ~TerrainFrameListener(); 31 31 32 32 … … 114 114 void toggleRecord(); 115 115 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 123 124 protected: 124 125 … … 212 213 EventProcessor* mEventProcessor; 213 214 214 bool m UseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;215 215 bool mShiftPressed; 216 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 216 217 }; 217 218 218 219 219 #endif //_Terrain MouseQueryListener_H__220 #endif //_TerrainFrameListener_H__ -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj
r130 r133 123 123 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 124 124 <File 125 RelativePath=".\Terrain MouseQueryListener.cpp">125 RelativePath=".\TerrainFrameListener.cpp"> 126 126 </File> 127 127 <File … … 134 134 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 135 135 <File 136 RelativePath=".\Terrain MouseQueryListener.h">136 RelativePath=".\TerrainFrameListener.h"> 137 137 </File> 138 138 <File -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r122 r133 187 187 CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme"); 188 188 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"); 191 191 192 192 CEGUI::MouseCursor::getSingleton().show(); … … 195 195 void TestCullingTerrainApplication::createFrameListener() 196 196 { 197 mTerrainFrameListener = new Terrain MouseQueryListener(mWindow, mCamera, mSceneMgr,197 mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 198 198 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight); 199 199 … … 218 218 void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt) 219 219 { 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; 221 222 const bool nShowViz = !showViz; 222 223 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r130 r133 7 7 8 8 #include <OgreRenderTargetListener.h> 9 #include "Terrain MouseQueryListener.h"9 #include "TerrainFrameListener.h" 10 10 11 11 class VisualizationRenderTargetListener: public RenderTargetListener … … 56 56 VisualizationRenderTargetListener *mRenderTargetListener; 57 57 58 Terrain MouseQueryListener *mTerrainFrameListener;58 TerrainFrameListener *mTerrainFrameListener; 59 59 60 60 private:
Note: See TracChangeset
for help on using the changeset viewer.