- Timestamp:
- 06/16/05 18:13:33 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r133 r135 16 16 17 17 18 String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =19 { 20 18 String currentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] = 19 { 20 "View Frustum Culling", 21 21 "Stop and Wait Culling", 22 22 "Coherent Hierarchical Culling" 23 23 }; 24 24 25 String queryTypeCaptions[4] = 26 { 27 "from camera, visible pixels", 28 "from viewpoint, visible pixels", 29 "from camera, relative visibility", 30 "from viewpoint, relative visibility" 31 }; 25 32 26 33 //----------------------------------------------------------------------- … … 73 80 mVisualizeCulledNodes(false), 74 81 mSunLight(sunLight), 75 mShiftPressed(false) 82 mShiftPressed(false), 83 mShowQueryStats(false) 76 84 { 77 85 //mInputDevice = PlatformManager::getSingleton().createInputReader(); 78 79 86 //mInputDevice->initialise(win, true, true); 87 80 88 mEventProcessor = new EventProcessor(); 81 89 … … 94 102 mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 95 103 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 96 104 mQueryOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/QueryOverlay"); 97 105 98 106 //-- visibility culling stats overlay … … 112 120 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 113 121 114 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);122 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 115 123 mThresholdInfo->setCaption(": 0"); 116 124 mFrustumCulledNodesInfo->setCaption(": 0"); … … 124 132 mQueriesIssuedInfo->setCaption(": 0"); 125 133 134 135 //-- visibility query stats overlay 136 mQueryTypeInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/QueryTypeInfo"); 137 mQueryVisibleNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleNodesInfo"); 138 mQueryVisibleGeometryInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleGeometryInfo"); 139 mQueryNodeVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/NodeVisibilityInfo"); 140 mQueryGeometryVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/GeometryVisibilityInfo"); 141 126 142 // show stats overlays 127 143 showStats(true); … … 145 161 mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 146 162 147 // TODO: change this 163 // TODO: change this (does not work with other scene manager plugins) 148 164 mVisibilityManager = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)-> 149 165 GetVisibilityManager(); … … 155 171 TerrainFrameListener::~TerrainFrameListener() 156 172 { 157 //PlatformManager::getSingleton().destroyInputReader(mInputDevice);158 159 173 delete mRayQueryExecutor; 160 174 delete mEventProcessor; … … 182 196 // Get results, create a node/entity on the position 183 197 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 184 mouseRay.getOrigin(), Vector3::ZERO, "robot" , false);198 mouseRay.getOrigin(), Vector3::ZERO, "robot"); 185 199 186 200 mLMouseDown = true; … … 341 355 if (fromPoint) 342 356 { 357 Vector3 point; 358 mVisibilityManager->GetQueryManager()-> 359 ComputeFromPointVisibility(point, &visibleNodes, &visibleGeometry, relativeVisibility); 343 360 } 344 361 else … … 348 365 } 349 366 367 float averageNodeVis = 0; 368 float averageGeometryVis = 0; 369 350 370 for (int i=0; i < visibleGeometry.size(); ++i) 351 371 { 352 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibiliy(); 372 averageGeometryVis += visibleGeometry[i].GetVisibility(); 373 374 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibility(); 353 375 LogManager::getSingleton().logMessage(d.str()); 354 376 } 355 377 for (int i=0; i < visibleNodes.size(); ++i) 356 378 { 357 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibiliy(); 379 averageNodeVis += visibleNodes[i].GetVisibility(); 380 381 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibility(); 358 382 LogManager::getSingleton().logMessage(d.str()); 359 383 } 360 384 385 averageNodeVis /= (float)visibleNodes.size(); 386 averageGeometryVis /= (float)visibleGeometry.size(); 387 388 char str[100]; 389 390 //-- update visibility queries stats 391 try 392 { 393 //-- visibility queries stats 394 int idx = fromPoint ? 1 : 0; 395 idx += relativeVisibility ? 2 : 0; 396 397 sprintf(str, ": %s", queryTypeCaptions[idx].c_str()); 398 mQueryTypeInfo->setCaption(str); 399 400 sprintf(str, ": %d", (int)visibleNodes.size()); 401 mQueryVisibleNodesInfo->setCaption(str); 402 403 sprintf(str,": %d", (int)visibleGeometry.size()); 404 mQueryVisibleGeometryInfo->setCaption(str); 405 406 sprintf(str,": %3.3f", averageNodeVis); 407 mQueryNodeVisibilityInfo->setCaption(str); 408 409 sprintf(str,": %3.3f", averageGeometryVis); 410 mQueryGeometryVisibilityInfo->setCaption(str); 411 } 412 catch (...) 413 { 414 // ignore 415 } 416 417 // show the results 418 if (!mShowQueryStats) 419 { 420 mQueryOverlay->show(); 421 mShowQueryStats = true; 422 } 361 423 } 362 424 //----------------------------------------------------------------------- … … 399 461 400 462 it_end = mFrameInfo.end(); 401 for (it = mFrameInfo.begin(); it < it_end; ++it)463 for (it = mFrameInfo.begin(); it < it_end; ++it) 402 464 { 403 465 ofstr << StringConverter::toString((*it).position) << " " … … 422 484 ifstr.getline(line, 256); 423 485 sscanf(line, "%f %f %f %f %f %f %f %f", &info.position.x, &info.position.y, &info.position.z, 424 425 486 &info.orientation.w, &info.orientation.x, &info.orientation.y, &info.orientation.z, 487 &info.timeElapsed); 426 488 427 489 mFrameInfo.push_back(info); … … 447 509 //-- write out stats for recorded walkthrough 448 510 std::stringstream d; 449 d << "Algorithm: " << mCurrentAlgorithmCaptions[mCurrentAlgorithm] << "\n"511 d << "Algorithm: " << currentAlgorithmCaptions[mCurrentAlgorithm] << "\n" 450 512 << "avg. FPS: " << mWindow->getAverageFPS() << "\n" 451 513 << "best FPS: " << mWindow->getBestFPS() << "\n" … … 532 594 void TerrainFrameListener::setAlgorithm(int algorithm) 533 595 { 534 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);596 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 535 597 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 536 598 } … … 548 610 549 611 // update stats when necessary 550 try { 612 try 613 { 551 614 OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps"); 552 615 OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps"); … … 591 654 mObjectsInfo->setCaption(str); 592 655 } 593 catch (...)594 { 595 656 catch (...) 657 { 658 // ignore 596 659 } 597 660 } … … 787 850 788 851 case KC_LSHIFT: 789 mShiftPressed = !mShiftPressed;852 mShiftPressed = true; 790 853 break; 791 854 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); … … 798 861 { 799 862 // Print camera details 800 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + " " +801 863 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 864 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); 802 865 } 803 866 … … 809 872 void TerrainFrameListener::keyReleased(KeyEvent* e) 810 873 { 874 if (e->getKey() == KC_LSHIFT) 875 { 876 mShiftPressed = false; 877 } 878 811 879 CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 812 880 e->consume(); … … 867 935 bool TerrainFrameListener::processUnbufferedKeyInput(const FrameEvent& evt) 868 936 { 869 /*if (mInputDevice->isKeyDown(KC_ESCAPE)) 870 { 871 return false; 872 }*/ 873 937 bool cursorPressed = false; 938 874 939 /* Move camera forward by keypress. */ 875 940 if (mInputDevice->isKeyDown(KC_UP)) 876 941 { 877 942 mTranslateVector.z = -mMoveScale; 878 }879 943 cursorPressed = true; 944 } 880 945 /* Move camera backward by keypress. */ 881 946 if (mInputDevice->isKeyDown(KC_DOWN)) 882 947 { 883 948 mTranslateVector.z = mMoveScale; 949 cursorPressed = true; 884 950 } 885 951 … … 887 953 { 888 954 mCamNode->yaw(-mRotScale); 955 cursorPressed = true; 889 956 } 890 957 … … 892 959 { 893 960 mCamNode->yaw(mRotScale); 961 cursorPressed = true; 894 962 } 895 963 // visualization camera … … 903 971 } 904 972 973 // show the results 974 if (cursorPressed && mShowQueryStats) 975 { 976 mQueryOverlay->hide(); 977 mShowQueryStats = false; 978 } 905 979 906 980 // Return true to continue rendering
Note: See TracChangeset
for help on using the changeset viewer.