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