Changeset 39
- Timestamp:
- 04/05/05 17:39:03 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene/TestCullingDotSceneApplication.cpp
r37 r39 481 481 void MouseQueryListener::mouseDragged (MouseEvent *e) 482 482 { 483 /*484 483 // If we are dragging the left mouse button. 485 484 if ( mLMouseDown ) 486 485 { 487 mShipNode->translate(-e->getRelX() * 200, -e->getRelY() * 200, 0.0); 486 mCamera->yaw( -e->getRelX() * mRotateSpeed ); 487 mCamera->pitch( -e->getRelY() * mRotateSpeed ); 488 488 } 489 */ 490 489 491 490 // If we are dragging the right mouse button. 492 491 if ( mRMouseDown ) 493 492 { 494 mCamera->yaw( -e->getRelX() * mRotateSpeed ); 495 mCamera->pitch( -e->getRelY() * mRotateSpeed ); 493 Vector3 translation; 494 translation.x += -e->getRelX() * 0.13; 495 translation.y -= -e->getRelY() * 0.13; 496 497 mCamera->moveRelative(translation); 496 498 } 497 499 } -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
r36 r39 30 30 }; 31 31 32 typedef pair<SceneNode *, HardwareOcclusionQuery *> query_pair;32 typedef pair<SceneNode *, HardwareOcclusionQuery *> QueryPair; 33 33 typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue; 34 typedef queue< query_pair> QueryQueue;34 typedef queue<QueryPair> QueryQueue; 35 35 /** 36 36 Class which implements a scene mangager which uses occlusion queries for culling occluded objects … … 100 100 //HACK 101 101 //unsigned int countSceneNodes(SceneNode *node); 102 v irtual void traverseNode( Camera *cam, SceneNode *node );102 void traverseNode( Camera *cam, SceneNode *node ); 103 103 /** Renders current scene node 104 104 @param cam current camera -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h
r34 r39 16 16 17 17 namespace Ogre { 18 18 template <typename T> class octreeless 19 { 20 public: 21 myless(Camera *cam) { mCamera = cam; } 22 //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const 23 bool operator() (T v1, T v2) const 24 { 25 v1->getCullBounds(&mAabb); 26 return mAabb->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera); 27 } 28 29 private: 30 Camera *mCamera; 31 AxisAlignedBox mAabb; 32 }; 33 19 34 /** 20 35 Class which implements a scene mangager which uses occlusion queries for culling occluded objects -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h
r36 r39 2 2 #define _OcclusionCullingTerrainSceneTraverser_H__ 3 3 4 #include "OgreOctree.h" 4 5 #include "OgreOcclusionCullingSceneTraverser.h" 5 6 … … 7 8 8 9 namespace Ogre { 10 void Octree::_getCullBounds( AxisAlignedBox *b ) 11 typedef pair<Octree *, HardwareOcclusionQuery *> OctreeQueryPair; 12 typedef priority_queue<Octree *, vector<Octree *>, myless<vector<Octree *>::value_type> > OctreePriorityQueue; 13 //typedef queue<QueryPair> QueryQueue; 9 14 10 15 class OcclusionCullingTerrainSceneTraverser: OcclusionCullingSceneTraverser 11 16 { 12 void traverseNode( Camera *cam, SceneNode *node ); 17 void renderScene( Camera *cam, Octree *root ); 18 void renderCullFrustum( Camera *cam ); 19 void pullUpVisibility( Octree *node ); 20 void traverseNode( Camera *cam, Octree *node ); 21 22 protected: 23 OctreePriorityQueue *mDistanceQueue; 13 24 }; 14 25 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingDotSceneManager.cpp
r38 r39 31 31 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 32 32 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 33 33 34 34 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 35 //DotSceneManager::_renderVisibleObjects( );35 DotSceneManager::_renderVisibleObjects( ); 36 36 _deleteRenderedQueueGroups(); 37 37 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r38 r39 118 118 { 119 119 HardwareOcclusionQuery *query = issueOcclusionQuery(node, wasVisible); 120 queryQueue.push( query_pair(node, query));120 queryQueue.push(QueryPair(node, query)); 121 121 } 122 122 … … 322 322 for(int half = 0; half < 2; half ++) 323 323 { 324 //static Matrix4 xform[256]; 325 324 326 SolidHalfBoundingBox *box = getSolidHalfBoundingBox(half); 327 box->setupBoundingBox(node->_getWorldAABB()); 328 329 mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 325 330 326 box->setupBoundingBox(node->_getWorldAABB());327 328 331 static RenderOperation ro; 332 329 333 mSceneManager->useRenderableViewProjMode(box); 330 334 box->getRenderOperation(ro); -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp
r37 r39 4 4 namespace Ogre { 5 5 //----------------------------------------------------------------------- 6 void OcclusionCullingTerrainSceneTraverser::traverseNode( Camera *cam, SceneNode *node )6 void OcclusionCullingTerrainSceneTraverser::traverseNode( Camera *cam, Octree *node ) 7 7 { 8 8 mNumTraversedNodes ++; 9 10 if(node->numAttachedObjects() > 0)9 10 /* if(node->numAttachedObjects() > 0) 11 11 { 12 12 renderSceneNode(cam, node); 13 } 13 }*/ 14 14 15 // internal node: add children to priority queue for further processing 16 Node::ChildNodeIterator it = node->getChildIterator(); 17 18 while (it.hasMoreElements()) 19 { 20 SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext()); 21 mDistanceQueue->push(sceneChild); 22 } 23 } 24 /* //----------------------------------------------------------------------- 25 void OcclusionCullingTerrainSceneTraverser::renderSceneNode( Camera *cam, SceneNode *node ) 26 { 27 setRenderingMode(MODE_RENDER); 28 29 //HACK (too slow) 30 mSceneManager->_renderSceneNode(cam, node); 31 //MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 32 } 33 //----------------------------------------------------------------------- 34 bool OcclusionCullingTerrainSceneTraverser::isLeaf( SceneNode *node ) 35 { 36 return (node->numChildren() == 0); 37 } 38 //----------------------------------------------------------------------- 39 void OcclusionCullingTerrainSceneTraverser::pullUpVisibility( SceneNode *node ) 40 { 41 while(node && !node->isNodeVisible()) 15 for(int i=0; i<8; i++) 42 16 { 43 node->setNodeVisible(true);44 node = static_cast<SceneNode *>(node->getParent());17 if(node->mChildren[i & 4][i & 2][i & 1] != 0) 18 traverseNode(cam, node->mChildren[i & 4][i & 2][i & 1]); 45 19 } 46 20 } 47 21 //----------------------------------------------------------------------- 48 void OcclusionCullingTerrainSceneTraverser::render BoundingBox( SceneNode *node)22 void OcclusionCullingTerrainSceneTraverser::renderScene( Camera *cam, Octree *root ) 49 23 { 50 // Render two halfes of the bounding box (using triangle fans) 51 for(int half = 0; half < 2; half ++) 24 mNumTraversedNodes = 0; 25 mNumQueryCulledNodes = 0; 26 mNumFrustumCulledNodes = 0; 27 mNumRenderedGeometry = 0; 28 29 mDistanceQueue = new OctreePriorityQueue(myless<Octree *>(cam)); 30 // mDistanceQueue->push(root); 31 mCurrentTestIdx = 0; 32 33 mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 34 switch(mCurrentAlgorithm) 52 35 { 53 SolidHalfBoundingBox *box = getSolidHalfBoundingBox(half); 54 55 box->setupBoundingBox(node->_getWorldAABB()); 36 case RENDER_CULL_FRUSTUM: 37 renderCullFrustum(cam); 38 break; 39 /* case RENDER_STOP_AND_WAIT: 40 renderStopAndWait(cam); 41 break; 42 case RENDER_COHERENT: 43 renderCoherentWithQueue(cam); 44 break;*/ 45 default: 46 renderCullFrustum(cam); 47 break; 48 } 49 50 // delete mDistanceQueue; 56 51 57 static RenderOperation ro; 58 mSceneManager->useRenderableViewProjMode(box); 59 box->getRenderOperation(ro); 60 ro.srcRenderable = box; 61 mRenderSystem->_render(ro); 62 63 //mSceneManager->renderSingleObject(getSolidHalfBoundingBox(half), 64 // getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false); 65 } 52 mFrameId ++; 53 } 54 //----------------------------------------------------------------------- 55 void OcclusionCullingTerrainSceneTraverser::renderCullFrustum(Camera *cam) 56 { 57 /*while(!mDistanceQueue->empty()) 58 { 59 SceneNode *node = mDistanceQueue->top(); 60 mDistanceQueue->pop(); 61 62 // interesting for visualization purpose 63 node->setNodeVisible(false); 64 65 if(cam->isVisible(node->_getWorldAABB())) 66 { 67 // update node's visited flag 68 node->setLastVisited(mFrameId); 69 node->setNodeVisible(true); 70 traverseNode(cam, node); 71 } 72 else 73 { 74 mNumFrustumCulledNodes ++; 75 } 76 }*/ 77 } 78 //----------------------------------------------------------------------- 79 /* bool OcclusionCullingTerrainSceneTraverser::isLeaf( SceneNode *node ) 80 { 81 return (node->numChildren() == 0); 66 82 }*/ 83 //----------------------------------------------------------------------- 84 void OcclusionCullingTerrainSceneTraverser::pullUpVisibility( Octree *node ) 85 { 86 } 67 87 }
Note: See TracChangeset
for help on using the changeset viewer.