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

Revision 2280, 5.5 KB checked in by mattausch, 17 years ago (diff)

removed dependency on ogre in gtpvisibility

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