Changeset 51 for trunk/VUT/OcclusionCullingSceneManager/src
- Timestamp:
- 04/19/05 09:12:55 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp
r45 r51 16 16 //mDisplayNodes = true; 17 17 //mShowBoundingBoxes = true; 18 //mShowBoxes = true;18 mShowBoxes = true; 19 19 mMaxDepth = 20; 20 20 } … … 57 57 // must be empty because objects are found and rendered in an interleaved fashion 58 58 // in _renderVisibibleObjects 59 //char *msg = "now finding visible objects\n"; OutputDebugString(msg);60 59 } 61 60 //----------------------------------------------------------------------- … … 92 91 return mOcclusionCullingOctreeSceneTraverser->getOptionKeys ( refKeys ) || OctreeSceneManager::getOptionKeys( refKeys ); 93 92 } 94 //-----------------------------------------------------------------------95 void OcclusionCullingOctreeSceneManager::_renderOctant(Camera *cam, Octree *octant)96 {97 //Add stuff to be rendered;98 NodeList::iterator it = octant->mNodes.begin();99 100 while(it != octant->mNodes.end())101 {102 OctreeNode *sn = *it;103 104 mNumObjects++;105 106 // check bounding box visibility of scene nodes107 if (cam->isVisible(sn->_getWorldAABB()))108 {109 sn->_addToRenderQueue(cam, getRenderQueue(), false);110 //node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false);111 mVisible.push_back(sn);112 113 if (mDisplayNodes)114 getRenderQueue()->addRenderable(sn);115 116 // check if the scene manager or this node wants the bounding box shown.117 if (sn->getShowBoundingBox() || mShowBoundingBoxes)118 sn->_addBoundingBoxToQueue(getRenderQueue());119 120 if (mShowBoxes)121 getRenderQueue()->addRenderable(octant->getWireBoundingBox());122 }123 ++it;124 }125 126 SceneManager::_renderVisibleObjects();127 128 // delete all rendered objects from renderqueue129 _deleteRenderedQueueGroups();130 }131 93 } -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp
r48 r51 28 28 { 29 29 Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 30 30 31 /*char msg[100]; 32 sprintf(msg, "node number: %d %d %d\n", (i & 4) >> 2, (i & 2) >> 1, i & 1); 33 OutputDebugString(msg);*/ 34 31 35 if(nextChild) 32 36 mOctreeDistanceQueue->push(nextChild); … … 44 48 45 49 // interesting for visualization purpose 46 //TODO: octree->setNodeVisible(false);50 octant->setOctreeVisible(false); 47 51 octant->_getCullBounds(&box); 48 52 … … 81 85 bool intersects = false; 82 86 83 //if(vis == OctreeCamera::NONE)84 87 if(!cam->isVisible(box, intersects)) 85 88 { … … 100 103 // wait if result not available 101 104 query->pullOcclusionQuery(&visiblePixels); 102 105 //visiblePixels = 1; 103 106 // node visible 104 107 if(visiblePixels > mVisibilityThreshold) … … 108 111 else 109 112 { 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 110 120 mNumQueryCulledNodes ++; 111 121 } … … 133 143 unsigned int visiblePixels; 134 144 query->pullOcclusionQuery(&visiblePixels); 135 145 //visiblePixels = 1; 136 146 if(visiblePixels > mVisibilityThreshold) 137 147 { … … 164 174 if(intersects) 165 175 { 166 // update node's visited flag176 // update octant's visited flag 167 177 octant->setLastVisited(mFrameId); 168 178 pullUpVisibility(cam, octant); … … 174 184 // identify previously visible nodes 175 185 bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1); 176 186 187 /* char msg[100]; 188 if(wasVisible) sprintf(msg, "yes, was visible, %d\n", mFrameId); 189 else sprintf(msg, "no was invisible, %d\n", mFrameId); 190 OutputDebugString(msg);*/ 191 177 192 // identify nodes that we cannot skip queries for 178 193 bool leafOrWasInvisible = !wasVisible || isLeaf(octant); … … 196 211 traverseOctant(cam, octant); 197 212 } 198 else199 {200 mNumFrustumCulledNodes ++;201 }202 213 } 203 214 } … … 218 229 void OcclusionCullingOctreeSceneTraverser::renderOctant( Camera *cam, Octree *octant ) 219 230 { 220 //if(octant->numNodes() > 0)231 if(octant->numNodes() == 0) return; 221 232 if(octant->lastVisited() != octant->lastRendered()) 222 233 { 223 //setRenderingMode(MODE_RENDER); 234 //TODO: does nothing useful 235 setRenderingMode(MODE_RENDER); 236 mNumRenderedNodes ++; 224 237 225 238 octant->setLastRendered(octant->lastVisited()); 226 ((Oc clusionCullingOctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant);227 } 228 else OutputDebugString("already rendered");239 ((OctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant); 240 } 241 //else OutputDebugString("already rendered"); 229 242 } 230 243 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp
r48 r51 34 34 namespace Ogre { 35 35 36 36 // OcclusionCullingDotSceneManager *occlusionDotPlugin; 37 37 OcclusionCullingOctreeSceneManager *occlusionOctreePlugin; 38 38 OcclusionCullingTerrainSceneManager *occlusionTerrainPlugin; … … 54 54 Root::getSingleton().setSceneManager( ST_GENERIC, occlusionOctreePlugin ); 55 55 Root::getSingleton().setSceneManager( ST_EXTERIOR_CLOSE, occlusionTerrainPlugin ); 56 57 // MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);58 56 } 59 57 extern "C" void dllStopPlugin(void) -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r44 r51 16 16 mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT), 17 17 mNumQueries(0), mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), 18 mNumRendered Geometry(0), mSceneManager(sm), mRenderSystem(rsys), mSceneRoot(NULL)18 mNumRenderedNodes(0),mNumRenderedGeometry(0), mSceneManager(sm), mRenderSystem(rsys), mSceneRoot(NULL) 19 19 { 20 20 mHalfBoundingBox[0] = mHalfBoundingBox[1] = 0; … … 39 39 mNumFrustumCulledNodes = 0; 40 40 mNumRenderedGeometry = 0; 41 41 mNumRenderedNodes = 0; 42 42 43 mCurrentTestIdx = 0; 43 44 44 45 initDistanceQueue(cam); 45 46 46 //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 47 //deleteQueries(); 48 //char *msg = "deleting queries\n"; OutputDebugString(msg); 49 //for(unsigned int i=0; i < 1000; i++) 50 //mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 51 //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 52 47 53 switch(mCurrentAlgorithm) 48 54 { … … 54 60 break; 55 61 case RENDER_COHERENT: 56 //renderCoherentWithQueue(cam); 57 renderStopAndWait(cam); 62 renderCoherentWithQueue(cam); 58 63 break; 59 64 default: … … 209 214 // wait if result not available 210 215 query->pullOcclusionQuery(&visiblePixels); 211 216 212 217 // node visible 213 218 if(visiblePixels > mVisibilityThreshold) … … 229 234 // TODO: in rendervisibleobjects, the rendermode is changed by ogre itself => change this!! 230 235 231 //setRenderingMode(MODE_QUERY);232 setRenderingMode(MODE_RENDER);236 setRenderingMode(MODE_QUERY); 237 //setRenderingMode(MODE_RENDER); 233 238 234 239 // get next available test id … … 251 256 //{ 252 257 bool enabled = (mode == MODE_RENDER); 253 258 //if(mode == MODE_QUERY){ 254 259 mRenderSystem->_setColourBufferWriteEnabled(enabled, 255 260 enabled, enabled, enabled); 256 261 mRenderSystem->_setDepthBufferWriteEnabled(enabled); 257 262 mRenderSystem->setLightingEnabled(enabled); 258 263 //} 259 264 mQueryMode = mode; 260 265 //} … … 346 351 void OcclusionCullingSceneTraverser::deleteQueries( void ) 347 352 { 348 for(unsigned int i=0; i < (unsigned int)mOcclusionQueries.size(); i++)353 for(unsigned int i=0; i < (unsigned int)mOcclusionQueries.size(); ++i) 349 354 delete mOcclusionQueries[i]; 350 355 … … 357 362 for(int half = 0; half < 2; half ++) 358 363 { 359 //static Matrix4 xform[256];360 //TODO: this should be full bou dning box364 static Matrix4 xform[256]; 365 //TODO: this should be full bounding box 361 366 SolidHalfBoundingBox *halfbox = getSolidHalfBoundingBox(half); 362 367 halfbox->setupBoundingBox(*box); 363 364 mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY);365 368 369 //mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 370 // Set world transformation 371 /*halfbox->getWorldTransforms(xform); 372 373 int numMatrices = halfbox->getNumWorldTransforms(); 374 if (numMatrices > 1) 375 { 376 mRenderSystem->_setWorldMatrices(xform, numMatrices); 377 } 378 else 379 { 380 mRenderSystem->_setWorldMatrix(*xform); 381 } 382 mRenderSystem->setClipPlanes(halfbox->getClipPlanes()); 383 366 384 static RenderOperation ro; 367 385 … … 369 387 halfbox->getRenderOperation(ro); 370 388 ro.srcRenderable = halfbox; 371 mRenderSystem->_render(ro); 372 373 //mSceneManager->renderSingleObject(getSolidHalfBoundingBox(half),374 //getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false);389 mRenderSystem->_render(ro);*/ 390 391 mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), 392 getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false); 375 393 } 376 394 } … … 410 428 { 411 429 mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 430 //char *msg = "creating query!!\n"; OutputDebugString(msg); 412 431 } 413 432 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
r48 r51 18 18 //mDisplayNodes = true; 19 19 //mShowBoundingBoxes = true; 20 //mShowBoxes = true;20 mShowBoxes = true; 21 21 mMaxDepth = 20; 22 22 } … … 95 95 } 96 96 //----------------------------------------------------------------------- 97 void OcclusionCullingTerrainSceneManager::_renderOctant(Camera *cam, Octree *octant)98 {99 //Add stuff to be rendered;100 NodeList::iterator it = octant->mNodes.begin();101 102 while(it != octant->mNodes.end())103 {104 OctreeNode *sn = *it;105 106 mNumObjects++;107 108 // check bounding box visibility of scene nodes109 if (cam->isVisible(sn->_getWorldAABB()))110 {111 sn->_addToRenderQueue(cam, getRenderQueue(), false);112 //node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false);113 mVisible.push_back(sn);114 115 if (mDisplayNodes)116 getRenderQueue()->addRenderable(sn);117 118 // check if the scene manager or this node wants the bounding box shown.119 if (sn->getShowBoundingBox() || mShowBoundingBoxes)120 sn->_addBoundingBoxToQueue(getRenderQueue());121 122 if (mShowBoxes)123 getRenderQueue()->addRenderable(octant->getWireBoundingBox());124 }125 ++it;126 }127 128 SceneManager::_renderVisibleObjects();129 130 // delete all rendered objects from renderqueue131 _deleteRenderedQueueGroups();132 }133 //-----------------------------------------------------------------------134 97 /*unsigned int OcclusionCullingTerrainSceneManager::countNumOctrees(Octree *root) 135 98 { -
trunk/VUT/OcclusionCullingSceneManager/src/OgreSolidHalfBoundingBox.cpp
r26 r51 89 89 setBoundingBox(aabb); 90 90 } 91 // Override this method to prevent parent transforms (rotation,translation,scale) 92 void SolidHalfBoundingBox::getWorldTransforms( Matrix4* xform ) const 93 { 94 // return identity matrix to prevent parent transforms 95 *xform = Matrix4::IDENTITY; 96 } 91 97 } 92 98
Note: See TracChangeset
for help on using the changeset viewer.