source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformHierarchyInterface.h @ 2455

Revision 2455, 6.3 KB checked in by mattausch, 17 years ago (diff)
Line 
1#ifndef _PlatformHierarchyInterface_H__
2#define _PlatformHierarchyInterface_H__
3
4#include <OgreSceneManager.h>
5#include <OgrePrerequisites.h>
6#include <OgreCamera.h>
7#include <OgreRenderSystem.h>
8#include "OgreSolidBoundingBox.h"
9#include "HierarchyInterface.h"
10#include "VisibilityInfo.h"
11#include "OgrePlatformOcclusionQuery.h"
12#include "VisibilityMesh.h"
13
14
15
16/** This namespace contains the Ogre dependent classes.
17*/
18namespace Ogre {
19
20/**     Class which implements a hierarchy interface for a specific type of hierarchy.
21        @remark also provides methods for using occlusion queries on the hierarchy nodes
22*/
23typedef std::vector<PlatformOcclusionQuery *> OcclusionQueryContainer;
24
25class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
26{
27public:
28
29        /** Construction taking the current scene manager and the
30                current rendersystem as argument
31                @param sm current scene manager
32                @param rsys current render system
33        */
34        PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
35        ~PlatformHierarchyInterface();
36        /** Returns next available occlusion query or creates new one.
37                @return the next occlusion query
38        */
39        virtual GtpVisibility::OcclusionQuery *GetNextOcclusionQuery();
40               
41        /** Sets the current camera used for the rendering.
42                @param cam the current camera
43        */
44        void SetCamera(Camera *cam);
45        /** Sets the current camera used for culling.
46                @param cam the current camera
47                @remark the default is the camera used for rendering
48        */
49        void SetCullCamera(Camera *cullCam);
50        /** Initialises this scene traverser for the current frame.
51                @remark This is a convenience method which resets the stats,
52                                sets the current camera, and initialises the distance queue.
53                @param cam the actual camera definding the view frustum
54                @param cullCam the camera used for culling.
55                @remark If cullCam is null, the actual camera is used for both viewing and culling             
56        */
57        void InitTraversal(Camera *cam, Camera *cullCam = NULL, int leavePassesInQueue = 0);
58        /** Checks if the node is visible from the current view frustum.
59                @param node the current node
60                @param intersects returns true if the current node intersects the near plane
61        */
62        bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects);
63        /** Sets pointer to the current scene manager.
64                @param sm the scene manager
65        */
66        void SetSceneManager(SceneManager *sm);
67        /** Sets pointer to the current render system .
68                @param rsys the rendersystem
69        */
70        void SetRenderSystem(RenderSystem *rsys);
71        /** Returns pointer to bounding box of node.
72                @param node current hierarchy node
73                @returns bounding box of current node
74        */
75        virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0;
76        /** Issue a occlusion query for this node.
77                @param node the current hierarchy node
78                @param gives a parameters that decideds on the type of occlusion query.
79               
80                @returns occlusion query for this node
81        */
82        GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery(
83                GtpVisibility::HierarchyNode *node, const bool testGeometry = false);
84
85        /** Issue a occlusion query for this mesh.
86                @param mesh the mesh for which an occlusion query is issued.
87                @returns occlusion query for this mesh.
88        */
89        GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh);
90        /** If true, the interface finds and renders only objects which are marked as shadow casters.
91                @remark This is important for the shadow texture pass
92        */
93        void SetOnlyShadowCasters(bool onlyShadowCasters);
94        /** see set
95        */
96        bool GetOnlyShadowCasters();
97        /** see set
98        */
99        SceneManager *GetSceneManager();
100        /** see set
101        */
102        RenderSystem *GetRenderSystem();
103        /** true if bounding box query is currently active.
104        */
105    bool IsBoundingBoxQuery();
106        /** Issues occlusion queries for a patch.
107        */
108        GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch);
109        /** Deletes all occlusion queries.
110        */
111        void ResetQueries();
112
113        /** Returns the geometry of a given hierarchy node.
114                @param node the hierarchy node containing the geometry
115                @param geometryList geometry is returned in this list
116                @param includeChildren if the geometry of the children should be taken into account
117        */
118        virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,   
119                                                                         GeometryVector *geometryList,
120                                                                         bool includeChildren) = 0;
121
122        void PullUpLastVisited(GtpVisibility::HierarchyNode *node, const int frameId) const {}
123
124        GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node) { return NULL; }
125
126        /** Returns #frames this node is assumed to be visible.
127        */
128        virtual int GetNodeAssumedVisible(GtpVisibility::HierarchyNode *node) { return 0; };
129        /** Sets #frames this node is assumed to be visible.
130        */
131        virtual void SetNodeAssumedVisible(GtpVisibility::HierarchyNode *node, int assumedVisible) {};
132        /** Decreases #frames this node is assumed to be visible.
133        */
134        virtual void DecNodeAssumedVisible(GtpVisibility::HierarchyNode *node) {};
135        /** Test tigher geometry bounds instead of hierarchy node.
136        */
137        void SetTestGeometryBounds(bool testGeometryForLeaves);
138        /** See get
139        */
140        int GetTestGeometryBounds();
141
142
143protected:
144
145        /** Renders the given geometry
146        */
147        void RenderGeometry(GtpVisibility::Mesh *geom);
148        /** Renders the given patch
149        */
150        void RenderPatch(GtpVisibility::Patch *patch);
151        /** Materials for visualizing frustum and query culled nodes.
152        */
153        void CreateNodeVizMaterials();
154        /** Returns pointer to current renderable bounding box geometry.
155        */
156        SolidBoundingBox *GetSolidBoundingBox();
157        /** Renders given bounding box.
158                @param box the bounding box of the scene node to be rendered
159        */
160        void RenderBoundingBox(AxisAlignedBox *box);
161        /** Renders bounding boxes of the geometry.
162                @param node the node to be rendered
163        */
164        virtual void RenderGeometryBounds(GtpVisibility::HierarchyNode *node) {};
165       
166
167        /////////////////////
168
169        /** Renderable of an aabb.
170        */
171        SolidBoundingBox *mSolidBoundingBox;
172
173        SceneManager *mSceneManager;
174        RenderSystem *mRenderSystem;
175
176        Camera *mCamera;
177        Camera *mCullCamera;
178
179        AxisAlignedBox mBox;
180       
181        OcclusionQueryContainer mOcclusionQueries;
182
183        Vector3 mCameraPosition;
184        bool mOnlyShadowCasters;
185        int mLeavePassesInQueue;
186        bool mIsBoundingBoxQuery;
187
188        bool mTestGeometryBounds;
189};
190
191} // namespace Ogre
192
193#endif // PlatformHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.