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

Revision 938, 5.1 KB checked in by mattausch, 18 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
9//#include "OgreSolidHalfBoundingBox.h"
10#include "OgreSolidBoundingBox.h"
11#include "HierarchyInterface.h"
12#include "VisibilityInfo.h"
13#include "OgrePlatformOcclusionQuery.h"
14
15/** This namespace contains the Ogre dependent classes.
16*/
17namespace Ogre {
18
19/**     Class which implements a hierarchy interface for a specific type of hierarchy.
20        @remark also provides methods for using occlusion queries on the hierarchy nodes
21*/
22typedef std::vector<PlatformOcclusionQuery *> OcclusionQueryContainer;
23
24class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
25{
26public:
27        /** Construction taking the current scene manager and the current rendersystem as argument
28                @param sm current scene manager
29                @param rsys current render system
30        */
31        PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
32        ~PlatformHierarchyInterface();
33               
34        /** Returns next available occlusion query or creates new one.
35                @return the next occlusion query
36        */
37        GtpVisibility::OcclusionQuery *GetNextOcclusionQuery();
38               
39        /** Sets the current camera used for the rendering.
40                @param cam the current camera
41        */
42        void SetCamera(Camera *cam);
43        /** Sets the current camera used for culling.
44                @param cam the current camera
45                @remark the default is the camera used for rendering
46        */
47        void SetCullCamera(Camera *cullCam);
48        /** Initialises this scene traverser for the current frame.
49                @remark This is a convenience method which resets the stats,
50                                sets the current camera, and initialises the distance queue.
51                @param cam the actual camera definding the view frustum
52                @param cullCam the camera used for culling.
53                @remark If cullCam is null, the actual camera is used for both viewing and culling             
54        */
55        void InitTraversal(Camera *cam, Camera *cullCam = NULL, int leavePassesInQueue = 0);
56        /** Checks if the node is visible from the current view frustum.
57                @param node the current node
58                @param intersects returns true if the current node intersects the near plane
59        */
60        bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects);
61        /** Sets pointer to the current scene manager.
62                @param sm the scene manager
63        */
64        void SetSceneManager(SceneManager *sm);
65        /** Sets pointer to the current render system .
66                @param rsys the rendersystem
67        */
68        void SetRenderSystem(RenderSystem *rsys);
69        /** Returns pointer to bounding box of node.
70                @param node current hierarchy node
71                @returns bounding box of current node
72        */
73        virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0;
74        /** Issue a occlusion query for this node.
75                @param node the current hierarchy node
76                @param wasVisible if the node was visible in the last frame
77                @returns occlusion query for this node
78        */
79        GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery(
80                GtpVisibility::HierarchyNode *node, const bool wasVisible);
81
82        /** Issue a occlusion query for this mesh.
83                @param mesh the mesh for which an occlusion query is issued.
84                @returns occlusion query for this mesh.
85        */
86        GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh);
87
88        /** If true, the interface finds and renders only objects which are marked as shadow casters.
89                @remark This is important for the shadow texture pass
90        */
91        void SetOnlyShadowCasters(bool onlyShadowCasters);
92        /** see set
93        */
94        bool GetOnlyShadowCasters();
95        /** see set
96        */
97        bool GetTestGeometryForVisibleLeaves();
98        /** see set
99        */
100        SceneManager *GetSceneManager();
101
102        /** see set
103        */
104        RenderSystem *GetRenderSystem();
105       
106        /** true if bounding box query is currently active.
107        */
108    bool IsBoundingBoxQuery();
109
110        GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch);
111
112        /** Deletes all occlusion queries.
113        */
114        void ResetQueries();
115
116protected:
117        /** Renders the given geometry
118        */
119        void RenderGeometry(GtpVisibility::Mesh *geom);
120       
121        /** Renders the given patch
122        */
123        void RenderPatch(GtpVisibility::Patch *patch);
124
125        /** Materials for visualizing frustum and query culled nodes.
126        */
127        void CreateNodeVizMaterials();
128
129        /** Returns pointer to current renderable bounding box geometry.
130        */
131        SolidBoundingBox *GetSolidBoundingBox();
132
133        /** A pass that prepares an occlusion query.
134                @remark disables depth write, colour write, lighting,
135                vertex and fragment program.*/
136        //void SetOcclusionPass();
137
138        /** Renders given bounding box.
139                @param box the bounding box of the scene node to be rendered
140        */
141        void RenderBoundingBox(AxisAlignedBox *box);
142
143        /** Renderable of an aabb.
144        */
145        SolidBoundingBox *mSolidBoundingBox;
146
147        SceneManager *mSceneManager;
148        RenderSystem *mRenderSystem;
149
150        Camera *mCamera;
151        Camera *mCullCamera;
152
153        AxisAlignedBox mBox;
154       
155        OcclusionQueryContainer mOcclusionQueries;
156
157        Vector3 mCameraPosition;
158        bool mOnlyShadowCasters;
159        int mLeavePassesInQueue;
160        bool mIsBoundingBoxQuery;
161};
162
163} // namespace Ogre
164
165#endif // PlatformHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.