Changeset 159 for trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
- Timestamp:
- 07/06/05 17:52:44 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r158 r159 31 31 mEnableDepthWrite(true), 32 32 mSkipTransparents(false), 33 mSavedShadowTechnique(SHADOWTYPE_NONE) 33 mSavedShadowTechnique(SHADOWTYPE_NONE), 34 mRenderTransparentsForItemBuffer(false), 35 mExecuteVertexProgramForAllPasses(false) 34 36 { 35 37 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 37 39 //mDisplayNodes = true; 38 40 //mShowBoundingBoxes = true; 41 //mShowBoxes = true; 42 //mShowBoxes = true; 39 43 40 44 // TODO: set maxdepth to reasonable value … … 48 52 if (depthMat.isNull()) 49 53 { 50 // Init51 54 depthMat = MaterialManager::getSingleton().create( 52 55 "Visibility/DepthPass", 53 56 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 57 54 58 mDepthPass = depthMat->getTechnique(0)->getPass(0); 55 59 mDepthPass->setColourWriteEnabled(false); … … 60 64 { 61 65 mDepthPass = depthMat->getTechnique(0)->getPass(0); 66 } 67 } 68 //----------------------------------------------------------------------- 69 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 70 { 71 if (mHierarchyInterface) 72 { 73 delete mHierarchyInterface; 74 mHierarchyInterface = NULL; 62 75 } 63 76 } … … 85 98 } 86 99 //mItemBufferPass->setAmbient(1, 1, 0); 87 }88 //-----------------------------------------------------------------------89 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()90 {91 if (mHierarchyInterface)92 {93 delete mHierarchyInterface;94 mHierarchyInterface = NULL;95 }96 100 } 97 101 //----------------------------------------------------------------------- … … 160 164 } 161 165 162 if (mRenderDepthPass) 163 { 164 // --- set vertex program of current pass so z-buffer is updated correctly 165 if (pass->hasVertexProgram()) 166 { 167 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 168 169 if (mDepthPass->hasVertexProgram()) 170 { 171 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 172 // Load this program if not done already 173 if (!prg->isLoaded()) 174 prg->load(); 175 // Copy params 176 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 177 } 178 } 179 else if (mDepthPass->hasVertexProgram()) 180 { 181 mDepthPass->setVertexProgram(""); 182 } 183 } 166 // --- set vertex program of current pass in order to set correct depth 167 if (mExecuteVertexProgramForAllPasses && mRenderDepthPass && pass->hasVertexProgram()) 168 { 169 // add vertex program of current pass to depth pass 170 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 171 172 if (mDepthPass->hasVertexProgram()) 173 { 174 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 175 // Load this program if not done already 176 if (!prg->isLoaded()) 177 prg->load(); 178 // Copy params 179 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 180 } 181 } 182 else if (mDepthPass->hasVertexProgram()) 183 { 184 mDepthPass->setVertexProgram(""); 185 } 186 184 187 185 188 bool IsDepthWrite = usedPass->getDepthWriteEnabled(); … … 228 231 // mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 229 232 } 230 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);233 231 234 232 235 // -- delete lists stored for visualization … … 240 243 ColourValue savedAmbient = mAmbientLight; 241 244 242 // --- apply standard rendering for some cases (e.g., visualization, shadow pass)245 //-- apply standard rendering for some modes (e.g., visualization, shadow pass) 243 246 244 247 if (mShowVisualization || … … 257 260 mIlluminationStage = savedStage; 258 261 } 259 else // 262 else //-- the hierarchical culling algorithm 260 263 { 261 264 // don't render backgrounds for item buffer … … 266 269 } 267 270 271 //-- hierarchical culling 268 272 // the objects of different layers (e.g., background, scene, 269 273 // overlay) must be identified and rendered one after another … … 279 283 280 284 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 281 // delete previously rendered conten bt285 // delete previously rendered content 282 286 _deleteRenderedQueueGroups(); 283 287 #endif … … 296 300 /** 297 301 * the hierarchical culling algorithm 298 * if we use a depth pass: will just find objects and update depth buffer 299 * for "delayed" rendering: will render some passes afterwards, e.g., transparents 302 * for depth pass: we just find objects and update depth buffer 303 * for "delayed" rendering: we render some passes afterwards 304 * e.g., transparents, because they need front-to-back sorting 300 305 **/ 301 306 … … 325 330 326 331 //-- now we can render all remaining queue objects 327 // for depth pass, transparents, overlay332 // used for depth pass, transparents, overlay 328 333 clearSpecialCaseRenderQueues(); 329 334 TerrainSceneManager::_renderVisibleObjects(); 330 335 } 331 336 332 // set the new render level index afterwards => new level in the next frame 333 int levelIdx = TerrainRenderable::getCurrentRenderLevelIndex() + 1; 334 TerrainRenderable::setCurrentRenderLevelIndex(levelIdx); 335 337 // set the new render level index 338 TerrainRenderable::NextRenderLevelIndex(); 339 336 340 // reset ambient light 337 341 setAmbientLight(savedAmbient); 338 342 339 getRenderQueue()->clear(); 343 getRenderQueue()->clear(); // finally clear render queue 340 344 //WriteLog(); // write out stats 341 345 } … … 397 401 return true; 398 402 } 399 // notifiy that frame has ended so terrain render level can be reset for correct 400 // terrain rendering 401 if (key == "TerrainLevelIdx") 402 { 403 TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 404 return true; 405 } 403 406 404 if (key == "DepthWrite") 407 405 { … … 414 412 return true; 415 413 } 416 414 if (key == "ExecuteVertexProgramForAllPasses") 415 { 416 mExecuteVertexProgramForAllPasses = (*static_cast<const bool *>(val)); 417 return true; 418 } 419 if (key == "RenderTransparentsForItemBuffer") 420 { 421 mRenderTransparentsForItemBuffer = (*static_cast<const bool *>(val)); 422 return true; 423 } 424 417 425 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 418 426 setOption(key, val) || TerrainSceneManager::setOption(key, val); … … 547 555 } 548 556 549 // ----- TRANSPARENT LOOP: must be handled differently 550 // TODO: HOW TO HANDLE OCCLUDED OBJECTS ???? 551 RenderPriorityGroup::TransparentRenderablePassList 552 transpObjs = pGroup->_getTransparentPasses(); 553 RenderPriorityGroup::TransparentRenderablePassList::const_iterator itrans, itransend; 554 555 itransend = transpObjs.end(); 556 for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 557 { 558 // like for solids, render only first pass 559 if (itrans->pass->getIndex() == 0) 560 { 561 RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass); 562 } 563 } 557 // -- TRANSPARENT LOOP: must be handled differently 558 559 // transparents are treated either as solids or completely discarded 560 if (mRenderTransparentsForItemBuffer) 561 { 562 RenderPriorityGroup::TransparentRenderablePassList transpObjs = 563 pGroup->_getTransparentPasses(); 564 RenderPriorityGroup::TransparentRenderablePassList::const_iterator 565 itrans, itransend; 566 567 itransend = transpObjs.end(); 568 for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 569 { 570 // like for solids, render only first pass 571 if (itrans->pass->getIndex() == 0) 572 { 573 RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass); 574 } 575 } 576 } 564 577 } 565 578 //----------------------------------------------------------------------- … … 583 596 584 597 // set vertex program of current pass 585 if ( pass->hasVertexProgram())598 if (mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 586 599 { 587 600 mItemBufferPass->setVertexProgram(pass->getVertexProgramName()); … … 614 627 } 615 628 //----------------------------------------------------------------------- 616 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,617 const String& meshName)618 {619 Entity *ent = SceneManager::createEntity(entityName, meshName);620 621 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)622 {623 ent->getSubEntity(i)->setId(mCurrentEntityId);624 }625 626 // increase counter of entity id values627 ++ mCurrentEntityId;628 629 return ent;630 }631 //-----------------------------------------------------------------------632 629 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 633 630 { … … 644 641 if ((mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) || 645 642 (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)) 646 { 647 643 { 648 644 mShadowTechnique = SHADOWTYPE_NONE; 649 645 } … … 660 656 661 657 662 // set passes which should be stored in render queue658 // set passes which are stored in render queue 663 659 // for rendering AFTER hierarchical culling, i.e., passes which need 664 660 // a special rendering order … … 715 711 } 716 712 //----------------------------------------------------------------------- 713 void VisibilityTerrainSceneManager::endFrame() 714 { 715 TerrainRenderable::ResetRenderLevelIndex(); 716 } 717 //----------------------------------------------------------------------- 717 718 /*void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup) 718 719 { … … 742 743 } 743 744 */ 745 //----------------------------------------------------------------------- 746 /* 747 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 748 const String& meshName) 749 { 750 Entity *ent = SceneManager::createEntity(entityName, meshName); 751 752 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 753 { 754 ent->getSubEntity(i)->setId(mCurrentEntityId); 755 } 756 757 // increase counter of entity id values 758 ++ mCurrentEntityId; 759 760 return ent; 761 } 762 */ 744 763 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.