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