Changeset 2123


Ignore:
Timestamp:
02/17/07 22:48:12 (17 years ago)
Author:
mattausch
Message:

worded on obj loading in Ogre

Location:
GTP/trunk
Files:
2 added
29 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj

    r2121 r2123  
    2222                                Optimization="0" 
    2323                                AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";..\..\GtpVisibility\include;..\..\Ogre\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include" 
    24                                 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG;PLUGIN_TERRAIN_IMPORTS;GTP_VISIBILITY_MODIFIED_OGRE" 
     24                                PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG;GTP_VISIBILITY_MODIFIED_OGRE" 
    2525                                MinimalRebuild="TRUE" 
    2626                                BasicRuntimeChecks="3" 
     
    3535                        <Tool 
    3636                                Name="VCLinkerTool" 
    37                                 AdditionalDependencies="Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib GtpVisibility.lib Preprocessor.lib OGREMain_d.LIB CEGUIBase_d.lib OgreGUIRenderer_d.lib zdll.lib zziplibd.lib" 
     37                                AdditionalDependencies="Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib GtpVisibility.lib Preprocessor.lib OGREMain_d.LIB CEGUIBase_d.lib OgreGUIRenderer_d.lib zdll.lib zziplibd.lib IVReader.lib" 
    3838                                OutputFile="$(OGRE_PATH)/Samples/Common/bin/Debug/TestCullingTerrain.exe" 
    3939                                LinkIncremental="1" 
    40                                 AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\Preprocessing\lib\$(ConfigurationName)&quot;" 
     40                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\Preprocessing\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;" 
    4141                                GenerateDebugInformation="TRUE" 
    4242                                ProgramDatabaseFile="$(OutDir)/TestCullingTerrain.pdb" 
     
    7878                                EnableIntrinsicFunctions="TRUE" 
    7979                                FavorSizeOrSpeed="1" 
     80                                OmitFramePointers="TRUE" 
    8081                                EnableFiberSafeOptimizations="TRUE" 
    8182                                OptimizeForProcessor="0" 
    8283                                OptimizeForWindowsApplication="TRUE" 
    8384                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include" 
    84                                 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS" 
     85                                PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE" 
    8586                                RuntimeLibrary="2" 
    8687                                RuntimeTypeInfo="TRUE" 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp

    r2121 r2123  
    282282        *       because then the camera is displayed correctly in the visualization 
    283283        */ 
    284         //Vector3 viewPoint(707, 5000, 528); 
     284        // hack: vienna view point 
    285285        Vector3 viewPoint(830, 300, -540); 
    286         std::stringstream d; d << "here3: " << viewPoint; 
    287         Ogre::LogManager::getSingleton().logMessage(d.str()); 
     286         
    288287        mCamNode = mSceneMgr->getRootSceneNode()-> 
    289288                createChildSceneNode("CamNode1", viewPoint); 
     
    454453{ 
    455454        ///////// 
    456         //-- load scene 
     455        //-- load parameters & scene 
    457456        loadConfig("terrainCulling.cfg"); 
    458          
    459         if (0 && !LoadScene(mFilename)) 
    460                 LogManager::getSingleton().logMessage("error loading scene"); 
    461          
    462457         
    463458        ///////////////////////////////////// 
     
    502497                mSceneMgr->setWorldGeometry(terrain_cfg); 
    503498 
     499                // was terrain loaded? 
    504500                mSceneMgr->getOption("ShowTerrain", &msShowHillyTerrain);  
    505501        } 
    506502         
     503        // hack view point for terrain 
     504        if (msShowHillyTerrain) 
     505        { 
     506                Vector3 viewPoint(707, 5000, 528); 
     507                mCamNode->setPosition(viewPoint); 
     508        } 
     509 
    507510        //////  
    508511        //-- CEGUI setup 
  • GTP/trunk/Lib/Vis/GtpVisibility.sln

    r2110 r2123  
    1616                {101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900} 
    1717                {EABCE292-D598-4600-A1C9-2591E7D62FDA} = {EABCE292-D598-4600-A1C9-2591E7D62FDA} 
     18                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
     19                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    1820        EndProjectSection 
    1921EndProject 
     
    465467                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Internal.ActiveCfg = Release Internal|Win32 
    466468                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Internal.Build.0 = Release Internal|Win32 
    467                 {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Static.ActiveCfg = Release Internal|Win32 
    468                 {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Static.Build.0 = Release Internal|Win32 
     469                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Static.ActiveCfg = Release|Win32 
     470                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release Static.Build.0 = Release|Win32 
    469471                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release_Internal.ActiveCfg = Release_Internal|Win32 
    470472                {7319E499-473D-4CE5-9983-725D6E68A55D}.Release_Internal.Build.0 = Release_Internal|Win32 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj

    r2122 r2123  
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
    26                                 RuntimeLibrary="1" 
     26                                RuntimeLibrary="3" 
    2727                                UsePrecompiledHeader="0" 
    2828                                WarningLevel="3" 
     
    7373                                Name="VCCLCompilerTool" 
    7474                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include" 
    75                                 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS" 
     75                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE" 
    7676                                RuntimeLibrary="2" 
    7777                                UsePrecompiledHeader="0" 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h

    r2115 r2123  
    217217 
    218218                        // we are only interested in scene entities 
    219                         if (mo->getMovableType() != "Entity") 
     219                        if ((mo->getMovableType() != "Entity") && 
     220                                (mo->getMovableType() != "ManualObject")) 
    220221                                continue; 
    221222                         
     
    237238} 
    238239 
     240static void AddToObjects(EntityContainer *entites,  
     241                                                 GtpVisibilityPreprocessor::ObjectContainer &objects, 
     242                                                 const int id) 
     243{ 
     244        // TODO: can actually just put single objects into pvs with same id,  
     245        // this can be sorted out later!! 
     246#if 0 
     247        EntityContainer::const_iterator eit, eit_end = entryObjects.end(); 
     248 
     249        for (eit = entryObjects.begin(); eit != eit_end; ++ eit) 
     250        { 
     251                Entity *ent = *eit; 
     252 
     253        // warning: multiple ids possible 
     254                OgreMeshInstance *omi = new OgreMeshInstance(ent); 
     255                omi->SetId(id); 
     256                objects.push_back(omi); 
     257        } 
     258 
     259        delete entryObjects; 
     260 
     261#else 
     262 
     263        EngineIntersectable *entry = new EngineIntersectable(entites); 
     264 
     265        entry->SetId(id); 
     266        objects.push_back(entry); 
     267#endif 
     268} 
     269 
    239270#if USE_KD_PVS 
    240271//------------------------------------------------------------------------- 
     
    255286                        OgreTypeConverter::ConvertToOgre(pbox); 
    256287                 
    257                 EntityContainer entryObjects; 
     288                EntityContainer *entryObjects = new EntityContainer(); 
    258289 
    259290                // find all objects that intersect the bounding box 
    260                 FindIntersectingObjects(box, entryObjects); 
    261  
    262                 // TODO: can actually just put single objects into pvs with same id,  
    263                 // this can be sorted out later!! 
    264 #if 1 
    265                 EntityContainer::const_iterator eit, eit_end = entryObjects.end(); 
    266  
    267                 for (eit = entryObjects.begin(); eit != eit_end; ++ eit) 
    268                 { 
    269                         Entity *ent = *eit; 
    270  
    271             // warning: multiple ids possible 
    272                         OgreMeshInstance *omi = new OgreMeshInstance(ent); 
    273                         omi->SetId(id); 
    274                         objects.push_back(omi); 
    275                 } 
    276 #else 
    277                 EngineIntersectable *entry =  
    278                         new EngineIntersectable(entryObjects); 
    279  
    280                 entry->SetId(id); 
    281                 objects.push_back(entry); 
    282 #endif 
     291                FindIntersectingObjects(box, *entryObjects); 
     292 
     293                AddToObjects(entryObjects, objects, id); 
    283294        } 
    284295 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h

    r2119 r2123  
    1414#include "ViewCellsManager.h" 
    1515 
     16 
     17namespace GtpVisibilityPreprocessor { 
     18class Intersectable; 
     19} 
     20 
     21class ObjReader; 
     22 
    1623namespace Ogre { 
    1724 
     
    2431{ 
    2532public: 
    26         OcclusionCullingSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager); 
     33        OcclusionCullingSceneManager(const String& name,  
     34                                                                 GtpVisibility::VisibilityManager *visManager); 
    2735        ~OcclusionCullingSceneManager(); 
    2836 
     
    7078        */ 
    7179        bool validatePassForRendering(Pass* pass); 
     80 
    7281#ifdef ITEM_BUFFER 
    7382        void RenderItemBuffer(RenderPriorityGroup* pGroup); 
    7483        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); 
    7584#endif // ITEM_BUFFER 
     85 
    7686        void _renderQueueGroupObjects(RenderQueueGroup* pGroup, 
    77                 QueuedRenderableCollection::OrganisationMode om); 
    78  
    79         /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 
     87                                                                  QueuedRenderableCollection::OrganisationMode om); 
     88 
     89        /** Override from SceneManager so that sub entities can be assigned  
     90                an id for item buffer. 
    8091        */ 
    8192        Entity* createEntity(const String& entityName, const String& meshName); 
     
    93104        void endFrame(); 
    94105 
    95         void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 
    96                 QueuedRenderableCollection::OrganisationMode om); 
    97         void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 
    98                 QueuedRenderableCollection::OrganisationMode om); 
     106        void renderAdditiveStencilShadowedQueueGroupObjects( 
     107                                RenderQueueGroup* pGroup, 
     108                                QueuedRenderableCollection::OrganisationMode om); 
     109        void renderModulativeStencilShadowedQueueGroupObjects( 
     110                                RenderQueueGroup* pGroup, 
     111                                QueuedRenderableCollection::OrganisationMode om); 
    99112         
    100113        /** Override standard function so octree boxes are always of equal side length. 
     
    113126protected: 
    114127         
     128        void MailPvsObjects(); 
     129        void RenderPvsEntry(GtpVisibilityPreprocessor::Intersectable *obj); 
     130        void SetObjectVisible(GtpVisibilityPreprocessor::Intersectable *entry,  
     131                                                  const bool visible); 
     132        void ShowViewCellsGeometry(); 
     133 
    115134        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.  
    116135        */ 
     
    254273 
    255274        bool mShowTerrain; 
     275 
     276        ObjReader *mObjReader; 
    256277}; 
    257278 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp

    r2115 r2123  
    13541354        while (pit.HasMoreEntries()) 
    13551355        {                
    1356                 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 
    1357  
    1358                 if (entry.mObject) 
    1359                 { 
    1360                         OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry.mObject); 
     1356                GtpVisibilityPreprocessor::Intersectable *entry = pit.Next(); 
     1357 
     1358                if (entry) 
     1359                { 
     1360                        OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 
    13611361                        omi->GetEntity()->setVisible(load); 
    13621362                } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r2115 r2123  
    13551355        while (pit.HasMoreEntries()) 
    13561356        {                
    1357                 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 
    1358  
    1359                 if (entry.mObject) 
    1360                 { 
    1361                         OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry.mObject); 
     1357                GtpVisibilityPreprocessor::Intersectable *entry = pit.Next(); 
     1358 
     1359                if (entry) 
     1360                { 
     1361                        OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 
    13621362                        omi->GetEntity()->setVisible(load); 
    13631363                } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2122 r2123  
    7878        // TODO: set maxdepth to reasonable value 
    7979        mMaxDepth = 50; 
     80 
     81        mObjReader = new ObjReader(this); 
    8082} 
    8183//----------------------------------------------------------------------- 
     
    107109        CLEAR_CONTAINER(mObjects); 
    108110        OGRE_DELETE(mCurrentViewCell); 
     111 
     112        OGRE_DELETE(mObjReader); 
    109113} 
    110114//----------------------------------------------------------------------- 
     
    379383        selectPageSource(pageSourceName, optlist); 
    380384} 
     385 
     386 
     387void OcclusionCullingSceneManager::MailPvsObjects() 
     388{ 
     389        GtpVisibilityPreprocessor::ObjectPvsIterator pit =  
     390                        mCurrentViewCell->GetPvs().GetIterator(); 
     391 
     392        while (pit.HasMoreEntries()) 
     393        {                
     394                GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 
     395 
     396                if (obj->Type() !=  
     397                        GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE) 
     398                        continue; 
     399                         
     400                EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 
     401 
     402                EntityContainer *entries = oi->GetItem(); 
     403                EntityContainer::const_iterator eit, eit_end = entries->end(); 
     404 
     405                for (eit = entries->begin(); eit != eit_end; ++ eit) 
     406                { 
     407                        (*eit)->setUserAny(Any((int)0)); 
     408                } 
     409        } 
     410} 
     411//----------------------------------------------------------------------- 
     412void OcclusionCullingSceneManager::ShowViewCellsGeometry() 
     413{/* 
     414        // show only current view cell 
     415        if (!mShowViewCells) 
     416        { 
     417                const int id = mCurrentViewCell->GetId(); 
     418 
     419                MovableMap::iterator fit = mViewCellsGeometry.find(id); 
     420 
     421                if ((fit != mViewCellsGeometry.end()) && (*fit).second) 
     422                        (*fit).second->_updateRenderQueue(getRenderQueue()); 
     423        } 
     424        else 
     425        { 
     426                MovableMap::const_iterator mit, mit_end = mViewCellsGeometry.end(); 
     427 
     428                for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit) 
     429                { 
     430                        if ((*mit).second) 
     431                                (*mit).second->_updateRenderQueue(getRenderQueue()); 
     432                }        
     433        }*/ 
     434} 
     435 
     436 
     437void OcclusionCullingSceneManager::RenderPvsEntry(GtpVisibilityPreprocessor::Intersectable *obj) 
     438{ 
     439        switch (obj->Type()) 
     440        {        
     441                case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 
     442                        { 
     443                                OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 
     444                                omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 
     445                        } 
     446                        break; 
     447 
     448                case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 
     449                        { 
     450                                EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 
     451 
     452                                EntityContainer *entries = oi->GetItem(); 
     453                                EntityContainer::const_iterator eit, eit_end = entries->end(); 
     454 
     455                                for (eit = entries->begin(); eit != eit_end; ++ eit) 
     456                                { 
     457                                        Entity *ent = *eit; 
     458                                        // mailing hack 
     459                                        Any newAny = ent->getUserAny(); 
     460                                        int flt = any_cast<int>(newAny); 
     461 
     462                                        if (any_cast<int>(newAny) == 0) 
     463                                        { 
     464                                                ent->setUserAny(Any((int)1)); 
     465                                                ent->_updateRenderQueue(getRenderQueue()); 
     466                                        } 
     467                                } 
     468                        } 
     469                        break; 
     470                default: 
     471                        break; 
     472        }        
     473} 
     474//----------------------------------------------------------------------- 
     475void OcclusionCullingSceneManager::SetObjectVisible(GtpVisibilityPreprocessor::Intersectable *entry,  
     476                                                                                                        const bool visible) 
     477{ 
     478        switch (entry->Type()) 
     479        { 
     480        case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 
     481                { 
     482                        OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 
     483                        omi->GetEntity()->setVisible(visible); 
     484                        //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 
     485                } 
     486                break; 
     487        case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 
     488                { 
     489                        EngineIntersectable *oi = static_cast<EngineIntersectable *>(entry); 
     490 
     491                        EntityContainer *entries = oi->GetItem(); 
     492                        EntityContainer::const_iterator eit, eit_end = entries->end(); 
     493                        for (eit = entries->begin(); eit != eit_end; ++ eit) 
     494                        { 
     495                                Entity *ent = *eit; 
     496                                ent->setVisible(visible); 
     497                        } 
     498                } 
     499                break; 
     500        default: 
     501                break; 
     502        } 
     503} 
    381504//----------------------------------------------------------------------- 
    382505void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) 
     
    404527 
    405528        // show current view cell geometry 
    406     if (mCurrentViewCell && mCurrentViewCell->GetMesh()) 
    407         {/* 
     529    if (mCurrentViewCell)// && mCurrentViewCell->GetMesh()) 
     530        { 
    408531                //const bool showSingleViewCell = true; 
    409532                if (mViewCellsGeometryLoaded) 
    410533                { 
    411                         if (!mShowViewCells) 
    412                         { 
    413                                 const int id = mCurrentViewCell->GetId(); 
    414  
    415                                 MovableMap::iterator fit = mViewCellsGeometry.find(id); 
    416  
    417                                 if ((fit != mViewCellsGeometry.end()) && (*fit).second) 
    418                                         (*fit).second->_updateRenderQueue(getRenderQueue()); 
    419                         } 
    420                         else 
    421                         { 
    422                                 MovableMap::const_iterator mit, mit_end = mViewCellsGeometry.end(); 
    423  
    424                                 for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit) 
    425                                 { 
    426                                         if ((*mit).second) 
    427                                                 (*mit).second->_updateRenderQueue(getRenderQueue()); 
    428                                 }        
    429                         } 
    430                 } 
    431                 */ 
     534                        ShowViewCellsGeometry(); 
     535                } 
     536                 
    432537                ////////// 
    433538                //-- set PVS of view cell visible 
    434539 
    435                 GtpVisibilityPreprocessor::ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 
     540                GtpVisibilityPreprocessor::ObjectPvsIterator pit =  
     541                        mCurrentViewCell->GetPvs().GetIterator(); 
     542 
     543                MailPvsObjects(); 
    436544 
    437545                while (pit.HasMoreEntries()) 
    438                 {                
    439                         GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 
    440                         GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 
    441  
    442                         OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 
    443                         omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 
    444                 } 
    445                  
    446         } 
    447 /* 
     546                { 
     547                        RenderPvsEntry(pit.Next()); 
     548                }        
     549        } 
     550#if 0 
    448551   if (mRenderNodesForViz || mRenderNodesContentForViz) 
    449552        { 
     
    479582                        } 
    480583                } 
    481         }*/ 
     584        } 
     585#endif 
    482586} 
    483587//----------------------------------------------------------------------- 
     
    601705{ 
    602706        // $$matt temp: Remove this!! 
    603         if (1)  
     707        if (0)  
    604708        { 
    605709                getDestinationRenderSystem()->_setCullingMode(CULL_NONE); 
    606                 LogManager::getSingleton().logMessage("warning: culling mode"); 
     710                //LogManager::getSingleton().logMessage("warning: culling mode"); 
    607711        } 
    608712 
     
    13671471                GtpVisibilityPreprocessor::Intersectable *entry = *it; 
    13681472 
    1369                 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 
    1370                 omi->GetEntity()->setVisible(visible); 
    1371                 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 
     1473                SetObjectVisible(entry, visible); 
    13721474        } 
    13731475} 
     
    14211523        } 
    14221524                 
    1423         GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
    1424  
    14251525        //////////// 
    14261526        //-- set PVS of view cell to visible 
     
    14291529        //LogManager::getSingleton().logMessage(d.str()); 
    14301530 
     1531        GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     1532 
    14311533        while (pit.HasMoreEntries()) 
    14321534        {                
    1433                 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 
    1434                 GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 
     1535                GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 
    14351536 
    14361537                // no associated geometry found 
    14371538                if (!obj) continue; 
    14381539         
    1439                 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 
    1440                 omi->GetEntity()->setVisible(load); 
     1540                SetObjectVisible(obj, load); 
    14411541        } 
    14421542} 
     
    17061806                                                                                                SceneNode *root) 
    17071807{ 
    1708         ObjReader objReader(this); 
    1709  
    17101808        Timer *timer = PlatformManager::getSingleton().createTimer(); 
    17111809        timer->reset(); 
    17121810 
    1713         if (!objReader.LoadFile(filename.c_str(), viewCellsFile, root)) 
     1811        if (!mObjReader->LoadFile(filename.c_str(), viewCellsFile, root)) 
    17141812        { 
    17151813                PlatformManager::getSingleton().destroyTimer(timer); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj

    r2122 r2123  
    2020                                Name="VCCLCompilerTool" 
    2121                                Optimization="0" 
    22                                 AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src" 
     22                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include" 
    2323                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE" 
    2424                                MinimalRebuild="TRUE" 
     
    3636                                Name="VCLinkerTool" 
    3737                                IgnoreImportLibrary="TRUE" 
    38                                 AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplibd.lib Preprocessor.lib devil.lib glut32.lib xerces-c_2D.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib glew32.lib" 
     38                                AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplibd.lib Preprocessor.lib devil.lib glut32.lib xerces-c_2D.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib glew32.lib IVReader.lib ObjReader.lib" 
    3939                                OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll" 
    4040                                Version="0.99" 
    4141                                LinkIncremental="1" 
    4242                                SuppressStartupBanner="TRUE" 
    43                                 AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;&quot;$(CG_LIB_PATH)&quot;" 
     43                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;&quot;$(CG_LIB_PATH)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;" 
    4444                                ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 
    4545                                GenerateDebugInformation="TRUE" 
     
    8787                                OmitFramePointers="TRUE" 
    8888                                EnableFiberSafeOptimizations="TRUE" 
    89                                 OptimizeForProcessor="3" 
     89                                OptimizeForProcessor="0" 
    9090                                OptimizeForWindowsApplication="TRUE" 
    91                                 AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\Preprocessing\src\Timer;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include" 
    92                                 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS" 
     91                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\Preprocessing\src\Timer;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include" 
     92                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE" 
    9393                                StringPooling="TRUE" 
    9494                                RuntimeLibrary="2" 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjManualMeshLoader.h

    r2111 r2123  
    22#define __ObjManualMeshLoader_H__ 
    33 
     4#include "Ogre.h" 
    45 
    5 #include "Ogre.h" 
    6 #include "ObjMeshData.h" 
    7  
     6namespace  GtpVisibilityPreprocessor { 
     7class BvhLeaf; 
     8} 
    89 
    910class __declspec(dllexport) ObjManualMeshLoader: public Ogre::ManualResourceLoader 
    1011{ 
    11         public: 
    12                 ObjManualMeshLoader(); 
    13                 ObjManualMeshLoader(ObjMeshData *mData); 
    14                 ~ObjManualMeshLoader();  
     12public: 
     13        ObjManualMeshLoader(GtpVisibilityPreprocessor::BvhLeaf *obj); 
     14        ~ObjManualMeshLoader();  
    1515 
    16                 void loadResource(Ogre::Resource *resource); 
     16        void loadResource(Ogre::Resource *resource); 
    1717 
    18                 Ogre::AxisAlignedBox *getBoundingBox(); 
    19         private: 
    20                 ObjMeshData *data; 
     18protected: 
    2119 
     20        GtpVisibilityPreprocessor::BvhLeaf *mObject; 
    2221}; 
    2322 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h

    r2122 r2123  
    77#include "Containers.h" 
    88 
     9namespace  GtpVisibilityPreprocessor { 
     10class Intersectable; 
     11} 
    912 
    1013class __declspec(dllexport) ObjReader 
     
    1417        ~ObjReader(); 
    1518 
    16         bool LoadFile(const string &sceneName,  
    17                                   const string &visibilitySolution, 
     19        bool LoadFile(const std::string &sceneName,  
     20                                  const std::string &visibilitySolution, 
    1821                                  Ogre::SceneNode *root); 
    19          
     22        void dummy(); 
     23        Ogre::Entity * dummy2(const std::string &name, 
     24                                GtpVisibilityPreprocessor::Intersectable *object); 
    2025        Ogre::Entity *CreateEntity(const std::string &name, 
    2126                                                           GtpVisibilityPreprocessor::Intersectable *object); 
     
    2530 
    2631        Ogre::SceneManager *mSceneManager; 
     32        GtpVisibilityPreprocessor::ObjectContainer mPvsObjects; 
    2733}; 
    2834 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjManualMeshLoader.cpp

    r2111 r2123  
    11#include "ObjManualMeshLoader.h" 
    2 #include "ObjReader.h" 
     2#include "Triangle3.h" 
     3#include "IntersectableWrapper.h" 
     4#include "BvHierarchy.h" 
     5#include "OgreLogManager.h" 
    36 
    4 ObjManualMeshLoader::ObjManualMeshLoader() 
    5 { 
    6         data = NULL; 
    7 } 
     7#define USE_HBL_DISCARD 1 
    88 
    9  
    10 ObjManualMeshLoader::ObjManualMeshLoader(ObjMeshData *mData): 
    11 data(mData) 
     9ObjManualMeshLoader::ObjManualMeshLoader(GtpVisibilityPreprocessor::BvhLeaf *obj): 
     10mObject(obj) 
    1211{ 
    1312} 
     
    1615ObjManualMeshLoader::~ObjManualMeshLoader() 
    1716{ 
    18         if (data != NULL) 
    19         { 
    20                 data->collapse(); 
    21                 delete data; 
    22         } 
    23 } 
    24  
    25  
    26 Ogre::AxisAlignedBox *ObjManualMeshLoader::getBoundingBox() 
    27 { 
    28         return data->boundingBox; 
    2917} 
    3018 
     
    3321{ 
    3422        using namespace Ogre; 
    35         Mesh *pMesh = (Mesh *) resource; 
    3623 
     24        Mesh *mesh = (Mesh *) resource; 
     25        SubMesh* submesh = mesh->createSubMesh(); 
    3726 
    38         Vector3 translation = data->boundingBox->getCenter(); 
     27        const int triCount = (int)mObject->mObjects.size(); 
     28        const int vertexCount = triCount * 3; 
    3929 
    40         bool nOk = ((data->normals != NULL) && (data->ncnt > 0)); 
    41         bool tOk = ((data->texCoords != NULL) && (data->tcnt > 0)); 
    42          
    43         pMesh->sharedVertexData = new VertexData();  
     30        // We must create the vertex data, indicating how many vertices there will be 
     31        submesh->useSharedVertices = false; 
     32        submesh->vertexData = new VertexData(); 
     33        submesh->vertexData->vertexStart = 0; 
     34        submesh->vertexData->vertexCount = vertexCount; 
    4435 
    45         VertexDeclaration* vertexDecl = pMesh->sharedVertexData->vertexDeclaration;  
     36        static const unsigned short source = 0; 
     37        size_t offset = 0; 
    4638 
    47         size_t currOffset = 0;  
    48         vertexDecl->addElement(0, currOffset, VET_FLOAT3, VES_POSITION);  
    49         currOffset += VertexElement::getTypeSize(VET_FLOAT3);  
    50         if (nOk) 
     39        // We must now declare what the vertex data contains 
     40        VertexDeclaration* declaration = submesh->vertexData->vertexDeclaration; 
     41 
     42        offset += declaration->addElement(source, offset, VET_FLOAT3, VES_POSITION).getSize(); 
     43        offset += declaration->addElement(source, offset, VET_FLOAT3, VES_NORMAL).getSize(); 
     44        //offset += declaration->addElement(source, offset, VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize(); 
     45 
     46        HardwareVertexBufferSharedPtr vbuffer = HardwareBufferManager::getSingleton(). 
     47                createVertexBuffer(declaration->getVertexSize(source), 
     48                                                   submesh->vertexData->vertexCount, 
     49                                                   HardwareBuffer::HBU_STATIC_WRITE_ONLY); 
     50 
     51    // we get access to the buffer to fill it.  During so we record the bounding box. 
     52        AxisAlignedBox aabox; 
     53 
     54        submesh->vertexData->vertexBufferBinding->setBinding(source, vbuffer); 
     55#if USE_HBL_DISCARD 
     56        float* vdata = static_cast<float*>(vbuffer->lock(HardwareBuffer::HBL_DISCARD)); 
     57#else 
     58        float* vdata = static_cast<float *>(vbuffer->lock(HardwareBuffer::HBL_NORMAL)); 
     59#endif 
     60 
     61        GtpVisibilityPreprocessor::ObjectContainer:: 
     62                const_iterator oit, oit_end = mObject->mObjects.end(); 
     63 
     64        for (oit = mObject->mObjects.begin(); oit != oit_end; ++ oit) 
    5165        { 
    52                 vertexDecl->addElement(0, currOffset, VET_FLOAT3, VES_NORMAL);  
    53                 currOffset += VertexElement::getTypeSize(VET_FLOAT3);  
    54         } 
    55     if (tOk) 
    56         { 
    57                 vertexDecl->addElement(0, currOffset, VET_FLOAT2, VES_TEXTURE_COORDINATES);  
    58                 currOffset += VertexElement::getTypeSize(VET_FLOAT2);  
    59         } 
     66                GtpVisibilityPreprocessor::TriangleIntersectable *tObj =  
     67                        static_cast<GtpVisibilityPreprocessor::TriangleIntersectable *>(*oit); 
     68                 
     69                const GtpVisibilityPreprocessor::Triangle3 tri = tObj->GetItem(); 
     70                const GtpVisibilityPreprocessor::Vector3 n = tri.GetNormal(); 
    6071 
    61         pMesh->sharedVertexData->vertexCount = data->vcnt/3;  
    62         HardwareVertexBufferSharedPtr vbuf =  
    63                 HardwareBufferManager::getSingleton().  
    64                 createVertexBuffer(vertexDecl->getVertexSize(0), pMesh->sharedVertexData->vertexCount,  
    65                         HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);  
     72                for (int i = 0; i < 3; ++ i) 
     73                { 
     74                        Vector3 vtx(tri.mVertices[i].x, tri.mVertices[i].y, tri.mVertices[i].z); 
     75                 
     76                        *(vdata ++) = vtx.x; 
     77                        *(vdata ++) = vtx.y; 
     78                        *(vdata ++) = vtx.z; 
    6679 
    67         VertexBufferBinding* binding = pMesh->sharedVertexData->vertexBufferBinding;  
    68         binding->setBinding(0, vbuf);  
     80                        *(vdata ++) = n.x; 
     81                        *(vdata ++) = n.y; 
     82                        *(vdata ++) = n.z; 
    6983 
    70         Real* pVertices = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));  
    71  
    72         int offset = 0, size = 3; 
    73         if (nOk) size += 3; 
    74         if (tOk) size += 2; 
    75         for (int i=0; i<data->vcnt/3; i++)  
    76         { 
    77                 pVertices[i*size]   = data->vertices[i*3]   - translation.x; 
    78                 pVertices[i*size+1] = data->vertices[i*3+1] - translation.y; 
    79                 pVertices[i*size+2] = data->vertices[i*3+2] - translation.z; 
    80  
    81                 offset = 3; 
    82                 if (nOk) 
    83                 { 
    84                         pVertices[i*size+offset] = data->normals[i*3];   offset++; 
    85                         pVertices[i*size+offset] = data->normals[i*3+1]; offset++; 
    86                         pVertices[i*size+offset] = data->normals[i*3+2]; offset++; 
    87                 } 
    88                 if (tOk) 
    89                 { 
    90                         pVertices[i*size+offset] = data->texCoords[i*2];   offset++; 
    91                         pVertices[i*size+offset] = -data->texCoords[i*2+1]; offset++; 
     84                        aabox.merge(vtx); 
    9285                } 
    9386        } 
    9487 
    95         vbuf->unlock();  
     88        vbuffer->unlock(); 
     89 
     90#if 0 
     91        RenderOperation rop; 
     92        submesh->_getRenderOperation(rop); 
     93        rop.useIndexes = false; 
     94#endif 
     95        ////// 
     96        //-- Creates the index data 
     97     
     98        const int indexCount = vertexCount; 
     99        submesh->indexData->indexStart = 0; 
     100        submesh->operationType = RenderOperation::OT_TRIANGLE_LIST; 
     101 
     102        // we use an index for every vertex 
     103        submesh->indexData->indexCount = indexCount; 
     104        submesh->indexData->indexBuffer = 
     105            HardwareBufferManager::getSingleton(). 
     106                        createIndexBuffer(HardwareIndexBuffer::IT_16BIT, 
     107                                                          submesh->indexData->indexCount, 
     108                                                          HardwareBuffer::HBU_STATIC_WRITE_ONLY); 
     109 
     110#if USE_HBL_DISCARD 
     111        uint16* idata = static_cast<uint16 *>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_DISCARD)); 
     112#else 
     113        uint16* idata = static_cast<uint16 *>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_NORMAL)); 
     114#endif 
     115        for (int j = 0; j < indexCount; ++ j) 
     116    { 
     117                idata[j] = j; 
     118    } 
     119     
     120        submesh->indexData->indexBuffer->unlock(); 
     121        submesh->setMaterialName("BaseWhite");  
     122 
     123        // indicate the bounding box 
     124        mesh->_setBounds(aabox);  
     125        mesh->_setBoundingSphereRadius((aabox.getMaximum() - aabox.getMinimum()).length() / 2.0);  
     126} 
    96127 
    97128 
    98         SubMesh *pSub = pMesh->createSubMesh();  
    99         pSub->operationType = RenderOperation::OT_TRIANGLE_LIST; //;data->roType; 
    100         pSub->useSharedVertices = true;  
    101129 
    102         pSub->indexData->indexCount = data->icnt;  
    103         pSub->indexData->indexBuffer = HardwareBufferManager::getSingleton().  
    104                 createIndexBuffer(HardwareIndexBuffer::IT_16BIT,  
    105                         pSub->indexData->indexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);  
    106  
    107         HardwareIndexBufferSharedPtr ibuf = pSub->indexData->indexBuffer;  
    108         unsigned short* pIndices = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_DISCARD));  
    109  
    110         for (i = 0; i < data->icnt; i++) pIndices[i] = data->indices[i]; 
    111          
    112         ibuf->unlock();  
    113                  
    114         AxisAlignedBox bb(data->boundingBox->getMinimum() - translation, data->boundingBox->getMaximum() - translation); 
    115         //AxisAlignedBox bb(data->boundingBox->getMinimum(), data->boundingBox->getMaximum()); 
    116         pMesh->_setBounds(bb);  
    117         Real radius = data->boundingBox->getMinimum().length(); 
    118         if (data->boundingBox->getMaximum().length() > radius) radius = data->boundingBox->getMaximum().length(); 
    119         pMesh->_setBoundingSphereRadius(radius);  
    120  
    121 } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp

    r2122 r2123  
    88#include "PreprocessorFactory.h" 
    99#include "OgreLogManager.h" 
     10#include "ObjManualMeshLoader.h" 
    1011 
    1112 
     
    1718 
    1819ObjReader::~ObjReader() 
    19 {} 
     20{ 
     21        CLEAR_CONTAINER(mPvsObjects); 
     22} 
    2023 
    2124 
     
    3134        // hack 
    3235        preprocessor->mLoadMeshes = false; 
    33         GtpVisibilityPreprocessor::ObjectContainer pvsObjects; 
    3436 
    35         Ogre::LogManager::getSingleton().logMessage("loading obj scene!!"); 
     37        Ogre::LogManager::getSingleton().logMessage("loading obj scene"); 
    3638 
    3739        if (preprocessor->LoadScene(sceneName)) 
     
    3941                Ogre::LogManager::getSingleton().logMessage("scene loaded, loading objects"); 
    4042                // form objects from the scene triangles 
    41                 if (!preprocessor->LoadObjects(visibilitySolution, pvsObjects, preprocessor->mObjects)) 
     43                if (!preprocessor->LoadObjects(visibilitySolution, mPvsObjects, preprocessor->mObjects)) 
    4244                { 
    4345                        Ogre::LogManager::getSingleton().logMessage("objects cannot be loaded"); 
     
    5254 
    5355        std::stringstream d;  
    54         d << "successfully loaded " << pvsObjects.size() << " objects from " << preprocessor->mObjects.size() << " preprocessor objects"; 
     56        d << "successfully loaded " << mPvsObjects.size() << " objects from " << preprocessor->mObjects.size() << " preprocessor objects"; 
    5557 
    5658        Ogre::LogManager::getSingleton().logMessage(d.str()); 
    5759 
    58         GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = pvsObjects.end(); 
     60        GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 
    5961 
    6062        int i = 0; 
    61         for (oit = pvsObjects.begin(); oit != oit_end; ++ oit, ++ i) 
     63        for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit, ++ i) 
    6264        { 
    63                 Ogre::LogManager::getSingleton().logMessage("r"); 
     65                if (i % 5000 == 4999) 
     66                { 
     67                        d << i << " objects created" << endl; 
     68                } 
     69         
    6470                const Ogre::String entname = "Object" + Ogre::StringConverter::toString(i); 
    6571 
    66                 Ogre::ManualObject *ent = CreateEntity(entname, *oit); 
     72#if 0 
     73                Ogre::ManualObject *ent = CreateManualObject(entname, *oit); 
     74#else 
     75                Ogre::Entity *ent = CreateEntity(entname, *oit); 
     76#endif 
    6777 
    6878                const Ogre::String nodeName = entname + "Node"; 
     
    7080                node->attachObject(ent); 
    7181 
    72                 if (i > 100) 
    73                         break; 
     82                // problems for too many objects (= vbo)? 
     83                //if (i > 30000)break; 
    7484        } 
    7585 
     
    8999        std::string entityName = name + "Entity"; 
    90100 
    91 GtpVisibilityPreprocessor::BvhLeaf *bvhObj =  
     101        GtpVisibilityPreprocessor::BvhLeaf *bvhObj =  
    92102                static_cast<GtpVisibilityPreprocessor::BvhLeaf *>(object); 
     103 
    93104        const int vertexCount = (int)bvhObj->mObjects.size() * 3; 
    94105 
    95106        ManualObject* manual = mSceneManager->createManualObject(entityName); 
    96         manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP); 
     107        manual->begin("BaseWhite", RenderOperation::OT_TRIANGLE_LIST); 
    97108         
     109        const float red = GtpVisibilityPreprocessor::Random(1.0f); 
     110        const float green = GtpVisibilityPreprocessor::Random(1.0f); 
     111        const float blue = GtpVisibilityPreprocessor::Random(1.0f); 
     112 
    98113        // create vertices 
    99          
    100         GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = bvhObj->mObjects.end(); 
     114        GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit,  
     115                oit_end = bvhObj->mObjects.end(); 
    101116         
    102117        for (oit = bvhObj->mObjects.begin(); oit != oit_end; ++ oit) 
     
    110125                { 
    111126                        const GtpVisibilityPreprocessor::Vector3 vtx = tri.mVertices[i]; 
     127                        const GtpVisibilityPreprocessor::Vector3 n = tri.GetNormal(); 
     128 
    112129                        manual->position(vtx.x, vtx.y, vtx.z); 
    113                         manual->colour(1.0f, 0.0f, 0.0f); 
     130                        manual->normal(n.x, n.y, n.z); 
     131                        //manual->colour(red, green, blue); 
    114132                } 
    115133        } 
    116134 
     135        if (0) 
    117136        for (int i = 0; i < vertexCount; ++ i) 
    118137        { 
    119138                manual->index(i); 
    120139        } 
     140 
     141        manual->end(); 
    121142 
    122143        return manual; 
     
    137158        std::string entityName = name + "Entity"; 
    138159 
    139         MeshPtr mesh = MeshManager::getSingleton().createManual(meshName, "Custom"); 
    140         SubMesh* submesh = mesh->createSubMesh(); 
     160        ObjManualMeshLoader *loader = new ObjManualMeshLoader(bvhObj); 
    141161 
    142         const int vertexCount = (int)bvhObj->mObjects.size() * 3; 
    143  
    144         // We must create the vertex data, indicating how many vertices there will be 
    145         submesh->useSharedVertices = false; 
    146         submesh->vertexData = new VertexData(); 
    147         submesh->vertexData->vertexStart = 0; 
    148         submesh->vertexData->vertexCount = vertexCount; 
    149  
    150         std::stringstream d; d << "objects: " << bvhObj->mObjects.size() << " vtx: " << submesh->vertexData->vertexCount << endl; 
    151         Ogre::LogManager::getSingleton().logMessage(d.str()); 
    152  
    153         static const unsigned short source = 0; 
    154         size_t offset = 0; 
    155  
    156         VertexDeclaration* declaration = HardwareBufferManager::getSingleton().createVertexDeclaration(); 
    157  
    158         offset += declaration->addElement(source, offset, VET_FLOAT3, VES_POSITION).getSize(); 
    159         //offset += declaration->addElement(source, offset, VET_FLOAT3,VES_NORMAL).getSize(); 
    160         //offset += declaration->addElement(source, offset, VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize(); 
    161  
    162  
    163         int numVertices = 0; 
    164  
    165         HardwareVertexBufferSharedPtr vbuffer = HardwareBufferManager::getSingleton(). 
    166                 createVertexBuffer(declaration->getVertexSize(source), 
    167                                                    submesh->vertexData->vertexCount, 
    168                                                    HardwareBuffer::HBU_STATIC_WRITE_ONLY); 
    169  
    170     // No we get access to the buffer to fill it.  During so we record the bounding box. 
    171         AxisAlignedBox aabox; 
    172  
    173         float* vdata = static_cast<float*>(vbuffer->lock(HardwareBuffer::HBL_DISCARD)); 
    174  
    175         GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = bvhObj->mObjects.end(); 
    176  
    177         for (oit = bvhObj->mObjects.begin(); oit != oit_end; ++ oit) 
    178         { 
    179                 GtpVisibilityPreprocessor::TriangleIntersectable *tObj =  
    180                         static_cast<GtpVisibilityPreprocessor::TriangleIntersectable *>(*oit); 
    181                  
    182                 GtpVisibilityPreprocessor::Triangle3 tri = tObj->GetItem(); 
    183  
    184                 for (int i = 0; i < 3; ++ i) 
    185                 { 
    186                         Vector3 vtx = Vector3(tri.mVertices[i]); 
    187  
    188                         *vdata ++ = vtx.x; 
    189                         *vdata ++ = vtx.y; 
    190                         *vdata ++ = vtx.z; 
    191  
    192                         //std::stringstream d; d << vtx; 
    193                         //Ogre::LogManager::getSingleton().logMessage(d.str()); 
    194                         aabox.merge(vtx); 
    195                 } 
    196         } 
    197         //Ogre::LogManager::getSingleton().logMessage("***"); 
    198         vbuffer->unlock(); 
    199          
    200         /*Ogre::RenderOperation rop; 
    201         submesh->_getRenderOperation(rop); 
    202         rop.useIndexes = false; 
    203 */ 
    204         ////// 
    205         //-- Creates the index data 
    206  
    207     submesh->vertexData->vertexBufferBinding->setBinding(source, vbuffer); 
    208  
    209         submesh->indexData->indexStart = 0; 
    210         // we use an index for every vertex 
    211         submesh->indexData->indexCount = vertexCount; 
    212         submesh->indexData->indexBuffer = 
    213             HardwareBufferManager::getSingleton(). 
    214                         createIndexBuffer(HardwareIndexBuffer::IT_16BIT, 
    215                                                           submesh->indexData->indexCount, 
    216                                                           HardwareBuffer::HBU_STATIC_WRITE_ONLY); 
    217         submesh->operationType = RenderOperation::OT_LINE_STRIP; 
    218         //uint16* idata = static_cast<uint16*>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_DISCARD)); 
    219     unsigned short* idata = static_cast<unsigned short*>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_DISCARD)); 
    220  
    221         for (int j = 0; j < vertexCount; ++ j) 
    222     { 
    223                 *idata = j; 
    224                 ++ idata; 
    225     } 
    226      
    227         submesh->indexData->indexBuffer->unlock(); 
    228  
    229         submesh->setMaterialName("BaseWhiteNoLighting");  
    230  
    231         // We must indicate the bounding box 
    232         mesh->_setBounds(aabox);  
    233         mesh->_setBoundingSphereRadius((aabox.getMaximum() - aabox.getMinimum()).length() / 2.0);  
    234         mesh->load(); 
    235         mesh->touch(); 
     162        Mesh* pMesh = MeshManager::getSingleton().createManual(meshName, "ObjGroup", loader).getPointer();  
     163        pMesh->load();  
    236164 
    237165        // Create an entity with the mesh 
    238166        entity = mSceneManager->createEntity(entityName, meshName); 
    239167 
    240         //entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN); 
     168        return entity; 
     169} 
    241170 
    242         return entity; 
    243 #endif 
    244 } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj

    r2122 r2123  
    2020                                Name="VCCLCompilerTool" 
    2121                                Optimization="0" 
    22                                 AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include" 
     22                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src" 
    2323                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE" 
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
    26                                 RuntimeLibrary="1" 
    27                                 UsePrecompiledHeader="0" 
    28                                 WarningLevel="3" 
    29                                 Detect64BitPortabilityProblems="TRUE" 
    30                                 DebugInformationFormat="3"/> 
    31                         <Tool 
    32                                 Name="VCCustomBuildTool"/> 
    33                         <Tool 
    34                                 Name="VCLinkerTool" 
    35                                 AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib" 
    36                                 OutputFile="$(OutDir)/ObjReader.dll" 
    37                                 LinkIncremental="1" 
    38                                 AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;" 
     26                                RuntimeLibrary="3" 
     27                                UsePrecompiledHeader="0" 
     28                                WarningLevel="3" 
     29                                Detect64BitPortabilityProblems="TRUE" 
     30                                DebugInformationFormat="3"/> 
     31                        <Tool 
     32                                Name="VCCustomBuildTool"/> 
     33                        <Tool 
     34                                Name="VCLinkerTool" 
     35                                AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Preprocessor.lib xerces-c_2.lib zdll.lib zziplibd.lib" 
     36                                OutputFile="$(OutDir)/ObjReader.dll" 
     37                                LinkIncremental="1" 
     38                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib" 
    3939                                GenerateDebugInformation="TRUE" 
    4040                                ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb" 
     
    7373                                Name="VCCLCompilerTool" 
    7474                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src" 
    75                                 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS" 
     75                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE" 
    7676                                RuntimeLibrary="2" 
    7777                                UsePrecompiledHeader="0" 
     
    339339                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 
    340340                        <File 
     341                                RelativePath=".\ObjManualMeshLoader.cpp"> 
     342                        </File> 
     343                        <File 
    341344                                RelativePath="..\src\ObjReader.cpp"> 
    342345                        </File> 
    343                         <Filter 
    344                                 Name="Header Files" 
    345                                 Filter="h;hpp;hxx;hm;inl;inc;xsd" 
    346                                 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
    347                                 <File 
    348                                         RelativePath="..\include\ObjReader.h"> 
    349                                 </File> 
    350                         </Filter> 
     346                </Filter> 
     347                <Filter 
     348                        Name="Header Files" 
     349                        Filter="h;hpp;hxx;hm;inl;inc;xsd" 
     350                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
     351                        <File 
     352                                RelativePath="..\include\ObjManualMeshLoader.h"> 
     353                        </File> 
     354                        <File 
     355                                RelativePath="..\include\ObjReader.h"> 
     356                        </File> 
    351357                </Filter> 
    352358        </Files> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h

    r2117 r2123  
    2020   { 
    2121      bucket_size = 4, 
    22       min_buckets = 80 
     22      min_buckets = 8 
    2323   }; 
    2424 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp

    r2105 r2123  
    5151  cerr<<"Muattion update..."<<endl; 
    5252  cerr<<"rays = "<<mRays.size()<<endl; 
    53   if (mRays.size()) { 
     53  if ((int)mRays.size()) { 
    5454        cerr<<"Oversampling factors = "<< 
    5555          GetEntry(0).mMutations<<" "<< 
     
    5959          GetEntry(4).mMutations<<" "<< 
    6060          GetEntry(5).mMutations<<" ... "<< 
    61           GetEntry(mRays.size()-6).mMutations<<" "<< 
    62           GetEntry(mRays.size()-5).mMutations<<" "<< 
    63           GetEntry(mRays.size()-4).mMutations<<" "<< 
    64           GetEntry(mRays.size()-3).mMutations<<" "<< 
    65           GetEntry(mRays.size()-2).mMutations<<" "<< 
    66           GetEntry(mRays.size()-1).mMutations<<endl; 
     61          GetEntry((int)mRays.size()-6).mMutations<<" "<< 
     62          GetEntry((int)mRays.size()-5).mMutations<<" "<< 
     63          GetEntry((int)mRays.size()-4).mMutations<<" "<< 
     64          GetEntry((int)mRays.size()-3).mMutations<<" "<< 
     65          GetEntry((int)mRays.size()-2).mMutations<<" "<< 
     66          GetEntry((int)mRays.size()-1).mMutations<<endl; 
    6767  } 
    6868  int contributingRays = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp

    r2119 r2123  
    203203        if (SqrMagnitude(cross_a_b) <= 0.000001 * FLT_EPSILON * FLT_EPSILON)  
    204204        { 
    205                 cout << "x"; 
    206205                // v0, v1 & v2 lies on a line (area == 0) 
    207206                return false; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.h

    r2120 r2123  
    2323                but the individual contributions of the entries are summed up. 
    2424        */ 
    25         float EvalPvsCost() const {      
    26                 //temp matt  
    27                 return 1.0f; } 
     25        float EvalPvsCost() const; 
    2826 
    2927        friend ostream &operator<<(ostream &s, const ObjectPvs &p)  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp

    r2119 r2123  
    8585  , mIsObjectSpaceHierarchy(false) 
    8686{ 
    87         // sort objects so we can search in them 
    88         //if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt)) 
    89                 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
    90 Debug << "here333"; 
    91         //if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt)) 
    92                 //sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt); 
    9387} 
    9488 
     
    257251        { 
    258252                const int objId = *it;   
     253 
     254#if 0 
     255                // assume there is is no id missing 
     256                objects.push_back(mPreprocessorObjects[objId]); 
     257#else 
    259258                dummyInst.SetId(objId); 
    260259 
     
    268267                { 
    269268                        objects.push_back(*oit); 
    270                         Debug << "x"; 
    271                 } 
    272                 else 
    273                 { 
    274                         Debug << "y"; 
    275                         //cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 
    276                 } 
     269                } 
     270#endif 
    277271        } 
    278272} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2120 r2123  
    7272                                OptimizeForWindowsApplication="TRUE" 
    7373                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
    74                                 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_VERBOSE_PVS" 
     74                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
    7575                                ExceptionHandling="TRUE" 
    7676                                RuntimeLibrary="2" 
     
    383383                        </File> 
    384384                        <File 
     385                                RelativePath=".\BitVectorPvs.cpp"> 
     386                        </File> 
     387                        <File 
    385388                                RelativePath=".\BitVectorPvs.h"> 
    386389                        </File> 
     
    582585                        <File 
    583586                                RelativePath="..\src\MutualVisibility.h"> 
     587                        </File> 
     588                        <File 
     589                                RelativePath=".\ObjectPvs.cpp"> 
    584590                        </File> 
    585591                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2122 r2123  
    10501050                                                                                                   preprocessorObjects,  
    10511051                                                                                                   bconverter); 
     1052 
     1053        //Debug << " view cells parsed in " 
     1054        //        << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
     1055         
    10521056 
    10531057        if (!success) 
     
    36873691        vector<ObjectPvs>::iterator oit = pvsList.begin(); 
    36883692 
     3693        PvsData pvsData; 
     3694 
    36893695        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 
    36903696        { 
     
    36943700                while (pit.HasMoreEntries()) 
    36953701                {                
    3696                         ObjectPvsEntry entry = pit.Next(); 
    3697  
    3698                         Intersectable *intersect = entry.mObject; 
     3702                        Intersectable *intersect = pit.Next(pvsData); 
    36993703 
    37003704                        if (!intersect->Mailed()) 
     
    37023706                                intersect->Mail(); 
    37033707 
    3704                                 pvs.AddSampleDirty(intersect, entry.mData.mSumPdf); 
     3708                                pvs.AddSampleDirty(intersect, pvsData.mSumPdf); 
    37053709                        } 
    37063710                } 
     
    41794183                        while (pit.HasMoreEntries()) 
    41804184                        {                
    4181                                 ObjectPvsEntry entry = pit.Next(); 
     4185                                Intersectable *intersect = pit.Next(); 
    41824186 
    41834187                // output PVS of view cell 
    4184                                 Intersectable *intersect = entry.mObject; 
    4185                                  
    41864188                                if (!intersect->Mailed()) 
    41874189                                { 
     
    46844686                        while (pit.HasMoreEntries()) 
    46854687                        {                
    4686                                 ObjectPvsEntry entry = pit.Next(); 
    4687                                  
    46884688                                //-- output PVS of view cell 
    4689                                 Intersectable *intersect = entry.mObject; 
     4689                                Intersectable *intersect = pit.Next(); 
     4690 
    46904691                                if (!intersect->Mailed()) 
    46914692                                { 
     
    55015502                        while (pit.HasMoreEntries()) 
    55025503                        { 
    5503                                 ObjectPvsEntry entry = pit.Next();               
    5504                                 Intersectable *intersect = entry.mObject; 
     5504                                Intersectable *intersect = pit.Next();           
    55055505                                 
    55065506                                if (!intersect->Mailed()) 
     
    62836283                while (pit.HasMoreEntries()) 
    62846284                {                
    6285                         ObjectPvsEntry entry = pit.Next(); 
     6285                        Intersectable *obj = pit.Next(); 
    62866286                                 
    6287                         BvhNode *node = static_cast<BvhNode *>(entry.mObject); 
     6287                        BvhNode *node = static_cast<BvhNode *>(obj); 
    62886288                         
    62896289                        // hack!! 
     
    64966496                        while (pit.HasMoreEntries()) 
    64976497                        {                
    6498                                 ObjectPvsEntry entry = pit.Next(); 
     6498                                Intersectable *intersect = pit.Next(); 
    64996499                                 
    6500                                 Intersectable *intersect = entry.mObject; 
    6501  
    65026500                                if (!intersect->Mailed()) 
    65036501                                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2117 r2123  
    77#include "Containers.h" 
    88#include "ViewCell.h" 
    9 //#include "ViewCellBsp.h" 
     9 
    1010 
    1111namespace GtpVisibilityPreprocessor { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r2119 r2123  
    6868// hack for loading bvh nodes 
    6969#define PVS_HACK 0 
     70#define USE_HASH_COMPARE 1 
     71 
    7072 
    7173inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 
     
    103105  , nObjects(0) 
    104106{ 
    105         // q: can we assume that the objects are sorted? 
    106          
    107         // sort objects so we can search in them 
    108         //if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt)) 
    109                 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
    110  
    111         //if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt)) 
    112         //      sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt); 
    113107} 
    114108 
     
    119113 
    120114 
     115void ViewCellsParseHandlers::CreateHashVector() 
     116{ 
     117        ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 
     118 
     119        for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit) 
     120        { 
     121                mHashPvs[(*oit)->GetId()] = (*oit); 
     122        } 
     123        //Debug<<"\nhsize: " << mHashPvs.size() << endl; 
     124} 
     125/* 
     126void ViewCellsParseHandlers::CreateHashVector2() 
     127{ 
     128        ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 
     129 
     130        for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit) 
     131        { 
     132                mHashPvs[(*oit)->GetId()] = (*oit); 
     133        } 
     134        Debug<<"\nhsize: " << mHashPvs.size() << endl; 
     135} 
     136*/ 
    121137// --------------------------------------------------------------------------- 
    122138//  StdInParseHandlers: Implementation of the SAX DocumentHandler interface 
     
    133149                EndBoundingBoxes(); 
    134150        } 
    135  
    136         if (element == "ViewCells") 
     151        else if (element == "ViewCells") 
    137152        {        
    138153                EndViewCells(); 
    139         } 
    140  
    141         if (element == "ObjectSpaceHierarchy") 
     154                Debug << "view cell hierarchy parsed" << endl; 
     155        } 
     156        else if (element == "ObjectSpaceHierarchy") 
    142157        { 
    143158                EndObjectSpaceHierarchy(); 
    144         } 
    145  
    146         // finished, create view cells manager 
    147         if (element == "VisibilitySolution") 
     159                Debug << "object space hierarchy parsed" << endl; 
     160                mObjectTimer.Exit(); 
     161        } 
     162        // finished paring, create view cells manager 
     163        else if (element == "VisibilitySolution") 
    148164        { 
    149165                CreateViewCellsManager(); 
    150         } 
    151  
    152         if (element == "Interior") 
     166 
     167                Debug << "pvs time: " << mPvsTimer.TotalTime() << endl; 
     168                Debug << "object time: " << mObjectTimer.TotalTime() << endl; 
     169                Debug << "box time: " << mBoxTimer.TotalTime() << endl; 
     170 
     171        } 
     172        else if (element == "Interior") 
    153173        { 
    154174                switch (mCurrentState) 
     
    289309        const long startTime = GetTime(); 
    290310         
     311        mBoxTimer.Entry(); 
     312 
    291313        if (mBoundingBoxConverter) 
    292314        { 
     
    296318        } 
    297319 
     320        if (USE_HASH_COMPARE) 
     321        { 
     322                CreateHashVector(); 
     323        } 
     324        else 
     325        { 
     326                sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
     327 
     328                /*ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 
     329         
     330                int id = 0; 
     331                for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit, ++ id) 
     332                { 
     333                        if ((*oit)->GetId() != id) 
     334                                Debug << "error" << endl; 
     335                }*/ 
     336        } 
     337 
    298338        Debug << "\nconverted bounding boxes to objects in " 
    299                   << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     339                  << TimeDiff(startTime, GetTime()) * 1e-6 << " secs" << endl; 
     340        mBoxTimer.Exit(); 
    300341} 
    301342 
     
    412453        if (element == "Interior")  
    413454        { 
    414                 //cout << "["; 
    415455                StartViewCell(attributes, false); 
     456                return; 
    416457        } 
    417458 
    418459        if (element == "Leaf")  
    419460        { 
    420                 //cout << "l"; 
    421461                StartViewCell(attributes, true); 
    422         } 
     462                return; 
     463        } 
     464 
     465        Debug << "StartViewCellHierarchyElement: should not come here: " << element << endl; 
    423466} 
    424467 
     
    440483                mViewCellsTree = new ViewCellsTree(); 
    441484        } 
    442  
    443485        // decides about the view cell hierarchy 
    444         if (element == "ViewSpaceHierarchy") 
     486        else if (element == "ViewSpaceHierarchy") 
    445487        {                
    446488                Debug << "\nparsing view space hierarchy" << endl; 
     
    450492                StartViewSpaceHierarchy(attributes); 
    451493        } 
    452  
    453494        // decides about the view cell hierarchy 
    454         if (element == "ObjectSpaceHierarchy") 
     495        else if (element == "ObjectSpaceHierarchy") 
    455496        { 
    456497                cout  << "\nparsing object space hierarchy" << endl; 
     
    458499 
    459500                mCurrentState = PARSE_OBJECTSPACE_HIERARCHY; 
     501                mObjectTimer.Entry(); 
    460502                StartObjectSpaceHierarchy(attributes); 
    461503        } 
    462          
    463504        // decides the used view cell hierarchy 
    464         if (element == "BoundingBox") 
     505        else if (element == "BoundingBox") 
    465506        { 
    466507                StartBoundingBox(attributes); 
    467508        } 
    468  
    469         // parse view space hierarchy 
    470         switch (mCurrentState) 
    471         { 
    472         case PARSE_VIEWSPACE_HIERARCHY: 
    473                 if ((++ nViewCells % 1000) == 0) 
    474                         cout << "\r" << nViewCells << " view cells parsed\r"; 
     509        else 
     510        { 
     511                // parse view space hierarchy 
     512                switch (mCurrentState) 
     513                { 
     514                case PARSE_VIEWSPACE_HIERARCHY: 
     515                        if ((++ nViewCells % 1000) == 0) 
     516                        { 
     517                                cout << "\r" << nViewCells << " view cells parsed\r"; 
     518                                Debug << nViewCells << " view cells parsed" << endl; 
     519                        } 
     520                        StartViewSpaceHierarchyElement(element, attributes); 
     521                        break; 
     522                case PARSE_OBJECTSPACE_HIERARCHY: 
     523                        if ((++ nObjects % 1000) == 0) 
     524                                cout <<"\r" << nObjects << " objects parsed\r"; 
    475525                 
    476                 StartViewSpaceHierarchyElement(element, attributes); 
    477                 break; 
    478         case PARSE_OBJECTSPACE_HIERARCHY: 
    479                 if ((++ nObjects % 1000) == 0) 
    480                         cout <<"\r" << nObjects << " objects parsed\r"; 
    481                  
    482                 StartObjectSpaceHierarchyElement(element, attributes); 
    483                 break; 
    484         case PARSE_VIEWCELLS: 
    485                 StartViewCellHierarchyElement(element, attributes); 
    486                 break; 
    487         default: 
    488                 break; 
     526                        StartObjectSpaceHierarchyElement(element, attributes); 
     527                        break; 
     528                case PARSE_VIEWCELLS: 
     529                        StartViewCellHierarchyElement(element, attributes); 
     530                        break; 
     531                default: 
     532                        break; 
     533                } 
    489534        } 
    490535         
     
    509554        } 
    510555 
    511 #if 1 
     556        Intersectable::NewMail(); 
     557 
     558        mPvsTimer.Entry(); 
     559 
    512560        // TODO:  
    513561        // 1) find objects and add them to pvs 
     
    522570        { 
    523571                const int objId = *it;   
    524                 dummyInst.SetId(objId); 
    525  
    526                 // equal indeces possible! 
    527                 result = equal_range(mPvsObjects.begin(),  
    528                                                          mPvsObjects.end(),  
    529                                                          (Intersectable *)&dummyInst,  
    530                                                          ilt);   
    531  
    532                 ObjectContainer::const_iterator eit = result.first; 
    533  
    534                 for (; eit != result.second; ++ eit) 
    535                 { 
    536                         pvs.AddSample(*eit, 1.0f); 
    537                 } 
    538         } 
    539  
     572         
     573#if USE_HASH_COMPARE 
     574                pvs_hash::iterator oit = mHashPvs.find(objId); 
     575 
     576                if ((oit != mHashPvs.end()) && ((*oit).second->GetId() == objId)) 
     577                { 
     578                        pvs.AddSample((*oit).second, 1.0f); 
     579                } 
    540580#else 
    541  
    542         // TODO:  
    543         // 1) find objects and add them to pvs 
    544         // 2) get view cell with specified id 
    545         MeshInstance dummyInst(NULL); 
    546  
    547         vector<int>::const_iterator it, it_end = objIndices.end(); 
    548         for (it = objIndices.begin(); it != it_end; ++ it) 
    549         { 
    550                 const int objId = *it;   
     581#if 0 
    551582                dummyInst.SetId(objId); 
    552583 
     
    558589                if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 
    559590                { 
    560                         // $$JB we should store a float a per object which corresponds 
    561                         // to sumof pdfs, i.e. its relative visibility 
    562                         // temporarily set to 1.0f 
    563591                        pvs.AddSample(*oit, 1.0f); 
    564592                } 
    565                 else 
    566                 { 
    567                         Debug << "x"; 
    568                         //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 
    569                 } 
    570         } 
     593#else 
     594                pvs.AddSample(mPvsObjects[objId], 1.0f); 
    571595#endif 
     596#endif 
     597        } 
     598         
     599        mPvsTimer.Exit(); 
    572600} 
    573601 
     
    814842{ 
    815843        ViewCell *viewCell = NULL; 
    816          
    817844        const int len = attributes.getLength(); 
    818845        float mergeCost; 
     
    841868                        viewCell->SetId(id); 
    842869 
    843                         if (mCurrentViewCell) // replace front or (if not NULL) back child 
    844                         {        
     870                        if (mCurrentViewCell)  
     871                        {       // replace front or (if not NULL) back child 
    845872                                ViewCellInterior *interior =  
    846873                                        static_cast<ViewCellInterior *>(mCurrentViewCell); 
     
    862889                        const char *ptr = attrValue.LocalForm(); 
    863890 
    864                         // note: id must come before pvs!  
     891                        // hack: assume that view cell id comes before pvs 
    865892                        // otherwise view cell is undefined 
    866893 
    867                         // hack: assume that view cell comes before pvs 
    868894                        StartViewCellPvs(viewCell->GetPvs(), ptr);  
    869895                        //StartViewCellPvs(pvs, ptr); 
     
    915941                for (vit = mViewCells.begin(); vit != vit_end; ++ vit, ++ i) 
    916942                { 
    917                         //if ((i % 1000) == 0) 
    918                         //      Debug << "\n exchanged " << i << " boxes" << endl; 
    919943                        ViewCell *vc = (*vit); 
    920944 
     
    13021326                { 
    13031327                        objects.push_back(*oit); 
    1304                         Debug << "x"; 
    13051328                } 
    13061329                else 
    13071330                { 
    1308                         Debug << "y"; 
    13091331                        //cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 
    13101332                } 
     
    14831505        } 
    14841506 
    1485         cout<<"parsed - will delete the parser"<<endl<<flush; 
    14861507        // 
    14871508        //  Delete the parser itself.  Must be done prior to calling Terminate, below. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h

    r2114 r2123  
    1111class BoundingBoxConverter; 
    1212class Environment; 
     13 
    1314 
    1415class ViewCellsParser: public Parser 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r2116 r2123  
    88#include "Mesh.h" 
    99#include "BoundingBoxConverter.h" 
    10  
     10#include "PerfTimer.h" 
     11#include <hash_map> 
    1112 
    1213namespace GtpVisibilityPreprocessor { 
     
    3031class BspNode; 
    3132 
     33/* 
     34struct pvs_hash_compare 
     35{ 
     36   enum 
     37   { 
     38      bucket_size = 4, 
     39      min_buckets = 8 
     40   }; 
     41 
     42   size_t operator()(Intersectable *a) const 
     43   { 
     44           size_t h = (size_t)(a->GetId());// % 2000; 
     45           return h; 
     46   } 
     47 
     48   bool operator()(int a, int b) const 
     49   { 
     50      return a < b; 
     51   } 
     52};*/ 
     53 
     54 
     55typedef stdext::hash_map<int, Intersectable *> pvs_hash; 
     56 
    3257 
    3358class ViewCellsParseHandlers: public HandlerBase 
     
    132157  int nObjects; 
    133158   
    134    
     159  PerfTimer mBoxTimer; 
     160  PerfTimer mPvsTimer; 
     161  PerfTimer mObjectTimer; 
     162 
     163  pvs_hash mHashPvs; 
     164 
    135165  //////////////////////////////// 
    136166 
    137167 
    138168  // Handlers for X3D 
    139    
     169 
     170  void CreateHashVector(); 
     171 
    140172  void StartBspLeaf(AttributeList& attributes); 
    141173  void StartBspInterior(AttributeList& attributes); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2116 r2123  
    33873387                while (oit.HasMoreEntries()) 
    33883388                { 
    3389                         const ObjectPvsEntry &entry = oit.Next(); 
    3390                         BvhNode *obj = static_cast<BvhNode *>(entry.mObject); 
     3389                        BvhNode *obj = static_cast<BvhNode *>(oit.Next()); 
    33913390 
    33923391                        if (!obj->IsRoot()) 
     
    34113410                        } 
    34123411                } 
    3413                  
     3412 
     3413                PvsData pvsData; 
    34143414                oit = leaf->GetViewCell()->GetPvs().GetIterator(); 
    34153415 
    34163416                while (oit.HasMoreEntries()) 
    34173417                { 
    3418                         const ObjectPvsEntry &entry = oit.Next(); 
    3419                         BvhNode *obj = static_cast<BvhNode *>(entry.mObject); 
     3418                        BvhNode *obj = static_cast<BvhNode *>(oit.Next(pvsData)); 
    34203419 
    34213420                        if (!obj->IsRoot()) 
     
    34263425                                if (!parent->Mailed(1)) 
    34273426                                { 
    3428                                         newPvs.AddSampleDirty(obj, entry.mData.mSumPdf); 
     3427                                        newPvs.AddSampleDirty(obj, pvsData.mSumPdf); 
    34293428                                } 
    34303429                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.cpp

    r2001 r2123  
    153153// return time diff. in ms 
    154154Real 
    155 TimeDiff(long time1,long time2) // in ms 
    156 { 
    157   //  const Real clk=1.0e-3f; // ticks per second 
     155TimeDiff(long time1, long time2) // in ms 
     156{ 
     157  const Real clk=1.0e-3f; // ticks per second 
    158158  // $$ tmp store time in ms 
    159   const Real clk=1.0f; // ticks per second 
     159  //const Real clk=1.0f; // ticks per second 
    160160  long t=time2-time1; 
    161161   
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.h

    r1757 r2123  
    330330long GetTime(); 
    331331long GetRealTime(); 
    332 Real TimeDiff(long t1,long t2); 
     332Real TimeDiff(long t1, long t2); 
    333333char *TimeString(); 
    334334 
Note: See TracChangeset for help on using the changeset viewer.