Changeset 52 for trunk/VUT/OcclusionCullingSceneManager/src
- Timestamp:
- 04/19/05 18:32:46 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.