- Timestamp:
- 06/10/05 01:46:50 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r119 r122 77 77 bool mDelayRenderTransparents; 78 78 bool mUseDepthPass; 79 bool m IsDepthPass;79 bool mRenderDepthPass; 80 80 81 81 Pass *mDepthPass; -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r121 r122 67 67 bool validatePassForRendering(Pass* pass); 68 68 69 void RenderItemBuffer(RenderPriorityGroup* pGroup); 70 void RenderSingleObjectForItemBuffer(Renderable *rend); 71 void renderQueueGroupObjects(RenderQueueGroup* pGroup); 72 73 /** Override from SceneManager so that sub entities can be assigned an id for item buffer */ 74 Entity* createEntity(const String& entityName, const String& meshName); 75 69 76 protected: 70 /** Creates material for depth pass, e.g., a pass that only fills the depth buffer */ 77 78 /** Creates material for depth pass, e.g., a pass that only fills the depth buffer. */ 71 79 void InitDepthPass(); 80 /** Creates material for item buffer. */ 81 void InitItemBufferPass(); 82 /** Fills render queue so that a visualization can be rendered. */ 72 83 void ShowVisualization(Camera *cam); 84 73 85 OctreeHierarchyInterface *mHierarchyInterface; 74 86 GtpVisibility::VisibilityManager *mVisibilityManager; … … 82 94 bool mDelayRenderTransparents; 83 95 bool mUseDepthPass; 84 bool mIsDepthPass; 96 bool mRenderDepthPass; 97 bool mRenderItemBuffer; 85 98 86 99 Pass *mDepthPass; 100 Pass *mItemBufferPass; 101 102 int mCurrentEntityId; 87 103 }; 88 104 -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r121 r122 173 173 //-- the actual query test 174 174 query->BeginQuery(); 175 175 176 176 // if node is leaf and was visible => will be rendered anyway. 177 177 // In this case we can also test with the real geometry. 178 178 // If camera for culling is different from camera for rendering or only solids 179 179 // will be rendereded => cannot optimize 180 if (mUseOptimization && (mCamera == mCullCamera) && wasVisible && IsLeaf(node) 180 if (mUseOptimization && (mCamera == mCullCamera) && wasVisible && IsLeaf(node)) 181 181 { 182 182 //LogManager::getSingleton().logMessage("render node\n"); -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r121 r122 16 16 : 17 17 mVisibilityManager(visManager), 18 m IsDepthPass(false),18 mRenderDepthPass(false), 19 19 mShowVisualization(false), 20 20 mRenderNodesForViz(false), … … 69 69 { 70 70 // setting vertex program is not efficient 71 Pass *usedPass = ((mIsDepthPass && pass->getDepthWriteEnabled() && !pass->hasVertexProgram()) ? mDepthPass : pass); 71 Pass *usedPass = ((mRenderDepthPass && pass->getDepthWriteEnabled() && 72 !pass->hasVertexProgram()) ? mDepthPass : pass); 72 73 73 74 /* 74 75 // set depth fill pass only if depth write enabled 75 Pass *usedPass = (m IsDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass);76 77 if (m IsDepthPass && pass->hasVertexProgram())76 Pass *usedPass = (mRenderDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 77 78 if (mRenderDepthPass && pass->hasVertexProgram()) 78 79 { 79 80 // set vertex program of current pass to depth pass … … 127 128 128 129 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 129 {130 { 130 131 131 132 if (mRenderNodesForViz) … … 169 170 // create material for depth pass 170 171 InitDepthPass(); 171 172 172 173 // visualization: apply standard rendering 173 174 if (mShowVisualization) … … 175 176 OctreeSceneManager::_renderVisibleObjects(); 176 177 return; 177 } 178 178 } 179 179 180 180 //-- hierarchical culling … … 218 218 219 219 // set state for depth pass 220 m IsDepthPass = mUseDepthPass;220 mRenderDepthPass = mUseDepthPass; 221 221 222 222 /** … … 241 241 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 242 242 } 243 m IsDepthPass = false;243 mRenderDepthPass = false; 244 244 } 245 245 mSkipTransparents = false; -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r121 r122 7 7 #include <OgreLogManager.h> 8 8 #include <OgreStringConverter.h> 9 9 #include <OgreEntity.h> 10 #include <OgreSubEntity.h> 10 11 11 12 namespace Ogre { … … 15 16 GtpVisibility::VisibilityManager *visManager): 16 17 mVisibilityManager(visManager), 17 m IsDepthPass(false),18 mRenderDepthPass(false), 18 19 mShowVisualization(false), 19 20 mRenderNodesForViz(false), … … 22 23 mSkipTransparents(false), 23 24 mDelayRenderTransparents(true), 24 mUseDepthPass(false) 25 mUseDepthPass(false), 26 mRenderItemBuffer(true), 27 mCurrentEntityId(0) 25 28 { 26 29 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 54 57 } 55 58 //----------------------------------------------------------------------- 59 void VisibilityTerrainSceneManager::InitItemBufferPass() 60 { 61 MaterialPtr itemBufferMat = MaterialManager::getSingleton(). 62 getByName("Visibility/ItemBufferPass"); 63 64 if (itemBufferMat.isNull()) 65 { 66 // Init 67 itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass", 68 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 69 70 mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0); 71 mItemBufferPass->setColourWriteEnabled(true); 72 mItemBufferPass->setDepthWriteEnabled(true); 73 mItemBufferPass->setLightingEnabled(true); 74 } 75 else 76 { 77 mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0); 78 } 79 mItemBufferPass->setAmbient(0, 0, 0); 80 } 81 //----------------------------------------------------------------------- 56 82 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 57 83 { … … 65 91 void VisibilityTerrainSceneManager::ShowVisualization(Camera *cam) 66 92 { 93 LogManager::getSingleton().logMessage("***********VISUALIZATION************"); 67 94 // add player camera for visualization purpose 68 95 try … … 101 128 if (mRenderNodesContentForViz) 102 129 { 103 (*it)->_ myAddToRenderQueue(cam, getRenderQueue(), false);130 (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 104 131 } 105 132 } … … 109 136 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 110 137 { 111 //Pass *usedPass = ((m IsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient138 //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient 112 139 113 140 // set depth fill pass only if depth write enabled 114 Pass *usedPass = (m IsDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ? mDepthPass : pass);141 Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ? mDepthPass : pass); 115 142 116 143 IlluminationRenderStage savedStage = mIlluminationStage; … … 118 145 // set illumination stage to NONE so no shadow material is used 119 146 // for depth pass or for occlusion query 120 if (m IsDepthPass || mHierarchyInterface->IsBoundingBoxQuery())147 if (mRenderDepthPass || mHierarchyInterface->IsBoundingBoxQuery()) 121 148 { 122 149 mIlluminationStage = IRS_NONE; 123 150 } 124 151 125 if (m IsDepthPass)152 if (mRenderDepthPass) 126 153 { 127 154 // set vertex program of current pass … … 157 184 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 158 185 { 186 // needs full ambient lighting for item colors to be exact 187 if (mRenderItemBuffer) 188 { 189 setAmbientLight(ColourValue(1,1,1,1)); 190 } 191 192 LogManager::getSingleton().logMessage("***********FIND OBJECTS************"); 193 getRenderQueue()->clear(); 194 159 195 //-- show visible scene nodes and octree bounding boxes from last frame 160 196 if (mShowVisualization) … … 163 199 } 164 200 201 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 202 165 203 mVisible.clear(); 166 204 mBoxes.clear(); 167 205 168 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);169 170 206 // if there is no depth pass => 171 207 // we interleave identification and rendering of objects … … 185 221 void VisibilityTerrainSceneManager::_renderVisibleObjects() 186 222 { 223 std::stringstream d; 224 d << "Terrain render level: " << TerrainRenderable::getCurrentRenderLevelIndex(); 225 LogManager::getSingleton().logMessage(d.str()); 226 227 // increase terrain renderlevel 228 int renderLevel = TerrainRenderable::getCurrentRenderLevelIndex() + 1; 229 230 if (TerrainRenderable::getCurrentRenderLevelIndex() >= 10) 231 { // max. 10 different renderlevels 232 renderLevel = 0; 233 } 234 187 235 // visualization: apply standard rendering 188 236 if (mShowVisualization) 189 237 { 190 238 TerrainSceneManager::_renderVisibleObjects(); 239 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 191 240 return; 192 241 } 193 194 // create material for depth pass 195 InitDepthPass(); 242 243 LogManager::getSingleton().logMessage("***********RENDER OBJECTS************"); 244 245 InitDepthPass(); // create material for depth pass 246 InitItemBufferPass(); // create material for item buffer pass 196 247 197 248 //-- hierarchical culling … … 228 279 229 280 // set state for depth pass 230 m IsDepthPass = mUseDepthPass;281 mRenderDepthPass = mUseDepthPass; 231 282 232 283 /** … … 242 293 if (mUseDepthPass) 243 294 { 244 /*for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)295 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 245 296 { 246 297 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 247 } */248 m IsDepthPass = false;298 } 299 mRenderDepthPass = false; 249 300 } 250 301 … … 257 308 TerrainSceneManager::_renderVisibleObjects(); 258 309 259 getRenderQueue()->clear();310 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 260 311 //WriteLog(); // write out stats 261 312 } 313 262 314 //----------------------------------------------------------------------- 263 315 void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) … … 318 370 mDelayRenderTransparents = (*static_cast<const bool *>(val)); 319 371 return true; 372 } 373 // notifiy that frame has ended so terrain render level can be reset for correct 374 // terrain rendering 375 if (key == "TerrainLevelIdx") 376 { 377 TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 320 378 } 321 379 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). … … 387 445 { 388 446 // skip all but first pass if we are doing the depth pass 389 if ( mIsDepthPass&& pass->getIndex() > 0)447 if ((mRenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0) 390 448 { 391 449 return false; … … 393 451 return SceneManager::validatePassForRendering(pass); 394 452 } 453 //----------------------------------------------------------------------- 454 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 455 { 456 if (!mRenderItemBuffer) 457 { 458 TerrainSceneManager::renderQueueGroupObjects(pGroup); 459 return; 460 } 461 462 //--- item buffer 463 // Iterate through priorities 464 RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 465 466 while (groupIt.hasMoreElements()) 467 { 468 RenderItemBuffer(groupIt.getNext()); 469 } 470 } 471 //----------------------------------------------------------------------- 472 void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 473 { 474 // Do solids 475 RenderPriorityGroup::SolidRenderablePassMap solidObjs = pGroup->_getSolidPasses(); 476 477 // ----- SOLIDS LOOP ----- 478 RenderPriorityGroup::SolidRenderablePassMap::const_iterator ipass, ipassend; 479 ipassend = solidObjs.end(); 480 481 for (ipass = solidObjs.begin(); ipass != ipassend; ++ipass) 482 { 483 // Fast bypass if this group is now empty 484 if (ipass->second->empty()) 485 continue; 486 487 // Render only first pass 488 if (ipass->first->getIndex() > 0) 489 continue; 490 491 RenderPriorityGroup::RenderableList* rendList = ipass->second; 492 493 RenderPriorityGroup::RenderableList::const_iterator irend, irendend; 494 irendend = rendList->end(); 495 496 for (irend = rendList->begin(); irend != irendend; ++irend) 497 { 498 RenderSingleObjectForItemBuffer(*irend); 499 } 500 } 501 502 // ----- TRANSPARENT LOOP 503 RenderPriorityGroup::TransparentRenderablePassList 504 transpObjs = pGroup->_getTransparentPasses(); 505 RenderPriorityGroup::TransparentRenderablePassList::const_iterator itrans, itransend; 506 507 itransend = transpObjs.end(); 508 for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 509 { 510 // Render only first pass 511 if (itrans->pass->getIndex() == 0) 512 { 513 RenderSingleObjectForItemBuffer(itrans->renderable); 514 } 515 } 516 } 517 //----------------------------------------------------------------------- 518 void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend) 519 { 520 static LightList nullLightList; 521 Real col = (Real)rend->getId() / (Real)mCurrentEntityId; 522 mItemBufferPass->setAmbient(col, 0, 0); 523 524 setPass(mItemBufferPass); 525 526 std::stringstream d; 527 d << "item buffer id: " << rend->getId() << ", col: " << col; 528 LogManager::getSingleton().logMessage(d.str()); 529 // Render a single object, this will set up auto params if required 530 renderSingleObject(rend, mItemBufferPass, true, &nullLightList); 531 } 532 //----------------------------------------------------------------------- 533 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, const String& meshName) 534 { 535 Entity *ent = SceneManager::createEntity(entityName, meshName); 536 537 for (int i = 0; i < ent->getNumSubEntities(); ++i) 538 { 539 ent->getSubEntity(i)->setId(mCurrentEntityId ++); 540 } 541 542 return ent; 543 } 395 544 396 545 } // namespace Ogre -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp
r121 r122 54 54 mTerrainContentGenerator(sceneGenerator), 55 55 mVisibilityThreshold(0), 56 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),57 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),56 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 57 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 58 58 mNodeVizMode(NODEVIZ_NONE), 59 59 mVizCameraHeight(Real(2500.0)), … … 231 231 bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 232 232 { 233 LogManager::getSingleton().logMessage("frame started"); 233 234 if (mWindow->isClosed()) 234 235 return false; … … 236 237 mInputDevice->capture(); 237 238 239 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 240 int terrainLevelIdx = 0; 241 mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 242 238 243 //-- setup what is needed for immediate mouse/key movement 239 244 if (mTimeDelay >= 0) -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r121 r122 22 22 TestCullingTerrainApplication::~TestCullingTerrainApplication() 23 23 { 24 if(mTerrainContentGenerator) 24 if (mTerrainContentGenerator) 25 { 25 26 delete mTerrainContentGenerator; 27 mTerrainContentGenerator = NULL; 28 } 26 29 //if(mRenderTargetListener) delete mRenderTargetListener; 27 30 }
Note: See TracChangeset
for help on using the changeset viewer.