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

Revision 345, 6.1 KB checked in by mattausch, 19 years ago (diff)

fixed bug in chc when traversing node two times because of priority queue. left debug info in there

RevLine 
[59]1#ifndef _GtpVisibilityHierarchyInterface_H__
2#define _GtpVisibilityHierarchyInterface_H__
3
4#include "DistanceQueue.h"
[130]5#include "VisibilityMesh.h"
[155]6#include <stack>
[59]7
8namespace GtpVisibility {
9
[112]10enum  CullingType {QUERY_CULLED, FRUSTUM_CULLED};
11
[130]12typedef std::vector<HierarchyNode *> HierarchyNodeList;
13typedef std::vector<GtpVisibility::Mesh *> GeometryList;
[171]14typedef std::vector<GtpVisibility::Patch *> PatchList;
[130]15typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair;
16typedef std::queue<QueryPair> QueryQueue;
17
[158]18
[59]19/**     Class which implements a hierarchy interface for a scene hierarchy.
20*/
21class HierarchyInterface
22{
23public:
24        /** Default constructor.
25        */
26        HierarchyInterface();
27        virtual ~HierarchyInterface();
28        /** Returns true if current node is leaf of the hierarchy.
29                @param node hierarchy node
30                @returns true if node is leaf
31        */
[74]32    virtual bool IsLeaf(HierarchyNode *node) const = 0;
[155]33        /** Traverses and renders the given node.
[59]34                @param node the hierarchy node
35        */
[158]36        virtual void TraverseNode(HierarchyNode *node) = 0;
[130]37        /** Renders current hierarchy node.
38                @param node current hierarchy node to be rendered
[59]39        */
40        virtual void RenderNode(HierarchyNode *node) = 0;
41        /** Pulls up the visibility from the current node recursively to the parent nodes.
42                @param node the current node
43        */
[345]44        virtual void PullUpVisibility(HierarchyNode *node) const = 0;
[59]45        /** Issue a occlusion query for this node.
46                @param node the current hierarchy node
47                @returns occlusion query for this node
48        */
[175]49        virtual OcclusionQuery *IssueNodeOcclusionQuery(HierarchyNode *node,
[86]50                const bool wasVisible = false) = 0;
[59]51        /** Sets the root of the scene hierarchy.
52                @param root the hierarchy root
53        */
[155]54        void SetHierarchyRoot(HierarchyNode *root);
[74]55    /** Get the root of the scene hierarchy.
56                @return the hierarchy root
57        */
[155]58        HierarchyNode *GetHierarchyRoot() const;
[158]59        /** Sets the scene root and initialises this hierarchy interface for a traversal.               
[155]60                @remark also resets the statistics evaluated in the last traversal
[59]61        */
[158]62        void InitTraversal();
[59]63        /** Returns current frame id.
64                @returns frame id
65        */
[74]66        unsigned int GetFrameId() const;
[155]67        /** Returns a pointer to the distance queue.
68                @returns current distance queue.
69                @remark the distance queue stores hierarchy nodes in a front-to-back order
[59]70        */
71        DistanceQueue *GetQueue();
[87]72        /** Returns distance of the node to the view plane.
73                @param node1 the hierarchy node
[59]74        */                     
[87]75        virtual float GetSquaredDistance(HierarchyNode *node) const = 0;
[59]76        /** Checks if the node is visible from the current view frustum.
77                @param node the current node
78                @param intersects returns true if the current node intersects the near plane
79        */
80        virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0;
[74]81        /** Checks if the node is visible from the current view frustum.
82                @param node the current node
83        */
84        bool CheckFrustumVisible(HierarchyNode *node);
[59]85        /** Returns next available occlusion query or creates new one.
86                @return the next occlusion query
87        */
88        virtual OcclusionQuery *GetNextOcclusionQuery() = 0;
89        /** Returns true if there is renderable geometry attached to this node
90                @param node the current node
91                @returns if the node has renderable geometry
92        */
[74]93    virtual bool HasGeometry(HierarchyNode *node) const = 0;
[59]94        /** Sets the visible flag for this node.
95                @param node the current node
96                @param visible the visible flag
97        */
[345]98        virtual void SetNodeVisible(HierarchyNode *node, const bool visible) const = 0;
[59]99        /** Returns true if node has the visible flag set. See set
100        */
[74]101        virtual bool IsNodeVisible(HierarchyNode *node) const = 0;
[59]102        /** Sets the last visited frame id for this node.
103                @param node the current node
104                @param frameId the current frame id
105        */
[74]106        virtual void SetLastVisited(HierarchyNode *node,
[345]107                                                                const unsigned int frameId) const = 0;
[59]108        /** Returns frame id when this node was last visited by the traverser. See set
109        */
[74]110        virtual unsigned int LastVisited(HierarchyNode *node) const = 0;
111        /** Returns number of traversed nodes.
112        */
113        unsigned int GetNumTraversedNodes();
114        /** Returns number of rendered nodes.
115        */
116        unsigned int GetNumRenderedNodes();
[155]117               
[112]118        //bool mIsShadowPass;
[59]119
[112]120        /** Visualization of a culled node, dependent on the culling type.
121                @param type can be one of FRUSTUM_CULLED, QUERY_CULLED
122        */
123        virtual void VisualizeCulledNode(HierarchyNode *node,
[345]124                CullingType type) const = 0;
[111]125
[175]126        /** Returns vector of visible hierarchy nodes from previous render.
[130]127        */
[174]128        std::vector<HierarchyNode *> *GetVisibleNodes();
[130]129        /** Returns vector of previoulsy rendered geometry.
130        */
131       
[155]132        /** Returns the geometry of a given hierarchy node.
133                @param node the hierarchy node containing the geometry
134                @param geometryList geometry is returned in this list
135                @param includeChildren if the geometry of the children should be taken into account
[130]136        */
[155]137        virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,   
[130]138                                                         GeometryList *geometryList,
139                                                         bool includeChildren) = 0;
140
[158]141       
[155]142        /** This is an optimization when issuing the occlusion test.
143                The test is done with actual geometry rather than the bounding
[158]144                box of leave nodes previously marked as visible.
145
[155]146                @param testGeometry if this optimization should be used
147                @remark this option is only useful for the coherent hierarchical culling algorithm
148        */
149        void TestGeometryForVisibleLeaves(bool testGeometry);
150
151
[59]152protected:
[155]153        /// chc optimization for testing geometry of leaves instead of bounding box
154        bool mTestGeometryForVisibleLeaves;
[158]155        /// the current frame number
[59]156        unsigned int mFrameId;
[158]157        /// points to the last occlusion query in the query list
[59]158        int mCurrentTestIdx;
159       
[155]160        /// number of traversed nodes
[59]161        unsigned int mNumTraversedNodes;
[158]162
163        /// The queue is useful for rendering hierarchy nodes in front to back order.
[59]164        DistanceQueue *mDistanceQueue;
[111]165
[155]166        /// the root of the hierarchy
167        HierarchyNode *mHierarchyRoot;
168       
[158]169        /// buffer for a node pointer
[155]170        HierarchyNode *mSavedNode;
[158]171        /// list of rendered hierarchy nodes (e.g., useful for exact visibility queries)
[174]172        std::vector<HierarchyNode *> mVisibleNodes;
[59]173};
174} // namespace GtpVisibility
[155]175
[112]176#endif // GtpVisisibilityHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.