Changeset 118 for trunk/VUT/Ogre
- Timestamp:
- 05/30/05 18:40:33 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r115 r118 28 28 29 29 /** Sets the given option for the SceneManager 30 @remarks 31 Options are: 32 "Algorithm", int *; 30 @remarks Options are: "Algorithm", int *; 33 31 */ 32 34 33 virtual bool setOption(const String &, const void *); 35 34 /** Gets the given option for the Scene VisibilityManager. … … 48 47 /** See set. 49 48 */ 50 GtpVisibility::VisibilityManager *getVisibilityManager( void ); 51 52 /** Writes out stats into the Ogre log file. 53 */ 54 void WriteLog(); 49 GtpVisibility::VisibilityManager *getVisibilityManager(); 55 50 56 51 /** Render a set of objects, see renderSingleObject for param definitions … … 59 54 virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 60 55 bool doLightIteration, const LightList* manualLightList = 0); 56 57 /** Writes out stats into the Ogre log file. 58 */ 59 void WriteLog(); 60 61 /** Override pass so we can do the z-fail pass */ 62 Pass* setPass(Pass* pass); 63 61 64 protected: 62 65 /** Creates material for depth pass, e.g., a pass that only fills the depth buffer */ 63 66 void CreateDepthPass(); 64 67 void ShowVisualization(Camera *cam); 65 68 OctreeHierarchyInterface *mHierarchyInterface; 66 69 GtpVisibility::VisibilityManager *mVisibilityManager; … … 74 77 bool mDelayRenderTransparents; 75 78 bool mUseDepthPass; 79 bool mIsDepthPass; 76 80 77 81 Pass *mDepthPass; -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r115 r118 3 3 4 4 #include <OgreSceneNode.h> 5 #include <OgreOctreeSceneManager.h>6 5 #include <OgreTerrainSceneManager.h> 7 #include <OgreOctreeSceneQuery.h>8 6 #include <OgreOctreeNode.h> 9 7 #include <OgreOctreeCamera.h> … … 25 23 ~VisibilityTerrainSceneManager(); 26 24 27 void _renderVisibleObjects( void);25 void _renderVisibleObjects(); 28 26 void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 29 27 void _updateSceneGraph(Camera* cam); … … 43 41 bool getOptionKeys( StringVector &refKeys ); 44 42 45 /** Sets the visibility manager 43 /** Sets the visibility manager. 46 44 @param visManager the visibility manager 47 45 */ 48 46 void setVisibilityManager(GtpVisibility::VisibilityManager *visManager); 49 /** See set 47 /** See set. 50 48 */ 51 49 GtpVisibility::VisibilityManager *getVisibilityManager(); -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r115 r118 86 86 87 87 // set no depth write, no color, no lighting material 88 //mSceneManager->setPass(solidBox->getTechnique()->getPass(0));89 SetOcclusionPass();88 mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 89 //SetOcclusionPass(); 90 90 91 91 solidBox->SetupBoundingBoxVertices(*box); -
trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp
r117 r118 2 2 #include "OgreSolidBoundingBox.h" 3 3 4 #include "OgreSimpleRenderable.h" 5 #include "OgreHardwareBufferManager.h" 6 #include "OgreCamera.h" 7 #include "OgreMaterialManager.h" 8 4 #include <OgreSimpleRenderable.h> 5 #include <OgreHardwareBufferManager.h> 6 #include <OgreCamera.h> 7 #include <OgreMaterialManager.h> 8 #include <OgreMaterial.h> 9 #include <OgrePass.h> 10 #include <OgreTechnique.h> 9 11 10 12 namespace Ogre { -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r115 r118 6 6 #include <OgreCamera.h> 7 7 #include <OgreLogManager.h> 8 #include <OgreStringConverter.h> 9 8 10 9 11 namespace Ogre { … … 15 17 mVisibilityManager(visManager), 16 18 mUseDepthPass(false), 19 mIsDepthPass(false), 17 20 mShowVisualization(false), 18 21 mRenderNodesForViz(false), 22 mRenderNodesContentForViz(false), 19 23 mVisualizeCulledNodes(false), 20 24 mSkipTransparents(false), … … 45 49 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 46 50 47 depthMat->createTechnique()->createPass(); 48 mDepthPass = depthMat->getTechnique(0)->getPass(0); 51 mDepthPass = depthMat->getTechnique(0)->getPass(0); 49 52 mDepthPass->setColourWriteEnabled(false); 50 53 mDepthPass->setDepthWriteEnabled(true); … … 62 65 } 63 66 //----------------------------------------------------------------------- 67 Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 68 { 69 // setting vertex program is not efficient 70 //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 71 Pass *usedPass = (mIsDepthPass ? mDepthPass : pass); 72 73 if (mIsDepthPass) 74 { 75 // set vertex program of current pass 76 if (pass->hasVertexProgram()) 77 { 78 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 79 80 if (mDepthPass->hasVertexProgram()) 81 { 82 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 83 // Load this program if not done already 84 if (!prg->isLoaded()) 85 prg->load(); 86 // Copy params 87 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 88 } 89 } 90 else if (mDepthPass->hasVertexProgram()) 91 { 92 mDepthPass->setVertexProgram(""); 93 } 94 } 95 96 OctreeSceneManager::setPass(usedPass); 97 98 return usedPass; 99 } 100 //----------------------------------------------------------------------- 101 void VisibilityOctreeSceneManager::ShowVisualization(Camera *cam) 102 { 103 // add player camera for visualization purpose 104 try { 105 Camera *c; 106 if ((c = getCamera("PlayerCam")) != NULL) 107 { 108 getRenderQueue()->addRenderable(c); 109 } 110 } 111 catch(...) 112 { 113 // ignore 114 } 115 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 116 { 117 getRenderQueue()->addRenderable(*it); 118 } 119 if (mRenderNodesForViz || mRenderNodesContentForViz) 120 { 121 // change node material so it is better suited for visualization 122 MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 123 nodeMat->setAmbient(1, 1, 0); 124 nodeMat->setLightingEnabled(true); 125 nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 126 127 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 128 { 129 130 if (mRenderNodesForViz) 131 { 132 getRenderQueue()->addRenderable(*it); 133 // addbounding boxes instead of node itself 134 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 135 } 136 if (mRenderNodesContentForViz) 137 { 138 (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 139 } 140 } 141 } 142 143 } 144 //----------------------------------------------------------------------- 145 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 146 { 147 //-- show visible scene nodes and octree bounding boxes from last frame 148 if (mShowVisualization) 149 { 150 ShowVisualization(cam); 151 } 152 else 153 { 154 mVisible.clear(); 155 mBoxes.clear(); 156 157 // if there is no depth pass => 158 // we interleave identification and rendering of objects 159 // in _renderVisibibleObjects 160 161 // only shadow casters will be rendered in shadow texture pass 162 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 163 } 164 } 165 //----------------------------------------------------------------------- 64 166 void VisibilityOctreeSceneManager::_renderVisibleObjects() 65 167 { 66 if (!mShowVisualization) 67 { 68 // two cameras (one for culling, one for rendering) 69 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 70 mCullCamera ? getCamera("CullCamera") : NULL, mDelayRenderTransparents); 71 72 // call initframe to reset culling manager stats 73 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 74 } 75 76 // standard terrain scenemanager rendering without hierarchical culling 77 if (!mUseDepthPass || mShowVisualization) 168 // visualization: apply standard rendering 169 if (mShowVisualization) 78 170 { 79 171 OctreeSceneManager::_renderVisibleObjects(); 80 81 172 return; 82 173 } 83 174 175 84 176 //-- hierarchical culling 85 177 // the objects of different layers (e.g., background, scene, 86 178 // overlay) must be identified and rendered one after another 87 179 180 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 181 182 // possible two cameras (one for culling, one for rendering) 183 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 184 mCullCamera ? getCamera("CullCamera") : NULL, 185 leaveTransparentsInQueue); 186 187 // call initframe to reset culling manager stats 188 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 189 88 190 mSkipTransparents = false; 89 191 90 //-- render background 192 //-- render background, in case there is one 91 193 clearSpecialCaseRenderQueues(); 92 194 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 93 195 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 94 95 196 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 197 96 198 SceneManager::_renderVisibleObjects(); 199 97 200 98 201 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 102 205 //-- render visible objects (i.e., all but overlay) 103 206 clearSpecialCaseRenderQueues(); 207 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 104 208 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 105 209 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 106 210 107 // render only solids in hierarchical algorithm.108 // Transparentsneed sorting, thus we render them afterwards211 // transparents are skipped from hierarchical rendering 212 // => they need sorting, thus we render them afterwards 109 213 mSkipTransparents = mDelayRenderTransparents; 110 214 215 // set state for depth pass 216 mIsDepthPass = mUseDepthPass; 217 111 218 /** 112 219 * the hierarchical culling algorithm 220 * for depth pass: will just find objects and update depth buffer 221 * for delayed rendering: will render all but transparents 113 222 **/ 114 223 … … 121 230 SceneManager::_renderVisibleObjects(); 122 231 232 // for depth pass: add visible nodes found with the visibility culling 233 if (mUseDepthPass) 234 { 235 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 236 { 237 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 238 } 239 mIsDepthPass = false; 240 } 241 mSkipTransparents = false; 242 243 //-- now we can render all remaining queue objects 244 // for depth pass: all 245 // for delayed rendering: transparents, overlay 246 clearSpecialCaseRenderQueues(); 247 SceneManager::_renderVisibleObjects(); 248 123 249 //WriteLog(); // write out stats 124 }125 //-----------------------------------------------------------------------126 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)127 {128 // only shadow casters will be rendered in shadow texture pass129 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);130 131 // does nothing if hierarchical culling is used =>132 // we interleave identification and rendering of objects133 // in _renderVisibibleObjects134 if (!mUseDepthPass)135 {136 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);137 return;138 }139 140 //-- show visibile scene nodes and octree bounding boxes from last frame141 if (mShowVisualization)142 {143 // add player camera for visualization purpose144 try {145 Camera *c;146 if ((c = getCamera("PlayerCam")) != NULL)147 {148 getRenderQueue()->addRenderable(c);149 }150 }151 catch(...)152 {153 // ignore154 }155 156 if (mRenderNodesForViz || mRenderNodesContentForViz)157 {158 /* // change node material so it is better suited for visualization159 MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");160 nodeMat->setAmbient(1, 1, 0);161 nodeMat->setLightingEnabled(true);162 nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();*/163 164 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)165 {166 if (mRenderNodesForViz)167 {168 getRenderQueue()->addRenderable(*it);169 }170 if (mRenderNodesContentForViz)171 {172 (*it)->_addToRenderQueue(cam, getRenderQueue(), false);173 }174 }175 }176 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)177 {178 getRenderQueue()->addRenderable(*it);179 }180 }181 182 mVisible.clear();183 mBoxes.clear();184 250 } 185 251 //----------------------------------------------------------------------- … … 212 278 return true; 213 279 } 280 if (key == "RenderNodesContentForViz") 281 { 282 mRenderNodesContentForViz = (*static_cast<const bool *>(val)); 283 return true; 284 } 214 285 if (key == "SkyBoxEnabled") 215 286 { … … 274 345 } 275 346 //----------------------------------------------------------------------- 276 void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,277 bool doLightIteration, const LightList* manualLightList)278 {279 if (!mSkipTransparents)280 {281 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);282 }283 }284 //-----------------------------------------------------------------------285 347 void VisibilityOctreeSceneManager::WriteLog() 286 348 { 287 349 std::stringstream d; 288 350 289 d << "Algorithm : " << mVisibilityManager->GetCullingManagerType() << ", "290 << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: "291 << mHierarchyInterface->GetNumTraversedNodes() << ", "351 d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 352 << "Hierarchy nodes: " << mNumOctreeNodes << ", " 353 << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 292 354 << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 293 355 << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " … … 297 359 LogManager::getSingleton().logMessage(d.str()); 298 360 } 361 //----------------------------------------------------------------------- 362 void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 363 bool doLightIteration, const LightList* manualLightList) 364 { 365 if (!mSkipTransparents) 366 { 367 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 368 } 369 } 370 299 371 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r117 r118 1 1 #include "OgreVisibilityTerrainSceneManager.h" 2 #include "OgreOctreeHierarchyInterface.h"3 2 #include "OgreVisibilityOptionsManager.h" 4 3 #include <OgreMath.h> … … 51 50 mDepthPass->setDepthWriteEnabled(true); 52 51 mDepthPass->setLightingEnabled(false); 53 //depthMat->load();54 52 } 55 53 else … … 112 110 // ignore 113 111 } 114 112 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 113 { 114 getRenderQueue()->addRenderable(*it); 115 } 115 116 if (mRenderNodesForViz || mRenderNodesContentForViz) 116 117 { 118 // change node material so it is better suited for visualization 119 MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 120 nodeMat->setAmbient(1, 1, 0); 121 nodeMat->setLightingEnabled(true); 122 nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 123 117 124 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 118 125 { 126 119 127 if (mRenderNodesForViz) 120 128 { 121 //getRenderQueue()->addRenderable(*it);129 getRenderQueue()->addRenderable(*it); 122 130 // addbounding boxes instead of node itself 123 (*it)->_addBoundingBoxToQueue(getRenderQueue());131 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 124 132 } 125 133 if (mRenderNodesContentForViz) … … 129 137 } 130 138 } 131 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 132 { 133 getRenderQueue()->addRenderable(*it); 134 } 139 135 140 } 136 141 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.