[59] | 1 | #ifndef _VisibilityTerrainSceneManager_H__
|
---|
| 2 | #define _VisibilityTerrainSceneManager_H__
|
---|
| 3 |
|
---|
| 4 | #include <OgreSceneNode.h>
|
---|
| 5 | #include <OgreTerrainSceneManager.h>
|
---|
| 6 | #include <OgreOctreeNode.h>
|
---|
| 7 | #include <OgreOctreeCamera.h>
|
---|
| 8 | #include <OgrePrerequisites.h>
|
---|
| 9 |
|
---|
| 10 | #include "OgreOctreeHierarchyInterface.h"
|
---|
[130] | 11 | #include "OgrePlatformQueryManager.h"
|
---|
[59] | 12 | #include "VisibilityManager.h"
|
---|
| 13 |
|
---|
[156] | 14 |
|
---|
[59] | 15 | namespace Ogre {
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | This class extends the terrain scene manager,
|
---|
| 19 | using occlusion queries for visibility culling.
|
---|
| 20 | */
|
---|
[130] | 21 | class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager
|
---|
[59] | 22 | {
|
---|
| 23 | public:
|
---|
| 24 | VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager);
|
---|
| 25 | ~VisibilityTerrainSceneManager();
|
---|
| 26 |
|
---|
[118] | 27 | void _renderVisibleObjects();
|
---|
[59] | 28 | void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
|
---|
| 29 | void _updateSceneGraph(Camera* cam);
|
---|
| 30 |
|
---|
| 31 | /** Sets the given option for the SceneManager
|
---|
[103] | 32 | @remarks Options are: "Algorithm", int *;
|
---|
[59] | 33 | */
|
---|
| 34 |
|
---|
[164] | 35 | virtual bool setOption(const String &, const void *);
|
---|
[59] | 36 | /** Gets the given option for the Scene VisibilityManager.
|
---|
| 37 | @remarks
|
---|
| 38 | See setOption
|
---|
| 39 | */
|
---|
[164] | 40 | virtual bool getOption(const String &, void *);
|
---|
[59] | 41 |
|
---|
[164] | 42 | bool getOptionValues(const String & key, StringVector &refValueList);
|
---|
| 43 | bool getOptionKeys(StringVector &refKeys);
|
---|
[59] | 44 |
|
---|
[118] | 45 | /** Sets the visibility manager.
|
---|
[59] | 46 | @param visManager the visibility manager
|
---|
| 47 | */
|
---|
| 48 | void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
|
---|
[118] | 49 | /** See set.
|
---|
[59] | 50 | */
|
---|
| 51 | GtpVisibility::VisibilityManager *getVisibilityManager();
|
---|
[113] | 52 |
|
---|
[114] | 53 | /** Render a set of objects, see renderSingleObject for param definitions
|
---|
| 54 | Override so we can handle delayed rendering of transparent objects
|
---|
| 55 | */
|
---|
| 56 | virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,
|
---|
| 57 | bool doLightIteration, const LightList* manualLightList = 0);
|
---|
[115] | 58 |
|
---|
| 59 | /** Writes out stats into the Ogre log file.
|
---|
[103] | 60 | */
|
---|
| 61 | void WriteLog();
|
---|
| 62 |
|
---|
[121] | 63 | /** Override pass so we can do the z-fail pass.
|
---|
| 64 | */
|
---|
[115] | 65 | Pass* setPass(Pass* pass);
|
---|
| 66 |
|
---|
[121] | 67 | /** Override from SceneManager so we can skip all but first pass for depth pass.
|
---|
| 68 | */
|
---|
| 69 | bool validatePassForRendering(Pass* pass);
|
---|
| 70 |
|
---|
[122] | 71 | void RenderItemBuffer(RenderPriorityGroup* pGroup);
|
---|
[129] | 72 | void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
|
---|
[122] | 73 | void renderQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
| 74 |
|
---|
[133] | 75 | /** Override from SceneManager so that sub entities can be assigned an id for item buffer.
|
---|
| 76 | */
|
---|
[164] | 77 | Entity* createEntity(const String& entityName, const String& meshName);
|
---|
[122] | 78 |
|
---|
[133] | 79 | /** Returns pointer to visibility manager.
|
---|
| 80 | */
|
---|
[130] | 81 | GtpVisibility::VisibilityManager *GetVisibilityManager();
|
---|
| 82 |
|
---|
[153] | 83 | /** Returns hierarchy interface.
|
---|
| 84 | */
|
---|
| 85 | OctreeHierarchyInterface *GetHierarchyInterface();
|
---|
| 86 |
|
---|
[164] | 87 | /** Inherited from scene manager. Neccesary to draw terrain properly.
|
---|
| 88 | */
|
---|
[159] | 89 | void endFrame();
|
---|
| 90 |
|
---|
[202] | 91 | void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
| 92 | void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
[159] | 93 |
|
---|
[347] | 94 | /** Override standard function so octree boxes are always of equal side length.
|
---|
| 95 | This has advantages for CHC, because terrain tiles are in different octree nodes
|
---|
| 96 | and can be culled.
|
---|
| 97 | */
|
---|
| 98 | void setWorldGeometry( const String& filename );
|
---|
| 99 |
|
---|
[115] | 100 | protected:
|
---|
[122] | 101 |
|
---|
[133] | 102 | /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.
|
---|
| 103 | */
|
---|
[119] | 104 | void InitDepthPass();
|
---|
[133] | 105 | /** Creates material for item buffer.
|
---|
| 106 | */
|
---|
[122] | 107 | void InitItemBufferPass();
|
---|
[133] | 108 | /** Fills render queue so that a visualization can be rendered.
|
---|
| 109 | */
|
---|
[139] | 110 | void PrepareVisualization(Camera *cam);
|
---|
[158] | 111 | /** Initialises necessary parameters for hierarchical visibility culling.
|
---|
| 112 | */
|
---|
[139] | 113 | void InitVisibilityCulling(Camera *cam);
|
---|
[122] | 114 |
|
---|
[158] | 115 | /// the interface to the scene hierarchy.
|
---|
[59] | 116 | OctreeHierarchyInterface *mHierarchyInterface;
|
---|
[158] | 117 | /// manages all visibility options
|
---|
[59] | 118 | GtpVisibility::VisibilityManager *mVisibilityManager;
|
---|
[99] | 119 |
|
---|
[158] | 120 | /// if a visualization of the hierarchical culling is shown
|
---|
[99] | 121 | bool mShowVisualization;
|
---|
[158] | 122 |
|
---|
| 123 | /// if the culled nodes are indicated in the visualization
|
---|
[114] | 124 | bool mVisualizeCulledNodes;
|
---|
| 125 |
|
---|
[158] | 126 | /// if symbols for the nodes are shown in the visualization
|
---|
[103] | 127 | bool mRenderNodesForViz;
|
---|
[158] | 128 | /// if content of the nodes is shown in the visualization
|
---|
[113] | 129 | bool mRenderNodesContentForViz;
|
---|
[158] | 130 |
|
---|
| 131 | /// if we render transparents after the hierarchical traversal
|
---|
[115] | 132 | bool mDelayRenderTransparents;
|
---|
[158] | 133 |
|
---|
| 134 | /// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
|
---|
[115] | 135 | bool mUseDepthPass;
|
---|
[254] | 136 | /// if we currently rendering the depth pass
|
---|
| 137 | bool mIsDepthPassPhase;
|
---|
[158] | 138 |
|
---|
| 139 | /// if we use an item buffer for rendering (i.e., object ids as color codes
|
---|
| 140 | bool mUseItemBuffer;
|
---|
| 141 | /// if we currently render the item buffer
|
---|
[254] | 142 | bool mIsItemBufferPhase;
|
---|
[158] | 143 |
|
---|
| 144 | /// if depth write should be enabled
|
---|
[133] | 145 | bool mEnableDepthWrite;
|
---|
[158] | 146 | /// if transparents are skipped during rendering
|
---|
[139] | 147 | bool mSkipTransparents;
|
---|
[115] | 148 |
|
---|
[158] | 149 | /// the depth pass (no lighting, just filling the depth buffer)
|
---|
[115] | 150 | Pass *mDepthPass;
|
---|
[122] | 151 | Pass *mItemBufferPass;
|
---|
| 152 |
|
---|
| 153 | int mCurrentEntityId;
|
---|
[158] | 154 | /// flag for passes which should not be deleted from queue during first traversal
|
---|
[139] | 155 | int mLeavePassesInQueue;
|
---|
[159] | 156 |
|
---|
| 157 | /// if transparent object are considered for item buffer visibility
|
---|
| 158 | bool mRenderTransparentsForItemBuffer;
|
---|
| 159 | /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
|
---|
| 160 | bool mExecuteVertexProgramForAllPasses;
|
---|
[202] | 161 |
|
---|
| 162 | bool mIsHierarchicalCulling;
|
---|
[59] | 163 | };
|
---|
| 164 |
|
---|
| 165 | } // namespace Ogre
|
---|
| 166 |
|
---|
| 167 | #endif // CullingTerrainSceneManager_H |
---|