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

Revision 139, 5.4 KB checked in by mattausch, 20 years ago (diff)

fixed bug with tight octree boxes
added more flexible renderqueue (can delete per flag)
reordered functions in visibility terrain scene manager

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 root root of the hierarchy
50                @param cam the actual camera definding the view frustum
51                @param cullCam the camera used for culling.
52                @remark If null, the actual camera is used for both viewing and culling         
53        */
54        void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL,
55                int leavePassesInQueue = 0);
56        /** Checks if the node is visible from the current view frustum.
57                @param node the current node
58                @param intersects returns true if the current node intersects the near plane
59        */
60        bool CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects);
61        /** Sets pointer to the current scene manager.
62                @param sm the scene manager
63        */
64        void SetSceneManager(SceneManager *sm);
65        /** Sets pointer to the current render system .
66                @param rsys the rendersystem
67        */
68        void SetRenderSystem(RenderSystem *rsys);
69        /** Returns pointer to bounding box of node.
70                @param node current hierarchy node
71                @returns bounding box of current node
72        */
73        virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node) = 0;
74        /** Issue a occlusion query for this node.
75                @param node the current hierarchy node
76                @param wasVisible if the node was visible in the last frame
77                @returns occlusion query for this node
78        */
79        GtpVisibility::OcclusionQuery *IssueOcclusionQuery(
80                GtpVisibility::HierarchyNode *node, const bool wasVisible);
81
82        /** Issue a occlusion query for this mesh.
83                @param node the current mesh
84                @returns occlusion query for this node
85        */
86        GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh);
87
88        /** If true, the interface finds and renders only objects which are marked as shadow casters.
89                @remark This is important for the shadow texture pass
90        */
91        void SetOnlyShadowCasters(bool onlyShadowCasters);
92        /** see set
93        */
94        bool GetOnlyShadowCasters();
95        /** see set
96        */
97        bool GetUseOptimization();
98        /** see set
99        */
100        SceneManager *GetSceneManager();
101
102        /** see set
103        */
104        RenderSystem *GetRenderSystem();
105       
106        /** true if bounding box query is currently active.
107        */
108    bool IsBoundingBoxQuery();
109
110        /** Finds visible objects of hierarchy node using occlusion queries
111        @param node the current scene node
112        @param objs the visible objects
113        @param includeChildren if the children of current scene nodes should also be traversed
114        */
115        /*virtual bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,   
116                                                                        InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
117                                                                        bool includeChildren = false) = 0;*/
118protected:
119        /** Renders geometry
120        */
121        void RenderGeometry(GtpVisibility::Mesh *geom);
122
123        /** Materials for visualizing frustum and query culled nodes.
124        */
125        void CreateNodeVizMaterials();
126
127        /** Deletes all occlusion queries.
128        */
129        void DeleteQueries();
130       
131        /** Renders bounding box of specified node.
132                @param box the bounding box of the scene node to be rendered
133        */
134        void RenderBoundingBox(AxisAlignedBox *box);
135
136        /** Returns pointer to current renderable bounding box geometry.
137        */
138        SolidBoundingBox *GetSolidBoundingBox();
139
140        /** A pass that prepares an occlusion query.
141                @remark disables depth write, colour write, lighting,
142                vertex and fragment program.
143        */
144        //void SetOcclusionPass();
145
146        /** Returns pointer to current renderable half bounding box geometry.*/
147        //SolidHalfBoundingBox *GetSolidHalfBoundingBox();
148
149        /** Renderable of an aabb.
150        */
151        SolidBoundingBox *mSolidBoundingBox;
152
153        SceneManager *mSceneManager;
154        RenderSystem *mRenderSystem;
155
156        Camera *mCamera;
157        Camera *mCullCamera;
158
159        AxisAlignedBox mBox;
160       
161        std::vector<PlatformOcclusionQuery *> mOcclusionQueries;
162
163        bool mOnlyShadowCasters;
164        int mLeavePassesInQueue;
165        bool mIsBoundingBoxQuery;
166};
167
168} // namespace Ogre
169
170#endif // PlatformHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.