- Timestamp:
- 08/26/05 23:24:31 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 1 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/VisibilityEnvironment.h
r175 r254 13 13 /** Different types of occlusion culling algorithms 14 14 */ 15 enum CullingManagerType { 16 COHERENT_HIERARCHICAL_CULLING, 15 enum CullingManagerType {COHERENT_HIERARCHICAL_CULLING, 17 16 FRUSTUM_CULLING, 18 17 STOP_AND_WAIT_CULLING, -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r187 r254 25 25 unsigned int visiblePixels = 0; 26 26 bool isAvailable = false; 27 //Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling");27 Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling"); 28 28 29 29 //-- PART 1: process finished occlusion queries -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r175 r254 7 7 void FrustumCullingManager::RenderScene() 8 8 { 9 //Ogre::LogManager::getSingleton().logMessage("Frustum Culling");9 Ogre::LogManager::getSingleton().logMessage("Frustum Culling"); 10 10 while (!mHierarchyInterface->GetQueue()->empty()) 11 11 { -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r175 r254 7 7 void StopAndWaitCullingManager::RenderScene() 8 8 { 9 //Ogre::LogManager::getSingleton().logMessage("Stop and Wait Culling");9 Ogre::LogManager::getSingleton().logMessage("Stop and Wait Culling"); 10 10 while (!mHierarchyInterface->GetQueue()->empty()) 11 11 { -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r155 r254 61 61 } 62 62 63 // 63 //-- set threshold 64 64 mCullingManager->SetVisibilityThreshold(mVisibilityThreshold); 65 65 } -
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r202 r254 86 86 void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 87 87 88 void loadVisibilityConfig(const String& filename); 89 88 90 protected: 89 91 … … 123 125 bool mUseDepthPass; 124 126 /// flag indicating if we currently render the depth pass 125 bool m RenderDepthPass;127 bool mIsDepthPassPhase; 126 128 127 129 /// if we use an item buffer for rendering (i.e., object ids as color codes 128 130 bool mUseItemBuffer; 129 131 /// if we currently render the item buffer 130 bool m RenderItemBuffer;132 bool mIsItemBufferPhase; 131 133 132 134 /// if depth write should be enabled -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r202 r254 128 128 /// if we use a depth pass (i.e., fill only the depth buffer in the first pass) 129 129 bool mUseDepthPass; 130 /// if we currently render the depth pass131 bool m RenderDepthPass;130 /// if we currently rendering the depth pass 131 bool mIsDepthPassPhase; 132 132 133 133 /// if we use an item buffer for rendering (i.e., object ids as color codes 134 134 bool mUseItemBuffer; 135 135 /// if we currently render the item buffer 136 bool m RenderItemBuffer;136 bool mIsItemBufferPhase; 137 137 138 138 /// if depth write should be enabled -
trunk/VUT/Ogre/resources/materials/scripts/natFX_Tree1_LOD3.material
r183 r254 204 204 texture_unit 205 205 { 206 texture D:\Profiles\giegl\My Documents\maya\projects\default\sourceimages\_12bb041f_1121354365.png206 texture _12bb041f_1121354365.png 207 207 tex_coord_set 0 208 208 colour_op modulate … … 228 228 texture_unit 229 229 { 230 texture D:\Profiles\giegl\My Documents\maya\projects\default\sourceimages\_12bb041l_1121354365.png230 texture _12bb041l_1121354365.png 231 231 tex_coord_set 0 232 232 colour_op modulate … … 252 252 texture_unit 253 253 { 254 texture D:\Profiles\giegl\My Documents\maya\projects\default\sourceimages\_12bb049f_1121354365.png254 texture _12bb049f_1121354365.png 255 255 tex_coord_set 0 256 256 colour_op modulate … … 276 276 texture_unit 277 277 { 278 texture D:\Profiles\giegl\My Documents\maya\projects\default\sourceimages\_12bb049l_1121354365.png279 tex_coord_set 0 280 colour_op modulate 281 } 282 } 283 } 284 } 285 278 texture _12bb049l_1121354365.png 279 tex_coord_set 0 280 colour_op modulate 281 } 282 } 283 } 284 } 285 -
trunk/VUT/Ogre/resources/overlays/VisibilityDemo.overlay
r183 r254 333 333 caption [F9] Start / End animation 334 334 } 335 element TextArea(Example/Visibility/Help/Video): Example/Visibility/Templates/BasicText 336 { 337 left 5 338 width 180 339 height 30 340 caption [F10] Write out video (i.e., one image per frame) 341 } 335 342 element TextArea(Example/Visibility/Help/Screenshots): Example/Visibility/Templates/BasicText 336 343 { -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r202 r254 9 9 #include <OgreEntity.h> 10 10 #include <OgreSubEntity.h> 11 11 #include <OgreConfigFile.h> 12 12 13 13 namespace Ogre { … … 24 24 mLeavePassesInQueue(0), 25 25 mDelayRenderTransparents(true), 26 //mDelayRenderTransparents(false), 27 //mUseDepthPass(true), 26 28 mUseDepthPass(false), 27 m RenderDepthPass(false),29 mIsDepthPassPhase(false), 28 30 mUseItemBuffer(false), 29 31 //mUseItemBuffer(true), 30 m RenderItemBuffer(false),32 mIsItemBufferPhase(false), 31 33 mCurrentEntityId(1), 32 34 mEnableDepthWrite(true), … … 44 46 // TODO: set maxdepth to reasonable value 45 47 mMaxDepth = 50; 48 49 //loadVisibilityConfig("GtpVisibility.cfg"); 46 50 } 47 51 //----------------------------------------------------------------------- … … 145 149 { 146 150 // set depth fill pass if we currently do not make an aabb occlusion query 147 Pass *usedPass = (m RenderDepthPass&& !mHierarchyInterface->IsBoundingBoxQuery() ?151 Pass *usedPass = (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery() ? 148 152 mDepthPass : pass); 149 153 … … 152 156 // set illumination stage to NONE so no shadow material is used 153 157 // for depth pass or for occlusion query 154 if (m RenderDepthPass|| mHierarchyInterface->IsBoundingBoxQuery())158 if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 155 159 { 156 160 mIlluminationStage = IRS_NONE; … … 158 162 159 163 //-- set vertex program of current pass in order to set correct depth 160 if (m RenderDepthPass&& mExecuteVertexProgramForAllPasses && pass->hasVertexProgram())164 if (mIsDepthPassPhase && mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 161 165 { 162 166 // add vertex program of current pass to depth pass … … 311 315 312 316 //-- reset parameters 313 m RenderDepthPass= false;314 m RenderItemBuffer= false;317 mIsDepthPassPhase = false; 318 mIsItemBufferPhase = false; 315 319 mSkipTransparents = false; 316 320 mIsHierarchicalCulling = false; … … 498 502 { 499 503 // skip all but first pass if we are doing the depth pass 500 if ((m RenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0)504 if ((mIsDepthPassPhase || mIsItemBufferPhase) && pass->getIndex() > 0) 501 505 { 502 506 return false; … … 507 511 void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 508 512 { 509 if (!m RenderItemBuffer)513 if (!mIsItemBufferPhase) 510 514 { 511 515 OctreeSceneManager::renderQueueGroupObjects(pGroup); … … 513 517 } 514 518 515 // ---item buffer519 //-- renders item buffer 516 520 517 521 // Iterate through priorities … … 559 563 } 560 564 561 // 565 //-- TRANSPARENT LOOP: must be handled differently 562 566 563 567 // transparents are treated either as solids or completely discarded … … 637 641 638 642 // set depth pass flag before rendering 639 m RenderDepthPass= mUseDepthPass;643 mIsDepthPassPhase = mUseDepthPass; 640 644 641 645 mIsHierarchicalCulling = true; // during hierarchical culling … … 644 648 if (mUseItemBuffer) 645 649 { 646 m RenderItemBuffer= true;650 mIsItemBufferPhase = true; 647 651 setAmbientLight(ColourValue(1,1,1,1)); 648 652 } … … 739 743 } 740 744 } 741 else 745 else // render the rest of the passes 742 746 { 743 747 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup); 744 745 /*RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();746 LightList lightList;747 748 while (groupIt.hasMoreElements())749 {750 751 RenderPriorityGroup* pPriorityGrp = groupIt.getNext();752 753 // Sort the queue first754 pPriorityGrp->sort(mCameraInProgress);755 756 // Clear light list757 lightList.clear();758 759 // Now iterate per light760 mIlluminationStage = IRS_PER_LIGHT;761 762 // Iterate over lights, render all volumes to stencil763 LightList::const_iterator li, liend;764 liend = mLightsAffectingFrustum.end();765 766 for (li = mLightsAffectingFrustum.begin(); li != liend; ++li)767 {768 LogManager::getSingleton().logMessage("iterating over lights");769 Light* l = *li;770 // Set light state771 772 if (l->getCastShadows())773 {774 // Clear stencil775 mDestRenderSystem->clearFrameBuffer(FBT_STENCIL);776 renderShadowVolumesToStencil(l, mCameraInProgress);777 // turn stencil check on778 mDestRenderSystem->setStencilCheckEnabled(true);779 // NB we render where the stencil is equal to zero to render lit areas780 mDestRenderSystem->setStencilBufferParams(CMPF_EQUAL, 0);781 }782 783 // render lighting passes for this light784 if (lightList.empty())785 lightList.push_back(l);786 else787 lightList[0] = l;788 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesDiffuseSpecular(), false, &lightList);789 790 // Reset stencil params791 mDestRenderSystem->setStencilBufferParams();792 mDestRenderSystem->setStencilCheckEnabled(false);793 mDestRenderSystem->_setDepthBufferParams();794 795 }// for each light796 797 // Now render decal passes, no need to set lights as lighting will be disabled798 mIlluminationStage = IRS_DECAL;799 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesDecal(), false);800 }// for each priority801 802 // reset lighting stage803 mIlluminationStage = IRS_NONE;*/804 748 } 805 749 } … … 828 772 } 829 773 } 830 } // namespace Ogre 774 //------------------------------------------------------------------------- 775 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename) 776 { 777 /// Set up the options 778 ConfigFile config; 779 String val; 780 781 config.load(filename); 782 783 val = config.getSetting("Algorithm"); 784 785 if (!val.empty()) 786 { 787 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str()); 788 } 789 790 val = config.getSetting("UseDepthPass"); 791 792 if (!val.empty()) 793 { 794 setOption("UseDepthPass", val.c_str()); 795 } 796 } 797 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r187 r254 15 15 if (key == "Algorithm") 16 16 { 17 // delete old queries (not needed for e.g., view frustum culling) 17 18 mHierarchyInterface->DeleteQueries(); 18 19 mVisibilityManager->SetCullingManager(*static_cast<const -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r202 r254 24 24 mDelayRenderTransparents(true), 25 25 mUseDepthPass(false), 26 m RenderDepthPass(false),26 mIsDepthPassPhase(false), 27 27 mUseItemBuffer(false), 28 28 //mUseItemBuffer(true), 29 m RenderItemBuffer(false),29 mIsItemBufferPhase(false), 30 30 mCurrentEntityId(1), 31 31 mEnableDepthWrite(true), … … 147 147 { 148 148 // TODO: setting vertex program is not efficient 149 //Pass *usedPass = ((m RenderDepthPass&& !pass->hasVertexProgram()) ? mDepthPass : pass);149 //Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass); 150 150 151 151 // set depth fill pass if we currently do not make an aabb occlusion query 152 Pass *usedPass = (m RenderDepthPass&& !mHierarchyInterface->IsBoundingBoxQuery() ?152 Pass *usedPass = (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery() ? 153 153 mDepthPass : pass); 154 154 … … 157 157 // set illumination stage to NONE so no shadow material is used 158 158 // for depth pass or for occlusion query 159 if (m RenderDepthPass|| mHierarchyInterface->IsBoundingBoxQuery())159 if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 160 160 { 161 161 mIlluminationStage = IRS_NONE; … … 163 163 164 164 // --- set vertex program of current pass in order to set correct depth 165 if (mExecuteVertexProgramForAllPasses && m RenderDepthPass&& pass->hasVertexProgram())165 if (mExecuteVertexProgramForAllPasses && mIsDepthPassPhase && pass->hasVertexProgram()) 166 166 { 167 167 // add vertex program of current pass to depth pass … … 315 315 316 316 //-- reset parameters 317 m RenderDepthPass= false;318 m RenderItemBuffer= false;317 mIsDepthPassPhase = false; 318 mIsItemBufferPhase = false; 319 319 mSkipTransparents = false; 320 320 mLeavePassesInQueue = 0; … … 501 501 { 502 502 // skip all but first pass if we are doing the depth pass 503 if ((m RenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0)503 if ((mIsDepthPassPhase || mIsItemBufferPhase) && pass->getIndex() > 0) 504 504 { 505 505 return false; … … 510 510 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 511 511 { 512 if (!m RenderItemBuffer)512 if (!mIsItemBufferPhase) 513 513 { 514 514 TerrainSceneManager::renderQueueGroupObjects(pGroup); … … 640 640 641 641 // set depth pass flag before rendering 642 m RenderDepthPass= mUseDepthPass;642 mIsDepthPassPhase = mUseDepthPass; 643 643 644 644 // item buffer needs full ambient lighting to use item colors as unique id 645 645 if (mUseItemBuffer) 646 646 { 647 m RenderItemBuffer= true;647 mIsItemBufferPhase = true; 648 648 setAmbientLight(ColourValue(1,1,1,1)); 649 649 } -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r160 r254 20 20 21 21 22 /*********************************************** /23 /* TestCullingApplication implementation */24 /*********************************************** /22 /***************************************************/ 23 /* TestCullingApplication implementation */ 24 /***************************************************/ 25 25 26 26 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r160 r254 17 17 } 18 18 19 String mCurrentAlgorithmCaptions[ GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =19 String mCurrentAlgorithmCaptions[] = 20 20 { 21 21 "View Frustum Culling", -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r187 r254 70 70 // output file for object positions / orientations 71 71 const char* objects_out_filename = "objects.out"; 72 72 73 std::ofstream video_out("video.lst"); 73 74 74 75 //----------------------------------------------------------------------- … … 117 118 mShowVisualization(false), 118 119 mCullCamera(false), 119 mRecord (false),120 mRecordFrames(false), 120 121 mShowShadows(false), 121 122 mShowHelp(false), … … 134 135 mDeleteObjects(false), 135 136 mUseItemBuffer(false), 136 mItemBufferMode(GtpVisibility::QueryManager::PATCH_VISIBILITY) 137 mItemBufferMode(GtpVisibility::QueryManager::PATCH_VISIBILITY), 138 mRecordVideo(false), 139 mPureRenderTimeFps(0.0), 140 mNumVideoFrames(0), 141 mDemoFps(0), 142 mUseDemoFps(false) 137 143 { 138 144 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 159 165 160 166 initVisStatsOverlay(); // visibility stats overlay 161 initHelpOverlay(); // help overlay162 initQueryOverlay(); // visibility query stats overlay167 initHelpOverlay(); // help overlay 168 initQueryOverlay(); // visibility query stats overlay 163 169 164 170 // show stats overlays … … 179 185 setObjectType(mCurrentObjectType); 180 186 187 // initialise timer 188 mTimer = Root::getSingleton().getTimer(); 189 mTimeFrameEnded = mTimeFrameStarted = mTimer->getMilliseconds(); 190 181 191 // reset statistics 182 192 resetStats(); … … 356 366 { return false; }*/ 357 367 358 // --- set parameters for visualization368 //-- set parameters for visualization 359 369 if (mShowVisualization) 360 370 { … … 362 372 mSceneMgr->setOption("ShowOctree", &mShowVisualization); 363 373 364 // ---- setup visualization camera374 //-- setup visualization camera 365 375 366 376 mVizCamera->setPosition(0, 0, 0); … … 380 390 mVizCamera->moveRelative(Vector3(0, 800, 0)); 381 391 } 392 else 393 { 394 // frame start time 395 mTimeFrameStarted = mTimer->getMilliseconds(); 396 //Ogre::LogManager::getSingleton().logMessage("Frame started"); 397 } 382 398 383 399 //-- set application state … … 385 401 { 386 402 case REPLAY: 403 /// set the current camera data to loaded frame information 387 404 setCurrentFrameInfo(evt.timeSinceLastFrame); 405 // HACK to produce demo 406 addFrameInfo(mSavedFrameInfo, mCamNode, evt.timeSinceLastFrame); 388 407 break; 389 408 case WALKTHROUGH: 390 //-- if we are recording camera status per frame391 if (mRecord )409 //-- recording the camera settings per frame 410 if (mRecordFrames) 392 411 { 393 addFrameInfo(m CamNode, evt.timeSinceLastFrame);412 addFrameInfo(mFrameInfo, mCamNode, evt.timeSinceLastFrame); 394 413 // print recording message 395 414 mWindow->setDebugText("Recording frame " + … … 573 592 return false; 574 593 594 // timer end time 595 if (!mShowVisualization) 596 { 597 mTimeFrameEnded = mTimer->getMilliseconds(); 598 //Ogre::LogManager::getSingleton().logMessage("Frame ended"); 599 } 600 575 601 updateStats(); 576 602 603 if (mRecordVideo) // record current frame 604 { 605 //Ogre::LogManager::getSingleton().logMessage("taking video frame"); 606 takeVideoFrame(video_out); 607 //Ogre::LogManager::getSingleton().logMessage("finished"); 608 } 577 609 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 578 610 mSceneMgr->endFrame(); 579 611 580 if (mTimeDelay <= 0) // approx. one second612 if (mTimeDelay <= 0) // simulates approx. one second 581 613 mTimeDelay = 1.0; 582 614 … … 603 635 ofstr << StringConverter::toString((*it).position) << " " 604 636 << StringConverter::toString((*it).orientation) << " " 605 << StringConverter::toString((*it).timeElapsed) << "\n"; 637 << StringConverter::toString((*it).timeElapsed) << " " 638 << StringConverter::toString((*it).fps) << "\n"; 639 } 640 ofstr.close(); 641 } 642 // quick hack 643 void TerrainFrameListener::writeNewFrameInfo() 644 { 645 std::ofstream ofstr("newframe.out"); 646 647 std::vector<frame_info>::const_iterator it, it_end; 648 649 it_end = mSavedFrameInfo.end(); 650 for (it = mSavedFrameInfo.begin(); it < it_end; ++it) 651 { 652 ofstr << StringConverter::toString((*it).position) << " " 653 << StringConverter::toString((*it).orientation) << " " 654 << StringConverter::toString((*it).timeElapsed) << " " 655 << StringConverter::toString((*it).fps) << "\n"; 606 656 } 607 657 ofstr.close(); … … 621 671 { 622 672 ifstr.getline(line, 256); 623 sscanf(line, "%f %f %f %f %f %f %f %f ", &info.position.x, &info.position.y, &info.position.z,673 sscanf(line, "%f %f %f %f %f %f %f %f %f", &info.position.x, &info.position.y, &info.position.z, 624 674 &info.orientation.w, &info.orientation.x, &info.orientation.y, &info.orientation.z, 625 &info.timeElapsed );675 &info.timeElapsed, &info.fps); 626 676 627 677 mFrameInfo.push_back(info); … … 636 686 { 637 687 mCurrentFrame = 0; 688 int lastState = mAppState; 689 690 // transition to the next state 691 mAppState = (mAppState + 1) % STATE_NUM; 638 692 639 693 // if last state was replay state 640 if ( mAppState == REPLAY)641 { 642 // reset debug text and write frame info to file 694 if (lastState == REPLAY) 695 { 696 // reset debug text 643 697 mWindow->setDebugText(""); 644 writeFrames(); 645 698 699 // hack for producing demo 700 writeNewFrameInfo(); 701 mSavedFrameInfo.clear(); 702 646 703 float avgFps = (float)mAvgFps / (float)mFrameCount; 647 704 … … 659 716 } 660 717 661 //-- set the next státe662 mAppState = (mAppState + 1) % STATE_NUM;663 664 718 // replay recorded walkthrough 665 719 if (mAppState == REPLAY) 666 720 { 667 721 // no recording during replay 668 mRecord = false;669 670 // load recorded walkthrough 722 mRecordFrames = false; mWindow->setDebugText(""); 723 724 // load recorded walkthrough from disk 671 725 if (mFrameInfo.size() == 0) 672 726 { 673 727 loadFrames(); 674 728 } 675 729 676 730 // if there are no recorded frames => set next state 677 731 if (mFrameInfo.size() == 0) … … 679 733 nextAppState(); 680 734 } 681 else 735 else // replay 682 736 { 683 737 mWindow->setDebugText("Replay"); … … 699 753 void TerrainFrameListener::toggleRecord() 700 754 { 701 mRecord = !mRecord; 702 703 // clear previous camera path 704 if (mRecord) 755 mRecordFrames = !mRecordFrames; 756 757 if (mRecordFrames) 758 { 759 // starting new recording => clear old frame info 705 760 mFrameInfo.clear(); 761 } 706 762 else 763 { 764 writeFrames(); // write frame info to file 707 765 mWindow->setDebugText(""); 766 } 708 767 } 709 768 //----------------------------------------------------------------------- … … 711 770 { 712 771 mVisibilityThreshold += incr; 713 if(mVisibilityThreshold < 0) mVisibilityThreshold = 0; 714 772 773 if (mVisibilityThreshold < 0) 774 { 775 mVisibilityThreshold = 0; 776 } 777 715 778 char str[100]; sprintf(str,": %d", mVisibilityThreshold); 716 779 … … 722 785 { 723 786 mAssumedVisibility += incr; 724 if(mAssumedVisibility < 0) mAssumedVisibility = 0; 725 787 788 if (mAssumedVisibility < 0) 789 { 790 mAssumedVisibility = 0; 791 } 792 726 793 char str[100]; sprintf(str,": %d", mAssumedVisibility); 727 794 … … 739 806 { 740 807 mCurrentAlgorithm = (mCurrentAlgorithm + 1) % 741 (GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS - 1);808 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 742 809 setAlgorithm(mCurrentAlgorithm); 743 810 } … … 745 812 void TerrainFrameListener::setObjectType(int objectType) 746 813 { 747 if (mCurrentObjectType >= 3) 814 if (mCurrentObjectType >= 3) // TODO: define a constant 748 815 mCurrentObjectType = 0; 749 816 … … 779 846 static String trisString = "Triangle Count: "; 780 847 848 int currentFps = mWindow->getStatistics().lastFPS; 849 850 if (mUseDemoFps) 851 currentFps = mDemoFps; 852 #if 0 853 // HACK: take pure rendering time, only measures the render call 854 long pureRenderTime = mTimeFrameEnded - mTimeFrameStarted; 855 856 if (pureRenderTime) 857 { 858 mPureRenderTimeFps = 1000.0 / (float) pureRenderTime; 859 } 860 currentFps = mPureRenderRenderTimeFps; 861 //std::stringstream d; d << "Pure render time fps: " << mPureRenderTimeFps << "\n"; 862 //Ogre::LogManager::getSingleton().logMessage(d.str()); 863 #endif 864 781 865 // HACK: compute average fps ourselfs, because ogre avg. fps is wrong 782 866 // TODO: update only once per second 783 mAvgFps += mWindow->getStatistics().lastFPS; 784 ++ mFrameCount; 785 786 float avgFps = (float)mAvgFps / (float)mFrameCount; 787 867 mAvgFps += currentFps; 868 float avgFps = (float)mAvgFps / (float)(mFrameCount++); 869 788 870 // update stats when necessary 789 871 try … … 796 878 const RenderTarget::FrameStats& stats = mWindow->getStatistics(); 797 879 798 // guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));799 if (mTimeDelay < 0) // only update once per second880 // HACK: take newly computed avg. fps instead of Ogre avg fps and update only once per second 881 if (mTimeDelay < 0) 800 882 { 801 883 guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps) + " ms"); 884 //guiCurr->setCaption(currFpsString + StringConverter::toString(currentFps)); 802 885 } 803 804 guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS)); 886 //guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 887 guiCurr->setCaption(currFpsString + StringConverter::toString(currentFps)); 888 889 805 890 guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS) 806 891 +" "+StringConverter::toString(stats.bestFrameTime) + " ms"); … … 1039 1124 break; 1040 1125 case KC_F2: 1041 toggleShowStats(); 1126 mStatsOn = !mStatsOn; 1127 showStats(mStatsOn); 1042 1128 break; 1043 1129 case KC_F3: … … 1063 1149 mUseAnimation = !mUseAnimation; 1064 1150 break; 1151 1152 case KC_F10: 1153 mRecordVideo = !mRecordVideo; 1154 1065 1155 case KC_F11: 1066 1156 takeScreenshot(); … … 1081 1171 case KC_DELETE: 1082 1172 mDeleteObjects = true; 1173 break; 1174 case KC_M: // hack 1175 mUseDemoFps = !mUseDemoFps; 1083 1176 break; 1084 1177 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); … … 1110 1203 } 1111 1204 //----------------------------------------------------------------------- 1112 void TerrainFrameListener::addFrameInfo( SceneNode *camNode, Real timeElapsed)1205 void TerrainFrameListener::addFrameInfo(FrameInfoContainer &frameInfos, SceneNode *camNode, Real timeElapsed) 1113 1206 { 1114 1207 frame_info info; 1208 1115 1209 info.orientation = mCamNode->getOrientation(); 1116 1210 info.position = mCamNode->getPosition(); 1117 1211 info.timeElapsed = timeElapsed; 1118 1119 mFrameInfo.push_back(info); 1212 info.fps = mWindow->getStatistics().lastFPS; 1213 1214 frameInfos.push_back(info); 1120 1215 } 1121 1216 //----------------------------------------------------------------------- … … 1124 1219 //-- find current frame relative to elapsed frame time 1125 1220 mReplayTimeElapsed -= timeElapsed; 1126 1221 1127 1222 while ((mReplayTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1)) 1128 1223 { … … 1130 1225 } 1131 1226 1132 frame_info new_frame = mFrameInfo[mCurrentFrame]; 1227 1228 // TODO: crashes here if recording / replaying on the same time!! 1229 frame_info new_frame = mFrameInfo[mCurrentFrame]; 1133 1230 frame_info old_frame = mFrameInfo[mCurrentFrame - 1]; 1134 1231 … … 1143 1240 Vector3 camPos = old_frame.position + factor 1144 1241 * (new_frame.position - old_frame.position); 1242 1243 // interpolate the orientation 1145 1244 Quaternion camOrienation = Quaternion::Slerp(factor, old_frame.orientation, 1146 1245 new_frame.orientation, true); 1147 1246 1247 // HACK: interpolate fps 1248 mDemoFps = old_frame.fps + factor * (new_frame.fps -old_frame.fps); 1249 1148 1250 mCamNode->setPosition(camPos); 1149 1251 mCamNode->setOrientation(camOrienation); 1150 1252 1151 // stop replay after afull walkthrough1253 // stop replaying after one full walkthrough 1152 1254 if (mCurrentFrame == (int)mFrameInfo.size() - 1) 1153 1255 { … … 1249 1351 } 1250 1352 //----------------------------------------------------------------------- 1353 void TerrainFrameListener::takeVideoFrame(std::ofstream &ofstr) 1354 { 1355 char name[50]; 1356 1357 sprintf(name, "frame_%05d.tga", ++mNumVideoFrames); 1358 mWindow->writeContentsToFile(name); 1359 //mWindow->setDebugText(String("Wrote ") + name); 1360 1361 ofstr << name << "\n"; 1362 } 1363 //----------------------------------------------------------------------- 1251 1364 void TerrainFrameListener::takeScreenshot() 1252 1365 { 1253 char tmp[20]; 1254 sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots); 1255 mWindow->writeContentsToFile(tmp); 1256 mWindow->setDebugText(String("Wrote ") + tmp); 1366 char name[50]; 1367 1368 sprintf(name, "screenshot_%05d.png", ++mNumScreenShots); 1369 mWindow->writeContentsToFile(name); 1370 //mWindow->setDebugText(String("Wrote ") + name); 1257 1371 } 1258 1372 //----------------------------------------------------------------------- … … 1283 1397 } 1284 1398 } 1285 //----------------------------------------------------------------------- 1286 void TerrainFrameListener::toggleShowStats() 1287 { 1288 mStatsOn = !mStatsOn; 1289 1290 showStats(mStatsOn); 1291 } 1399 1292 1400 //----------------------------------------------------------------------- 1293 1401 void TerrainFrameListener::toggleShowHelp() … … 1336 1444 initHelpOverlayElement("Recorded", top); top += vert_space; 1337 1445 initHelpOverlayElement("Animation", top); top += vert_space; 1446 initHelpOverlayElement("Video", top); top += vert_space; 1338 1447 initHelpOverlayElement("Screenshots", top); top += vert_space; 1339 1448 initHelpOverlayElement("WriteOut", top); top += vert_space; 1449 1340 1450 1341 1451 top +=vert_space; -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r187 r254 20 20 21 21 22 22 23 /** Frame listener specialised for terrains. 23 24 */ … … 75 76 Quaternion orientation; 76 77 Real timeElapsed; 78 Real fps; 77 79 } frame_info; 80 81 typedef std::vector<frame_info> FrameInfoContainer; 78 82 79 83 enum {WALKTHROUGH, REPLAY, STATE_NUM}; … … 85 89 void zoomVizCamera(int zoom); 86 90 87 void addFrameInfo( SceneNode *camNode, Real timeElapsed);91 void addFrameInfo(FrameInfoContainer &frameInfos, SceneNode *camNode, Real timeElapsed); 88 92 void setCurrentFrameInfo(Real timeElapsed); 89 93 … … 95 99 void loadFrames(); 96 100 97 98 // Constructor takes a RenderWindow because it uses that to determine input context 99 //ExampleFrameListener(RenderWindow* win, Camera* cam, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false) 101 // quick hack 102 void writeNewFrameInfo(); 100 103 101 104 bool processUnbufferedKeyInput(const FrameEvent& evt); 102 105 bool processUnbufferedMouseInput(const FrameEvent& evt); 103 106 107 /** Shows the frame / algorithm statistics. 108 */ 104 109 void showStats(bool show); 105 110 111 /** Updates frame statistics and the frame statistics display. 112 */ 106 113 void updateStats(); 107 114 115 /** Toggles wether help screen is shown or not. 116 */ 108 117 void toggleShowHelp(); 109 void toggleShowStats(); 110 118 119 /** Toggles wether shadows are shown or not. 120 */ 111 121 void toggleShowShadows(); 112 122 void toggleDisplayCameraDetails(); 123 /** Takes screenshot of the current scene. 124 */ 113 125 void takeScreenshot(); 126 /** Takes one video frame. 127 */ 128 void takeVideoFrame(std::ofstream &ofstr); 129 114 130 void nextSceneDetailLevel(); 115 131 void nextFilter(); … … 120 136 void changeAssumedVisibility(int incr); 121 137 void setTestGeometryForVisibleLeaves(bool testGeometryForVisibleLeaves); 138 /** Shows octree hierarchy of the scene. 139 */ 122 140 void toggleShowOctree(); 141 /** Toggles wether we use the initial depth pass. 142 */ 123 143 void toggleUseDepthPass(); 144 /** Toggles wether the visualization is shown. 145 */ 124 146 void toggleShowViz(); 147 /** Toggles wether the frames are recorded. 148 */ 125 149 void toggleRecord(); 126 150 … … 134 158 void applyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer); 135 159 160 /** Shows result from visibility queries. 161 */ 136 162 void toggleShowQueryStats(); 137 163 … … 168 194 int mVisibilityThreshold; 169 195 int mAssumedVisibility; 170 // the current frame number196 /// the current frame number 171 197 int mCurrentFrame; 172 // the current application state198 /// the current application state 173 199 int mAppState; 174 // The number of objects on the screen200 /// The number of objects on the screen 175 201 int mObjectCount; 176 // visualization mode202 /// visualization mode 177 203 int mNodeVizMode; 178 179 SceneNode *mCurrentObject; // the newly created object 180 204 /// number of video frames 205 int mNumVideoFrames; 206 /// the newly created object 207 SceneNode *mCurrentObject; 208 /// HACK 209 float mDemoFps; 210 bool mUseDemoFps; 181 211 OverlayElement *mAlgorithmInfo; 182 212 OverlayElement *mThresholdInfo; … … 214 244 bool mShowVisualization; 215 245 bool mCullCamera; 216 bool mRecord ;246 bool mRecordFrames; 217 247 bool mShowShadows; 218 248 bool mVisualizeCulledNodes; … … 232 262 SceneNode *mCamNode; 233 263 234 //std::deque<Vector3> mWalkList; // The list of points we are walking to 235 std::vector<frame_info> mFrameInfo; 236 264 /// Per frame data stored for a walkthrough 265 FrameInfoContainer mFrameInfo; 266 /// HACK: for demo 267 FrameInfoContainer mSavedFrameInfo; 268 237 269 Real mReplayTimeElapsed; 238 270 //EventProcessor* mEventProcessor; … … 282 314 283 315 bool mDeleteObjects; 284 316 bool mRecordVideo; 317 318 Timer *mTimer; 319 long mTimeFrameEnded; 320 long mTimeFrameStarted; 321 float mPureRenderTimeFps; 285 322 TestCullingTerrainApplication *mApplication; 286 323 }; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r187 r254 305 305 { 306 306 // the objects are generated randomly distributed over the terrain 307 generateScene(900, 0); 307 generateScene(900, 0); // create soldiers, trees, ninjas 308 308 generateScene(500, 1); 309 309 generateScene(100, 2); -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r183 r254 157 157 Vector3 mTerrainMaxPos; 158 158 159 160 159 private: 161 160 void chooseSceneManager(void); -
trunk/VUT/work/iv/IVFrameListener.cpp
r187 r254 66 66 mShowVisualization(false), 67 67 mCullCamera(false), 68 mRecord (false),68 mRecordFrames(false), 69 69 mShowShadows(false), 70 70 mShowHelp(false), … … 288 288 case WALKTHROUGH: 289 289 //-- if we are recording camera status per frame 290 if (mRecord )290 if (mRecordFrames) 291 291 { 292 292 addFrameInfo(mCamNode, evt.timeSinceLastFrame); … … 442 442 { 443 443 // no recording during replay 444 mRecord = false;444 mRecordFrames = false; 445 445 446 446 // load recorded walkthrough … … 475 475 void IVFrameListener::toggleRecord() 476 476 { 477 mRecord = !mRecord;477 mRecordFrames = !mRecordFrames; 478 478 479 479 // clear previous camera path 480 if (mRecord )480 if (mRecordFrames) 481 481 mFrameInfo.clear(); 482 482 else … … 834 834 info.position = mCamNode->getPosition(); 835 835 info.timeElapsed = timeElapsed; 836 836 837 837 mFrameInfo.push_back(info); 838 838 } -
trunk/VUT/work/iv/IVFrameListener.h
r187 r254 182 182 bool mShowVisualization; 183 183 bool mCullCamera; 184 bool mRecord ;184 bool mRecordFrames; 185 185 bool mShowShadows; 186 186 bool mVisualizeCulledNodes;
Note: See TracChangeset
for help on using the changeset viewer.