- Timestamp:
- 07/13/05 18:28:40 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreOcclusionQueriesQueryManager.h
r171 r173 68 68 void RemoveDuplicateNodes(InfoContainer<GtpVisibility::NodeInfo> *visibleNodes); 69 69 void RemoveDuplicateGeometry(InfoContainer<GtpVisibility::MeshInfo> *visibleMesh); 70 void RemoveDuplicatePatches(InfoContainer<GtpVisibility::PatchInfo> *visiblePatches); 70 71 71 72 bool mUseItemBuffer; -
trunk/VUT/Ogre/include/OgrePlatformQueryManager.h
r171 r173 45 45 protected: 46 46 47 void CollectItemBufferResults( 48 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 49 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches); 50 47 51 void InitItemBuffer(InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 48 52 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches); -
trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp
r171 r173 22 22 } 23 23 //----------------------------------------------------------------------- 24 inline bool patchinfo_eq(const GtpVisibility::PatchInfo &info1, const GtpVisibility::PatchInfo &info2) 25 { 26 return info1.GetPatch() == info2.GetPatch(); 27 } 28 //----------------------------------------------------------------------- 24 29 inline bool nodeinfo_lower(const GtpVisibility::NodeInfo &info1, const GtpVisibility::NodeInfo &info2) 25 30 { … … 31 36 return info1.GetMesh() < info2.GetMesh(); 32 37 } 33 38 //----------------------------------------------------------------------- 39 inline bool patchinfo_lower(const GtpVisibility::PatchInfo &info1, const GtpVisibility::PatchInfo &info2) 40 { 41 return info1.GetPatch() < info2.GetPatch(); 42 } 34 43 35 44 … … 100 109 GtpVisibility::GeometryList::iterator geometryIt, geometryIt_end = geometryList.end(); 101 110 111 // vector for storing subentities of meshes 112 GtpVisibility::PatchList patchList; 113 GtpVisibility::PatchList::iterator patchIt, patchIt_end = patchList.end(); 102 114 103 115 // to obtain the correct number of projected pixels, depth write must be disabled … … 128 140 129 141 //-- queries for geometry: if item buffer, capture only projected visibility 142 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt) 143 { 144 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*geometryIt)); 145 } 146 147 //-- queries for patches: if item buffer, capture only projected visibility 130 148 if (!(mUseItemBuffer && (i == 0))) 131 149 { 132 for ( geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt)150 for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt) 133 151 { 134 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(* geometryIt));152 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*patchIt)); 135 153 } 136 154 } … … 150 168 if (relativeVisibility) 151 169 { 152 CollectRelative GeometryVisibilityForItemBuffer(projQueryIt, &geometryList, visibleGeometry);170 CollectRelativePatchVisibilityForItemBuffer(projQueryIt, &patchList, visiblePatches); 153 171 } 154 172 } 155 173 else 156 174 { 157 CollectGeometryVisibility(visQueryIt, projQueryIt, &geometryList, 158 visibleGeometry, relativeVisibility); 159 //CollectPatchVisibility(patchList, visiblePatches); 160 } 161 162 175 CollectPatchVisibility(visQueryIt, projQueryIt, &patchList, visiblePatches, relativeVisibility); 176 } 177 178 CollectGeometryVisibility(visQueryIt, projQueryIt, &geometryList, visibleGeometry, relativeVisibility); 179 163 180 //-- reset options 164 181 enableDepthWrite = true; … … 397 414 meshinfo_eq), visibleGeometry->end()); 398 415 } 399 416 //----------------------------------------------------------------------- 417 void OcclusionQueriesQueryManager::RemoveDuplicatePatches( 418 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches) 419 { 420 sort(visiblePatches->begin(), visiblePatches->end(), patchinfo_lower); 421 422 InfoContainer<GtpVisibility::PatchInfo>::iterator visiblePatchIt, 423 visiblePatchIt_end = visiblePatches->end(); 424 425 GtpVisibility::PatchInfo *patchInfo = NULL; 426 427 for (visiblePatchIt = visiblePatches->begin(); visiblePatchIt != visiblePatchIt_end; 428 ++visiblePatchIt) 429 { 430 if (!patchInfo || (patchInfo->GetPatch() != (*visiblePatchIt).GetPatch())) 431 { 432 patchInfo = &(*visiblePatchIt); 433 } 434 else // info points to same mesh, just add visibility 435 { 436 patchInfo->AddVisibility(*visiblePatchIt); 437 } 438 } 439 440 // physically delete duplicates 441 visiblePatches->erase(std::unique(visiblePatches->begin(), visiblePatches->end(), 442 patchinfo_eq), visiblePatches->end()); 443 } 400 444 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
r171 r173 16 16 mViewport(vp), 17 17 mWasInitialised(false), 18 mRenderPatches( false)18 mRenderPatches(renderPatches) 19 19 { 20 20 } … … 125 125 126 126 //-- collect results 127 127 CollectItemBufferResults(visibleGeometry, visiblePatches); 128 129 //-- reset options 130 131 useItemBuffer = false; // don't need item buffer anymore 132 sm->setOption("UseItemBuffer", &useItemBuffer); 133 134 mWasInitialised = false; // reset initialised - flag 135 mViewport->setOverlaysEnabled(overlayEnabled); // reset old overlay status 136 mViewport->setBackgroundColour(bg); // reset background color 137 } 138 //----------------------------------------------------------------------- 139 void PlatformQueryManager::CollectItemBufferResults( 140 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 141 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches) 142 { 128 143 int dimx = 0; 129 144 int dimy = 0; … … 151 166 { 152 167 if (mRenderPatches) 153 { 168 { 154 169 ((*visiblePatches)[id]).AddVisibility(1, 0); 155 170 } … … 161 176 } 162 177 163 164 //-- reset options 165 166 useItemBuffer = false; // don't need item buffer anymore 167 sm->setOption("UseItemBuffer", &useItemBuffer); 168 169 mWasInitialised = false; // reset initialised - flag 170 mViewport->setOverlaysEnabled(overlayEnabled); // reset old overlay status 171 mViewport->setBackgroundColour(bg); // reset background color 172 173 delete [] buf; // delete copy of the frame buffer 174 } 178 delete [] buf; 179 } 180 175 181 //----------------------------------------------------------------------- 176 182 void PlatformQueryManager::InitItemBuffer( … … 215 221 subEnt->setId(id); 216 222 //subEnt->setId((41 << 16) + (4 << 8) + 60); 217 //subEnt->setId((2 << 16) + (4 << 8) + 60);218 223 } 219 224 -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r171 r173 12 12 #include "TestCullingTerrainApplication.h" 13 13 14 15 //-- captions for overlays 16 String TerrainFrameListener::msAlgorithmCaptions[] = 17 { 18 "View Frustum Culling", 19 "Stop and Wait Culling", 20 "Coherent Hierarchical Culling" 21 }; 22 23 String TerrainFrameListener::msQueryTypeCaptions[] = 24 { 25 "from camera", 26 "from viewpoint" 27 }; 28 29 String TerrainFrameListener::msQueryRelativeVisCaptions[] = 30 { 31 "visible pixels", 32 "relative visibility" 33 }; 34 35 String TerrainFrameListener::msQueryMethodCaptions[] = 36 { 37 "occlusion queries", 38 "item buffer" 39 }; 40 41 Real TerrainFrameListener::msObjectTerrainOffsets[] = 42 { 43 0, 44 7, 45 0 46 }; 47 48 Real TerrainFrameListener::msObjectScales[] = 49 { 50 0.1, 51 0.6, 52 0.07 53 }; 54 55 String TerrainFrameListener::msObjectCaptions[] = 56 { 57 "robot", 58 "athene", 59 //"tree2", 60 //"HongKong_Tower", 61 "ninja" 62 //"ogrehead" 63 }; 64 14 65 // output file for frame info 15 66 const char* frames_out_filename = "frame.out"; … … 17 68 const char* objects_out_filename = "objects.out"; 18 69 19 20 // --- captions for overlays21 22 String currentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =23 {24 "View Frustum Culling",25 "Stop and Wait Culling",26 "Coherent Hierarchical Culling"27 };28 29 String queryTypeCaptions[] =30 {31 "from camera",32 "from viewpoint"33 };34 35 String queryRelativeVisCaptions[] =36 {37 "visible pixels",38 "relative visibility"39 };40 41 String queryMethodCaptions[] =42 {43 "occlusion queries",44 "item buffer"45 };46 47 Real currentObjectTerrainOffsets[] =48 {49 0,50 7,51 052 };53 Real currentObjectScales[] =54 {55 0.1,56 0.1,57 0.0758 };59 70 60 71 //----------------------------------------------------------------------- … … 210 221 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 211 222 mouseRay.getOrigin()/*queryResult*/, Vector3(val, 0, 0), 212 m Application->getCurrentObjectCaption(mCurrentObjectType));223 msObjectCaptions[mCurrentObjectType]); 213 224 214 225 mLMouseDown = true; … … 281 292 { 282 293 // apply offset so object is ON terrain 283 queryResult.y += currentObjectTerrainOffsets[mCurrentObjectType];294 queryResult.y += msObjectTerrainOffsets[mCurrentObjectType]; 284 295 mCurrentObject->setPosition(queryResult); 285 296 } … … 414 425 415 426 mQueryManager = new OcclusionQueriesQueryManager(sm->GetHierarchyInterface(), 416 mWindow->getViewport(0), false, useItemBuffer);427 mWindow->getViewport(0), true, useItemBuffer); 417 428 //mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0), false); 418 429 … … 437 448 438 449 std::stringstream d; 439 d << queryTypeCaptions[fromPoint ? 1 : 0].c_str() << " "440 << queryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str() << " "441 << queryMethodCaptions[useItemBuffer ? 1 : 0].c_str();450 d << msQueryTypeCaptions[fromPoint ? 1 : 0].c_str() << " " 451 << msQueryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str() << " " 452 << msQueryMethodCaptions[useItemBuffer ? 1 : 0].c_str(); 442 453 LogManager::getSingleton().logMessage(d.str()); 443 454 … … 515 526 516 527 sprintf(str, ": %s, %s, %s", 517 queryTypeCaptions[fromPoint ? 1 : 0].c_str(),518 queryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str(),519 queryMethodCaptions[useItemBuffer ? 1 : 0].c_str());528 msQueryTypeCaptions[fromPoint ? 1 : 0].c_str(), 529 msQueryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str(), 530 msQueryMethodCaptions[useItemBuffer ? 1 : 0].c_str()); 520 531 521 532 mQueryTypeInfo->setCaption(str); … … 635 646 //-- write out stats for recorded walkthrough 636 647 std::stringstream d; 637 d << "Algorithm: " << currentAlgorithmCaptions[mCurrentAlgorithm] << "\n"648 d << "Algorithm: " << msAlgorithmCaptions[mCurrentAlgorithm] << "\n" 638 649 //<< "avg. FPS: " << mWindow->getAverageFPS() << "\n" 639 650 << "avg. FPS: " << avgFps << "\n" … … 737 748 738 749 // parameters for new object 739 mTerrainContentGenerator->SetOffset( currentObjectTerrainOffsets[mCurrentObjectType]);740 Real scale = currentObjectScales[mCurrentObjectType];750 mTerrainContentGenerator->SetOffset(msObjectTerrainOffsets[mCurrentObjectType]); 751 Real scale = msObjectScales[mCurrentObjectType]; 741 752 mTerrainContentGenerator->SetScale(Vector3(scale, scale, scale)); 742 753 743 mCurrentObjectTypeInfo->setCaption(": " + 744 mApplication->getCurrentObjectCaption(mCurrentObjectType)); 754 mCurrentObjectTypeInfo->setCaption(": " + msObjectCaptions[mCurrentObjectType]); 745 755 } 746 756 //----------------------------------------------------------------------- 747 757 void TerrainFrameListener::setAlgorithm(int algorithm) 748 758 { 749 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]);759 mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]); 750 760 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 751 761 } … … 1370 1380 1371 1381 initOverlayElement(&mAlgorithmInfo, ext, "Algorithm", top, 1372 ": " + currentAlgorithmCaptions[mCurrentAlgorithm]); top += vert_space;1382 ": " + msAlgorithmCaptions[mCurrentAlgorithm]); top += vert_space; 1373 1383 1374 1384 initOverlayElement(&mThresholdInfo, ext, "Threshold", top, ": 0"); top += vert_space; -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r164 r173 13 13 #include "OgrePlatformQueryManager.h" 14 14 15 15 16 class TestCullingTerrainApplication; 16 17 … … 18 19 using namespace Ogre; 19 20 20 // z order index of visualizaion viewport21 #define VIZ_VIEWPORT_Z_ORDER 1022 21 23 22 /** Frame listener specialised for terrains. … … 84 83 //enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM}; 85 84 86 void zoomVizCamera(int zoom);85 void zoomVizCamera(int zoom); 87 86 88 87 void addFrameInfo(SceneNode *camNode, Real timeElapsed); … … 141 140 void setObjectType(int objectType); 142 141 142 static String msAlgorithmCaptions[]; 143 static String msQueryTypeCaptions[]; 144 static String msQueryRelativeVisCaptions[]; 145 static String msQueryMethodCaptions[]; 146 static Real msObjectTerrainOffsets[]; 147 static Real msObjectScales[]; 148 static String msObjectCaptions[]; 149 143 150 protected: 144 151 145 152 void initHelpOverlayElement(String name, int top); 146 void initOverlayElement(OverlayElement **elInfo, String ext, String name, int top, String caption); 153 void initOverlayElement(OverlayElement **elInfo, String ext, String name, 154 int top, String caption); 147 155 148 156 //-- initialise overlays -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r164 r173 11 11 //#include "OgreRefAppWorld.h" 12 12 #include "TestCullingTerrainApplication.h" 13 13 #include "TerrainFrameListener.h" 14 14 15 15 #define WIN32_LEAN_AND_MEAN 16 16 #include <windows.h> 17 17 18 String currentObjectCaptions[] = 19 { 20 "robot", 21 "athene", 22 "ninja" 23 //"ogrehead" 24 }; 25 26 const float walk_duration = 10.0f; 27 const float wait_duration = 2.0f; 28 const float rotate_factor = 0.7f; 29 const float move_factor = 0.03; 30 31 /***************************************/ 32 /* EntityState implementation */ 33 /***************************************/ 18 19 /**********************************************/ 20 /* EntityState implementation */ 21 /**********************************************/ 22 23 34 24 Vector3 EntityState::msMinPos = Vector3::ZERO; 35 25 Vector3 EntityState::msMaxPos = Vector3::ZERO; … … 250 240 mSunLight->setCastShadows(true); 251 241 252 // set light angle not too s harp, otherwise shadows textures will be broken242 // set light angle not too small over the surface, otherwise shadows textures will be broken 253 243 Vector3 dir(0.5, 1, 0.5); 254 244 dir.normalise(); … … 288 278 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); */ 289 279 290 mSceneMgr->setShadowTextureSettings(1024, 2); 280 // Use 512x512 texture in GL since we can't go higher than the window res 281 mSceneMgr->setShadowTextureSettings(512, 2); 282 291 283 mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 292 284 … … 326 318 void TestCullingTerrainApplication::generateScene(int num, int objectType) 327 319 { 328 mTerrainContentGenerator->GenerateScene(num, currentObjectCaptions[objectType]); 320 Vector3 scale(TerrainFrameListener::msObjectScales[objectType], 321 TerrainFrameListener::msObjectScales[objectType], 322 TerrainFrameListener::msObjectScales[objectType]); 323 324 mTerrainContentGenerator->SetScale(scale); 325 mTerrainContentGenerator->SetOffset(TerrainFrameListener::msObjectTerrainOffsets[objectType]); 326 mTerrainContentGenerator->GenerateScene(num, TerrainFrameListener::msObjectCaptions[objectType]); 329 327 330 328 if (objectType != 0) // from our objects, only robot has animation phases … … 384 382 } 385 383 //----------------------------------------------------------------------- 386 String TestCullingTerrainApplication::getCurrentObjectCaption(int id)387 {388 return currentObjectCaptions[id];389 }390 //-----------------------------------------------------------------------391 384 void TestCullingTerrainApplication::chooseSceneManager() 392 385 { -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r164 r173 11 11 #include <OgreEntity.h> 12 12 13 // z order index of visualizaion viewport 14 #define VIZ_VIEWPORT_Z_ORDER 10 15 16 17 //-- constants for animation 18 const float walk_duration = 10.0f; 19 const float wait_duration = 2.0f; 20 const float rotate_factor = 0.7f; 21 const float move_factor = 0.03; 22 23 24 /** Rendertarget listener which shows a visualization. 25 */ 13 26 class VisualizationRenderTargetListener: public RenderTargetListener 14 27 {
Note: See TracChangeset
for help on using the changeset viewer.