source: trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h @ 187

Revision 187, 5.0 KB checked in by mattausch, 19 years ago (diff)

added animationbug fix (deleting while animation)fixed visibilityQueriesadditive shadow volumes fixed for octree
hack to fully empty queue after traversal
added demo for vienna model

Line 
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 "OgreSolidBoundingBox.h"
11#include "HierarchyInterface.h"
12#include "VisibilityInfo.h"
13#include "OgrePlatformOcclusionQuery.h"
14
15/** This namespace contains the Ogre dependent classes.
16*/
17namespace Ogre {
18
19/**     Class which implements a hierarchy interface for a specific type of hierarchy.
20        @remark also provides methods for using occlusion queries on the hierarchy nodes
21*/
22class PlatformHierarchyInterface: public GtpVisibility::HierarchyInterface
23{
24public:
25        /** Construction taking the current scene manager and the current rendersystem as argument
26                @param sm current scene manager
27                @param rsys current render system
28        */
29        PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
30        ~PlatformHierarchyInterface();
31               
32        /** Returns next available occlusion query or creates new one.
33                @return the next occlusion query
34        */
35        GtpVisibility::OcclusionQuery *GetNextOcclusionQuery();
36               
37        /** Sets the current camera used for the rendering.
38                @param cam the current camera
39        */
40        void SetCamera(Camera *cam);
41        /** Sets the current camera used for culling.
42                @param cam the current camera
43                @remark the default is the camera used for rendering
44        */
45        void SetCullCamera(Camera *cullCam);
46        /** Initialises this scene traverser for the current frame.
47                @remark This is a convenience method which resets the stats,
48                                sets the current camera, and initialises the distance queue.
49                @param cam the actual camera definding the view frustum
50                @param cullCam the camera used for culling.
51                @remark If cullCam is null, the actual camera is used for both viewing and culling             
52        */
53        void InitTraversal(Camera *cam, Camera *cullCam = NULL, int leavePassesInQueue = 0);
54        /** Checks if the node is visible from the current view frustum.
55                @param node the current node
56                @param intersects returns true if the current node intersects the near plane
57        */
58        bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects);
59        /** Sets pointer to the current scene manager.
60                @param sm the scene manager
61        */
62        void SetSceneManager(SceneManager *sm);
63        /** Sets pointer to the current render system .
64                @param rsys the rendersystem
65        */
66        void SetRenderSystem(RenderSystem *rsys);
67        /** Returns pointer to bounding box of node.
68                @param node current hierarchy node
69                @returns bounding box of current node
70        */
71        virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0;
72        /** Issue a occlusion query for this node.
73                @param node the current hierarchy node
74                @param wasVisible if the node was visible in the last frame
75                @returns occlusion query for this node
76        */
77        GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery(
78                GtpVisibility::HierarchyNode *node, const bool wasVisible);
79
80        /** Issue a occlusion query for this mesh.
81                @param mesh the mesh for which an occlusion query is issued.
82                @returns occlusion query for this mesh.
83        */
84        GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh);
85
86        /** If true, the interface finds and renders only objects which are marked as shadow casters.
87                @remark This is important for the shadow texture pass
88        */
89        void SetOnlyShadowCasters(bool onlyShadowCasters);
90        /** see set
91        */
92        bool GetOnlyShadowCasters();
93        /** see set
94        */
95        bool GetTestGeometryForVisibleLeaves();
96        /** see set
97        */
98        SceneManager *GetSceneManager();
99
100        /** see set
101        */
102        RenderSystem *GetRenderSystem();
103       
104        /** true if bounding box query is currently active.
105        */
106    bool IsBoundingBoxQuery();
107
108        GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch);
109
110        /** Deletes all occlusion queries.
111        */
112        void DeleteQueries();
113
114protected:
115        /** Renders the given geometry
116        */
117        void RenderGeometry(GtpVisibility::Mesh *geom);
118       
119        /** Renders the given patch
120        */
121        void RenderPatch(GtpVisibility::Patch *patch);
122
123        /** Materials for visualizing frustum and query culled nodes.
124        */
125        void CreateNodeVizMaterials();
126
127        /** Returns pointer to current renderable bounding box geometry.
128        */
129        SolidBoundingBox *GetSolidBoundingBox();
130
131        /** A pass that prepares an occlusion query.
132                @remark disables depth write, colour write, lighting,
133                vertex and fragment program.*/
134        //void SetOcclusionPass();
135
136        /** Renders given bounding box.
137                @param box the bounding box of the scene node to be rendered
138        */
139        void RenderBoundingBox(AxisAlignedBox *box);
140
141        /** Renderable of an aabb.
142        */
143        SolidBoundingBox *mSolidBoundingBox;
144
145        SceneManager *mSceneManager;
146        RenderSystem *mRenderSystem;
147
148        Camera *mCamera;
149        Camera *mCullCamera;
150
151        AxisAlignedBox mBox;
152       
153        std::vector<PlatformOcclusionQuery *> mOcclusionQueries;
154
155        bool mOnlyShadowCasters;
156        int mLeavePassesInQueue;
157        bool mIsBoundingBoxQuery;
158};
159
160} // namespace Ogre
161
162#endif // PlatformHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.