Changeset 19
- Timestamp:
- 03/17/05 17:37:09 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
r12 r19 17 17 { 18 18 public: 19 19 myless(Camera *cam) { mCamera = cam; } 20 20 //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const 21 21 bool operator() (T v1, T v2) const 22 22 { 23 return true;//(v1->getSquaredViewDepth(cam) > v2->getSquaredViewDepth(cam));23 return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera); 24 24 } 25 private: 26 Camera *mCamera; 25 27 }; 26 28 … … 39 41 /** Overriden from SceneManager. */ 40 42 void _renderVisibleObjects(void); 41 43 void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 44 42 45 protected: 43 46 44 void walkTree(SceneNode *node); 45 47 void renderZPass(); 48 void traverseNode(SceneNode *node); 49 void renderSceneNode(SceneNode *node); 46 50 /** renders the scene with view frustum culling only */ 47 51 void renderCullFrustum(); 48 52 49 53 /** we use a priority queue rather than a renderstack */ 50 PriorityQueue mDistanceQueue; 51 54 PriorityQueue *mDistanceQueue; 55 // RenderQueue* mDistanceQueue; 56 52 57 int mFrameID; 53 58 }; -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
r18 r19 2 2 #include "OgreMath.h" 3 3 #include "OgreIteratorWrappers.h" 4 #include "OgreRenderSystem.h" 5 #include "OgreCamera.h" 4 6 #include <windows.h> 5 7 … … 8 10 //----------------------------------------------------------------------- 9 11 OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 10 mFrameID(1) 12 mFrameID(1), mDistanceQueue(NULL) 11 13 { 14 } 15 16 void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 17 { 18 // empty because we have to find in _renderVisibleObjects 12 19 } 13 20 … … 15 22 void OcclusionCullingSceneManager::_renderVisibleObjects(void) 16 23 { 17 //RenderZPass(); 18 SceneManager::_renderVisibleObjects(); 24 mDistanceQueue = new PriorityQueue(myless<SceneNode *>(mCameraInProgress)); 25 mDistanceQueue->push(mSceneRoot); 26 //renderZPass(); 27 renderCullFrustum(); 28 delete mDistanceQueue; 29 //mDestRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS); 30 //SceneManager::_renderVisibleObjects(); 31 //mDestRenderSystem->_setDepthBufferParams(); 19 32 //mDistanceQueue.push(mSceneRoot); 20 33 //Preprocess(); 21 //printf("registered my plugin!!\n"); 22 //MessageBox( NULL, "myplugin", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 23 renderCullFrustum(); 34 35 //renderCullFrustum(); 24 36 25 37 //mFrameID ++; … … 28 40 29 41 //----------------------------------------------------------------------- 42 void OcclusionCullingSceneManager::renderZPass() 43 { 44 traverseNode(mSceneRoot); 45 } 46 47 //----------------------------------------------------------------------- 30 48 void OcclusionCullingSceneManager::renderCullFrustum() 31 49 { 32 //RenderQueue::QueueGroupIterator queueIt = getRenderQueue()->_getQueueGroupIterator(); 33 34 //while (queueIt.hasMoreElements()) 35 if(! mDistanceQueue.empty()) 50 while(!mDistanceQueue->empty()) 36 51 { 37 SceneNode *node = mDistanceQueue.top(); 38 mDistanceQueue.pop(); 39 40 //walkTree( 41 42 } 43 /* 44 HierarchyNode *node = mDistanceQueue.top(); 45 mDistanceQueue.pop(); 52 SceneNode *node = mDistanceQueue->top(); 53 mDistanceQueue->pop(); 46 54 47 55 // interesting for the visualization, so rest and set 48 node->SetVisible(false); 49 50 // We don't need to know about near plane intersection 51 // for frustum culling only, but we have to pass a parameter 52 bool intersectsNearplane; 53 if(InsideViewFrustum(node, intersectsNearplane)) 56 //node->SetVisible(false); 57 58 if(mCameraInProgress->isVisible(node->_getWorldAABB())) 54 59 { 55 60 // update node's visited flag => needed for rendering 56 61 // so set it also here 57 node->SetLastVisited(mFrameID);58 node->SetVisible(true);59 TraverseNode(node);62 //node->SetLastVisited(mFrameID); 63 //node->SetVisible(true); 64 traverseNode(node); 60 65 } 61 }*/ 66 //else 67 //MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 68 } 62 69 } 63 70 64 71 //----------------------------------------------------------------------- 65 void OcclusionCullingSceneManager:: walkTree(SceneNode *node)72 void OcclusionCullingSceneManager::traverseNode(SceneNode *node) 66 73 { 67 if(node->numChildren() > 0)74 if(node->numChildren() == 0) // reached leaf 68 75 { 69 //node->Render();76 renderSceneNode(node); 70 77 } 71 78 else // internal node: add children to priority queue for further processing 72 79 { 73 80 Node::ChildNodeIterator it = node->getChildIterator(); 81 char str[100]; sprintf(str, "number of children: %d", node->numChildren()); 74 82 75 83 while (it.hasMoreElements()) 76 { 84 { 77 85 SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext()); 78 // getRenderQueue()->addRenderable(sceneChild);79 mDistanceQueue .push(sceneChild);86 //mDistanceQueue->addRenderable(sceneChild); 87 mDistanceQueue->push(sceneChild); 80 88 } 81 } 89 } 90 91 /* 92 static RenderOperation ro; 93 node->getRenderOperation(ro); 94 ro.srcRenderable = node; 95 mDestRenderSystem->_render(ro); 96 Pass pass(); 97 renderSingleObject(node, &pass, true); 98 */ 99 } 100 101 void OcclusionCullingSceneManager::renderSceneNode(SceneNode *node) 102 { 103 node->_findVisibleObjects(mCameraInProgress, getRenderQueue(), false, 104 mDisplayNodes, false); 105 SceneManager::_renderVisibleObjects(); 106 getRenderQueue()->clear(); 82 107 } 83 108 }
Note: See TracChangeset
for help on using the changeset viewer.