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 | */
|
---|
18 | namespace 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 | */
|
---|
23 | typedef std::vector<PlatformOcclusionQuery *> OcclusionQueryContainer;
|
---|
24 |
|
---|
25 | class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
|
---|
26 | {
|
---|
27 | public:
|
---|
28 | /** Construction taking the current scene manager and the
|
---|
29 | current rendersystem as argument
|
---|
30 | @param sm current scene manager
|
---|
31 | @param rsys current render system
|
---|
32 | */
|
---|
33 | PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
|
---|
34 | ~PlatformHierarchyInterface();
|
---|
35 |
|
---|
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 wasVisible if the node was visible in the last frame
|
---|
79 | @returns occlusion query for this node
|
---|
80 | */
|
---|
81 | GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery(
|
---|
82 | GtpVisibility::HierarchyNode *node, const bool wasVisible);
|
---|
83 |
|
---|
84 | /** Issue a occlusion query for this mesh.
|
---|
85 | @param mesh the mesh for which an occlusion query is issued.
|
---|
86 | @returns occlusion query for this mesh.
|
---|
87 | */
|
---|
88 | GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh);
|
---|
89 |
|
---|
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 | bool GetTestGeometryForVisibleLeaves();
|
---|
100 | /** see set
|
---|
101 | */
|
---|
102 | SceneManager *GetSceneManager();
|
---|
103 |
|
---|
104 | /** see set
|
---|
105 | */
|
---|
106 | RenderSystem *GetRenderSystem();
|
---|
107 |
|
---|
108 | /** true if bounding box query is currently active.
|
---|
109 | */
|
---|
110 | bool IsBoundingBoxQuery();
|
---|
111 |
|
---|
112 | GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch);
|
---|
113 |
|
---|
114 | /** Deletes all occlusion queries.
|
---|
115 | */
|
---|
116 | void ResetQueries();
|
---|
117 |
|
---|
118 | /** Returns the geometry of a given hierarchy node.
|
---|
119 | @param node the hierarchy node containing the geometry
|
---|
120 | @param geometryList geometry is returned in this list
|
---|
121 | @param includeChildren if the geometry of the children should be taken into account
|
---|
122 | */
|
---|
123 | virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,
|
---|
124 | GeometryVector *geometryList,
|
---|
125 | bool includeChildren) = 0;
|
---|
126 |
|
---|
127 | void PullUpLastVisited(GtpVisibility::HierarchyNode *node, const int frameId) const {}
|
---|
128 | void DetermineVisibilityRatio(GtpVisibility::HierarchyNode *node) const {}
|
---|
129 |
|
---|
130 | float GetNodeVisibilityRatio(GtpVisibility::HierarchyNode *node) const { return 1.0f;}
|
---|
131 |
|
---|
132 | GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node) { return NULL;}
|
---|
133 |
|
---|
134 |
|
---|
135 | protected:
|
---|
136 |
|
---|
137 | /** Renders the given geometry
|
---|
138 | */
|
---|
139 | void RenderGeometry(GtpVisibility::Mesh *geom);
|
---|
140 |
|
---|
141 | /** Renders the given patch
|
---|
142 | */
|
---|
143 | void RenderPatch(GtpVisibility::Patch *patch);
|
---|
144 |
|
---|
145 | /** Materials for visualizing frustum and query culled nodes.
|
---|
146 | */
|
---|
147 | void CreateNodeVizMaterials();
|
---|
148 |
|
---|
149 | /** Returns pointer to current renderable bounding box geometry.
|
---|
150 | */
|
---|
151 | SolidBoundingBox *GetSolidBoundingBox();
|
---|
152 |
|
---|
153 | /** A pass that prepares an occlusion query.
|
---|
154 | @remark disables depth write, colour write, lighting,
|
---|
155 | vertex and fragment program.*/
|
---|
156 | //void SetOcclusionPass();
|
---|
157 |
|
---|
158 | /** Renders given bounding box.
|
---|
159 | @param box the bounding box of the scene node to be rendered
|
---|
160 | */
|
---|
161 | void RenderBoundingBox(AxisAlignedBox *box);
|
---|
162 |
|
---|
163 | /** Renderable of an aabb.
|
---|
164 | */
|
---|
165 | SolidBoundingBox *mSolidBoundingBox;
|
---|
166 |
|
---|
167 | SceneManager *mSceneManager;
|
---|
168 | RenderSystem *mRenderSystem;
|
---|
169 |
|
---|
170 | Camera *mCamera;
|
---|
171 | Camera *mCullCamera;
|
---|
172 |
|
---|
173 | AxisAlignedBox mBox;
|
---|
174 |
|
---|
175 | OcclusionQueryContainer mOcclusionQueries;
|
---|
176 |
|
---|
177 | Vector3 mCameraPosition;
|
---|
178 | bool mOnlyShadowCasters;
|
---|
179 | int mLeavePassesInQueue;
|
---|
180 | bool mIsBoundingBoxQuery;
|
---|
181 | };
|
---|
182 |
|
---|
183 | } // namespace Ogre
|
---|
184 |
|
---|
185 | #endif // PlatformHierarchyInterface_H |
---|