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

Revision 2558, 6.6 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        virtual void AddToQueue(GtpVisibility::HierarchyNode *node) {};
143
144        virtual void RenderQueue() {};
145
146        virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) {};
147       
148        virtual GtpVisibility::OcclusionQuery *IssueMultiQuery(
149                                                                                        const GtpVisibility::HierarchyNodeContainer &nodes);
150
151protected:
152
153        /** Renders the given geometry
154        */
155        void RenderGeometry(GtpVisibility::Mesh *geom);
156        /** Renders the given patch
157        */
158        void RenderPatch(GtpVisibility::Patch *patch);
159        /** Materials for visualizing frustum and query culled nodes.
160        */
161        void CreateNodeVizMaterials();
162        /** Returns pointer to current renderable bounding box geometry.
163        */
164        SolidBoundingBox *GetSolidBoundingBox();
165        /** Renders given bounding box.
166                @param box the bounding box of the scene node to be rendered
167        */
168        void RenderBoundingBox(AxisAlignedBox *box);
169        /** Renders bounding boxes of the geometry.
170                @param node the node to be rendered
171        */
172        virtual void RenderGeometryBounds(GtpVisibility::HierarchyNode *node) {};
173       
174
175        /////////////////////
176
177        /** Renderable of an aabb.
178        */
179        SolidBoundingBox *mSolidBoundingBox;
180
181        SceneManager *mSceneManager;
182        RenderSystem *mRenderSystem;
183
184        Camera *mCamera;
185        Camera *mCullCamera;
186
187        AxisAlignedBox mBox;
188       
189        OcclusionQueryContainer mOcclusionQueries;
190
191        Vector3 mCameraPosition;
192        bool mOnlyShadowCasters;
193        int mLeavePassesInQueue;
194        bool mIsBoundingBoxQuery;
195
196        bool mTestGeometryBounds;
197
198        bool mTestMode;
199};
200
201} // namespace Ogre
202
203#endif // PlatformHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.