[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"
|
---|
| 12 | #include "OgrePlatformOcclusionQuery.h"
|
---|
| 13 |
|
---|
[71] | 14 | /** This namespace contains the Ogre dependent classes.
|
---|
| 15 | */
|
---|
[59] | 16 | namespace Ogre {
|
---|
| 17 |
|
---|
| 18 | /** Class which implements a hierarchy interface for a specific type of hierarchy.
|
---|
| 19 | @remark also provides methods for using occlusion queries on the hierarchy nodes
|
---|
| 20 | */
|
---|
| 21 | class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
|
---|
| 22 | {
|
---|
| 23 | public:
|
---|
| 24 | /** Construction taking the current scene manager and the current rendersystem as argument
|
---|
| 25 | @param sm current scene manager
|
---|
| 26 | @param rsys current render system
|
---|
| 27 | */
|
---|
| 28 | PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
|
---|
| 29 | ~PlatformHierarchyInterface();
|
---|
| 30 |
|
---|
| 31 | /** Returns next available occlusion query or creates new one.
|
---|
| 32 | @return the next occlusion query
|
---|
| 33 | */
|
---|
| 34 | GtpVisibility::OcclusionQuery *GetNextOcclusionQuery();
|
---|
| 35 |
|
---|
[94] | 36 | /** Sets the current camera used for the rendering.
|
---|
[59] | 37 | @param cam the current camera
|
---|
| 38 | */
|
---|
| 39 | void SetCamera(Camera *cam);
|
---|
[94] | 40 | /** Sets the current camera used for culling.
|
---|
| 41 | @param cam the current camera
|
---|
| 42 | @remark the default is the camera used for rendering
|
---|
| 43 | */
|
---|
| 44 | void SetCullCamera(Camera *cullCam);
|
---|
[59] | 45 | /** Initialises this scene traverser for the current frame.
|
---|
[103] | 46 | @remark This is a convenience method which resets the stats,
|
---|
| 47 | sets the current camera, and initialises the distance queue.
|
---|
| 48 | @param root root of the hierarchy
|
---|
| 49 | @param cam the actual camera definding the view frustum
|
---|
| 50 | @param cullCam the camera used for culling.
|
---|
| 51 | @remark If null, the actual camera is used for both viewing and culling
|
---|
[59] | 52 | */
|
---|
[94] | 53 | void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL);
|
---|
[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 | */
|
---|
[86] | 77 | GtpVisibility::OcclusionQuery *IssueOcclusionQuery(
|
---|
| 78 | GtpVisibility::HierarchyNode *node, const bool wasVisible);
|
---|
[59] | 79 |
|
---|
[103] | 80 | /** If true, the interface finds and renders only objects which are marked as shadow casters.
|
---|
| 81 | @remark This is important for the shadow texture pass
|
---|
| 82 | */
|
---|
| 83 | void SetOnlyShadowCasters(bool onlyShadowCasters);
|
---|
[111] | 84 | /** see set */
|
---|
| 85 | bool GetOnlyShadowCasters();
|
---|
[103] | 86 |
|
---|
[59] | 87 | protected:
|
---|
[112] | 88 | /** materials for visualizing frustum and query culled nodes */
|
---|
| 89 | void CreateCulledNodeMaterials();
|
---|
| 90 |
|
---|
[103] | 91 | /** A pass that prepares an occlusion query.
|
---|
| 92 | @remark disables depth write, colour write, lighting,
|
---|
| 93 | vertex and fragment program.
|
---|
| 94 | */
|
---|
| 95 | void SetOcclusionPass();
|
---|
| 96 |
|
---|
[59] | 97 | /** Deletes all occlusion queries.
|
---|
| 98 | */
|
---|
| 99 | void DeleteQueries();
|
---|
| 100 | /** Renders bounding box of specified node.
|
---|
| 101 | @param box the bounding box of the scene node to be rendered
|
---|
| 102 | */
|
---|
| 103 | void RenderBoundingBox(AxisAlignedBox *box);
|
---|
[103] | 104 |
|
---|
[92] | 105 | /** Returns pointer to current renderable bounding box geometry
|
---|
| 106 | */
|
---|
| 107 | SolidBoundingBox *GetSolidBoundingBox();
|
---|
[59] | 108 |
|
---|
[103] | 109 | /** Returns pointer to current renderable half bounding box geometry
|
---|
[59] | 110 | */
|
---|
[103] | 111 | //SolidHalfBoundingBox *GetSolidHalfBoundingBox();
|
---|
| 112 |
|
---|
| 113 | /** Renderable of an aabb
|
---|
| 114 | */
|
---|
[92] | 115 | SolidBoundingBox *mSolidBoundingBox;
|
---|
[59] | 116 |
|
---|
| 117 | SceneManager *mSceneManager;
|
---|
| 118 | RenderSystem *mRenderSystem;
|
---|
| 119 |
|
---|
| 120 | Camera *mCamera;
|
---|
[94] | 121 | Camera *mCullCamera;
|
---|
| 122 |
|
---|
[59] | 123 | AxisAlignedBox mBox;
|
---|
[85] | 124 |
|
---|
[59] | 125 | std::vector<PlatformOcclusionQuery *> mOcclusionQueries;
|
---|
[103] | 126 |
|
---|
| 127 | bool mOnlyShadowCasters;
|
---|
[59] | 128 | };
|
---|
| 129 |
|
---|
| 130 | } // namespace Ogre
|
---|
| 131 |
|
---|
| 132 | #endif // PlatformHierarchyInterface_H |
---|