source: trunk/VUT/GtpVisibility/include/HierarchyInterface.h @ 87

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