Changeset 103 for trunk/VUT/Ogre
- Timestamp:
- 05/18/05 02:06:32 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r94 r103 44 44 void SetCullCamera(Camera *cullCam); 45 45 /** Initialises this scene traverser for the current frame. 46 @param root root of the hierarchy 47 @param cam current camera 48 @param cullCam the camera used for culling. If null, the current camera is used 49 @remark convenience method wich calls VisibilitySceneTraverser::initFrame, 50 sets the current camera, and initialises the distance queue. 46 @remark This is a convenience method which resets the stats, 47 sets the current camera, and initialises the distance queue. 48 @param root root of the hierarchy 49 @param cam the actual camera definding the view frustum 50 @param cullCam the camera used for culling. 51 @remark If null, the actual camera is used for both viewing and culling 51 52 */ 52 53 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL); … … 60 61 */ 61 62 void SetSceneManager(SceneManager *sm); 62 /** Sets pointer to the current render system 63 /** Sets pointer to the current render system . 63 64 @param rsys the rendersystem 64 65 */ … … 77 78 GtpVisibility::HierarchyNode *node, const bool wasVisible); 78 79 80 /** If true, the interface finds and renders only objects which are marked as shadow casters. 81 @remark This is important for the shadow texture pass 82 */ 83 void SetOnlyShadowCasters(bool onlyShadowCasters); 84 79 85 protected: 86 /** A pass that prepares an occlusion query. 87 @remark disables depth write, colour write, lighting, 88 vertex and fragment program. 89 */ 90 void SetOcclusionPass(); 91 80 92 /** Deletes all occlusion queries. 81 93 */ … … 85 97 */ 86 98 void RenderBoundingBox(AxisAlignedBox *box); 87 /** Returns pointer to current renderable half bounding box geometry 88 */ 89 //SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 99 90 100 /** Returns pointer to current renderable bounding box geometry 91 101 */ 92 102 SolidBoundingBox *GetSolidBoundingBox(); 93 103 94 /** one renderable half of an aabb. 104 /** Returns pointer to current renderable half bounding box geometry 105 */ 106 //SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 107 108 /** Renderable of an aabb 95 109 */ 96 110 SolidBoundingBox *mSolidBoundingBox; … … 105 119 106 120 std::vector<PlatformOcclusionQuery *> mOcclusionQueries; 121 122 bool mOnlyShadowCasters; 107 123 }; 108 124 -
trunk/VUT/Ogre/include/OgreVisibilitySceneManager.h
r99 r103 56 56 SceneNodeHierarchyInterface *mHierarchyInterface; 57 57 GtpVisibility::VisibilityManager *mVisibilityManager; 58 58 59 bool mUseVisibilityCulling; 60 bool mShowVisualization; 59 61 }; 60 62 } // namespace Ogre -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r100 r103 30 30 31 31 /** Sets the given option for the SceneManager 32 @remarks 33 Options are: 34 "Algorithm", int *; 32 @remarks Options are: "Algorithm", int *; 35 33 */ 36 34 … … 45 43 bool getOptionKeys( StringVector &refKeys ); 46 44 47 /** Sets the visibility manager .45 /** Sets the visibility manager 48 46 @param visManager the visibility manager 49 47 */ 50 48 void setVisibilityManager(GtpVisibility::VisibilityManager *visManager); 51 /** See set .49 /** See set 52 50 */ 53 51 GtpVisibility::VisibilityManager *getVisibilityManager(); 54 52 55 //writes out stats into the Ogre log file56 void WriteLog();57 void SetShowVisualization(bool showViz);58 59 /* void SetSkyBoxEnabled(bool enabled);60 void SetSkyPlaneEnabled(bool enabled);61 void SetSkyDomeEnabled(bool enabled);*/62 63 53 protected: 64 54 55 /** Writes out stats into the Ogre log file 56 */ 57 void WriteLog(); 58 65 59 OctreeHierarchyInterface *mHierarchyInterface; 66 60 GtpVisibility::VisibilityManager *mVisibilityManager; … … 68 62 bool mUseVisibilityCulling; 69 63 bool mShowVisualization; 64 bool mRenderNodesForViz; 70 65 }; 71 66 -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r101 r103 106 106 octant->setLastRendered(mFrameId); 107 107 108 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, octant); 108 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 109 octant, mOnlyShadowCasters); 109 110 110 111 mNumRenderedNodes ++; -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r100 r103 1 1 #include <OgreCamera.h> 2 2 #include <OgreLogManager.h> 3 //#include "OgreSolidHalfBoundingBox.h"4 3 #include "OgreSolidBoundingBox.h" 5 4 #include "OgrePlatformHierarchyInterface.h" 6 5 #include "OgrePlatformOcclusionQuery.h" 7 #include <windows.h>8 6 9 7 namespace Ogre { … … 12 10 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 13 11 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), 14 mCamera(NULL), mCullCamera(NULL) 12 mCamera(NULL), mCullCamera(NULL), mOnlyShadowCasters(false) 15 13 { 16 14 } … … 36 34 static RenderOperation ro; 37 35 38 //TODO: this should be the full bounding box39 36 SolidBoundingBox *solidBox = GetSolidBoundingBox(); 40 37 41 38 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 42 39 mSceneManager->useRenderableViewProjMode(solidBox); 43 mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 40 //mSceneManager->setOcclusionPass(solidBox->getTechnique()->getPass(0)); 41 SetOcclusionPass(); 44 42 45 43 solidBox->SetupBoundingBoxVertices(*box); … … 80 78 } 81 79 //----------------------------------------------------------------------- 82 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam) 80 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, 81 Camera *cam, Camera *cullCam) 83 82 { 84 83 GtpVisibility::HierarchyInterface::InitFrame(root); … … 88 87 89 88 if (cullCam) 89 { 90 90 SetCullCamera(cullCam); 91 } 91 92 else 93 { 92 94 SetCullCamera(cam); 95 } 93 96 } 94 97 //----------------------------------------------------------------------- … … 141 144 } 142 145 //----------------------------------------------------------------------- 146 void PlatformHierarchyInterface::SetOcclusionPass() 147 { 148 // disable vertex and fragment program 149 mRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM); 150 mRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM); 151 152 // disable lighting 153 mRenderSystem->setLightingEnabled(false); 154 155 // Disable remaining texture units 156 mRenderSystem->_disableTextureUnitsFrom(0); 157 158 //--Set up non-texture related material settings 159 160 // Depth buffer settings 161 mRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS_EQUAL); 162 // Set colour write mode off 163 mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 164 // Set colour write mode pff 165 mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 166 } 167 //----------------------------------------------------------------------- 143 168 SolidBoundingBox *PlatformHierarchyInterface::GetSolidBoundingBox() 144 169 { … … 148 173 return mSolidBoundingBox; 149 174 } 150 175 //----------------------------------------------------------------------- 176 void PlatformHierarchyInterface::SetOnlyShadowCasters(bool onlyShadowCasters) 177 { 178 mOnlyShadowCasters = onlyShadowCasters; 179 } 151 180 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r100 r103 115 115 AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 116 116 { 117 // only create renderable bounding box for new node 117 118 if (node != mPreviousNode) 118 119 { -
trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp
r100 r103 74 74 //setMaterial("BaseWhiteNoLighting"); 75 75 } 76 //----------------------------------------------------------------------- 76 77 SolidBoundingBox::~SolidBoundingBox() 77 78 { -
trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp
r100 r103 6 6 #include "OgreCamera.h" 7 7 #include "OgreMaterialManager.h" 8 //#include <windows.h> 8 9 9 10 10 namespace Ogre { -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r100 r103 36 36 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 37 37 mCullCamera ? getCamera("CullCamera") : NULL); 38 //mVisibilityManager->GetCullingManager()->InitFrame();39 38 40 // standard scenemanager rendering without hierarchical culling 41 if(!mUseVisibilityCulling) 39 // call initframe to reset culling manager stats 40 mVisibilityManager->GetCullingManager()->InitFrame(); 41 42 // standard terrain scenemanager rendering without hierarchical culling 43 if (!mUseVisibilityCulling || mShowVisualization) 42 44 { 43 45 OctreeSceneManager::_renderVisibleObjects(); 44 46 return; 45 47 } 46 48 47 49 //-- hierarchical culling 48 50 // the objects of different layers (e.g., background, scene, … … 77 79 #endif 78 80 79 //-- render remaining objects, e.g.,overlay81 //-- render overlay 80 82 clearSpecialCaseRenderQueues(); 81 83 SceneManager::_renderVisibleObjects(); … … 86 88 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 87 89 { 90 // if shadow pass => render only shadow casters 91 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 92 88 93 // does nothing if hierarchical culling is used => 89 94 // we interleave identification and rendering of objects … … 104 109 } 105 110 106 getRenderQueue()->clear(); 107 mBoxes.clear(); 111 mBoxes.clear(); 108 112 mVisible.clear(); 109 113 } … … 156 160 { 157 161 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 158 getOptionKeys ( refKeys) || OctreeSceneManager::getOptionKeys(refKeys);162 getOptionKeys (refKeys) || OctreeSceneManager::getOptionKeys(refKeys); 159 163 } 160 164 //----------------------------------------------------------------------- … … 174 178 175 179 d << "Algorithm: " << mVisibilityManager->GetCullingManagerType() << ", " 176 << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 180 << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " 181 << mHierarchyInterface->GetNumTraversedNodes() << ", " 177 182 << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 178 183 << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r100 r103 12 12 //----------------------------------------------------------------------- 13 13 VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 14 :mVisibilityManager(visManager), mUseVisibilityCulling(true) 14 :mVisibilityManager(visManager), mUseVisibilityCulling(true), mShowVisualization(false) 15 15 { 16 mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem); 16 mHierarchyInterface = 17 new SceneNodeHierarchyInterface(this, mDestRenderSystem); 17 18 } 18 19 //----------------------------------------------------------------------- … … 24 25 void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 25 26 { 26 // emptyif hierarchical culling is used =>27 // does nothing if hierarchical culling is used => 27 28 // we interleave identification and rendering of objects 28 // in _renderVisibibleObjects 29 // in _renderVisibibleObjects 29 30 if (!mUseVisibilityCulling) 30 31 { 31 32 SceneManager::_findVisibleObjects(cam, onlyShadowCasters); 33 return; 32 34 } 33 35 } … … 35 37 void VisibilitySceneManager::_renderVisibleObjects() 36 38 { 39 // two cameras (one for culling, one for rendering) 37 40 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 41 42 // call initframe to reset culling manager stats 38 43 mVisibilityManager->GetCullingManager()->InitFrame(); 39 44 40 if (!mUseVisibilityCulling) 45 // standard terrain scenemanager rendering without hierarchical culling 46 if (!mUseVisibilityCulling || mShowVisualization) 41 47 { 42 48 SceneManager::_renderVisibleObjects(); … … 55 61 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 56 62 SceneManager::_renderVisibleObjects(); 63 57 64 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 58 65 _deleteRenderedQueueGroups(); … … 64 71 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 65 72 66 //-- the hierarchical culling algorithm 73 74 /** 75 * the hierarchical culling algorithm 76 **/ 67 77 mVisibilityManager->ApplyVisibilityCulling(); 78 68 79 69 80 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 74 85 clearSpecialCaseRenderQueues(); 75 86 SceneManager::_renderVisibleObjects(); 87 88 //WriteLog(); // write out stats 76 89 } 77 90 //----------------------------------------------------------------------- … … 123 136 } 124 137 125 //} // namespace GtpVisibility126 138 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r101 r103 16 16 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 17 17 GtpVisibility::VisibilityManager *visManager) 18 : mVisibilityManager(visManager), mUseVisibilityCulling(true), 19 mShowVisualization(false) 18 : mVisibilityManager(visManager), 19 mUseVisibilityCulling(true), 20 mShowVisualization(false), 21 mRenderNodesForViz(false) 20 22 { 21 23 mHierarchyInterface = … … 24 26 //mDisplayNodes = true; 25 27 //mShowBoundingBoxes = true; 28 29 // TODO: set maxdepth to reasonable value 26 30 mMaxDepth = 50; 27 31 } … … 32 36 } 33 37 //----------------------------------------------------------------------- 38 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 39 { 40 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 41 // does nothing if hierarchical culling is used => 42 // we interleave identification and rendering of objects 43 // in _renderVisibibleObjects 44 if (!mUseVisibilityCulling) 45 { 46 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 47 return; 48 } 49 50 //-- show visibile scene nodes and octree bounding boxes from last frame 51 if (mShowVisualization) 52 { 53 // add player camera for visualization purpose 54 Camera *c; 55 if ((c = getCamera("PlayerCam")) != NULL) 56 { 57 getRenderQueue()->addRenderable(c); 58 } 59 60 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 61 { 62 getRenderQueue()->addRenderable(*it); 63 64 if (mRenderNodesForViz) 65 { 66 (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 67 } 68 } 69 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 70 { 71 getRenderQueue()->addRenderable(*it); 72 } 73 } 74 75 mVisible.clear(); 76 mBoxes.clear(); 77 } 78 //----------------------------------------------------------------------- 34 79 void VisibilityTerrainSceneManager::_renderVisibleObjects() 35 80 { 36 // two cameras (one for culling, one for rendering) 37 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 38 mCullCamera ? getCamera("CullCamera") : NULL); 39 //mVisibilityManager->GetCullingManager()->InitFrame(); 40 81 if (!mShowVisualization) 82 { 83 // two cameras (one for culling, one for rendering) 84 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 85 mCullCamera ? getCamera("CullCamera") : NULL); 86 87 // call initframe to reset culling manager stats 88 mVisibilityManager->GetCullingManager()->InitFrame(); 89 } 90 41 91 // standard terrain scenemanager rendering without hierarchical culling 42 if (!mUseVisibilityCulling || mShowVisualization)92 if (!mUseVisibilityCulling || mShowVisualization) 43 93 { 44 94 TerrainSceneManager::_renderVisibleObjects(); … … 85 135 } 86 136 //----------------------------------------------------------------------- 87 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)88 {89 // does nothing if hierarchical culling is used =>90 // we interleave identification and rendering of objects91 // in _renderVisibibleObjects92 getRenderQueue()->clear();93 94 if (!mUseVisibilityCulling)95 {96 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);97 return;98 }99 100 //-- show visibile scene nodes and octree bounding boxes from last frame101 if (mShowVisualization)102 {103 // add cull camera for visualization purpose104 if (mCullCamera)105 {106 Camera *c;107 if ((c = getCamera("CullCamera")) != NULL)108 {109 getRenderQueue()->addRenderable(c);110 }111 }112 113 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)114 {115 getRenderQueue()->addRenderable(*it);116 }117 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)118 {119 getRenderQueue()->addRenderable(*it);120 }121 }122 123 mVisible.clear();124 mBoxes.clear();125 }126 //-----------------------------------------------------------------------127 137 void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) 128 138 { 129 // mHierarchyInterface->setNumSceneNodes((int)mSceneNodes.size());130 139 mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 131 140 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); … … 149 158 return true; 150 159 } 160 if (key == "RenderNodesForViz") 161 { 162 mRenderNodesForViz = (*static_cast<const bool *>(val)); 163 return true; 164 } 151 165 if (key == "SkyBoxEnabled") 152 166 { … … 180 194 } 181 195 //----------------------------------------------------------------------- 182 bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector 196 bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector &refValueList) 183 197 { 184 198 return TerrainSceneManager::getOptionValues( key, refValueList); … … 200 214 return mVisibilityManager; 201 215 } 202 //----------------------------------------------------------------------- 203 void VisibilityTerrainSceneManager::SetShowVisualization(bool showViz) 204 { 205 mShowVisualization = showViz; 206 } 207 /* 208 //----------------------------------------------------------------------- 209 void SetSkyBoxEnabled(bool enabled) 210 { 211 mSkyBoxEnabled = enabled; 212 } 213 //----------------------------------------------------------------------- 214 void SetSkyPlaneEnabled(bool enabled) 215 { 216 mSkyPlaneEnabled = enabled; 217 } 218 //----------------------------------------------------------------------- 219 void SetSkyDomeEnabled(bool enabled) 220 { 221 mSkyDomeEnabled = enabled; 222 } */ 216 223 217 //----------------------------------------------------------------------- 224 218 void VisibilityTerrainSceneManager::WriteLog() … … 236 230 LogManager::getSingleton().logMessage(d.str()); 237 231 } 232 233 238 234 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.