Ignore:
Timestamp:
05/04/06 18:26:23 (19 years ago)
Author:
mattausch
Message:

updated to ogre 1.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp

    r880 r897  
    99#include <OgreEntity.h> 
    1010#include <OgreSubEntity.h> 
     11#include <OgreMaterialManager.h> 
    1112#include <OgreIteratorWrappers.h> 
    1213#include "VspBspTree.h" 
     
    2425 
    2526//----------------------------------------------------------------------- 
    26 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 
    27         GtpVisibility::VisibilityManager *visManager): 
    28 OctreeSceneManager(), 
     27VisibilityOctreeSceneManager::VisibilityOctreeSceneManager(const String& name,  
     28        GtpVisibility::VisibilityManager *visManager) 
     29: 
     30OctreeSceneManager(name), 
    2931mVisibilityManager(visManager),  
    3032mShowVisualization(false), 
     
    135137    } 
    136138        // add bounding boxes of rendered objects 
    137         if (0) 
     139        if (1) 
    138140        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    139141{ 
     
    159161                                        (*it)->getAttachedObject(0)->isVisible()) 
    160162                                { 
    161                                         getRenderQueue()->addRenderable((*it)); 
    162                                 } 
     163                                getRenderQueue()->addRenderable((*it)); 
     164                        } 
    163165                        } 
    164166                        // add renderables itself 
     
    171173} 
    172174//----------------------------------------------------------------------- 
    173 Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 
     175const Pass *VisibilityOctreeSceneManager::_setPass(Pass* pass) 
    174176{ 
    175177        if (NORMAL_RENDER_HACK) 
    176178        { 
    177                 return SceneManager::setPass(pass); 
     179                return SceneManager::_setPass(pass); 
    178180        } 
    179181 
     
    230232 
    231233        //-- set actual pass here 
    232         Pass *result = SceneManager::setPass(usedPass); 
     234        const Pass *result = SceneManager::_setPass(usedPass); 
    233235 
    234236 
     
    291293        { 
    292294                OctreeSceneManager::_renderVisibleObjects(); 
    293  
     295         
    294296                return; 
    295297        } 
     
    357359                // exclude this queues from hierarchical rendering 
    358360                setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
     361         
    359362 
    360363                // set all necessary parameters for  
     
    402405                //-- used for depth pass, transparents, overlay 
    403406                clearSpecialCaseRenderQueues(); 
    404  
     407         
     408                //-- we render all remaining queue objects 
     409                // used for depth pass, transparents, overlay  
     410                clearSpecialCaseRenderQueues(); 
    405411                OctreeSceneManager::_renderVisibleObjects(); 
    406412         
    407         } // hierarchical culling 
     413        }   // hierarchical culling 
    408414 
    409415        // reset ambient light 
     
    535541                return true; 
    536542        } 
    537  
     543         
    538544        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    539545                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
     
    593599//----------------------------------------------------------------------- 
    594600void VisibilityOctreeSceneManager::renderObjects( 
    595         const RenderPriorityGroup::TransparentRenderablePassList& objs,  
     601                        const QueuedRenderableCollection& objs,  
     602                        QueuedRenderableCollection::OrganisationMode om, 
    596603            bool doLightIteration, const LightList* manualLightList) 
    597604{ 
     
    600607        if (NORMAL_RENDER_HACK || !mSkipTransparents) 
    601608        { 
    602                 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 
     609                OctreeSceneManager::renderObjects(objs, om, doLightIteration, manualLightList); 
    603610        } 
    604611} 
     
    625632} 
    626633//----------------------------------------------------------------------- 
    627 void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 
     634void VisibilityOctreeSceneManager::_renderQueueGroupObjects( 
     635        RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 
    628636{ 
    629637        if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 
    630638        { 
    631                 OctreeSceneManager::renderQueueGroupObjects(pGroup); 
     639                OctreeSceneManager::_renderQueueGroupObjects(pGroup, om); 
    632640                return; 
    633641        } 
    634  
    635         //-- item buffer: render objects using false colors 
     642#ifdef ITEM_BUFFER 
     643        //-- renders item buffer 
    636644 
    637645    // Iterate through priorities 
     
    642650                RenderItemBuffer(groupIt.getNext()); 
    643651        } 
    644 } 
     652#endif // ITEM_BUFFER 
     653} 
     654#ifdef ITEM_BUFFER 
    645655//----------------------------------------------------------------------- 
    646656void VisibilityOctreeSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 
     
    748758        renderSingleObject(rend, usedPass, false, &nullLightList); 
    749759} 
     760#endif // ITEM_BUFFER 
    750761//----------------------------------------------------------------------- 
    751762GtpVisibility::VisibilityManager *VisibilityOctreeSceneManager::GetVisibilityManager() 
     
    789800                        mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 
    790801 
    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; 
    793805                        getRenderQueue()->setSplitPassesByLightingType(true); 
    794806                } 
     
    821833                                                        mLeavePassesInQueue); 
    822834                 
     835        //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue; 
     836        //LogManager::getSingleton().logMessage(d.str()); 
    823837} 
    824838//----------------------------------------------------------------------- 
     
    845859//----------------------------------------------------------------------- 
    846860void VisibilityOctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 
    847         RenderQueueGroup* pGroup) 
     861        RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 
    848862{ 
    849863        // only render solid passes during hierarchical culling 
     
    864878 
    865879                        // 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); 
    869884                        // Also render any objects which have receive shadows disabled 
    870                         OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesNoShadow(), true); 
     885                        OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true);           
    871886#if 0            
    872887                        std::stringstream d;  
     
    881896        else // render the rest of the passes 
    882897        { 
    883                 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup); 
    884         } 
    885 } 
    886 //----------------------------------------------------------------------- 
    887 void VisibilityOctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
     898                OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om); 
     899        } 
     900} 
     901//----------------------------------------------------------------------- 
     902void VisibilityOctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 
     903        RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 
    888904{ 
    889905   if (mIsHierarchicalCulling) 
     
    900916 
    901917                   // Do (shadowable) solids 
    902                    OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPasses(), true); 
     918                   OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true); 
    903919           } 
    904920   } 
    905921   else 
    906922   { 
    907            SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup); 
     923           SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 
    908924   } 
    909925} 
    910  
     926//------------------------------------------------------------------------- 
     927void 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//------------------------------------------------------------------------- 
     939void 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//------------------------------------------------------------------------- 
    911963inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 
    912964{ 
     
    10561108} 
    10571109//------------------------------------------------------------------------- 
    1058 void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible) 
    1059 { 
    1060         // for OGRE 1.2 
    1061 //#ifdef OGRE12 
    1062         //MovableObjectIterator mit = getMovableObjectIterator("Entity"); 
    1063 #if 0 
    1064         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 #else 
    1074         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 #endif 
    1083 } 
    1084 //------------------------------------------------------------------------- 
    1085 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String &filename) 
    1086 { 
    1087         // TODO matt 
    1088         // Set up the options 
    1089         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 //------------------------------------------------------------------------- 
    11091110void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 
    11101111{ 
     
    11561157} 
    11571158 
     1159 
     1160 
     1161//----------------------------------------------------------------------- 
     1162const String VisibilityOctreeSceneManagerFactory::FACTORY_TYPE_NAME = "VisibilityOctreeSceneManager"; 
     1163//----------------------------------------------------------------------- 
     1164void 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//----------------------------------------------------------------------- 
     1172SceneManager* VisibilityOctreeSceneManagerFactory::createInstance( 
     1173        const String& instanceName) 
     1174{ 
     1175        return new VisibilityOctreeSceneManager(instanceName, visManager); 
     1176} 
     1177//----------------------------------------------------------------------- 
     1178void VisibilityOctreeSceneManagerFactory::destroyInstance(SceneManager* instance) 
     1179{ 
     1180        delete instance; 
     1181} 
     1182 
    11581183}  // namespace Ogre 
Note: See TracChangeset for help on using the changeset viewer.