[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 |
|
---|
| 9 | #include "OgreSolidHalfBoundingBox.h"
|
---|
| 10 | #include "HierarchyInterface.h"
|
---|
| 11 | #include "OgrePlatformOcclusionQuery.h"
|
---|
| 12 |
|
---|
[71] | 13 | /** This namespace contains the Ogre dependent classes.
|
---|
| 14 | */
|
---|
[59] | 15 | namespace Ogre {
|
---|
| 16 |
|
---|
| 17 | /** Class which implements a hierarchy interface for a specific type of hierarchy.
|
---|
| 18 | @remark also provides methods for using occlusion queries on the hierarchy nodes
|
---|
| 19 | */
|
---|
| 20 | class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
|
---|
| 21 | {
|
---|
| 22 | public:
|
---|
| 23 | /** Construction taking the current scene manager and the current rendersystem as argument
|
---|
| 24 | @param sm current scene manager
|
---|
| 25 | @param rsys current render system
|
---|
| 26 | */
|
---|
| 27 | PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
|
---|
| 28 | ~PlatformHierarchyInterface();
|
---|
| 29 |
|
---|
| 30 | /** Returns next available occlusion query or creates new one.
|
---|
| 31 | @return the next occlusion query
|
---|
| 32 | */
|
---|
| 33 | GtpVisibility::OcclusionQuery *GetNextOcclusionQuery();
|
---|
| 34 |
|
---|
| 35 | /** Sets the current camera.
|
---|
| 36 | @param cam the current camera
|
---|
| 37 | */
|
---|
| 38 | void SetCamera(Camera *cam);
|
---|
| 39 |
|
---|
| 40 | /** Initialises this scene traverser for the current frame.
|
---|
| 41 | @param root root of the hierarchy
|
---|
| 42 | @param cam current camera
|
---|
| 43 | @remark convenience method wich calls VisibilitySceneTraverser::initFrame,
|
---|
| 44 | sets the current camera, and initialises the distance queue.
|
---|
| 45 | */
|
---|
| 46 | void InitFrame(GtpVisibility::HierarchyNode *root, Ogre::Camera *cam);
|
---|
| 47 | /** Checks if the node is visible from the current view frustum.
|
---|
| 48 | @param node the current node
|
---|
| 49 | @param intersects returns true if the current node intersects the near plane
|
---|
| 50 | */
|
---|
| 51 | bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects);
|
---|
| 52 | /** Sets pointer to the current scene manager.
|
---|
| 53 | @param sm the scene manager
|
---|
| 54 | */
|
---|
| 55 | void SetSceneManager(SceneManager *sm);
|
---|
| 56 | /** Sets pointer to the current render system
|
---|
| 57 | @param rsys the rendersystem
|
---|
| 58 | */
|
---|
| 59 | void SetRenderSystem(RenderSystem *rsys);
|
---|
| 60 | /** Returns pointer to bounding box of node.
|
---|
| 61 | @param node current hierarchy node
|
---|
| 62 | @returns bounding box of current node
|
---|
| 63 | */
|
---|
| 64 | virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0;
|
---|
| 65 | /** Issue a occlusion query for this node.
|
---|
| 66 | @param node the current hierarchy node
|
---|
[86] | 67 | @param wasVisible if the node was visible in the last frame
|
---|
[59] | 68 | @returns occlusion query for this node
|
---|
| 69 | */
|
---|
[86] | 70 | GtpVisibility::OcclusionQuery *IssueOcclusionQuery(
|
---|
| 71 | GtpVisibility::HierarchyNode *node, const bool wasVisible);
|
---|
[59] | 72 |
|
---|
| 73 | protected:
|
---|
| 74 | /** Deletes all occlusion queries.
|
---|
| 75 | */
|
---|
| 76 | void DeleteQueries();
|
---|
| 77 | /** Renders bounding box of specified node.
|
---|
| 78 | @param box the bounding box of the scene node to be rendered
|
---|
| 79 | */
|
---|
| 80 | void RenderBoundingBox(AxisAlignedBox *box);
|
---|
[85] | 81 | /** Returns pointer to current renderable half bounding box geometry
|
---|
[59] | 82 | */
|
---|
[85] | 83 | SolidHalfBoundingBox *GetSolidHalfBoundingBox();
|
---|
[59] | 84 |
|
---|
[85] | 85 | /** one renderable half of an aabb.
|
---|
[59] | 86 | */
|
---|
[85] | 87 | SolidHalfBoundingBox *mSolidHalfBoundingBox;
|
---|
[59] | 88 |
|
---|
| 89 | SceneManager *mSceneManager;
|
---|
| 90 | RenderSystem *mRenderSystem;
|
---|
| 91 |
|
---|
| 92 | Camera *mCamera;
|
---|
| 93 | AxisAlignedBox mBox;
|
---|
[85] | 94 |
|
---|
[59] | 95 | std::vector<PlatformOcclusionQuery *> mOcclusionQueries;
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | } // namespace Ogre
|
---|
| 99 |
|
---|
| 100 | #endif // PlatformHierarchyInterface_H |
---|