Changeset 175
- Timestamp:
- 07/14/05 20:54:07 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r174 r175 47 47 @returns occlusion query for this node 48 48 */ 49 virtual OcclusionQuery *Issue OcclusionQuery(HierarchyNode *node,49 virtual OcclusionQuery *IssueNodeOcclusionQuery(HierarchyNode *node, 50 50 const bool wasVisible = false) = 0; 51 51 /** Sets the root of the scene hierarchy. … … 124 124 CullingType type) = NULL; 125 125 126 /** Returns vector of previously rendered hierarchy nodes.126 /** Returns vector of visible hierarchy nodes from previous render. 127 127 */ 128 128 std::vector<HierarchyNode *> *GetVisibleNodes(); … … 130 130 */ 131 131 132 /** Issue a occlusion query for this mesh.133 @param node the current mesh134 @returns occlusion query for this node135 */136 virtual GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh) = 0;137 138 132 /** Returns the geometry of a given hierarchy node. 139 133 @param node the hierarchy node containing the geometry … … 144 138 GeometryList *geometryList, 145 139 bool includeChildren) = 0; 146 147 148 /** Renders the given geometry.149 */150 virtual void RenderGeometry(GtpVisibility::Mesh *geom) = 0;151 140 152 141 … … 159 148 */ 160 149 void TestGeometryForVisibleLeaves(bool testGeometry); 161 162 150 163 151 -
trunk/VUT/GtpVisibility/include/VisibilityEnvironment.h
r74 r175 13 13 /** Different types of occlusion culling algorithms 14 14 */ 15 enum CullingManagerType {FRUSTUM_CULLING, 15 enum CullingManagerType { 16 COHERENT_HIERARCHICAL_CULLING, 17 FRUSTUM_CULLING, 16 18 STOP_AND_WAIT_CULLING, 17 COHERENT_HIERARCHICAL_CULLING,18 19 NUM_CULLING_MANAGERS}; 19 20 -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r158 r175 25 25 unsigned int visiblePixels = 0; 26 26 bool isAvailable = false; 27 27 //Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling"); 28 28 29 //-- PART 1: process finished occlusion queries 29 30 while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) … … 105 106 106 107 queryQueue.push(QueryPair(node, mHierarchyInterface-> 107 Issue OcclusionQuery(node, wasVisible)));108 IssueNodeOcclusionQuery(node, wasVisible))); 108 109 } 109 110 -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r158 r175 7 7 void FrustumCullingManager::RenderScene() 8 8 { 9 //Ogre::LogManager::getSingleton().logMessage("Frustum Culling"); 9 10 while (!mHierarchyInterface->GetQueue()->empty()) 10 11 { -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r158 r175 7 7 void StopAndWaitCullingManager::RenderScene() 8 8 { 9 //Ogre::LogManager::getSingleton().logMessage("Stop and Wait Culling"); 9 10 while (!mHierarchyInterface->GetQueue()->empty()) 10 11 { … … 40 41 unsigned int visiblePixels = 0; 41 42 42 mHierarchyInterface->Issue OcclusionQuery(node)->GetQueryResult(visiblePixels, true);43 mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); 43 44 44 45 // node visible -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r174 r175 75 75 @returns occlusion query for this node 76 76 */ 77 GtpVisibility::OcclusionQuery *Issue OcclusionQuery(77 GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery( 78 78 GtpVisibility::HierarchyNode *node, const bool wasVisible); 79 79 80 80 /** Issue a occlusion query for this mesh. 81 @param node the current mesh82 @returns occlusion query for this node81 @param mesh the mesh for which an occlusion query is issued. 82 @returns occlusion query for this mesh. 83 83 */ 84 GtpVisibility::OcclusionQuery *Issue OcclusionQuery(GtpVisibility::Mesh *mesh);84 GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh); 85 85 86 86 /** If true, the interface finds and renders only objects which are marked as shadow casters. … … 106 106 bool IsBoundingBoxQuery(); 107 107 108 GtpVisibility::OcclusionQuery *Issue OcclusionQuery(GtpVisibility::Patch *patch);108 GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch); 109 109 110 110 protected: 111 /** Renders geometry111 /** Renders the given geometry 112 112 */ 113 113 void RenderGeometry(GtpVisibility::Mesh *geom); 114 115 /** Renders apatch114 115 /** Renders the given patch 116 116 */ 117 117 void RenderPatch(GtpVisibility::Patch *patch); -
trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp
r174 r175 68 68 69 69 //-- render scene with item buffer (i.e., objects with their id as color codes) 70 //mItemBufferMode = 0; 70 71 if ((mItemBufferMode && mQueryModes) != 0) 71 72 { … … 104 105 GtpVisibility::HierarchyNodeList nodeList; 105 106 106 if (mQueryModes & &NODE_VISIBILITY)107 if (mQueryModes & NODE_VISIBILITY) 107 108 { 108 109 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) … … 118 119 119 120 // store geometry of the hierarchy nodes in a geometry list 120 if (mQueryModes & &GEOMETRY_VISIBILITY)121 if (mQueryModes & GEOMETRY_VISIBILITY) 121 122 { 122 123 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) … … 133 134 134 135 // store patchges of the geometries in a patch list 135 if (mQueryModes & &PATCH_VISIBILITY)136 if (mQueryModes & PATCH_VISIBILITY) 136 137 { 137 138 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) … … 159 160 // for relative visibility we need 2 rendering passes 160 161 int n = relativeVisibility ? 2 : 1; 161 162 if (mItemBufferMode > 0) 163 LogManager::getSingleton().logMessage("item buffer"); 164 162 165 for (int i = 0; i < n; ++i) 163 166 { … … 166 169 { 167 170 // TODO: DELETE QUERIES FROM PREVIOUS RENDER 168 queryList[i].push_back(mHierarchyInterface->Issue OcclusionQuery(*nodeIt, false));171 queryList[i].push_back(mHierarchyInterface->IssueNodeOcclusionQuery(*nodeIt, false)); 169 172 } 170 173 171 174 //-- queries for geometry: if item buffer, capture only projected visibility 172 175 if ((mItemBufferMode != GEOMETRY_VISIBILITY) || (i == 1)) 173 { 176 { 174 177 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt) 175 178 { 176 queryList[i].push_back( mHierarchyInterface->IssueOcclusionQuery(*geometryIt));179 queryList[i].push_back(pfHierarchyInterface->IssueMeshOcclusionQuery(*geometryIt)); 177 180 } 178 181 } … … 183 186 for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt) 184 187 { 185 queryList[i].push_back( mHierarchyInterface->IssueOcclusionQuery(*patchIt));188 queryList[i].push_back(pfHierarchyInterface->IssuePatchOcclusionQuery(*patchIt)); 186 189 } 187 190 } … … 199 202 200 203 201 202 204 // collect occlusion queries for geometry 203 205 if ((mItemBufferMode == GEOMETRY_VISIBILITY) && relativeVisibility) … … 207 209 CollectRelativeGeometryVisibilityForItemBuffer(projQueryIt, &geometryList, visibleGeometry); 208 210 } 209 else 211 else if (mItemBufferMode != GEOMETRY_VISIBILITY) 210 212 { 211 213 CollectGeometryVisibility(visQueryIt, projQueryIt, &geometryList, visibleGeometry, … … 219 221 CollectRelativePatchVisibilityForItemBuffer(projQueryIt, &patchList, visiblePatches); 220 222 } 221 else 223 else if (mItemBufferMode != PATCH_VISIBILITY) 222 224 { 223 225 CollectPatchVisibility(visQueryIt, projQueryIt, &patchList, visiblePatches, relativeVisibility); … … 244 246 visibleGeometry, visiblePatches, relativeVisibility); 245 247 246 // remove duplicates (duplicates occur if an object is on the edge of the viewport)247 // before duplicates can be deleted we have to add up their visibility248 // adds up their visibility and removes duplicates 249 // (duplicates occur if an object is on the edge of the viewport) 248 250 RemoveDuplicateNodes(visibleNodes); 249 251 … … 258 260 } 259 261 } 260 //------ -----------------------------------------------------------------262 //------j----------------------------------------------------------------- 261 263 void OcclusionQueriesQueryManager::CollectNodeVisibility( 262 264 GtpVisibility::QueryList::iterator &visQueryIt, -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r174 r175 165 165 } 166 166 //----------------------------------------------------------------------- 167 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::Issue OcclusionQuery(167 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueNodeOcclusionQuery( 168 168 GtpVisibility::HierarchyNode *node, const bool wasVisible) 169 169 { … … 200 200 } 201 201 //----------------------------------------------------------------------- 202 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::Issue OcclusionQuery(202 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssuePatchOcclusionQuery( 203 203 GtpVisibility::Patch *patch) 204 204 { … … 216 216 } 217 217 //----------------------------------------------------------------------- 218 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::Issue OcclusionQuery(218 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueMeshOcclusionQuery( 219 219 GtpVisibility::Mesh *mesh) 220 220 { … … 287 287 void PlatformHierarchyInterface::RenderPatch(GtpVisibility::Patch *patch) 288 288 { 289 Pass *pass = patch->getTechnique()->getPass(0); 290 mSceneManager->setPass(pass); 291 mSceneManager->renderSingleObject(patch, pass, false); 289 mSceneManager->_renderSingleRenderable(patch); 292 290 } 293 291 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp
r160 r175 29 29 void SceneContentGenerator::GenerateScene(int numObjects, const String &objName) 30 30 { 31 // initialise random generator32 srand (time(0));33 34 Vector3 rotationRatio;35 Vector3 translationRatio;36 37 31 int new_size = GetObjectCount() + numObjects; 38 32 int failed_attempts = 0; // counter used to avoid invinite loop … … 42 36 (failed_attempts < MAX_FAILED_ATTEMPTS)) 43 37 { 44 rotationRatio.x = rand() / (float) RAND_MAX;45 rotationRatio.y = rand() / (float) RAND_MAX;46 rotationRatio.z = rand() / (float) RAND_MAX;47 48 translationRatio.x = rand() / (float) RAND_MAX;49 translationRatio.y = rand() / (float) RAND_MAX;50 translationRatio.z = rand() / (float) RAND_MAX;51 52 38 // Setup the ray scene query 53 Vector3 rotation = mMinAngle + rotationRatio * (mMaxAngle - mMinAngle); 54 Vector3 position = mMinPos + translationRatio * (mMaxPos - mMinPos); 39 Vector3 rotation = Vector3(Math::RangeRandom(mMinAngle.x, mMaxAngle.x), 40 Math::RangeRandom(mMinAngle.y, mMaxAngle.y), 41 Math::RangeRandom(mMinAngle.z, mMaxAngle.z)); 42 43 Vector3 position = Vector3(Math::RangeRandom(mMinPos.x, mMaxPos.x), 44 Math::RangeRandom(mMinPos.y, mMaxPos.y), 45 Math::RangeRandom(mMinPos.z, mMaxPos.z)); 55 46 56 47 // failed to generate new object 57 48 if (!GenerateSceneObject(position, rotation, objName)) 58 ++ failed_attempts;49 ++ failed_attempts; 59 50 } 60 51 } … … 68 59 69 60 Entity *ent = mSceneMgr->createEntity(name, objName + ".mesh"); 70 61 ent->setCastShadows(true); 62 71 63 SceneNode *node = mSceneMgr->getRootSceneNode()-> 72 64 createChildSceneNode(String(name) + "Node", position); … … 80 72 mSceneNodes.push_back(node); 81 73 mEntities.push_back(ent); 82 74 83 75 return node; 84 76 } -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r174 r175 237 237 void VisibilityOctreeSceneManager::_renderVisibleObjects() 238 238 { 239 InitDepthPass(); // create material for depth pass 240 InitItemBufferPass(); // create material for item buffer pass 241 239 242 // save ambient light to reset later 240 243 ColourValue savedAmbient = mAmbientLight; … … 629 632 void VisibilityOctreeSceneManager::InitVisibilityCulling(Camera *cam) 630 633 { 631 InitDepthPass(); // create material for depth pass632 InitItemBufferPass(); // create material for item buffer pass633 634 634 // reset culling manager stats 635 635 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r174 r175 240 240 void VisibilityTerrainSceneManager::_renderVisibleObjects() 241 241 { 242 InitDepthPass(); // create material for depth pass 243 InitItemBufferPass(); // create material for item buffer pass 244 242 245 // save ambient light to reset later 243 246 ColourValue savedAmbient = mAmbientLight; … … 629 632 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 630 633 { 631 InitDepthPass(); // create material for depth pass632 InitItemBufferPass(); // create material for item buffer pass633 634 634 // reset culling manager stats 635 635 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r174 r175 16 16 String TerrainFrameListener::msAlgorithmCaptions[] = 17 17 { 18 "Coherent Hierarchical Culling", 18 19 "View Frustum Culling", 19 "Stop and Wait Culling", 20 "Coherent Hierarchical Culling" 20 "Stop and Wait Culling" 21 21 }; 22 22 … … 42 42 { 43 43 0, 44 7, 44 0, 45 //7, 45 46 0 46 47 }; … … 49 50 { 50 51 0.1, 51 0.6, 52 0.07 52 0.03, 53 //0.1, 54 0.04 53 55 }; 54 56 … … 56 58 { 57 59 "robot", 58 "athene", 60 //"athene", 61 "natFX_Tree1_LOD2", 59 62 //"tree2", 60 63 //"HongKong_Tower", … … 111 114 mShowOctree(false), 112 115 mUseDepthPass(false), 113 mTestGeometryForVisibleLeaves( true),116 mTestGeometryForVisibleLeaves(false), 114 117 mShowVisualization(false), 115 118 mCullCamera(false), … … 426 429 int itemBufferMode = useItemBuffer ? mItemBufferMode : 0; 427 430 428 int queryModes = GtpVisibility::QueryManager::PATCH_VISIBILITY; 431 int queryModes = 0; 432 queryModes |= GtpVisibility::QueryManager::PATCH_VISIBILITY; 429 433 queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY; 430 434 queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 431 435 432 436 mQueryManager = new OcclusionQueriesQueryManager(sm->GetHierarchyInterface(), 433 mWindow->getViewport(0), queryModes, useItemBuffer);437 mWindow->getViewport(0), queryModes, itemBufferMode); 434 438 435 439 //mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0), false); … … 455 459 456 460 std::stringstream d; 457 d << msQueryTypeCaptions[fromPoint ? 1 : 0].c_str() << " " 461 d << "Query mode: " << queryModes << ", " 462 << msQueryTypeCaptions[fromPoint ? 1 : 0].c_str() << " " 458 463 << msQueryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str() << " " 459 464 << msQueryMethodCaptions[useItemBuffer ? 1 : 0].c_str(); … … 744 749 { 745 750 mCurrentAlgorithm = (mCurrentAlgorithm + 1) % 746 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 747 751 (GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS - 1); 748 752 setAlgorithm(mCurrentAlgorithm); 749 753 } -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r173 r175 228 228 { 229 229 // Set ambient light 230 mAmbientLight = ColourValue(0.5 , 0.5, 0.5);230 mAmbientLight = ColourValue(0.5 , 0.5, 0.5); 231 231 mSceneMgr->setAmbientLight(mAmbientLight); 232 232 … … 256 256 257 257 // Create a skybox 258 mSceneMgr->setSkyBox(true, "Examples/ SpaceSkyBox", 5000, false);258 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 259 259 260 260 std::string terrain_cfg("terrain.cfg"); … … 301 301 if (!mTerrainContentGenerator->LoadObjects("objects.out")) 302 302 { 303 // to provide much occlusion,304 // height is restricted to 50 => no objects are created on peaks305 mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos));306 mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, 50.0f, mTerrainMaxPos.z));307 mTerrainContentGenerator->SetOffset(0);308 309 303 // the objects are generated randomly distributed over the terrain 310 generateScene(1500, 0); 304 generateScene(900, 0); 305 generateScene(500, 1); 306 generateScene(100, 2); 307 } 308 309 // no limitations on height => it is possible for the user to put single 310 // objects on peaks of the terrain (only few, not relevant for occlusion) 311 mTerrainContentGenerator->SetMaxPos(mTerrainMaxPos); 312 } 313 //----------------------------------------------------------------------- 314 void TestCullingTerrainApplication::generateScene(int num, int objectType) 315 { 316 Vector3 scale(TerrainFrameListener::msObjectScales[objectType], 317 TerrainFrameListener::msObjectScales[objectType], 318 TerrainFrameListener::msObjectScales[objectType]); 319 320 // to provide much occlusion, 321 // height is restricted to 50 => no objects are created on peaks 322 mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos)); 323 mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, 75.0f, mTerrainMaxPos.z)); 324 325 mTerrainContentGenerator->SetScale(scale); 326 mTerrainContentGenerator->SetOffset(TerrainFrameListener::msObjectTerrainOffsets[objectType]); 327 mTerrainContentGenerator->GenerateScene(num, TerrainFrameListener::msObjectCaptions[objectType]); 328 329 if (objectType != 0) // from our objects, only robot has animation phases 330 return; 331 332 EntityList *entList = mTerrainContentGenerator->GetGeneratedEntities(); 333 334 //-- add animation state for new robots (located at the end of the list) 335 for (int i = (int)entList->size() - num; i < (int)entList->size(); ++i) 336 { 337 mEntityStates.push_back(new EntityState((*entList)[i], 338 EntityState::WAITING, Math::RangeRandom(0.5, 1.5))); 311 339 } 312 340 … … 314 342 // objects on peaks of the terrain (only few, not relevant for occlusion) 315 343 mTerrainContentGenerator->SetMaxPos(mTerrainMaxPos); 316 }317 //-----------------------------------------------------------------------318 void TestCullingTerrainApplication::generateScene(int num, int objectType)319 {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]);327 328 if (objectType != 0) // from our objects, only robot has animation phases329 return;330 331 EntityList *entList = mTerrainContentGenerator->GetGeneratedEntities();332 333 //-- add animation state for new robots (located at the end of the list)334 for (int i = entList->size() - num; i < (int)entList->size(); ++i)335 {336 mEntityStates.push_back(new EntityState((*entList)[i],337 EntityState::WAITING, Math::RangeRandom(0.5, 1.5)));338 }339 344 } 340 345 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.