Changeset 1271


Ignore:
Timestamp:
08/24/06 08:55:05 (18 years ago)
Author:
mattausch
Message:

removed the visibility env, now explicitly giving the view cells as argument

Location:
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp

    r1268 r1271  
    8383// if we are recording a demo 
    8484static const bool DEMO_HACK = false; 
     85 
     86//using namespace GtpVisibility; 
    8587 
    8688//----------------------------------------------------------------------- 
     
    109111mVisibilityThreshold(0), 
    110112mAssumedVisibility(0), 
    111 #if 1 
    112113mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 
    113 #else 
    114 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 
    115 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING), 
    116 #endif 
    117114mNodeVizMode(NODEVIZ_NONE), 
    118115mVizCameraHeight(Real(4000.0)), 
     
    181178        mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 
    182179         
     180 
    183181        //-- overlays 
    184182         
     
    217215        } 
    218216 
    219         // loading overlay 
    220  
     217        // loading view cells overlay 
    221218        mLoadingOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/LoadingOverlay"); 
    222219        mMyLoadingInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Loading/MyLoadingInfo"); 
    223220        mMyLoadingInfo->setCaption("loading view cells ..."); 
    224          
    225         /*const int top = 10; 
    226                 mMyStatsAlgorithmInfo->setTop(top); 
    227  
    228                 char str[100]; sprintf(str,": %d", 0); 
    229                 mMyStatsFpsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/MyFpsInfo"); 
    230                 mMyStatsFpsInfo->setCaption(str);*/ 
     221 
    231222 
    232223        mLoadingOverlay->hide(); 
     
    241232        mSceneMgr->setOption("NodeVizScale", &mVizScale); 
    242233                 
    243         //-- set culling algorithm type 
    244         setAlgorithm(mCurrentAlgorithm); 
     234        //-- set the current culling algorithm type 
     235        setAlgorithm(mApplication->mAlgorithm); 
    245236 
    246237        // set scene manager options 
     
    253244        mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 
    254245         
    255         setObjectType(mCurrentObjectType); 
     246        applyObjectType(); 
    256247 
    257248        // initialise timer 
     
    983974        mCurrentAlgorithm = (mCurrentAlgorithm + 1) %  
    984975                GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 
    985         setAlgorithm(mCurrentAlgorithm); 
    986 } 
    987 //----------------------------------------------------------------------- 
    988 void TerrainFrameListener::setObjectType(int objectType) 
     976        applyCurrentAlgorithm(); 
     977} 
     978//----------------------------------------------------------------------- 
     979void TerrainFrameListener::applyObjectType() 
    989980{ 
    990981        if (mCurrentObjectType >= 3) // TODO: define a constant 
     
    999990} 
    1000991//----------------------------------------------------------------------- 
    1001 void TerrainFrameListener::setAlgorithm(int algorithm) 
     992void TerrainFrameListener::applyCurrentAlgorithm() 
    1002993{ 
    1003994        mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]); 
     
    11841175//----------------------------------------------------------------------- 
    11851176void TerrainFrameListener::toggleUseViewCells() 
    1186 {LogManager::getSingleton().logMessage("here52"); 
     1177{ 
    11871178        // HACK: no view cells for hilly terrain 
    11881179        if (mApplication->msShowHillyTerrain) 
     
    14091400         
    14101401        case KC_F7: 
    1411                 setObjectType(++ mCurrentObjectType); 
     1402                ++ mCurrentObjectType; 
     1403                applyObjectType(); 
    14121404                break; 
    14131405        #endif 
     
    18491841        int top = border_height + 25; 
    18501842 
    1851         String ext = "Example/Visibility/Query/"; 
     1843        const String ext = "Example/Visibility/Query/"; 
    18521844             
    18531845        initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top,     ": 0"); top += vert_space; 
     
    18671859        queryPanel->setHeight(top + border_height); 
    18681860} 
     1861//----------------------------------------------------------------------- 
     1862void TerrainFrameListener::setAlgorithm(const int algorithm) 
     1863{ 
     1864        mCurrentAlgorithm = algorithm; 
     1865        applyCurrentAlgorithm(); 
     1866} 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h

    r945 r1271  
    164164   void setCurrentFrameInfo(Real timeElapsed); 
    165165 
    166    void setAlgorithm(int algorithm); 
     166   void applyCurrentAlgorithm(); 
    167167 
    168168   void moveCamera(); 
     
    244244        /** Sets the type of the objects generated in the scene. 
    245245        */ 
    246         void setObjectType(int objectType); 
     246        void applyObjectType(); 
     247 
     248        void setAlgorithm(const int algorithm); 
     249 
    247250 
    248251        static String msAlgorithmCaptions[]; 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp

    r1268 r1271  
    2525 
    2626 
     27//using namespace GtpVisibility; 
    2728 
    2829/*************************************************************/ 
     
    165166mIVReader(NULL), 
    166167mFilename("terrain"), 
    167 mEnvironmentFilename("generate_viewcells.env") 
     168mViewCellsFilename(""), 
     169mAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
    168170{ 
    169171} 
     
    191193 
    192194         
    193         /*val = config.getSetting("ViewCells"); 
     195        val = config.getSetting("ViewCells"); 
     196 
    194197        if (!val.empty()) 
    195         {        mViewCellsFilename = val.c_str();}*/ 
    196  
    197         val = config.getSetting("VisibilityEnvironment"); 
    198  
    199         if (!val.empty()) 
    200         { 
    201                  mEnvironmentFilename = val.c_str(); 
    202                  std::stringstream d; d << "loading environment from file: " << mEnvironmentFilename; 
     198        { 
     199                 mViewCellsFilename = val.c_str(); 
     200                 std::stringstream d; d << "view cells file name: " << mViewCellsFilename; 
    203201                 LogManager::getSingleton().logMessage(d.str()); 
    204202        } 
     
    222220 
    223221 
     222        val = config.getSetting("OnlineCullingAlgorithm"); 
     223 
     224        if (!val.empty()) 
     225        { 
     226                 if (val == "CHC") 
     227                 { 
     228                         mAlgorithm =  
     229                                 GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 
     230                 } 
     231                 else if (val == "SWC") 
     232                 { 
     233                         mAlgorithm =  
     234                                 GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING; 
     235                 } 
     236                 else if (val == "VFC") 
     237                 { 
     238                         mAlgorithm =  
     239                                 GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING; 
     240                 } 
     241        } 
     242 
    224243        ///////////////////////// 
    225244        // setup scene 
    226245 
    227246        //-- load the scene from specified file 
    228 LogManager::getSingleton().logMessage("here5112"); 
    229247        if (!LoadScene(mFilename)) 
    230                 LogManager::getSingleton().logMessage("error loading scene"); 
    231  
    232 LogManager::getSingleton().logMessage("here6"); 
    233         GtpVisibility::VisibilityManager *mVisManager = NULL; 
    234  
    235         //-- load the environment from file 
    236         if (mSceneMgr->getOption("VisibilityManager", &mVisManager)) 
    237         { 
    238                 LogManager::getSingleton().logMessage("here7"); 
    239                 GtpVisibility::VisibilityEnvironment *visEnv = mVisManager->GetVisibilityEnvironment(); 
    240                 LogManager::getSingleton().logMessage("here7.04"); 
    241                 if (!visEnv->LoadEnvironment(mEnvironmentFilename)) 
    242                 {LogManager::getSingleton().logMessage("here7.l2"); 
    243                         std::stringstream d; d << "failed loading environment from " << mEnvironmentFilename; 
    244                         LogManager::getSingleton().logMessage(d.str()); 
    245                 } 
    246                 else //-- load environment options 
    247                 {LogManager::getSingleton().logMessage("here8"); 
    248                         //-- get view cells file name, load view cells only on demand 
    249                         mViewCellsFilename = visEnv->getViewCellsFileName(); 
    250  
    251                         std::stringstream d; d << "view cells file name: " << mViewCellsFilename; 
    252                         LogManager::getSingleton().logMessage(d.str()); 
    253                 } 
    254         } 
    255         else 
    256         { 
    257                 LogManager::getSingleton().logMessage("error: no visibility scenemanager available"); 
    258         } 
    259 LogManager::getSingleton().logMessage("here9"); 
     248        { 
     249        LogManager::getSingleton().logMessage("error loading scene"); 
     250        } 
     251         
    260252        // set camera position accordingly 
    261253        mCamNode->setPosition(v); 
     
    477469        mSunLight->setCastShadows(true); 
    478470 
    479         // set light angle not too small over the surface, otherwise shadows textures will be broken 
     471        // set light angle not too small over the surface,  
     472        // otherwise shadows textures will be broken 
    480473        Vector3 dir(0.5, 1, 0.5); 
    481474        dir.normalise(); 
     
    490483        ColourValue fadeColour(0.93, 0.86, 0.76); 
    491484        mWindow->getViewport(0)->setBackgroundColour(fadeColour); 
    492         //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 
     485        //mSceneMgr->setFog(FOG_LINEAR, fadeColour, .001, 500, 1000); 
    493486         
    494487        // Create a skybox 
    495488        mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 
    496489         
     490        // terrain creation 
    497491        if (msShowHillyTerrain) 
    498492        { 
     
    505499         
    506500 
    507         //-- CEGUI setup 
    508         setupGui(); 
     501        setupGui(); //-- CEGUI setup 
    509502 
    510503        // occluder plane to test visibility 
     
    530523        mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 
    531524 
     525 
    532526        //-- terrain content setup 
    533527 
    534         // HACK: necessary to call once before the content creation for 
    535         // terrain initialisation 
     528        // HACK: necessary to call once here for terrain initialisation 
    536529        mSceneMgr->_renderScene(mCamera, mWindow->getViewport(0), true); 
    537530 
     
    634627void TestCullingTerrainApplication::createFrameListener() 
    635628{ 
    636         mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr,  
    637                 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this); 
     629        mTerrainFrameListener =  
     630                new TerrainFrameListener(mWindow,  
     631                                                                 mCamera,  
     632                                                                 mSceneMgr,  
     633                                                                 mGUIRenderer,  
     634                                                                 mTerrainContentGenerator,  
     635                                                                 mVizCamera,  
     636                                                                 mCamNode,  
     637                                                                 mSunLight,  
     638                                                                 this); 
    638639         
    639640        mRoot->addFrameListener(mTerrainFrameListener); 
     
    655656        if (msShowHillyTerrain) 
    656657        { 
     658                mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
    657659                //mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 
    658                 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
    659660                //mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager"); 
    660661        } 
    661662        else 
    662663        {        
     664                mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
    663665                //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 
    664                 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
    665666                //mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager"); 
    666667        } 
     
    741742        return (int)filenames.size(); 
    742743} 
    743  
    744744//----------------------------------------------------------------------- 
    745745bool TestCullingTerrainApplication::LoadScene(const String &filename) 
     
    757757        vector<string>::const_iterator fit, fit_end = filenames.end(); 
    758758        int i = 0; 
    759         // root for different files 
     759 
    760760        for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i) 
    761761        { 
     
    764764                if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl")) 
    765765                { 
    766                         // hack: set postion manually for vienna 
    767                         //mCamNode->setPosition(Vector3(830, 300, -540)); 
    768                         //mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 
    769  
    770766                        // load iv files 
    771767                        if (!LoadSceneIV(fn, mSceneMgr->getRootSceneNode(), i)) 
     
    773769                                // terrain hack 
    774770                                msShowHillyTerrain = true; 
    775                                 LogManager::getSingleton().logMessage("error loading scene. loading terrain instead"); 
     771                                LogManager::getSingleton().logMessage("error loading scene => load terrain"); 
    776772                        } 
    777                         LogManager::getSingleton().logMessage("here521"); 
    778773                } 
    779774                else if (strstr(filename.c_str(), ".dae")) 
     
    793788        } 
    794789         
    795  
    796         /* 
    797         if (result)  
    798         { 
    799                 int intersectables, faces; 
    800  
    801           std::stringstream d; 
    802           d << filename << " parsed successfully.\n" 
    803                 << "#NUM_OBJECTS (Total numner of objects)\n" << intersectables << "\n" 
    804                 << "#NUM_FACES (Total numner of faces)\n" << faces << "\n"; 
    805         } 
    806         */ 
    807          
    808790        return result; 
    809791} 
     
    847829    mSceneMgr->setOption("PrepareVisualization", &showViz); 
    848830        mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 
    849         //mSceneMgr->setOption("SkyPlaneEnabled", &showViz); 
    850831         
    851832        RenderTargetListener::preViewportUpdate(evt); 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h

    r1003 r1271  
    137137        */ 
    138138        void loadConfig(const String& filename); 
    139          
     139 
     140 
    140141        /// if hilly terrain should be loaded 
    141142        static bool msShowHillyTerrain; 
    142  
    143143 
    144144        String mFilename; 
     
    146146        /// name of the visibility environment file 
    147147        String mEnvironmentFilename; 
     148         
     149        int mAlgorithm; 
     150 
    148151 
    149152protected: 
     
    192195         
    193196        StaticGeometry *mStaticGeometry; 
    194  
    195          
     197     
    196198 
    197199private: 
Note: See TracChangeset for help on using the changeset viewer.