Changeset 160 for trunk/VUT/work
- Timestamp:
- 07/08/05 01:53:01 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r155 r160 31 31 32 32 // Position it at 500 in Z direction 33 mCamera->setPosition(Vector3(128, 25,128));33 mCamera->setPosition(Vector3(128, 25, 128)); 34 34 35 35 // Look back along -Z 36 mCamera->lookAt(Vector3(0, 0,-300));37 mCamera->setNearClipDistance( 1);38 mCamera->setFarClipDistance( 1000);36 mCamera->lookAt(Vector3(0, 0, -300)); 37 mCamera->setNearClipDistance(1); 38 mCamera->setFarClipDistance(1000); 39 39 }*/ 40 40 //----------------------------------------------------------------------- … … 67 67 void TestCullingApplication::setupGui() 68 68 { 69 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 69 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, 70 Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 70 71 mGUISystem = new CEGUI::System(mGUIRenderer); 71 72 … … 93 94 94 95 95 /*********************************************** /96 /* TerrainFrameListener implementation */97 /*********************************************** /96 /*****************************************************/ 97 /* TerrainFrameListener implementation */ 98 /*****************************************************/ 98 99 //----------------------------------------------------------------------- 99 100 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, 100 101 SceneManager *sceneManager, 101 102 CEGUI::Renderer *renderer, 102 SceneContentGenerator *sceneContentGenerator) 103 :ExampleFrameListener(win, cam, false, true),103 SceneContentGenerator *sceneContentGenerator): 104 ExampleFrameListener(win, cam, false, true), 104 105 mSceneMgr(sceneManager), 105 106 mGUIRenderer(renderer), … … 136 137 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo"); 137 138 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 138 mObjects Info = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");139 mObjectsCountInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 139 140 mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo"); 140 141 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); … … 148 149 mHierarchyNodesInfo->setCaption(": 0"); 149 150 mRenderedNodesInfo->setCaption(": 0"); 150 mObjects Info->setCaption(": 0");151 mObjectsCountInfo->setCaption(": 0"); 151 152 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 152 153 mQueriesIssuedInfo->setCaption(": 0"); … … 330 331 331 332 sprintf(str,": %d", mSceneContentGenerator->GetObjectCount()); 332 mObjects Info->setCaption(str);333 mObjectsCountInfo->setCaption(str); 333 334 } 334 335 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r155 r160 1 /** 2 \file 3 TestCullingApplication.h 4 */ 1 #ifndef _TerrainFrameListener_H__ 2 #define _TerrainFrameListener_H__ 3 5 4 #include "CEGUIForwardRefs.h" 6 5 #include "ExampleApplication.h" … … 29 28 public: 30 29 31 TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 32 CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator); 30 TerrainFrameListener(RenderWindow* win, 31 Camera* cam, 32 SceneManager *sceneManager, 33 CEGUI::Renderer *renderer, 34 SceneContentGenerator *sceneContentGenerator); 33 35 34 36 35 ~TerrainFrameListener( 37 ~TerrainFrameListener(); 36 38 37 39 bool frameStarted(const FrameEvent& evt); … … 86 88 OverlayElement *mHierarchyNodesInfo; 87 89 OverlayElement *mRenderedNodesInfo; 88 OverlayElement *mObjects Info;90 OverlayElement *mObjectsCountInfo; 89 91 OverlayElement *mTestGeometryForVisibleLeavesInfo; 90 92 OverlayElement *mQueriesIssuedInfo; … … 130 132 }; 131 133 134 #endif // _TerrainFrameListener_H__ -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r159 r160 11 11 #include "OgreItemBufferQueryManager.h" 12 12 #include "OgreOcclusionQueriesQueryManager.h" 13 14 15 13 #include "TestCullingTerrainApplication.h" 16 14 17 15 // output file for frame info … … 48 46 }; 49 47 48 Real currentObjectTerrainOffsets[] = 49 { 50 0, 51 7, 52 0 53 }; 54 Real currentObjectScales[] = 55 { 56 0.1, 57 0.1, 58 0.07 59 }; 50 60 //----------------------------------------------------------------------- 51 61 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, … … 55 65 Camera *vizCamera, 56 66 SceneNode *camNode, 57 Light *sunLight): 67 Light *sunLight, 68 TestCullingTerrainApplication *app): 58 69 mCamera(cam), 59 70 mWindow(win), … … 79 90 mAppState(WALKTHROUGH), 80 91 mCurrentFrame(0), 81 m TimeElapsed(0),92 mReplayTimeElapsed(0), 82 93 mRotateSpeed(72), 83 94 mMoveSpeed(50), … … 105 116 mDelayedTraversedNodes(0.0), 106 117 mUseItemBuffer(false), 107 mRenderPatchesForItemBuffer(false) 118 mRenderPatchesForItemBuffer(false), 119 mCurrentObjectType(0), 120 mApplication(app) 108 121 { 109 122 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 118 131 mEventProcessor->addKeyListener(this); 119 132 120 mInputDevice = mEventProcessor->getInputReader(); 121 133 mInputDevice = mEventProcessor->getInputReader(); 122 134 123 135 // create ray query executor, used to place objects in terrain 124 136 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 125 137 138 //-- overlays 139 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 126 140 mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 127 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");128 141 mQueryOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/QueryOverlay"); 129 130 //-- visibility culling stats overlay 131 mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/DemoOverlay"); 132 133 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo"); 134 mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo"); 135 mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo"); 136 mUseDepthPassInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseDepthPassInfo"); 137 mAssumedVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AssumedVisibilityInfo"); 138 139 mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/FrustumCulledNodesInfo"); 140 mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueryCulledNodesInfo"); 141 mTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TraversedNodesInfo"); 142 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo"); 143 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 144 mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 145 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 146 mDelayedQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedQueriesIssuedInfo"); 147 mDelayedTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedTraversedNodesInfo"); 148 149 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 150 mThresholdInfo->setCaption(": 0"); 151 mFrustumCulledNodesInfo->setCaption(": 0"); 152 mQueryCulledNodesInfo->setCaption(": 0"); 153 mTraversedNodesInfo->setCaption(": 0"); 154 mHierarchyNodesInfo->setCaption(": 0"); 155 mRenderedNodesInfo->setCaption(": 0"); 156 mObjectsInfo->setCaption(": 0"); 157 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 158 mUseDepthPassInfo->setCaption(": false"); 159 mQueriesIssuedInfo->setCaption(": 0"); 160 mAssumedVisibilityInfo->setCaption(": 0"); 161 mDelayedQueriesIssuedInfo->setCaption(": 0"); 162 mDelayedTraversedNodesInfo->setCaption(": 0"); 163 164 //-- visibility query stats overlay 165 mQueryTypeInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/QueryTypeInfo"); 166 167 mQueryVisibleNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleNodesInfo"); 168 mQueryVisibleGeometryInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleGeometryInfo"); 169 mQueryVisiblePatchInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisiblePatchInfo"); 170 171 mQueryNodeVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/NodeVisibilityInfo"); 172 mQueryGeometryVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/GeometryVisibilityInfo"); 173 mQueryPatchVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/PatchVisibilityInfo"); 142 mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/CullStatsOverlay"); 143 144 initVisStatsOverlay(); // visibility stats overlay 145 initHelpOverlay(); // help overlay 146 initQueryOverlay(); // visibility query stats overlay 174 147 175 148 // show stats overlays 176 149 showStats(true); 177 //mHelpOverlay->show(); 178 150 179 151 // set culling algorithm type 180 152 setAlgorithm(mCurrentAlgorithm); … … 193 165 mSceneMgr->setOption("CullCamera", &mCullCamera); 194 166 mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 167 168 setObjectType(mCurrentObjectType); 195 169 196 170 // reset statistics … … 229 203 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 230 204 231 // Get results, create a node/entity on the position205 // get results, create a node/entity on the position 232 206 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 233 mouseRay.getOrigin()/*queryResult*/, Vector3::ZERO, "robot"); 207 mouseRay.getOrigin()/*queryResult*/, Vector3::ZERO, 208 mApplication->getCurrentObjectCaption(mCurrentObjectType)); 234 209 210 if (mCurrentObjectType == 0) // only robot has animation phases 211 { 212 Entity *ent = mTerrainContentGenerator->GetGeneratedEntities()->back(); 213 AnimationState *st = ent->getAnimationState("Walk"); 214 215 st->setLoop(true); 216 st->setEnabled(true); 217 218 mApplication->getAnimationStates().push_back(st); 219 mApplication->getAnimationSpeed().push_back(Math::RangeRandom(0.5, 1.5)); 220 } 221 235 222 mLMouseDown = true; 236 223 } … … 271 258 if (mCurrentObject) 272 259 { 260 // apply offset so object is ON terrain 261 queryResult.y += currentObjectTerrainOffsets[mCurrentObjectType]; 262 273 263 mCurrentObject->setPosition(queryResult); 274 264 } … … 292 282 } 293 283 284 for (int i = 0; i < (int)mApplication->getAnimationStates().size(); ++i) 285 { 286 mApplication->getAnimationStates()[i]->addTime(evt.timeSinceLastFrame * 287 mApplication->getAnimationSpeed()[i]); 288 } 289 294 290 if (mDisplayCameraDetails) 295 291 { … … 299 295 } 300 296 301 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly302 mSceneMgr->endFrame();303 304 297 //-- setup what is needed for immediate mouse/key movement 305 298 if (mTimeDelay >= 0) … … 307 300 mTimeDelay -= evt.timeSinceLastFrame; 308 301 } 309 302 310 303 // If this is the first frame, pick a speed 311 304 if (evt.timeSinceLastFrame == 0) … … 387 380 } 388 381 //----------------------------------------------------------------------- 389 void TerrainFrameListener:: ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility,382 void TerrainFrameListener::applyVisibilityQuery(bool fromPoint, bool relativeVisibility, 390 383 bool useItemBuffer) 391 384 { … … 523 516 524 517 // show the results 525 if (!mShowQueryStats )518 if (!mShowQueryStats && !mShowHelp) 526 519 { 527 520 mQueryOverlay->show(); … … 552 545 553 546 updateStats(); 547 548 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 549 mSceneMgr->endFrame(); 550 551 if (mTimeDelay <= 0) // approx. one second 552 mTimeDelay = 1.0; 554 553 555 554 return true; … … 660 659 661 660 //-- initialise frame data 662 m TimeElapsed = 0;661 mReplayTimeElapsed = 0; 663 662 664 663 mCamNode->setPosition(mFrameInfo[0].position); … … 716 715 } 717 716 //----------------------------------------------------------------------- 717 void TerrainFrameListener::setObjectType(int objectType) 718 { 719 if (mCurrentObjectType >= 3) 720 mCurrentObjectType = 0; 721 722 // parameters for new object 723 mTerrainContentGenerator->SetOffset(currentObjectTerrainOffsets[mCurrentObjectType]); 724 Real scale = currentObjectScales[mCurrentObjectType]; 725 mTerrainContentGenerator->SetScale(Vector3(scale, scale, scale)); 726 727 mCurrentObjectTypeInfo->setCaption(": " + 728 mApplication->getCurrentObjectCaption(mCurrentObjectType)); 729 } 730 //----------------------------------------------------------------------- 718 731 void TerrainFrameListener::setAlgorithm(int algorithm) 719 732 { … … 739 752 static String trisString = "Triangle Count: "; 740 753 754 // HACK: compute average fps ourselfs, because ogre avg. fps is wrong 755 // TODO: update only once per second 741 756 mAvgFps += mWindow->getStatistics().lastFPS; 742 757 ++ mFrameCount; … … 755 770 756 771 //guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 757 guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps)); 772 if (mTimeDelay < 0) // only update once per second 773 guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps) + " ms"); 758 774 guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS)); 759 775 guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS) 760 +" "+StringConverter::toString(stats.bestFrameTime) +" ms");776 +" "+StringConverter::toString(stats.bestFrameTime) + " ms"); 761 777 guiWorst->setCaption(worstFpsString + StringConverter::toString(stats.worstFPS) 762 +" "+StringConverter::toString(stats.worstFrameTime) +" ms");778 +" "+StringConverter::toString(stats.worstFrameTime) + " ms"); 763 779 764 780 OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris"); … … 772 788 mFrustumCulledNodesInfo->setCaption(str); 773 789 774 // delay so there is no jump775 mSceneMgr->getOption("NumQueriesIssued", &opt);776 sprintf(str,": %d", (int)opt);777 mQueriesIssuedInfo->setCaption(str);778 779 790 mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 780 791 mQueryCulledNodesInfo->setCaption(str); 781 792 782 mSceneMgr->getOption("NumTraversedNodes", &opt); sprintf(str,": %d", opt);783 mTraversedNodesInfo->setCaption(str);784 785 793 mSceneMgr->getOption("NumHierarchyNodes", &opt); sprintf(str,": %d", opt); 786 794 mHierarchyNodesInfo->setCaption(str); … … 790 798 791 799 sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount()); 792 mObjects Info->setCaption(str);793 794 // delay so there is no jump800 mObjectsCountInfo->setCaption(str); 801 802 // take old value into account in order to create no sudden changes 795 803 mSceneMgr->getOption("NumQueriesIssued", &opt); 796 804 mDelayedQueriesIssued = mDelayedQueriesIssued * 0.8 + (float)opt * 0.2; 797 805 sprintf(str,": %d", (int)mDelayedQueriesIssued); 798 m DelayedQueriesIssuedInfo->setCaption(str);806 mQueriesIssuedInfo->setCaption(str); 799 807 800 808 mSceneMgr->getOption("NumTraversedNodes", &opt); 801 809 mDelayedTraversedNodes = mDelayedTraversedNodes * 0.8 + (float)opt * 0.2; 802 810 sprintf(str,": %d", (int)mDelayedTraversedNodes); 803 m DelayedTraversedNodesInfo->setCaption(str);811 mTraversedNodesInfo->setCaption(str); 804 812 805 813 } … … 815 823 mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 816 824 817 // disable optimization which tests geometry instead of aabb 818 // for delayed rendering (i.e., render transparents after all the solids) 819 // because otherwise visible transparents could be skipped 825 /* disable optimization which tests geometry instead of aabb 826 * for "delayed" rendering of transparents (i.e., render transparents after all the solids) 827 * because otherwise visible transparents could be skipped 828 */ 820 829 bool delayedRendering = !mTestGeometryForVisibleLeaves; 821 830 … … 928 937 void TerrainFrameListener::keyPressed(KeyEvent* e) 929 938 { 939 // hide exact visibility query overlay 940 if (mShowQueryStats) 941 { 942 mQueryOverlay->hide(); 943 mShowQueryStats = false; 944 } 945 930 946 switch(e->getKey()) 931 947 { … … 997 1013 break; 998 1014 case KC_F5: 999 ApplyVisibilityQuery(false, mShiftPressed, mUseItemBuffer);1015 applyVisibilityQuery(false, mShiftPressed, mUseItemBuffer); 1000 1016 break; 1001 1017 case KC_F6: 1002 ApplyVisibilityQuery(true, mShiftPressed, mUseItemBuffer); 1018 applyVisibilityQuery(true, mShiftPressed, mUseItemBuffer); 1019 break; 1020 1021 case KC_F7: 1022 setObjectType(++mCurrentObjectType); 1023 break; 1024 case KC_F8: 1025 mApplication->generateScene(500, mCurrentObjectType); 1003 1026 break; 1004 1027 … … 1018 1041 case KC_LSHIFT: 1019 1042 mShiftPressed = true; 1043 break; 1044 case KC_DELETE: 1045 mTerrainContentGenerator->RemoveGeneratedObjects(); 1046 mApplication->getAnimationStates().clear(); 1047 mApplication->getAnimationSpeed().clear(); 1020 1048 break; 1021 1049 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); … … 1060 1088 { 1061 1089 //-- find current frame relative to elapsed frame time 1062 m TimeElapsed -= timeElapsed;1063 1064 while ((m TimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1))1065 { 1066 m TimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed;1090 mReplayTimeElapsed -= timeElapsed; 1091 1092 while ((mReplayTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1)) 1093 { 1094 mReplayTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed; 1067 1095 } 1068 1096 … … 1075 1103 if (old_frame.timeElapsed > 0) 1076 1104 { 1077 factor = m TimeElapsed / old_frame.timeElapsed;1105 factor = mReplayTimeElapsed / old_frame.timeElapsed; 1078 1106 } 1079 1107 … … 1241 1269 } 1242 1270 } 1271 //----------------------------------------------------------------------- 1272 void TerrainFrameListener::initOverlayElement(OverlayElement **elInfo, String ext, 1273 String name, int top, String caption) 1274 { 1275 OverlayElement *el = 1276 OverlayManager::getSingleton().getOverlayElement(ext + name); 1277 1278 (*elInfo) = OverlayManager::getSingleton().getOverlayElement(ext + name + "Info"); 1279 (*elInfo)->setCaption(caption); 1280 1281 el->setTop(top); 1282 (*elInfo)->setTop(top); 1283 } 1284 //----------------------------------------------------------------------- 1285 void TerrainFrameListener::initHelpOverlayElement(String name, int top) 1286 { 1287 OverlayElement *el = OverlayManager::getSingleton().getOverlayElement( 1288 "Example/Visibility/Help/" + name); 1289 1290 el->setTop(top); 1291 } 1292 //----------------------------------------------------------------------- 1293 void TerrainFrameListener::initHelpOverlay() 1294 { 1295 const int vert_space = 15; 1296 int top = 30; 1297 1298 initHelpOverlayElement("ShowHelp", top); top += vert_space; 1299 initHelpOverlayElement("Stats", top); top += vert_space; 1300 initHelpOverlayElement("AppState", top); top += vert_space; 1301 initHelpOverlayElement("Recorded", top); top += vert_space; 1302 initHelpOverlayElement("Screenshots", top); top += vert_space; 1303 initHelpOverlayElement("WriteOut", top); top += vert_space; 1304 1305 top +=vert_space; 1306 initHelpOverlayElement("SceneDetail", top); top += vert_space; 1307 initHelpOverlayElement("DisplayCameraDetails", top); top += vert_space; 1308 initHelpOverlayElement("DisplayOctree", top); top += vert_space; 1309 initHelpOverlayElement("UseShadows", top); top += vert_space; 1310 initHelpOverlayElement("Filter", top); top += vert_space; 1311 1312 //-- visualization 1313 top += vert_space; 1314 initHelpOverlayElement("VizSection", top); top += vert_space; 1315 initHelpOverlayElement("Viz", top); top += vert_space; 1316 initHelpOverlayElement("NextVizMode", top); top += vert_space; 1317 initHelpOverlayElement("ZoomViz", top); top += vert_space; 1318 1319 1320 //-- visibility queries 1321 top += vert_space; 1322 initHelpOverlayElement("VisQuery", top); top += vert_space; 1323 initHelpOverlayElement("FromCameraQuery", top); top += vert_space; 1324 initHelpOverlayElement("FromPointQuery", top); top += vert_space; 1325 initHelpOverlayElement("QueryType", top); top += vert_space; 1326 initHelpOverlayElement("QueryTarget", top); top += vert_space; 1327 1328 //-- object generation 1329 top += vert_space; 1330 initHelpOverlayElement("SceneObjects", top); top += vert_space; 1331 initHelpOverlayElement("GenerateObjects", top); top += vert_space; 1332 initHelpOverlayElement("RemoveObjects", top); top += vert_space; 1333 initHelpOverlayElement("DropObject", top); top += vert_space; 1334 1335 OverlayElement *helpPanel = OverlayManager::getSingleton().getOverlayElement( 1336 "Example/Visibility/Help/HelpPanel"); 1337 1338 helpPanel->setHeight(top + 10); 1339 } 1340 //----------------------------------------------------------------------- 1341 void TerrainFrameListener::initVisStatsOverlay() 1342 { 1343 const int border_height = 10; 1344 const int vert_space = 15; 1345 1346 //-- visibility culling stats overlay 1347 int top = border_height; 1348 1349 String ext = "Example/Visibility/"; 1350 1351 initOverlayElement(&mAlgorithmInfo, ext, "Algorithm", top, 1352 ": " + currentAlgorithmCaptions[mCurrentAlgorithm]); top += vert_space; 1353 1354 initOverlayElement(&mThresholdInfo, ext, "Threshold", top, ": 0"); top += vert_space; 1355 initOverlayElement(&mTestGeometryForVisibleLeavesInfo, ext, 1356 "TestGeometryForVisibleLeaves", top, ": true"); top += vert_space; 1357 initOverlayElement(&mUseDepthPassInfo, ext, "UseDepthPass", top, ": false"); top += vert_space; 1358 initOverlayElement(&mAssumedVisibilityInfo, ext, "AssumedVisibility", top, ": 0"); top += vert_space; 1359 initOverlayElement(&mCurrentObjectTypeInfo, ext, "CurrentObjectType", top, ": "); top += vert_space; 1360 1361 OverlayElement *optionsPanel = OverlayManager::getSingleton(). 1362 getOverlayElement("Example/Visibility/VisibilityPanel"); 1363 1364 optionsPanel->setHeight(top + border_height); 1365 1366 top = border_height; 1367 //ext = "Example/Visibility/"; 1368 initOverlayElement(&mFrustumCulledNodesInfo, ext, "FrustumCulledNodes", top, ": 0"); top += vert_space; 1369 initOverlayElement(&mQueryCulledNodesInfo, ext, "QueryCulledNodes", top, ": 0"); top += vert_space; 1370 initOverlayElement(&mTraversedNodesInfo, ext, "TraversedNodes", top, ": 0"); top += vert_space; 1371 initOverlayElement(&mHierarchyNodesInfo, ext, "HierarchyNodes", top, ": 0"); top += vert_space; 1372 initOverlayElement(&mRenderedNodesInfo, ext, "RenderedNodes", top, ": 0"); top += vert_space; 1373 initOverlayElement(&mObjectsCountInfo, ext, "ObjectsCount", top, ": 0"); top += vert_space; 1374 initOverlayElement(&mQueriesIssuedInfo, ext, "QueriesIssued", top, ": 0"); top += vert_space; 1375 1376 OverlayElement *visPanel = OverlayManager::getSingleton(). 1377 getOverlayElement("Example/Visibility/VisibilityStatsPanel"); 1378 1379 visPanel->setHeight(top + border_height); 1380 } 1381 //----------------------------------------------------------------------- 1382 void TerrainFrameListener::initQueryOverlay() 1383 { 1384 const int border_height = 10; 1385 const int vert_space = 15; 1386 1387 //-- visibility culling stats overlay 1388 int top = border_height + 25; 1389 1390 String ext = "Example/Visibility/Query/"; 1391 1392 initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top, ": 0"); top += vert_space; 1393 initOverlayElement(&mQueryVisibleGeometryInfo , ext, "VisibleGeometry", top, ": 0"); top += vert_space; 1394 initOverlayElement(&mQueryVisibleNodesInfo , ext, "VisibleNodes", top, ": 0"); top += vert_space; 1395 initOverlayElement(&mQueryVisiblePatchInfo , ext, "VisiblePatches", top, ": 0"); top += vert_space; 1396 initOverlayElement(&mQueryNodeVisibilityInfo , ext, "NodeVisibility", top, ": 0"); top += vert_space; 1397 initOverlayElement(&mQueryGeometryVisibilityInfo , ext, "GeometryVisibility", top, ": 0"); top += vert_space; 1398 initOverlayElement(&mQueryPatchVisibilityInfo , ext, "PatchVisibility", top, ": 0"); top += vert_space; 1399 1400 1401 OverlayElement *queryPanel = OverlayManager::getSingleton(). 1402 getOverlayElement("Example/Visibility/Query/QueryPanel"); 1403 1404 queryPanel->setHeight(top + border_height); 1405 } -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r159 r160 13 13 #include "OgrePlatformQueryManager.h" 14 14 15 class TestCullingTerrainApplication; 16 17 15 18 using namespace Ogre; 16 19 … … 25 28 public: 26 29 27 TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 28 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera, 29 SceneNode *camNode, Light *sunLight); 30 TerrainFrameListener(RenderWindow* win, 31 Camera* cam, 32 SceneManager *sceneManager, 33 CEGUI::Renderer *renderer, 34 TerrainContentGenerator *contentGenerator, 35 Camera *vizCamera, 36 SceneNode *camNode, 37 Light *sunLight, 38 TestCullingTerrainApplication *app); 30 39 31 40 ~TerrainFrameListener(); … … 122 131 @param useItemBuffer if item buffer should be used or occlusion queries 123 132 */ 124 void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer);133 void applyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer); 125 134 126 135 void toggleShowQueryStats(); 127 136 137 /** Sets the type of the objects generated in the scene. 138 */ 139 void setObjectType(int objectType); 140 128 141 protected: 142 143 void initHelpOverlayElement(String name, int top); 144 void initOverlayElement(OverlayElement **elInfo, String ext, String name, int top, String caption); 145 146 //-- initialise overlays 147 void initHelpOverlay(); 148 void initVisStatsOverlay(); 149 void initQueryOverlay(); 129 150 130 151 void resetStats(); … … 162 183 OverlayElement *mUseDepthPassInfo; 163 184 OverlayElement *mRenderedNodesInfo; 164 OverlayElement *mObjects Info;185 OverlayElement *mObjectsCountInfo; 165 186 OverlayElement *mQueriesIssuedInfo; 166 187 OverlayElement *mDelayedQueriesIssuedInfo; 167 188 OverlayElement *mDelayedTraversedNodesInfo; 189 OverlayElement *mCurrentObjectTypeInfo; 168 190 169 191 OverlayElement *mQueryTypeInfo; … … 203 225 std::vector<frame_info> mFrameInfo; 204 226 205 Real m TimeElapsed;227 Real mReplayTimeElapsed; 206 228 //EventProcessor* mEventProcessor; 207 229 InputReader* mInputDevice; … … 211 233 RenderWindow* mWindow; 212 234 213 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;214 235 unsigned int mNumScreenShots; 215 236 int mSceneDetailIndex; … … 248 269 249 270 bool mRenderPatchesForItemBuffer; 271 272 int mCurrentObjectType; 273 274 TestCullingTerrainApplication *mApplication; 250 275 }; 251 276 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r159 r160 15 15 #include <windows.h> 16 16 17 /*******************************************************/ 18 /* TestCullingTerrainApplication implementation */ 19 /*******************************************************/ 17 String currentObjectCaptions[] = 18 { 19 "robot", 20 "athene", 21 "ninja" 22 //"ogrehead" 23 }; 24 25 /*********************************************************/ 26 /* TestCullingTerrainApplication implementation */ 27 /*********************************************************/ 28 29 20 30 TestCullingTerrainApplication::TestCullingTerrainApplication(): 21 31 mTerrainContentGenerator(NULL) … … 30 40 mTerrainContentGenerator = NULL; 31 41 } 32 //if(mRenderTargetListener) delete mRenderTargetListener;33 42 } 34 43 //----------------------------------------------------------------------- … … 127 136 setupGui(); 128 137 129 130 138 /* // occluder plane to test visibility 131 Plane plane; 132 plane.normal = Vector3::UNIT_Y; 133 plane.d = -60; 139 Plane plane; plane.normal = Vector3::UNIT_Y; plane.d = -60; 134 140 MeshManager::getSingleton().createPlane("Myplane", 135 141 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, … … 152 158 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 153 159 154 // if no objects file generate yourself160 // if no objects in file, we generate new objects 155 161 if (!mTerrainContentGenerator->LoadObjects("objects.out")) 156 162 { 157 163 // to provide much occlusion, 158 // height is restricted to 50 , sono objects appear on peaks164 // height is restricted to 50 => no objects appear on peaks 159 165 mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f)); 160 166 mTerrainContentGenerator->SetOffset(0); 161 167 162 // the objects are generated on the whole terrain 163 //mTerrainContentGenerator->GenerateScene(1500, "robot"); 164 mTerrainContentGenerator->GenerateScene(1500, "athene"); 165 //mTerrainContentGenerator->GenerateScene(500, "ninja"); 168 // the objects are generated randomly distributed over the terrain 169 generateScene(1500, 0); 166 170 } 167 171 … … 169 173 // objects also on peaks of terrain 170 174 mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 5000.0f, 3000.0f)); 175 } 176 //----------------------------------------------------------------------- 177 void TestCullingTerrainApplication::generateScene(int num, int objectType) 178 { 179 mTerrainContentGenerator->GenerateScene(num, currentObjectCaptions[objectType]); 180 181 if (objectType != 0) // from our objects, only robot has animation phases 182 return; 183 184 EntityList *entList = mTerrainContentGenerator->GetGeneratedEntities(); 185 186 //-- add animation state for new robots (located at the end of the list) 187 for (int i = entList->size() - num; i < entList->size(); ++i) 188 { 189 Entity *ent = (*entList)[i]; 190 AnimationState *st = ent->getAnimationState("Idle"); 191 st->setEnabled(true); 192 st->setLoop(true); 193 194 mAnimationStates.push_back(st); 195 mAnimationSpeed.push_back(Math::RangeRandom(0.5, 1.5)); 196 } 197 } 198 //----------------------------------------------------------------------- 199 std::vector<AnimationState *> &TestCullingTerrainApplication::getAnimationStates() 200 { 201 return mAnimationStates; 202 } 203 //----------------------------------------------------------------------- 204 std::vector<Real> &TestCullingTerrainApplication::getAnimationSpeed() 205 { 206 return mAnimationSpeed; 171 207 } 172 208 //----------------------------------------------------------------------- … … 189 225 { 190 226 mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 191 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight );227 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this); 192 228 193 229 mRoot->addFrameListener(mTerrainFrameListener); 194 230 } 195 231 //----------------------------------------------------------------------- 232 String TestCullingTerrainApplication::getCurrentObjectCaption(int id) 233 { 234 return currentObjectCaptions[id]; 235 } 236 //----------------------------------------------------------------------- 196 237 void TestCullingTerrainApplication::chooseSceneManager() 197 238 { 198 239 mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 199 240 } 200 201 202 241 /**************************************************************/ 203 242 /* VisualizationRenderTargetListener implementation */ -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r145 r160 25 25 26 26 27 class TestCullingTerrainApplication 27 class TestCullingTerrainApplication: public ExampleApplication 28 28 { 29 29 public: … … 31 31 ~TestCullingTerrainApplication(); 32 32 33 void generateScene(int num, int objectType); 34 35 String getCurrentObjectCaption(int id); 36 37 std::vector<AnimationState *> &getAnimationStates(); 38 std::vector<Real> &getAnimationSpeed(); 39 33 40 protected: 41 34 42 //-- inherited from ExampleApplication 35 43 bool setup(); … … 40 48 41 49 virtual void createRenderTargetListener(); 50 51 std::vector<AnimationState *> mAnimationStates; 52 std::vector<Real> mAnimationSpeed; 42 53 43 54 /** cegui setup */ … … 61 72 TerrainFrameListener *mTerrainFrameListener; 62 73 ColourValue mAmbientLight; 63 //VisualizationRenderTargetListener *mVizRenderTargetListener;64 74 65 75 private: -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
r158 r160 262 262 mWorldAABB = mWorldAABB.intersection(box); 263 263 264 //std::stringstream d; d << "updating box: " << mWorldAABB << ", depth: " << mDepth << "null: " << mBox.isNull();265 //LogManager::getSingleton().logMessage(d.str());266 267 264 // recursively update parent bounds 268 265 if (mParent)
Note: See TracChangeset
for help on using the changeset viewer.