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

worded on obj loading in Ogre

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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); 
Note: See TracChangeset for help on using the changeset viewer.