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