- Timestamp:
- 04/19/05 18:32:46 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r51 r52 57 57 mMaxAngle = Vector3(360, 360, 360); 58 58 59 /* 60 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 61 62 Entity *ogreHeadEnt = mSceneMgr->createEntity("head", "ogrehead.mesh"); 63 mOgreHead = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode" ); 64 mOgreHead->attachObject(ogreHeadEnt); 65 */ 66 generateScene(4); 59 generateScene(330); 60 67 61 // Create a skybox 68 62 //mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 1000, false); 69 ColourValue fadeColour(0. 3, 0.9, 0.5);63 ColourValue fadeColour(0.1, 0.1, 0.6); 70 64 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 71 65 … … 176 170 mSceneNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/SceneNodesInfo"); 177 171 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/HierarchyNodesInfo"); 172 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/RenderedNodesInfo"); 178 173 179 174 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 184 179 mSceneNodesInfo->setCaption(": 0"); 185 180 mHierarchyNodesInfo->setCaption(": 0"); 181 mRenderedNodesInfo->setCaption(": 0"); 186 182 187 183 pOver->show(); … … 306 302 mSceneMgr->getOption("NumOctreeNodes", &opt); sprintf(str,": %d", opt); 307 303 mHierarchyNodesInfo->setCaption(str); 304 305 mSceneMgr->getOption("NumRenderedNodes", &opt); sprintf(str,": %d", opt); 306 mRenderedNodesInfo->setCaption(str); 308 307 } 309 308 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r51 r52 79 79 OverlayElement *mHierarchyNodesInfo; 80 80 OverlayElement *mSceneNodesInfo; 81 OverlayElement *mRenderedNodesInfo; 81 82 }; 82 83 -
trunk/VUT/OcclusionCullingSceneManager/TestCullingTerrain/TestCullingTerrainApplication.cpp
r51 r52 183 183 mSceneNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/SceneNodesInfo"); 184 184 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/HierarchyNodesInfo"); 185 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/RenderedNodesInfo"); 185 186 186 187 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 191 192 mSceneNodesInfo->setCaption(": 0"); 192 193 mHierarchyNodesInfo->setCaption(": 0"); 193 194 mRenderedNodesInfo->setCaption(": 0"); 195 194 196 pOver->show(); 195 197 } … … 362 364 mSceneMgr->getOption("NumOctreeNodes", &opt); sprintf(str,": %d", opt); 363 365 mHierarchyNodesInfo->setCaption(str); 366 367 mSceneMgr->getOption("NumRenderedNodes", &opt); sprintf(str,": %d", opt); 368 mRenderedNodesInfo->setCaption(str); 364 369 } 365 370 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/TestCullingTerrain/TestCullingTerrainApplication.h
r48 r52 79 79 OverlayElement *mHierarchyNodesInfo; 80 80 OverlayElement *mSceneNodesInfo; 81 OverlayElement *mRenderedNodesInfo; 81 82 82 83 SceneNode *mCurrentObject; // The newly created object -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneTraverser.h
r45 r52 74 74 75 75 void initDistanceQueue(Camera *cam); 76 void pullUpVisibility( Camera *cam, Octree *octree);77 void traverseOctant(Camera *cam, Octree *octant 78 void renderOctant( Camera *cam, Octree *octant);76 void pullUpVisibility(Octree *octree); 77 void traverseOctant(Camera *cam, Octree *octant); 78 void renderOctant(Camera *cam, Octree *octant); 79 79 bool isLeaf(Octree *octant); 80 80 -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
r51 r52 132 132 */ 133 133 HardwareOcclusionQuery *getNextOcclusionQuery(void); 134 /** Pulls up the visibility from the child nodes. */ 135 void pullUpVisibility( Camera *cam, SceneNode *node ); 134 /** Pulls up the visibility from the child node. 135 @param the child node 136 */ 137 void pullUpVisibility(SceneNode *node); 136 138 /** delete all previously defined occlusion queries */ 137 139 void deleteQueries(); … … 171 173 unsigned int mNumRenderedGeometry; 172 174 unsigned int mNumRenderedNodes; 173 175 174 176 private: 175 177 // the scene root -
trunk/VUT/OcclusionCullingSceneManager/scripts/OcclusionCullingDemo.overlay
r42 r52 87 87 top 5 88 88 width 450 89 height 9089 height 105 90 90 material Core/StatsBlockCenter 91 91 border_size 1 1 1 1 … … 230 230 colour_bottom 0.3 0.5 0.3 231 231 } 232 element TextArea(Example/Occlusion/RenderedNodes) 233 { 234 metrics_mode pixels 235 left 5 236 top 80 237 width 180 238 height 30 239 font_name TrebuchetMSBold 240 char_height 16 241 caption Rendered Nodes 242 colour_top 0.5 0.7 0.5 243 colour_bottom 0.3 0.5 0.3 244 } 245 element TextArea(Example/Occlusion/RenderedNodesInfo) 246 { 247 metrics_mode pixels 248 left 180 249 top 80 250 width 90 251 height 30 252 font_name TrebuchetMSBold 253 char_height 16 254 caption : 255 colour_top 0.5 0.7 0.5 256 colour_bottom 0.3 0.5 0.3 257 } 258 232 259 233 260 } -
trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.sln
r45 r52 6 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCulling", "..\TestCulling\TestCulling.vcproj", "{248F19A6-2FE0-4F5D-8928-E0EA10609887}" 7 7 ProjectSection(ProjectDependencies) = postProject 8 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 8 9 EndProjectSection 9 10 EndProject -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp
r51 r52 16 16 //mDisplayNodes = true; 17 17 //mShowBoundingBoxes = true; 18 mShowBoxes = true;19 mMaxDepth = 20;18 //mShowBoxes = true; 19 //mMaxDepth = 20; 20 20 } 21 21 //----------------------------------------------------------------------- … … 43 43 mOcclusionCullingOctreeSceneTraverser->setSceneRoot(mOctree); 44 44 mOcclusionCullingOctreeSceneTraverser->renderScene(mCameraInProgress); 45 45 46 46 _deleteRenderedQueueGroups(); 47 47 48 //-- render overlay48 //-- render rest, e.g., overlay 49 49 clearSpecialCaseRenderQueues(); 50 SceneManager::_renderVisibleObjects( ); 51 52 clearSpecialCaseRenderQueues(); 50 SceneManager::_renderVisibleObjects(); 51 //_deleteRenderedQueueGroups(); 53 52 } 54 53 //----------------------------------------------------------------------- … … 61 60 void OcclusionCullingOctreeSceneManager::_updateSceneGraph(Camera* cam) 62 61 { 63 //char *msg = "now updating scenegraph\n"; OutputDebugString(msg); 64 //mOcclusionCullingOctreeSceneTraverser->preprocess(); 65 66 mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size()); 62 mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size()); 67 63 mOcclusionCullingOctreeSceneTraverser->setRenderSystem(mDestRenderSystem); 68 64 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp
r51 r52 18 18 } 19 19 //----------------------------------------------------------------------- 20 void OcclusionCullingOctreeSceneTraverser::traverseOctant(Camera *cam, Octree *octant 20 void OcclusionCullingOctreeSceneTraverser::traverseOctant(Camera *cam, Octree *octant) 21 21 { 22 22 mNumTraversedNodes ++; … … 34 34 35 35 if(nextChild) 36 { 36 37 mOctreeDistanceQueue->push(nextChild); 38 } 37 39 } 38 40 } … … 51 53 octant->_getCullBounds(&box); 52 54 53 //if(static_cast<OctreeCamera *>(cam)->getVisibility(box) == OctreeCamera::NONE)54 55 if(!cam->isVisible(box)) 55 56 { … … 85 86 bool intersects = false; 86 87 88 /*char msg2[100]; 89 Vector3 min = box.getMinimum(); 90 Vector3 max = box.getMaximum(); 91 92 sprintf(msg2, "culling box: %3.3f %3.3f %3.3f %3.3f %3.3f %3.3f\n", min.x, min.y, min.z, max.x, max.y, max.z); 93 OutputDebugString(msg2);*/ 94 87 95 if(!cam->isVisible(box, intersects)) 88 96 { … … 94 102 { 95 103 octant->setOctreeVisible(true); 104 // char msg[100]; sprintf(msg, "intersecting\n"); 105 // OutputDebugString(msg); 96 106 traverseOctant(cam, octant); 97 107 continue; … … 103 113 // wait if result not available 104 114 query->pullOcclusionQuery(&visiblePixels); 105 //visiblePixels = 1; 115 116 char msg[100]; sprintf(msg, "visible pixels: %d\n", visiblePixels, intersects); 117 OutputDebugString(msg); 118 106 119 // node visible 107 120 if(visiblePixels > mVisibilityThreshold) … … 111 124 else 112 125 { 113 char msg[100];114 Vector3 min = box.getMinimum();115 Vector3 max = box.getMaximum();116 117 sprintf(msg, "culling box: %3.3f %3.3f %3.3f %3.3f %3.3f %3.3f\n", min.x, min.y, min.z, max.x, max.y, max.z);118 OutputDebugString(msg);119 120 126 mNumQueryCulledNodes ++; 121 127 } … … 143 149 unsigned int visiblePixels; 144 150 query->pullOcclusionQuery(&visiblePixels); 145 //visiblePixels = 1; 151 146 152 if(visiblePixels > mVisibilityThreshold) 147 153 { 148 pullUpVisibility( cam,octant);154 pullUpVisibility(octant); 149 155 traverseOctant(cam, octant); 150 156 } … … 176 182 // update octant's visited flag 177 183 octant->setLastVisited(mFrameId); 178 pullUpVisibility(cam, octant); 184 185 pullUpVisibility(octant); 179 186 traverseOctant(cam, octant); 180 187 … … 185 192 bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1); 186 193 187 /* char msg[100]; 194 /* 195 char msg[100]; 188 196 if(wasVisible) sprintf(msg, "yes, was visible, %d\n", mFrameId); 189 197 else sprintf(msg, "no was invisible, %d\n", mFrameId); 190 OutputDebugString(msg);*/ 198 OutputDebugString(msg); 199 */ 191 200 192 201 // identify nodes that we cannot skip queries for 193 bool leafOrWasInvisible = !wasVisible|| isLeaf(octant);202 bool mustQuery = !wasVisible || (octant->numNodes() > 0) || isLeaf(octant); 194 203 195 204 // reset node's visibility classification … … 200 209 201 210 // skip testing previously visible interior nodes 202 if( leafOrWasInvisible)211 if(mustQuery) 203 212 { 204 213 HardwareOcclusionQuery *query = issueOcclusionQuery(&box, wasVisible); … … 215 224 } 216 225 //----------------------------------------------------------------------- 217 void OcclusionCullingOctreeSceneTraverser::pullUpVisibility( Camera *cam,Octree *octant )226 void OcclusionCullingOctreeSceneTraverser::pullUpVisibility( Octree *octant ) 218 227 { 219 228 while(octant && !octant->isOctreeVisible()) 220 229 { 221 // if we come across some renderable geometry => render it222 renderOctant(cam, octant);223 224 230 octant->setOctreeVisible(true); 225 231 octant = octant->getParent(); … … 229 235 void OcclusionCullingOctreeSceneTraverser::renderOctant( Camera *cam, Octree *octant ) 230 236 { 231 if(octant->numNodes() == 0) return; 232 if(octant->lastVisited() != octant->lastRendered()) 233 { 237 if(octant->lastRendered() != mFrameId) 238 { 239 octant->setLastRendered(mFrameId); 240 241 if(octant->numNodes() == 0) return; 242 234 243 //TODO: does nothing useful 235 244 setRenderingMode(MODE_RENDER); 245 246 ((OctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant); 247 236 248 mNumRenderedNodes ++; 237 238 octant->setLastRendered(octant->lastVisited()); 239 ((OctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant); 240 } 241 //else OutputDebugString("already rendered"); 242 } 243 //----------------------------------------------------------------------- 244 void OcclusionCullingOctreeSceneTraverser::setSceneRoot(Octree *root) 249 } 250 } 251 //----------------------------------------------------------------------- 252 void OcclusionCullingOctreeSceneTraverser::setSceneRoot( Octree *root ) 245 253 { 246 254 mOctreeSceneRoot = root; 247 255 } 248 256 //----------------------------------------------------------------------- 249 void OcclusionCullingOctreeSceneTraverser::initDistanceQueue( Camera *cam)257 void OcclusionCullingOctreeSceneTraverser::initDistanceQueue( Camera *cam ) 250 258 { 251 259 if(mOctreeDistanceQueue) … … 274 282 bool OcclusionCullingOctreeSceneTraverser::getOption( const String & key, void *val ) 275 283 { 276 if ( key == "NumOctreeNodes")284 if (key == "NumOctreeNodes") 277 285 { 278 286 * static_cast < unsigned int * > ( val ) = mNumOctreeNodes; … … 285 293 bool OcclusionCullingOctreeSceneTraverser::getOptionKeys( StringVector & refKeys ) 286 294 { 287 refKeys.push_back( "NumOctreeNodes");295 refKeys.push_back("NumOctreeNodes"); 288 296 289 297 return OcclusionCullingSceneTraverser::getOptionKeys(refKeys); -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r51 r52 49 49 //for(unsigned int i=0; i < 1000; i++) 50 50 //mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 51 51 52 //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 52 53 … … 66 67 break; 67 68 } 68 69 69 70 mFrameId ++; 70 71 } … … 91 92 if(visiblePixels > mVisibilityThreshold) 92 93 { 93 pullUpVisibility( cam,node);94 pullUpVisibility(node); 94 95 traverseNode(cam, node); 95 96 } … … 119 120 // update node's visited flag 120 121 node->setLastVisited(mFrameId); 121 pullUpVisibility( cam,node);122 pullUpVisibility(node); 122 123 traverseNode(cam, node); 123 124 … … 129 130 130 131 // identify nodes that we cannot skip queries for 131 bool leafOrWasInvisible = !wasVisible|| isLeaf(node);132 bool mustQuery= !wasVisible || (node->numAttachedObjects() > 0) || isLeaf(node); 132 133 133 134 // reset node's visibility classification … … 137 138 node->setLastVisited(mFrameId); 138 139 139 // skip testing previously visible interior nodes 140 if( leafOrWasInvisible)140 // skip testing previously visible interior nodes without geometry 141 if(mustQuery) 141 142 { 142 143 HardwareOcclusionQuery *query = issueOcclusionQuery(&node->_getWorldAABB(), wasVisible); … … 235 236 236 237 setRenderingMode(MODE_QUERY); 237 // setRenderingMode(MODE_RENDER);238 //mRenderSystem->_setRasterisationMode(SDL_SOLID);setRenderingMode(MODE_RENDER); 238 239 239 240 // get next available test id … … 247 248 query->endOcclusionQuery(); 248 249 250 251 //mRenderSystem->_setRasterisationMode(SDL_WIREFRAME); 252 setRenderingMode(MODE_RENDER); 253 renderBoundingBox(box); 254 //mRenderSystem->_setRasterisationMode(SDL_SOLID); 255 249 256 return query; 250 257 } … … 253 260 { 254 261 // avoid unnecessary state changes 255 //if(mode != mQueryMode) 256 //{ 262 if(mode != mQueryMode) 263 { 264 mQueryMode = mode; 257 265 bool enabled = (mode == MODE_RENDER); 258 //if(mode == MODE_QUERY){ 259 mRenderSystem->_setColourBufferWriteEnabled(enabled, 260 enabled, enabled, enabled); 266 267 //if(mode == MODE_RENDER) return; 268 269 /* 270 mRenderSystem->_setRasterisationMode(SDL_SOLID); 271 mRenderSystem->_setSurfaceParams(ColourValue(0.9, 0.2, 0.2), 272 ColourValue(0.2, 0.2, 0.2), ColourValue(0.2, 0.2, 0.2), 273 ColourValue(0, 0, 0), Real(100)); 274 mRenderSystem->_setDepthBufferCheckEnabled(false); 275 mRenderSystem->_setAlphaRejectSettings(CMPF_ALWAYS_PASS, 255); 276 */ 277 278 mRenderSystem->_setColourBufferWriteEnabled(enabled, enabled, enabled, enabled); 261 279 mRenderSystem->_setDepthBufferWriteEnabled(enabled); 262 280 mRenderSystem->setLightingEnabled(enabled); 263 //} 264 mQueryMode = mode; 265 //} 281 } 266 282 } 267 283 //----------------------------------------------------------------------- … … 290 306 setRenderingMode(MODE_RENDER); 291 307 292 mSceneManager->_renderSceneNode(cam, node); 308 if(node->lastRendered() != node->lastVisited()) 309 { 310 node->setLastRendered(node->lastVisited()); 311 mNumRenderedNodes ++; 312 313 mSceneManager->_renderSceneNode(cam, node); 314 } 293 315 } 294 316 //----------------------------------------------------------------------- … … 334 356 } 335 357 //----------------------------------------------------------------------- 336 void OcclusionCullingSceneTraverser::pullUpVisibility( Camera *cam,SceneNode *node )358 void OcclusionCullingSceneTraverser::pullUpVisibility(SceneNode *node ) 337 359 { 338 360 while(node && !node->isNodeVisible()) 339 361 { 340 // if we come across some renderable geometry => render it341 if(node->numAttachedObjects() > 0)342 {343 renderSceneNode(cam, node);344 }345 346 362 node->setNodeVisible(true); 347 363 node = node->getParentSceneNode(); … … 367 383 halfbox->setupBoundingBox(*box); 368 384 369 //mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 385 mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 386 370 387 // Set world transformation 371 388 /*halfbox->getWorldTransforms(xform); … … 380 397 mRenderSystem->_setWorldMatrix(*xform); 381 398 } 382 mRenderSystem->setClipPlanes(halfbox->getClipPlanes()); 399 mRenderSystem->setClipPlanes(halfbox->getClipPlanes());*/ 383 400 384 401 static RenderOperation ro; … … 387 404 halfbox->getRenderOperation(ro); 388 405 ro.srcRenderable = halfbox; 389 mRenderSystem->_render(ro);*/ 390 391 mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), 392 getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false); 406 mRenderSystem->_render(ro); 407 408 //mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true); 393 409 } 394 410 } … … 480 496 { 481 497 * static_cast < unsigned int * > ( val ) = mNumFrustumCulledNodes; 498 return true; 499 } 500 if ( key == "NumRenderedNodes" ) 501 { 502 * static_cast < unsigned int * > ( val ) = mNumRenderedNodes; 482 503 return true; 483 504 } … … 493 514 refKeys.push_back( "NumQueryCulledNodes" ); 494 515 refKeys.push_back( "NumFrustumCulledNodes" ); 495 //refKeys.push_back( "mNumRenderedGeometry" );516 refKeys.push_back( "mNumRenderedGeometry" ); 496 517 497 518 return true; -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
r51 r52 16 16 new OcclusionCullingOctreeSceneTraverser(this, mDestRenderSystem); 17 17 18 mShowBoxes = true; 18 19 //mDisplayNodes = true; 19 20 //mShowBoundingBoxes = true; 20 mShowBoxes = true; 21 mMaxDepth = 20; 21 //mMaxDepth = 20; 22 22 } 23 23 //----------------------------------------------------------------------- … … 35 35 36 36 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 37 SceneManager::_renderVisibleObjects( 37 SceneManager::_renderVisibleObjects(); 38 38 _deleteRenderedQueueGroups(); 39 39 … … 51 51 clearSpecialCaseRenderQueues(); 52 52 SceneManager::_renderVisibleObjects( ); 53 54 clearSpecialCaseRenderQueues();55 53 } 56 54 //----------------------------------------------------------------------- … … 59 57 // must be empty because objects are found and rendered in an interleaved fashion 60 58 // in _renderVisibibleObjects 61 //char *msg = "now finding visible objects\n"; OutputDebugString(msg);62 59 } 63 60 //----------------------------------------------------------------------- 64 61 void OcclusionCullingTerrainSceneManager::_updateSceneGraph(Camera* cam) 65 62 { 66 //char *msg = "now updating scenegraph\n"; OutputDebugString(msg); 67 //mOcclusionCullingTerrainSceneTraverser->preprocess(); 68 69 mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size()); 63 mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size()); 70 64 mOcclusionCullingOctreeSceneTraverser->setRenderSystem(mDestRenderSystem); 71 65
Note: See TracChangeset
for help on using the changeset viewer.