Changeset 36 for trunk/VUT/OcclusionCullingSceneManager/include
- Timestamp:
- 03/31/05 17:51:17 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
r33 r36 100 100 //HACK 101 101 //unsigned int countSceneNodes(SceneNode *node); 102 v oid traverseNode( Camera *cam, SceneNode *node );102 virtual void traverseNode( Camera *cam, SceneNode *node ); 103 103 /** Renders current scene node 104 104 @param cam current camera -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h
r35 r36 1 #ifndef _OcclusionCulling SceneTraverser_H__2 #define _OcclusionCulling SceneTraverser_H__1 #ifndef _OcclusionCullingTerrainSceneTraverser_H__ 2 #define _OcclusionCullingTerrainSceneTraverser_H__ 3 3 4 #include "OgreSceneNode.h" 5 #include "OgreSceneManager.h" 6 #include "OgrePrerequisites.h" 7 #include "OgreSolidHalfBoundingBox.h" 8 #include "OgreCamera.h" 9 #include "OgreRenderSystem.h" 10 #include <queue> 4 #include "OgreOcclusionCullingSceneTraverser.h" 11 5 12 6 using namespace std; 13 7 14 8 namespace Ogre { 15 /** 16 This class implements the compare operator for the priority queue. 17 a lower distance has a higher value in the queue 18 */ 19 template <typename T> class myless 9 10 class OcclusionCullingTerrainSceneTraverser: OcclusionCullingSceneTraverser 20 11 { 21 public:22 myless(Camera *cam) { mCamera = cam; }23 //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const24 bool operator() (T v1, T v2) const25 {26 return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera);27 }28 private:29 Camera *mCamera;30 };31 32 typedef pair<SceneNode *, HardwareOcclusionQuery *> query_pair;33 typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;34 typedef queue<query_pair> QueryQueue;35 /**36 Class which implements a scene mangager which uses occlusion queries for culling occluded objects37 */38 class OcclusionCullingSceneTraverser39 {40 public:41 /** Construction taking the current scene manager and the current rendersystem as argument42 @param sm current scene manager43 @param rsys current render system44 */45 OcclusionCullingSceneTraverser(SceneManager *sm, RenderSystem *rsys);46 ~OcclusionCullingSceneTraverser();47 48 enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};49 50 /** Renders the scene with the specified algorithm51 @comment52 The algorithm type can be set with the parameter "Algorithm" and setOption.53 54 The algorithm is one of:55 RENDER_CULL_FRUSTUM: renders the scene with view frustum culling only56 RENDER_STOP_AND_WAIT: renders the scene with the hierarchical stop and wait algorithm57 RENDER_COHERENT: renders the scene with the coherent hierarchical algorithm58 59 @param cam current camera60 @param root root of hierarchy61 */62 void renderScene( Camera *cam, SceneNode *root );63 64 65 /** Sets the given option for the scene traverser.66 @remarks67 Options are:68 "Algorithm", int *;69 */70 bool setOption( const String &, const void * );71 /** Gets the given option for the scene traverser.72 @remarks73 See setOption74 */75 bool getOption( const String &, void * );76 bool getOptionKeys( StringVector &refKeys );77 78 /** Sets pointer to the current scene manager.79 @param the scene manager */80 void setSceneManager( SceneManager *sm );81 82 /** Sets pointer to the current render system83 @param the rendersystem */84 void setRenderSystem( RenderSystem *rsys );85 86 /** Doing some necessary preprocessing.87 @comment e.g., initialises occlusion queries */88 void preprocess( void );89 90 /** Sets the current number of scene nodes in the scene.91 @param num number of scene nodes92 */93 void setNumSceneNodes(int num );94 95 protected:96 /** query mode (= without color) or RENDER_MODE */97 enum {MODE_QUERY, MODE_RENDER};98 /** returns true if node is leaf of the hierarchy */99 bool isLeaf( SceneNode *node );100 //HACK101 //unsigned int countSceneNodes(SceneNode *node);102 12 void traverseNode( Camera *cam, SceneNode *node ); 103 /** Renders current scene node104 @param cam current camera105 @param node current scene node to be rendered106 */107 void renderSceneNode( Camera *cam, SceneNode *node);108 /** Sets rendering mode, e.g. query mode or render mode*/109 void setRenderingMode( int mode );110 /** Renders the scene with view frustum culling only. */111 void renderCullFrustum( Camera *cam );112 /** Renders the scene with the hierarchical stop and wait algorithm. */113 void renderStopAndWait( Camera *cam );114 /** Renders the scene with the coherent hierarchical algorithm and the query queye. */115 void renderCoherentWithQueue( Camera *cam );116 /** Issue a occlusion query for this node. */117 HardwareOcclusionQuery *issueOcclusionQuery( SceneNode *node, bool wasVisible );118 /** Pulls up the visibility from the child nodes. */119 void pullUpVisibility( SceneNode *node );120 /** delete all previously defined occlusion queries */121 void deleteQueries();122 /** Renders bounding box of specified node.123 @param the scene node contained in the bounding box to be rendered124 */125 void renderBoundingBox( SceneNode *node );126 /** Returns one half of the bounding box.127 @param the half of the bouding box128 */129 SolidHalfBoundingBox *getSolidHalfBoundingBox( int half );130 131 // we use a priority queue rather than a renderstack132 PriorityQueue *mDistanceQueue;133 134 std::vector<HardwareOcclusionQuery *> mOcclusionQueries;135 // two halfes of a aabb136 SolidHalfBoundingBox *mHalfBoundingBox[2];137 138 int mCurrentAlgorithm;139 140 unsigned int mFrameId;141 unsigned int mVisibilityThreshold;142 143 SceneManager *mSceneManager;144 RenderSystem *mRenderSystem;145 146 int mCurrentTestIdx;147 int mQueryMode;148 149 //--- statistics150 unsigned int mNumSceneNodes;151 unsigned int mNumTraversedNodes;152 unsigned int mNumQueryCulledNodes;153 unsigned int mNumFrustumCulledNodes;154 unsigned int mNumRenderedGeometry;155 13 }; 156 14 157 15 } 158 #endif // O CCLUSIONCULLINGSCENEMANAGER_H16 #endif // OcclusionCullingTerrainSceneTraverser_H
Note: See TracChangeset
for help on using the changeset viewer.