Changeset 897 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Timestamp:
- 05/04/06 18:26:23 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r868 r897 10 10 #include <OgreEntity.h> 11 11 #include <OgreSubEntity.h> 12 #include <OgreMaterialManager.h> 12 13 #include <OgreIteratorWrappers.h> 13 14 #include "VspBspTree.h" … … 22 23 23 24 //----------------------------------------------------------------------- 24 OcclusionCullingSceneManager::OcclusionCullingSceneManager( 25 GtpVisibility::VisibilityManager *visManager): 26 TerrainSceneManager( ),25 OcclusionCullingSceneManager::OcclusionCullingSceneManager(const String& name, 26 GtpVisibility::VisibilityManager *visManager): 27 TerrainSceneManager(name), 27 28 mVisibilityManager(visManager), 28 29 mShowVisualization(false), … … 35 36 mIsDepthPassPhase(false), 36 37 mUseItemBuffer(false), 38 //mUseItemBuffer(true), 37 39 mIsItemBufferPhase(false), 38 40 mCurrentEntityId(1), … … 105 107 //mItemBufferPass->setAmbient(1, 1, 0); 106 108 } 109 //------------------------------------------------------------------------- 110 void OcclusionCullingSceneManager::setWorldGeometry( DataStreamPtr& stream, const String& typeName ) 111 { 112 // Clear out any existing world resources (if not default) 113 if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() != 114 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) 115 { 116 ResourceGroupManager::getSingleton().clearResourceGroup( 117 ResourceGroupManager::getSingleton().getWorldResourceGroupName()); 118 } 119 destroyLevelIndexes(); 120 mTerrainPages.clear(); 121 // Load the configuration 122 loadConfig( stream ); 123 initLevelIndexes(); 124 125 // Resize the octree, allow for 1 page for now 126 float max_x = mOptions.scale.x * mOptions.pageSize; 127 float max_y = mOptions.scale.y; 128 float max_z = mOptions.scale.z * mOptions.pageSize; 129 130 float maxAxis = std::max(max_x, max_y); 131 maxAxis = std::max(maxAxis, max_z); 132 resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) ); 133 134 setupTerrainMaterial(); 135 136 setupTerrainPages(); 137 138 } 139 107 140 //----------------------------------------------------------------------- 108 141 void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) … … 157 190 } 158 191 //----------------------------------------------------------------------- 159 Pass *OcclusionCullingSceneManager::setPass(Pass* pass)192 const Pass *OcclusionCullingSceneManager::_setPass(Pass* pass) 160 193 { 161 194 if (NORMAL_RENDER_HACK) 162 195 { 163 return SceneManager:: setPass(pass);196 return SceneManager::_setPass(pass); 164 197 } 165 198 … … 217 250 218 251 //-- set actual pass here 219 Pass *result = SceneManager::setPass(usedPass);252 const Pass *result = SceneManager::_setPass(usedPass); 220 253 221 254 … … 232 265 } 233 266 //----------------------------------------------------------------------- 234 void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 267 void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, 268 bool onlyShadowCasters) 235 269 { 236 270 if (NORMAL_RENDER_HACK) … … 335 369 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 336 370 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 337 371 338 372 // exclude this queues from hierarchical rendering 339 373 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); … … 343 377 InitVisibilityCulling(mCameraInProgress); 344 378 345 379 346 380 /** 347 381 * the hierarchical culling algorithm … … 366 400 367 401 mLeavePassesInQueue = 0; 368 402 369 403 #if 1 370 404 // add visible nodes found by the visibility culling algorithm … … 495 529 if (useArbQueries) 496 530 { 497 mHierarchyInterface-> DeleteQueries();531 mHierarchyInterface->ResetQueries(); 498 532 mDestRenderSystem->setConfigOption("ArbQueries", "Yes"); 499 533 } 500 534 else 501 535 { 502 mHierarchyInterface-> DeleteQueries();536 mHierarchyInterface->ResetQueries(); 503 537 mDestRenderSystem->setConfigOption("ArbQueries", "No"); 504 538 } 505 539 } 506 507 540 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 508 541 setOption(key, val) || TerrainSceneManager::setOption(key, val); … … 564 597 //----------------------------------------------------------------------- 565 598 void OcclusionCullingSceneManager::renderObjects( 566 const RenderPriorityGroup::TransparentRenderablePassList& objs, 599 const QueuedRenderableCollection& objs, 600 QueuedRenderableCollection::OrganisationMode om, 567 601 bool doLightIteration, const LightList* manualLightList) 568 602 { … … 571 605 if (NORMAL_RENDER_HACK || !mSkipTransparents) 572 606 { 573 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);607 OctreeSceneManager::renderObjects(objs, om, doLightIteration, manualLightList); 574 608 } 575 609 } … … 596 630 } 597 631 //----------------------------------------------------------------------- 598 void OcclusionCullingSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 632 void OcclusionCullingSceneManager::_renderQueueGroupObjects(RenderQueueGroup* pGroup, 633 QueuedRenderableCollection::OrganisationMode om) 599 634 { 600 635 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 601 636 { 602 TerrainSceneManager:: renderQueueGroupObjects(pGroup);637 TerrainSceneManager::_renderQueueGroupObjects(pGroup, om); 603 638 return; 604 639 } 605 640 #ifdef ITEM_BUFFER 641 //-- item buffer 606 642 //-- item buffer: render objects using false colors 607 643 … … 613 649 RenderItemBuffer(groupIt.getNext()); 614 650 } 615 } 651 #endif // ITEM_BUFFER 652 } 653 #ifdef ITEM_BUFFER 616 654 //----------------------------------------------------------------------- 617 655 void OcclusionCullingSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 618 656 { 619 657 // Do solids 620 RenderPriorityGroup::SolidRenderablePassMap solidObjs = pGroup->_getSolidPasses();658 QueuedRenderableCollection solidObjs = pGroup->getSolidsBasic();//msz 621 659 622 660 // ----- SOLIDS LOOP ----- … … 658 696 if (mRenderTransparentsForItemBuffer) 659 697 { 660 RenderPriorityGroup::TransparentRenderablePassList transpObjs = 661 pGroup->_getTransparentPasses(); 698 QueuedRenderableCollection transpObjs = pGroup->getTransparents(); //msz 662 699 RenderPriorityGroup::TransparentRenderablePassList::const_iterator 663 700 itrans, itransend; … … 713 750 } 714 751 715 Pass *usedPass =setPass(mItemBufferPass);752 const Pass *usedPass = _setPass(mItemBufferPass); 716 753 717 754 … … 719 756 renderSingleObject(rend, usedPass, false, &nullLightList); 720 757 } 758 #endif // ITEM_BUFFER 721 759 //----------------------------------------------------------------------- 722 760 GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::GetVisibilityManager() … … 749 787 mLeavePassesInQueue = 0; 750 788 751 if (!mUseDepthPass && !mUseItemBuffer) 789 // if we have the depth pass or use an item buffer, no passes are left in the queue 790 if (1 && !mUseDepthPass && !mUseItemBuffer) 752 791 { 753 792 if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) … … 761 800 762 801 // just render ambient stuff 763 mIlluminationStage = IRS_AMBIENT;764 getRenderQueue()->setSplitPassesByLightingType(true);802 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 803 // mIlluminationStage = IRS_AMBIENT; 765 804 } 766 805 … … 820 859 } 821 860 //----------------------------------------------------------------------- 822 void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 861 void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 862 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 823 863 { 824 864 // only render solid passes during hierarchical culling … … 839 879 840 880 // Render all the ambient passes first, no light iteration, no lights 841 mIlluminationStage = IRS_AMBIENT; 842 843 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPasses(), false, &lightList); 881 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 882 // mIlluminationStage = IRS_AMBIENT; 883 884 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, false, &lightList); 844 885 // Also render any objects which have receive shadows disabled 845 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPassesNoShadow(), true);886 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true); 846 887 } 847 888 } 848 889 else 849 890 { 850 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup); 851 } 852 } 853 //----------------------------------------------------------------------- 854 void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 891 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om); 892 } 893 } 894 //----------------------------------------------------------------------- 895 void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 896 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 855 897 { 856 898 if (mIsHierarchicalCulling) … … 867 909 868 910 // Do (shadowable) solids 869 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPasses(), true);911 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true); 870 912 } 871 913 } 872 914 else 873 915 { 874 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup );916 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 875 917 } 876 }877 //-------------------------------------------------------------------------878 void OcclusionCullingSceneManager::setWorldGeometry( const String& filename )879 {880 // Clear out any existing world resources (if not default)881 if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() !=882 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)883 {884 ResourceGroupManager::getSingleton().clearResourceGroup(885 ResourceGroupManager::getSingleton().getWorldResourceGroupName());886 }887 mTerrainPages.clear();888 // Load the configuration889 loadConfig(filename);890 891 // Resize the octree, allow for 1 page for now892 float max_x = mOptions.scale.x * mOptions.pageSize;893 float max_y = mOptions.scale.y;894 float max_z = mOptions.scale.z * mOptions.pageSize;895 896 float maxAxis = std::max(max_x, max_y);897 maxAxis = std::max(maxAxis, max_z);898 resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) );899 900 setupTerrainMaterial();901 setupTerrainPages();902 918 } 903 919 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r726 r897 4 4 #include <OgreEntity.h> 5 5 #include <OgreMovableObject.h> 6 #include <OgreMaterialManager.h> 6 7 #include "OgreSolidBoundingBox.h" 7 8 #include "OgrePlatformHierarchyInterface.h" … … 73 74 PlatformHierarchyInterface::~PlatformHierarchyInterface() 74 75 { 75 DeleteQueries();76 ResetQueries(); 76 77 77 78 OGRE_DELETE(mSolidBoundingBox); 78 79 } 79 80 //----------------------------------------------------------------------- 80 void PlatformHierarchyInterface::DeleteQueries() 81 { 82 for (int i = 0; i < (int)mOcclusionQueries.size(); ++ i) 83 OGRE_DELETE(mOcclusionQueries[i]); 81 void PlatformHierarchyInterface::ResetQueries() 82 { 83 // for (int i = 0; i < (int)mOcclusionQueries.size(); ++ i) OGRE_DELETE(mOcclusionQueries[i]); 84 84 85 85 mCurrentTestIdx = 0; 86 mOcclusionQueries.clear();86 //mOcclusionQueries.clear(); 87 87 } 88 88 //----------------------------------------------------------------------- … … 97 97 98 98 // set no depth write, no color, no lighting material 99 mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); // HACK! (mySetPass should be setPass) 99 //mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); // HACK! (mySetPass should be setPass) 100 mSceneManager->_setPass(solidBox->getTechnique()->getPass(0)); // HACK! (mySetPass should be setPass) 100 101 //SetOcclusionPass(); 101 102 … … 119 120 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::GetNextOcclusionQuery() 120 121 { 121 if (mCurrentTestIdx == mOcclusionQueries.size()) 122 // create new query if there is no query left 123 if (mCurrentTestIdx == (int)mOcclusionQueries.size()) 122 124 { 123 125 mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp
r115 r897 28 28 const bool waitForResult) const 29 29 { 30 return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 30 // return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 31 32 bool isAvailable = true; 33 34 if (!waitForResult) 35 isAvailable = !mHardwareOcclusionQuery->isStillOutstanding(); 36 37 if (isAvailable) 38 return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 39 40 return isAvailable; 31 41 } 32 42 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp
r726 r897 111 111 mViewport->setBackgroundColour(ColourValue(0, 0, 0, 0)); 112 112 //pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_COLOUR | FBT_DEPTH); 113 113 #ifdef ITEM_BUFFER 114 114 // initialise item buffer (if not already initialised) 115 115 InitItemBuffer(visibleGeometry, visiblePatches); … … 120 120 bool useItemBuffer = true; 121 121 sm->setOption("UseItemBuffer", &useItemBuffer); 122 122 #endif // ITEM_BUFFER 123 123 124 124 sm->_renderScene(pCam, mViewport, false); // render item buffer 125 125 126 126 #ifdef ITEM_BUFFER 127 127 //-- collect results 128 128 CollectItemBufferResults(visibleGeometry, visiblePatches); … … 132 132 useItemBuffer = false; // don't need item buffer anymore 133 133 sm->setOption("UseItemBuffer", &useItemBuffer); 134 #endif // ITEM_BUFFER 134 135 135 136 mWasInitialised = false; // reset initialised - flag … … 137 138 mViewport->setBackgroundColour(bg); // reset background color 138 139 } 140 #ifdef ITEM_BUFFER 139 141 //----------------------------------------------------------------------- 140 142 void PlatformQueryManager::CollectItemBufferResults( … … 232 234 } 233 235 } 236 #endif // ITEM_BUFFER 234 237 //----------------------------------------------------------------------- 235 238 void PlatformQueryManager::SetViewport(Viewport *vp) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSceneContentGenerator.cpp
r415 r897 207 207 mEntities.pop_back(); 208 208 209 mSceneMgr-> removeEntity(ent);209 mSceneMgr->destroyEntity(ent); 210 210 } 211 211 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
r880 r897 9 9 #include <OgreEntity.h> 10 10 #include <OgreSubEntity.h> 11 #include <OgreMaterialManager.h> 11 12 #include <OgreIteratorWrappers.h> 12 13 #include "VspBspTree.h" … … 24 25 25 26 //----------------------------------------------------------------------- 26 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 27 GtpVisibility::VisibilityManager *visManager): 28 OctreeSceneManager(), 27 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager(const String& name, 28 GtpVisibility::VisibilityManager *visManager) 29 : 30 OctreeSceneManager(name), 29 31 mVisibilityManager(visManager), 30 32 mShowVisualization(false), … … 135 137 } 136 138 // add bounding boxes of rendered objects 137 if ( 0)139 if (1) 138 140 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 139 141 { … … 159 161 (*it)->getAttachedObject(0)->isVisible()) 160 162 { 161 162 163 getRenderQueue()->addRenderable((*it)); 164 } 163 165 } 164 166 // add renderables itself … … 171 173 } 172 174 //----------------------------------------------------------------------- 173 Pass *VisibilityOctreeSceneManager::setPass(Pass* pass)175 const Pass *VisibilityOctreeSceneManager::_setPass(Pass* pass) 174 176 { 175 177 if (NORMAL_RENDER_HACK) 176 178 { 177 return SceneManager:: setPass(pass);179 return SceneManager::_setPass(pass); 178 180 } 179 181 … … 230 232 231 233 //-- set actual pass here 232 Pass *result = SceneManager::setPass(usedPass);234 const Pass *result = SceneManager::_setPass(usedPass); 233 235 234 236 … … 291 293 { 292 294 OctreeSceneManager::_renderVisibleObjects(); 293 295 294 296 return; 295 297 } … … 357 359 // exclude this queues from hierarchical rendering 358 360 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 361 359 362 360 363 // set all necessary parameters for … … 402 405 //-- used for depth pass, transparents, overlay 403 406 clearSpecialCaseRenderQueues(); 404 407 408 //-- we render all remaining queue objects 409 // used for depth pass, transparents, overlay 410 clearSpecialCaseRenderQueues(); 405 411 OctreeSceneManager::_renderVisibleObjects(); 406 412 407 } // hierarchical culling413 } // hierarchical culling 408 414 409 415 // reset ambient light … … 535 541 return true; 536 542 } 537 543 538 544 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 539 545 setOption(key, val) || OctreeSceneManager::setOption(key, val); … … 593 599 //----------------------------------------------------------------------- 594 600 void VisibilityOctreeSceneManager::renderObjects( 595 const RenderPriorityGroup::TransparentRenderablePassList& objs, 601 const QueuedRenderableCollection& objs, 602 QueuedRenderableCollection::OrganisationMode om, 596 603 bool doLightIteration, const LightList* manualLightList) 597 604 { … … 600 607 if (NORMAL_RENDER_HACK || !mSkipTransparents) 601 608 { 602 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);609 OctreeSceneManager::renderObjects(objs, om, doLightIteration, manualLightList); 603 610 } 604 611 } … … 625 632 } 626 633 //----------------------------------------------------------------------- 627 void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 634 void VisibilityOctreeSceneManager::_renderQueueGroupObjects( 635 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 628 636 { 629 637 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 630 638 { 631 OctreeSceneManager:: renderQueueGroupObjects(pGroup);639 OctreeSceneManager::_renderQueueGroupObjects(pGroup, om); 632 640 return; 633 641 } 634 635 //-- item buffer: render objects using false colors642 #ifdef ITEM_BUFFER 643 //-- renders item buffer 636 644 637 645 // Iterate through priorities … … 642 650 RenderItemBuffer(groupIt.getNext()); 643 651 } 644 } 652 #endif // ITEM_BUFFER 653 } 654 #ifdef ITEM_BUFFER 645 655 //----------------------------------------------------------------------- 646 656 void VisibilityOctreeSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) … … 748 758 renderSingleObject(rend, usedPass, false, &nullLightList); 749 759 } 760 #endif // ITEM_BUFFER 750 761 //----------------------------------------------------------------------- 751 762 GtpVisibility::VisibilityManager *VisibilityOctreeSceneManager::GetVisibilityManager() … … 789 800 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 790 801 791 // just render ambient stuff 792 mIlluminationStage = IRS_AMBIENT; 802 // just render ambient passes 803 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 804 // mIlluminationStage = IRS_AMBIENT; 793 805 getRenderQueue()->setSplitPassesByLightingType(true); 794 806 } … … 821 833 mLeavePassesInQueue); 822 834 835 //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue; 836 //LogManager::getSingleton().logMessage(d.str()); 823 837 } 824 838 //----------------------------------------------------------------------- … … 845 859 //----------------------------------------------------------------------- 846 860 void VisibilityOctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 847 RenderQueueGroup* pGroup )861 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 848 862 { 849 863 // only render solid passes during hierarchical culling … … 864 878 865 879 // Render all the ambient passes first, no light iteration, no lights 866 mIlluminationStage = IRS_AMBIENT; 867 868 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPasses(), false, &lightList); 880 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 881 // mIlluminationStage = IRS_AMBIENT; 882 883 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, false, &lightList); 869 884 // Also render any objects which have receive shadows disabled 870 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPassesNoShadow(), true);885 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true); 871 886 #if 0 872 887 std::stringstream d; … … 881 896 else // render the rest of the passes 882 897 { 883 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup); 884 } 885 } 886 //----------------------------------------------------------------------- 887 void VisibilityOctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 898 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om); 899 } 900 } 901 //----------------------------------------------------------------------- 902 void VisibilityOctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 903 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 888 904 { 889 905 if (mIsHierarchicalCulling) … … 900 916 901 917 // Do (shadowable) solids 902 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPasses(), true);918 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true); 903 919 } 904 920 } 905 921 else 906 922 { 907 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup );923 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 908 924 } 909 925 } 910 926 //------------------------------------------------------------------------- 927 void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible) 928 { 929 GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 930 931 for (it = mObjects.begin(); it != it_end; ++ it) 932 { 933 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 934 Entity *ent = omi->GetMesh(); 935 ent->setVisible(visible); 936 } 937 } 938 //------------------------------------------------------------------------- 939 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename) 940 { 941 // TODO matt 942 // Set up the options 943 ConfigFile config; 944 String val; 945 946 config.load(filename); 947 948 val = config.getSetting("Algorithm"); 949 950 if (!val.empty()) 951 { 952 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str()); 953 } 954 955 val = config.getSetting("UseDepthPass"); 956 957 if (!val.empty()) 958 { 959 setOption("UseDepthPass", val.c_str()); 960 } 961 } 962 //------------------------------------------------------------------------- 911 963 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 912 964 { … … 1056 1108 } 1057 1109 //------------------------------------------------------------------------- 1058 void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible)1059 {1060 // for OGRE 1.21061 //#ifdef OGRE121062 //MovableObjectIterator mit = getMovableObjectIterator("Entity");1063 #if 01064 EntityIterator eit = getEntityIterator();1065 1066 // set all objects to invisible (initially);1067 while (eit.hasMoreElements())1068 {1069 Entity *ent = eit.getNext();1070 ent->setVisible(visible);1071 }1072 1073 #else1074 GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end();1075 1076 for (it = mObjects.begin(); it != it_end; ++ it)1077 {1078 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);1079 Entity *ent = omi->GetMesh();1080 ent->setVisible(visible);1081 }1082 #endif1083 }1084 //-------------------------------------------------------------------------1085 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String &filename)1086 {1087 // TODO matt1088 // Set up the options1089 ConfigFile config;1090 String val;1091 1092 config.load(filename);1093 1094 val = config.getSetting("Algorithm");1095 1096 if (!val.empty())1097 {1098 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str());1099 }1100 1101 val = config.getSetting("UseDepthPass");1102 1103 if (!val.empty())1104 {1105 setOption("UseDepthPass", val.c_str());1106 }1107 }1108 //-------------------------------------------------------------------------1109 1110 void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 1110 1111 { … … 1156 1157 } 1157 1158 1159 1160 1161 //----------------------------------------------------------------------- 1162 const String VisibilityOctreeSceneManagerFactory::FACTORY_TYPE_NAME = "VisibilityOctreeSceneManager"; 1163 //----------------------------------------------------------------------- 1164 void VisibilityOctreeSceneManagerFactory::initMetaData(void) const 1165 { 1166 mMetaData.typeName = FACTORY_TYPE_NAME; 1167 mMetaData.description = "Scene manager organising the scene on the basis of an octree with advanced occlusion culling (TM)."; 1168 mMetaData.sceneTypeMask = 0xFFFF; // support all types 1169 mMetaData.worldGeometrySupported = false; 1170 } 1171 //----------------------------------------------------------------------- 1172 SceneManager* VisibilityOctreeSceneManagerFactory::createInstance( 1173 const String& instanceName) 1174 { 1175 return new VisibilityOctreeSceneManager(instanceName, visManager); 1176 } 1177 //----------------------------------------------------------------------- 1178 void VisibilityOctreeSceneManagerFactory::destroyInstance(SceneManager* instance) 1179 { 1180 delete instance; 1181 } 1182 1158 1183 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOptionsManager.cpp
r254 r897 16 16 { 17 17 // delete old queries (not needed for e.g., view frustum culling) 18 mHierarchyInterface-> DeleteQueries();18 mHierarchyInterface->ResetQueries(); 19 19 mVisibilityManager->SetCullingManager(*static_cast<const 20 20 GtpVisibility::VisibilityEnvironment::CullingManagerType *>(val)); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManager.cpp
r155 r897 11 11 12 12 //----------------------------------------------------------------------- 13 VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 14 :mVisibilityManager(visManager), mUseDepthPass(false), mShowVisualization(false) 13 VisibilitySceneManager::VisibilitySceneManager(const String& name, 14 GtpVisibility::VisibilityManager *visManager) 15 :SceneManager(name), mVisibilityManager(visManager), mUseDepthPass(false), mShowVisualization(false) 15 16 { 16 17 mHierarchyInterface = -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
r870 r897 28 28 //#include <OgreVisibilityDotSceneManager.h> 29 29 30 #include <OgreHeightmapTerrainPageSource.h>30 //#include <OgreHeightmapTerrainPageSource.h> 31 31 #include <OgreRoot.h> 32 32 #include <OgreLogManager.h> 33 33 34 #include "VisibilityManager.h" 34 35 #include "VisibilityEnvironment.h" 35 36 36 37 GtpVisibility::VisibilityEnvironment *visEnv; 37 38 GtpVisibility::VisibilityManager *visManager; … … 39 40 namespace Ogre { 40 41 41 VisibilityOctreeSceneManager *visibilityOctreePlugin; 42 VisibilityTerrainSceneManager *visibilityTerrainPlugin; 43 //VisibilityDotSceneManager *visibilityDotPlugin; 44 45 HeightmapTerrainPageSource *heightmapTerrainPageSource; 42 VisibilityOctreeSceneManagerFactory *visibilityOctreePlugin; 43 VisibilityTerrainSceneManagerFactory *visibilityTerrainPlugin; 46 44 47 45 //----------------------------------------------------------------------- … … 53 51 54 52 // Create new scene manager 55 visibilityOctreePlugin = new VisibilityOctreeSceneManager(visManager); 56 visibilityTerrainPlugin = new VisibilityTerrainSceneManager(visManager); 57 //occlusionDotPlugin = new VisibilityDotSceneManager(); 53 visibilityOctreePlugin = new VisibilityOctreeSceneManagerFactory(visManager); 54 visibilityTerrainPlugin = new VisibilityTerrainSceneManagerFactory(visManager); 55 // Construct listener manager singleton 56 new TerrainPageSourceListenerManager(); 58 57 59 heightmapTerrainPageSource = new HeightmapTerrainPageSource();60 61 58 // Register 62 Root::getSingleton().setSceneManager(ST_GENERIC, visibilityOctreePlugin); 63 Root::getSingleton().setSceneManager(ST_EXTERIOR_CLOSE, visibilityTerrainPlugin); 64 //Root::getSingleton().setSceneManager(ST_GENERIC, occlusionDotPlugin); 65 66 visibilityTerrainPlugin->registerPageSource("Heightmap", heightmapTerrainPageSource); 59 Root::getSingleton().addSceneManagerFactory(visibilityOctreePlugin); 60 Root::getSingleton().addSceneManagerFactory(visibilityTerrainPlugin); 67 61 } 68 62 //----------------------------------------------------------------------- 69 63 extern "C" void __declspec(dllexport) dllShutdownPlugin() 70 64 { 71 visibilityTerrainPlugin->shutdown(); 72 heightmapTerrainPageSource->shutdown(); 65 Root::getSingleton().removeSceneManagerFactory(visibilityOctreePlugin); 66 Root::getSingleton().removeSceneManagerFactory(visibilityTerrainPlugin); 67 // destroy listener manager 68 delete TerrainPageSourceListenerManager::getSingletonPtr(); 73 69 } 74 70 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
r868 r897 10 10 #include <OgreSubEntity.h> 11 11 #include <OgreConfigFile.h> 12 #include <OgreMaterialManager.h> 13 #include <OgreHeightmapTerrainPageSource.h> 12 14 13 15 // normal terrain rendering 14 const static NORMAL_RENDER_HACK = false;16 const static int NORMAL_RENDER_HACK = false; 15 17 16 18 namespace Ogre { 17 19 18 20 //----------------------------------------------------------------------- 19 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 21 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(const String& name, 20 22 GtpVisibility::VisibilityManager *visManager): 21 TerrainSceneManager( ),23 TerrainSceneManager(name), 22 24 mVisibilityManager(visManager), 23 25 mShowVisualization(false), … … 62 64 63 65 mDepthPass = depthMat->getTechnique(0)->getPass(0); 66 64 67 mDepthPass->setColourWriteEnabled(false); 65 68 mDepthPass->setDepthWriteEnabled(true); 66 69 mDepthPass->setLightingEnabled(false); 70 //mDepthPass->setDepthCheckEnabled(false); 67 71 } 68 72 else … … 152 156 } 153 157 //----------------------------------------------------------------------- 154 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)158 const Pass *VisibilityTerrainSceneManager::_setPass(Pass* pass) 155 159 { 156 160 if (NORMAL_RENDER_HACK) 157 161 { 158 return SceneManager:: setPass(pass);162 return SceneManager::_setPass(pass); 159 163 } 160 164 … … 212 216 213 217 //-- set actual pass here 214 Pass *result = SceneManager::setPass(usedPass);218 const Pass *result = SceneManager::_setPass(usedPass); 215 219 216 220 … … 391 395 392 396 getRenderQueue()->clear(); // finally clear render queue 393 if ( 1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...397 if (0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 394 398 395 399 if (0) WriteLog(); // write out stats … … 491 495 if (useArbQueries) 492 496 { 493 mHierarchyInterface-> DeleteQueries();497 mHierarchyInterface->ResetQueries(); 494 498 mDestRenderSystem->setConfigOption("ArbQueries", "Yes"); 495 499 } 496 500 else 497 501 { 498 mHierarchyInterface-> DeleteQueries();502 mHierarchyInterface->ResetQueries(); 499 503 mDestRenderSystem->setConfigOption("ArbQueries", "No"); 500 504 } … … 559 563 //----------------------------------------------------------------------- 560 564 void VisibilityTerrainSceneManager::renderObjects( 561 const RenderPriorityGroup::TransparentRenderablePassList& objs,562 bool doLightIteration, 563 565 const QueuedRenderableCollection& objs, 566 QueuedRenderableCollection::OrganisationMode om, 567 bool doLightIteration, const LightList* manualLightList) 564 568 { 565 569 // for correct rendering, transparents must be rendered after hierarchical culling … … 567 571 if (NORMAL_RENDER_HACK || !mSkipTransparents) 568 572 { 569 SceneManager::renderObjects(objs, doLightIteration, manualLightList);573 SceneManager::renderObjects(objs, om, doLightIteration, manualLightList); 570 574 } 571 575 } … … 592 596 } 593 597 //----------------------------------------------------------------------- 594 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 598 void VisibilityTerrainSceneManager::_renderQueueGroupObjects( 599 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 595 600 { 596 601 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 597 602 { 598 OctreeSceneManager::renderQueueGroupObjects(pGroup);603 SceneManager::_renderQueueGroupObjects(pGroup, om); 599 604 return; 600 605 } 601 606 #ifdef ITEM_BUFFER 602 607 //-- item buffer: render objects using false colors 603 608 … … 609 614 RenderItemBuffer(groupIt.getNext()); 610 615 } 611 } 616 #endif // ITEM_BUFFER 617 } 618 #ifdef ITEM_BUFFER 612 619 //----------------------------------------------------------------------- 613 620 void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) … … 715 722 renderSingleObject(rend, usedPass, false, &nullLightList); 716 723 } 724 #endif // ITEM_BUFFER 717 725 //----------------------------------------------------------------------- 718 726 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager() … … 757 765 758 766 // just render ambient stuff 759 mIlluminationStage = IRS_AMBIENT;760 getRenderQueue()->setSplitPassesByLightingType(true);767 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 768 // mIlluminationStage = IRS_AMBIENT; 761 769 } 762 770 … … 818 826 //----------------------------------------------------------------------- 819 827 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 820 RenderQueueGroup* pGroup )828 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 821 829 { 822 830 // only render solid passes during hierarchical culling … … 837 845 838 846 // Render all the ambient passes first, no light iteration, no lights 839 mIlluminationStage = IRS_AMBIENT; 840 841 OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPasses(), false, &lightList); 847 /*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/ 848 // mIlluminationStage = IRS_AMBIENT; 849 850 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, false, &lightList); 842 851 // Also render any objects which have receive shadows disabled 843 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPassesNoShadow(), true);852 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true); 844 853 } 845 854 } 846 855 else // render the rest of the passes 847 856 { 848 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup );857 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om); 849 858 } 850 859 } 851 860 //----------------------------------------------------------------------- 852 861 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 853 RenderQueueGroup* pGroup )862 RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 854 863 { 855 864 if (mIsHierarchicalCulling) … … 866 875 867 876 // Do (shadowable) solids 868 OctreeSceneManager::renderObjects(pPriorityGrp-> _getSolidPasses(), true);877 OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true); 869 878 } 870 879 } 871 880 else 872 881 { 873 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup );882 SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 874 883 } 875 884 } 876 885 886 const String& VisibilityTerrainSceneManager::getTypeName(void) const 887 { 888 return VisibilityTerrainSceneManagerFactory::FACTORY_TYPE_NAME; 889 } 890 877 891 //------------------------------------------------------------------------- 878 void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename )892 void VisibilityTerrainSceneManager::setWorldGeometry( DataStreamPtr& stream, const String& typeName ) 879 893 { 880 894 // Clear out any existing world resources (if not default) … … 885 899 ResourceGroupManager::getSingleton().getWorldResourceGroupName()); 886 900 } 887 901 destroyLevelIndexes(); 888 902 mTerrainPages.clear(); 889 903 // Load the configuration 890 loadConfig(filename); 904 loadConfig( stream ); 905 initLevelIndexes(); 891 906 892 907 // Resize the octree, allow for 1 page for now … … 895 910 float max_z = mOptions.scale.z * mOptions.pageSize; 896 911 897 //-- note: slows down view frustum culling!898 #if 1899 912 float maxAxis = std::max(max_x, max_y); 900 913 maxAxis = std::max(maxAxis, max_z); 901 914 resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) ); 902 #else 903 resize( AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z ) ); 904 #endif 905 915 906 916 setupTerrainMaterial(); 917 907 918 setupTerrainPages(); 908 919 909 920 } 910 921 922 //----------------------------------------------------------------------- 923 const String VisibilityTerrainSceneManagerFactory::FACTORY_TYPE_NAME = "VisibilityTerrainSceneManager"; 924 //----------------------------------------------------------------------- 925 VisibilityTerrainSceneManagerFactory::VisibilityTerrainSceneManagerFactory( 926 GtpVisibility::VisibilityManager *vm) 927 { 928 visManager = vm; 929 } 930 //----------------------------------------------------------------------- 931 VisibilityTerrainSceneManagerFactory::~VisibilityTerrainSceneManagerFactory() 932 { 933 for (TerrainPageSources::iterator i = mTerrainPageSources.begin(); 934 i != mTerrainPageSources.end(); ++i) 935 { 936 delete *i; 937 } 938 mTerrainPageSources.clear(); 939 } 940 //----------------------------------------------------------------------- 941 void VisibilityTerrainSceneManagerFactory::initMetaData(void) const 942 { 943 mMetaData.typeName = FACTORY_TYPE_NAME; 944 mMetaData.description = "Scene manager which generally organises the scene on " 945 "the basis of an octree, but also supports terrain world geometry and has awesome (TM) occlusion culling capabilities. "; 946 mMetaData.sceneTypeMask = ST_EXTERIOR_CLOSE; // previous compatiblity 947 mMetaData.worldGeometrySupported = true; 948 } 949 //----------------------------------------------------------------------- 950 SceneManager* VisibilityTerrainSceneManagerFactory::createInstance( 951 const String& instanceName) 952 { 953 VisibilityTerrainSceneManager* tsm = new VisibilityTerrainSceneManager(instanceName, visManager); 954 // Create & register default sources (one per manager) 955 HeightmapTerrainPageSource* ps = new HeightmapTerrainPageSource(); 956 mTerrainPageSources.push_back(ps); 957 tsm->registerPageSource("Heightmap", ps); 958 959 return tsm; 960 } 961 //----------------------------------------------------------------------- 962 void VisibilityTerrainSceneManagerFactory::destroyInstance(SceneManager* instance) 963 { 964 delete instance; 965 } 966 911 967 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.