1 | #ifndef _GtpVisibilityHierarchyInterface_H__
|
---|
2 | #define _GtpVisibilityHierarchyInterface_H__
|
---|
3 |
|
---|
4 | #include "DistanceQueue.h"
|
---|
5 |
|
---|
6 | namespace GtpVisibility {
|
---|
7 |
|
---|
8 | enum CullingType {QUERY_CULLED, FRUSTUM_CULLED};
|
---|
9 |
|
---|
10 | /** Class which implements a hierarchy interface for a scene hierarchy.
|
---|
11 | */
|
---|
12 | class HierarchyInterface
|
---|
13 | {
|
---|
14 | public:
|
---|
15 | /** Default constructor.
|
---|
16 | */
|
---|
17 | HierarchyInterface();
|
---|
18 | virtual ~HierarchyInterface();
|
---|
19 | /** Returns true if current node is leaf of the hierarchy.
|
---|
20 | @param node hierarchy node
|
---|
21 | @returns true if node is leaf
|
---|
22 | */
|
---|
23 | virtual bool IsLeaf(HierarchyNode *node) const = 0;
|
---|
24 | /** Traverses the given node.
|
---|
25 | @param node the hierarchy node
|
---|
26 | */
|
---|
27 | virtual void TraverseNode(HierarchyNode *node) = 0;
|
---|
28 | /** Renders current scene node .
|
---|
29 | @param node current scene node to be rendered
|
---|
30 | */
|
---|
31 | virtual void RenderNode(HierarchyNode *node) = 0;
|
---|
32 | /** Pulls up the visibility from the current node recursively to the parent nodes.
|
---|
33 | @param node the current node
|
---|
34 | */
|
---|
35 | virtual void PullUpVisibility(HierarchyNode *node) = 0;
|
---|
36 | /** Issue a occlusion query for this node.
|
---|
37 | @param node the current hierarchy node
|
---|
38 | @returns occlusion query for this node
|
---|
39 | */
|
---|
40 | virtual OcclusionQuery *IssueOcclusionQuery(HierarchyNode *node,
|
---|
41 | const bool wasVisible = false) = 0;
|
---|
42 | /** Sets the root of the scene hierarchy.
|
---|
43 | @param root the hierarchy root
|
---|
44 | */
|
---|
45 | void SetSceneRoot(HierarchyNode *root);
|
---|
46 | /** Get the root of the scene hierarchy.
|
---|
47 | @return the hierarchy root
|
---|
48 | */
|
---|
49 | HierarchyNode *GetSceneRoot() const;
|
---|
50 | /** Sets the scene root and initialises this scene traverser for a traversal.
|
---|
51 | @param root current scene root
|
---|
52 | @remark initialises some parameters, and also the statistics.
|
---|
53 | */
|
---|
54 | void InitFrame(HierarchyNode *root);
|
---|
55 | /** Returns current frame id.
|
---|
56 | @returns frame id
|
---|
57 | */
|
---|
58 | unsigned int GetFrameId() const;
|
---|
59 | /** Returns the current distance queue.
|
---|
60 | @returns current distance queue
|
---|
61 | */
|
---|
62 | DistanceQueue *GetQueue();
|
---|
63 | /** Returns distance of the node to the view plane.
|
---|
64 | @param node1 the hierarchy node
|
---|
65 | */
|
---|
66 | virtual float GetSquaredDistance(HierarchyNode *node) const = 0;
|
---|
67 | /** Checks if the node is visible from the current view frustum.
|
---|
68 | @param node the current node
|
---|
69 | @param intersects returns true if the current node intersects the near plane
|
---|
70 | */
|
---|
71 | virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0;
|
---|
72 | /** Checks if the node is visible from the current view frustum.
|
---|
73 | @param node the current node
|
---|
74 | */
|
---|
75 | bool CheckFrustumVisible(HierarchyNode *node);
|
---|
76 | /** Returns next available occlusion query or creates new one.
|
---|
77 | @return the next occlusion query
|
---|
78 | */
|
---|
79 | virtual OcclusionQuery *GetNextOcclusionQuery() = 0;
|
---|
80 | /** Returns true if there is renderable geometry attached to this node
|
---|
81 | @param node the current node
|
---|
82 | @returns if the node has renderable geometry
|
---|
83 | */
|
---|
84 | virtual bool HasGeometry(HierarchyNode *node) const = 0;
|
---|
85 | /** Sets the visible flag for this node.
|
---|
86 | @param node the current node
|
---|
87 | @param visible the visible flag
|
---|
88 | */
|
---|
89 | virtual void SetNodeVisible(HierarchyNode *node, const bool visible) = 0;
|
---|
90 | /** Returns true if node has the visible flag set. See set
|
---|
91 | */
|
---|
92 | virtual bool IsNodeVisible(HierarchyNode *node) const = 0;
|
---|
93 | /** Sets the last visited frame id for this node.
|
---|
94 | @param node the current node
|
---|
95 | @param frameId the current frame id
|
---|
96 | */
|
---|
97 | virtual void SetLastVisited(HierarchyNode *node,
|
---|
98 | const unsigned int frameId) = 0;
|
---|
99 | /** Returns frame id when this node was last visited by the traverser. See set
|
---|
100 | */
|
---|
101 | virtual unsigned int LastVisited(HierarchyNode *node) const = 0;
|
---|
102 | /** Returns number of traversed nodes.
|
---|
103 | */
|
---|
104 | unsigned int GetNumTraversedNodes();
|
---|
105 | /** Returns number of rendered nodes.
|
---|
106 | */
|
---|
107 | unsigned int GetNumRenderedNodes();
|
---|
108 | /** Optimization when issuing occlusion test: test is done with actual geometry
|
---|
109 | rather than the bounding box
|
---|
110 | @param useOptimization if the optimization should be used
|
---|
111 | */
|
---|
112 | void SetUseOptimization(bool useOptimization);
|
---|
113 | //bool mIsShadowPass;
|
---|
114 |
|
---|
115 | /** Visualization of a culled node, dependent on the culling type.
|
---|
116 | @param type can be one of FRUSTUM_CULLED, QUERY_CULLED
|
---|
117 | */
|
---|
118 | virtual void VisualizeCulledNode(HierarchyNode *node,
|
---|
119 | CullingType type) = NULL;
|
---|
120 |
|
---|
121 | protected:
|
---|
122 |
|
---|
123 | bool mUseOptimization;
|
---|
124 | unsigned int mFrameId;
|
---|
125 |
|
---|
126 | int mCurrentTestIdx;
|
---|
127 |
|
---|
128 | //--- statistics
|
---|
129 | unsigned int mNumTraversedNodes;
|
---|
130 | unsigned int mNumRenderedNodes;
|
---|
131 |
|
---|
132 | DistanceQueue *mDistanceQueue;
|
---|
133 | HierarchyNode *mSceneRoot;
|
---|
134 | HierarchyNode *mPreviousNode;
|
---|
135 |
|
---|
136 |
|
---|
137 | };
|
---|
138 | } // namespace GtpVisibility
|
---|
139 | #endif // GtpVisisibilityHierarchyInterface_H |
---|