source: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp @ 19

Revision 19, 3.2 KB checked in by gametools, 20 years ago (diff)

doing some basic traversal

RevLine 
[12]1#include "OgreOcclusionCullingSceneManager.h"
2#include "OgreMath.h"
3#include "OgreIteratorWrappers.h"
[19]4#include "OgreRenderSystem.h"
5#include "OgreCamera.h"
[16]6#include <windows.h>
[12]7
8namespace Ogre {
9       
10        //-----------------------------------------------------------------------
11        OcclusionCullingSceneManager::OcclusionCullingSceneManager():
[19]12        mFrameID(1), mDistanceQueue(NULL)
[16]13        {               
[12]14        }
15
[19]16        void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
17        {
18                // empty because we have to find in _renderVisibleObjects
19        }
20
[12]21        //-----------------------------------------------------------------------
22        void OcclusionCullingSceneManager::_renderVisibleObjects(void)
23        {
[19]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();
[18]32        //mDistanceQueue.push(mSceneRoot);
[12]33                //Preprocess();
[19]34               
35                //renderCullFrustum();
[12]36
37                //mFrameID ++;
38                //ResetQueries();
39        }
40
41        //-----------------------------------------------------------------------
[19]42        void OcclusionCullingSceneManager::renderZPass()
43        {
44                traverseNode(mSceneRoot);
45        }
46
47        //-----------------------------------------------------------------------
[12]48        void OcclusionCullingSceneManager::renderCullFrustum()
49        {
[19]50                while(!mDistanceQueue->empty())
51                {
52                        SceneNode *node = mDistanceQueue->top();
53                        mDistanceQueue->pop();
54       
55                        // interesting for the visualization, so rest and set
56                        //node->SetVisible(false);
57                               
58                        if(mCameraInProgress->isVisible(node->_getWorldAABB()))
59                        {
60                                // update node's visited flag => needed for rendering
61                                // so set it also here
62                                //node->SetLastVisited(mFrameID);
63                                //node->SetVisible(true);
64                                traverseNode(node);
65                        }
66                        //else
67                        //MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);
[12]68                }
69        }
70
71        //-----------------------------------------------------------------------
[19]72        void OcclusionCullingSceneManager::traverseNode(SceneNode *node)
[12]73        {
[19]74                if(node->numChildren() == 0) // reached leaf
[12]75                {
[19]76                        renderSceneNode(node);
[12]77                }
78                else // internal node: add children to priority queue for further processing
79                {
80                        Node::ChildNodeIterator it = node->getChildIterator();
[19]81                        char str[100]; sprintf(str, "number of children: %d", node->numChildren());
[12]82               
83                        while (it.hasMoreElements())
[19]84                        {
[12]85                                SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext());
[19]86                                //mDistanceQueue->addRenderable(sceneChild);
87                mDistanceQueue->push(sceneChild);
[12]88                        }
[19]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                 */
[12]99        }
[19]100
101        void OcclusionCullingSceneManager::renderSceneNode(SceneNode *node)
102        {
103                node->_findVisibleObjects(mCameraInProgress, getRenderQueue(), false,
104                                                                  mDisplayNodes, false);
105                SceneManager::_renderVisibleObjects();
106                getRenderQueue()->clear();
107        }
[12]108}       
Note: See TracBrowser for help on using the repository browser.