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