Changeset 1300 for GTP


Ignore:
Timestamp:
08/30/06 15:10:48 (18 years ago)
Author:
szydlowski
Message:

view cells load/use implemented

Location:
GTP/trunk/App/Demos/Vis/KdTreeDemo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTree.h

    r1296 r1300  
    5050        void createTerrainScene(Real max_x, Real max_y, Real max_z); 
    5151        Vector3 clampToGround(const Vector3& vect, Real offset, Real cap); 
     52 
     53        const String& getViewCellsFileName() const { return mViewCells; } 
    5254protected: 
    5355        KdTreeAppListener *mFrameListener; 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h

    r1296 r1300  
    100100        }; 
    101101 
     102        enum ViewCellsMode 
     103        { 
     104                VCM_OFF, 
     105                VCM_ON, 
     106                VCM_FILTER, 
     107                VCM_SIZE, 
     108                VCM_NOTSET 
     109        }; 
     110 
    102111        enum ShowTree 
    103112        { 
     
    128137                mBuildMethod(KdTree::KDBM_PRIORITYQUEUE), 
    129138                mSceneType(ST_SIMPLE), 
     139                mViewCells(VCM_OFF), 
    130140                mFastStart(false), 
    131141                mBurnIn(false), 
     
    153163                int mBuildMethod; 
    154164                int mSceneType; 
     165                int mViewCells; 
    155166                bool mFastStart; 
    156167                bool mBurnIn; 
     
    248259 
    249260        // view cells 
     261        bool mViewCellsLoaded; 
    250262        bool mUseViewCells; 
    251263        bool mUseVisibilityFilter; 
     
    268280        Overlay *mDebugOverlay; 
    269281        Overlay *mKdTreeOverlay; 
    270  
     282        Overlay *mLoadingOverlay; 
     283 
     284        OverlayElement *mMyLoadingInfo; 
    271285        OverlayElement *mDemoStatus; 
    272286        TextAreaOverlayElement *mDemoTime; 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp

    r1296 r1300  
    4141                                .addOpt("","savesceneto", ARGUMENT_REQUIRED) 
    4242                                .addOpt("f","faststart", ARGUMENT_NONE) 
    43                                 .addOpt("b","burnin", ARGUMENT_NONE); 
     43                                .addOpt("b","burnin", ARGUMENT_NONE) 
     44                                .addOpt("v","viewcells", ARGUMENT_OPTIONAL); 
    4445 
    4546 
     
    135136                        } 
    136137 
     138                        if (cmdparser.getOpt("v",tmp)) 
     139                        { 
     140                                if (tmp == "0") 
     141                                        options.mViewCells = KdTreeAppListener::VCM_OFF; 
     142                                else if (tmp == "" || tmp == "1") 
     143                                        options.mViewCells = KdTreeAppListener::VCM_ON; 
     144                                else if (tmp == "2") 
     145                                        options.mViewCells = KdTreeAppListener::VCM_FILTER; 
     146                                else 
     147                                { 
     148                                        MessageBox(NULL, ("Invalid argument for option --viewcells: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 
     149                                        return -1; 
     150                                } 
     151 
     152                        } 
    137153                } 
    138154                catch (std::string s) 
     
    328344                        mTopCam->setPosition(Vector3(1232, 3990, -1477)); 
    329345 
    330                         // try loading view cells if specified and if scene manager supports it 
    331                         if (!mViewCells.empty()) 
    332                                 mSceneMgr->setOption("LoadViewCells", mViewCells.c_str()); 
     346                        //// try loading view cells if specified and if scene manager supports it 
     347                        //if (!mViewCells.empty()) 
     348                        //      mSceneMgr->setOption("LoadViewCells", mViewCells.c_str()); 
    333349 
    334350                        // sky box 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp

    r1296 r1300  
    114114mShowTree(SHOWTREE_OFF), 
    115115// view cells 
     116mViewCellsLoaded(false), 
    116117mUseViewCells(false), 
    117118mUseVisibilityFilter(false), 
     
    167168        mCamNode = sm->getSceneNode("PlayerCamNode"); 
    168169 
    169         sm->getOption("UseViewCells", &mUseViewCells); 
    170         sm->getOption("UseVisibilityFilter", &mUseVisibilityFilter); 
    171  
    172170        mRaySceneQuery = mSceneMgr->createRayQuery(Ray(mCamNode->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 
    173171 
     
    178176        mDemoTime = 0; 
    179177 
     178        // loading view cells overlay 
     179        mLoadingOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/LoadingOverlay"); 
     180        mMyLoadingInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Loading/MyLoadingInfo"); 
     181        mMyLoadingInfo->setCaption("loading view cells ..."); 
     182 
     183        mLoadingOverlay->hide(); 
     184 
    180185        initKdTreeOverlay(); 
    181186        initStatsOverlay(); 
     187 
     188        // set view cells 
     189        if (mOptions.mSceneType == ST_GEOMETRY) 
     190        { 
     191                switch(mOptions.mViewCells) 
     192                { 
     193                case VCM_ON: 
     194                        toggleUseViewCells(); 
     195                        break; 
     196                case VCM_FILTER: 
     197                        toggleUseViewCells(); 
     198                        toggleUseVisibilityFilter(); 
     199                        break; 
     200                } 
     201        } 
    182202 
    183203        if (!mOptions.mDemoInfileName.empty()) 
     
    326346                sTC = ": Free"; 
    327347 
    328         if (mSceneMgr->getOption("UseViewCells", &mUseViewCells)) 
     348        if (mSceneMgr->getOption("UseViewCells", &mUseViewCells) && mOptions.mSceneType == ST_GEOMETRY) 
    329349        { 
    330350                if (mUseViewCells) 
     
    335355        else 
    336356        { 
    337                 sVC = NA; 
    338         } 
    339  
    340         if (mSceneMgr->getOption("UseVisibilityFilter", &mUseVisibilityFilter)) 
     357                if (mOptions.mSceneType == ST_GEOMETRY && mOptions.myApp->getViewCellsFileName() != "" &&  
     358                        (mOptions.mSceneManager == SM_KDT ||  
     359                         mOptions.mSceneManager == SM_KTE ||  
     360                         mOptions.mSceneManager == SM_OCM)) 
     361                { 
     362                        sVC = ": off"; 
     363                } 
     364                else 
     365                { 
     366                        sVC = NA; 
     367                } 
     368        } 
     369 
     370        if (mSceneMgr->getOption("UseVisibilityFilter", &mUseVisibilityFilter) && mOptions.mSceneType == ST_GEOMETRY) 
    341371        { 
    342372                if (mUseVisibilityFilter) 
     
    347377        else 
    348378        { 
    349                 sVF = NA; 
     379                if (mOptions.mSceneType == ST_GEOMETRY && mOptions.myApp->getViewCellsFileName() != "" &&  
     380                        (mOptions.mSceneManager == SM_KDT ||  
     381                         mOptions.mSceneManager == SM_KTE ||  
     382                         mOptions.mSceneManager == SM_OCM)) 
     383                { 
     384                        sVF = ": off"; 
     385                } 
     386                else 
     387                { 
     388                        sVF = NA; 
     389                } 
    350390        } 
    351391 
     
    387427void KdTreeAppListener::toggleUseViewCells() 
    388428{ 
     429        // viewcells apply only for scenes loaded from geometry 
     430        if (mOptions.mSceneType != ST_GEOMETRY) 
     431                return; 
     432 
    389433        mUseViewCells = !mUseViewCells; 
     434 
     435 
     436        // load on demand 
     437        if (mUseViewCells && !mViewCellsLoaded) 
     438        { 
     439                mLoadingOverlay->show(); 
     440 
     441                // call once to load view cell loading overlay 
     442                mWindow->update(); 
     443                mViewCellsLoaded = mSceneMgr->setOption("LoadViewCells", mOptions.myApp->getViewCellsFileName().c_str()); 
     444 
     445                if (!mViewCellsLoaded) 
     446                { 
     447                        LogManager::getSingleton().logMessage("#@#@ Error: loading view cells from " +  
     448                                mOptions.myApp->getViewCellsFileName() + " failed."); 
     449                } 
     450 
     451                mLoadingOverlay->hide(); 
     452        } 
     453 
    390454        if (mSceneMgr->setOption("UseViewCells", &mUseViewCells)) 
    391455        { 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/README.txt

    r1296 r1300  
    3131  -b, --burnin 
    3232    Run a burn-in demo, i.e. loop the demo until ESC is pressed. Requires 
    33     --demomode. If --logfile is specified, the result of each run will be saved. 
     33    --demomode. When --logfile is specified, the result of each run will be 
     34    saved. 
    3435 
    3536  -s <sm_id>, --scenemgr <sm_id> 
     
    5253    no effect. For supported scene managers, render mode switching is also 
    5354    available ingame (see INGAME COMMANDS). 
     55     
     56  -v [mode], --viewcells [mode] 
     57    Set view cell mode. Applies only to scenes where view cells can be loaded 
     58    (see CONFIG FILE), otherwise has no effect. [mode] is optional. 
     59    Valid values for [mode] are: 
     60      0 ... do not use view cells for visibility (same as ommiting -v) 
     61      1 ... use view cells for visibility (same as -v without parameter) 
     62      2 ... use view cells and visibility filter 
     63    These setting can also be changeg ingame (see INGAME COMMANDS). 
    5464 
    5565  --comment 
     
    107117            following formats: 
    108118              .iv, .wrl:  Mesh files like the vienna scene. 
    109               .cfg:       Config files for terrain creation. You need to specify 
    110                           an appropriate scene manager which supports terrain 
    111                           world geometry rendering (KTE, OCM, TER). 
     119              .cfg:       Config files for terrain creation. You need to 
     120                          specify an appropriate scene manager which supports 
     121                          terrain world geometry rendering (KTE, OCM, TER). 
    112122              .txt:       Text file created by the application which store 
    113123                          positions of entites (small movable objects) 
     
    134144            on enables shadows 
    135145    selectentities: 
    136             Sum up the following numbers to select which entities will appear in 
    137             the scene: 
     146            Sum up the following numbers to select which entities will appear 
     147            in the scene: 
    138148              1  robots in grid 
    139149              2  randomly placed robots 
     
    186196    R     Toggle OpenGL/Direct3D render mode (Full, Line, Point) 
    187197    T     Toggle OpenGL/Direct3D texture filtering (Bilinear, Trilinear, Aniso) 
    188     C     Toggle use view cells from PVS (need to load them first) 
     198    C     Toggle use view cells from PVS (load on demand) 
    189199    X     Toggle use visibility filter (whatever that is) 
    190200 
     
    212222  If the demo shall be permanently stored, the program must be launched with 
    213223  the --outfile option, specifying a file to which the demo will be saved. The 
    214   file name must have on of the above mentioned extensions. If the file allready 
    215   exists and a demo is saved, it will be overwritten. To save a recorded demo, 
    216   simply press F6 to store it in the file. If a demo has been allready stored in 
    217   this session, it will be overwritten. 
     224  file name must have on of the above mentioned extensions. If the file 
     225  allready exists and a demo is saved, it will be overwritten. To save a 
     226  recorded demo, simply press F6 to store it in the file. If a demo has been 
     227  allready stored in this session, it will be overwritten. 
    218228  It is recommended to limit the framerate of the application (e.g. by enabling 
    219229  vsync) when recording a demo, since it will produce smaller files. 
    220230  To load a demo from a file, specify it with the --infile command line option. 
    221231  To run a benchmark, a prerecorded demo must be loaded. Also, a logfile has to 
    222   be specified using the --logfile option. Finally the --demomode option must be 
    223   set. The program starts with disabled user input and no overlays. After an 
     232  be specified using the --logfile option. Finally the --demomode option must 
     233  be set. The program starts with disabled user input and no overlays. After an 
    224234  initial 5 second delay, to stabilize the framerate and preload the scene, the 
    225235  demo is played back and the framerate and other statistics are recored. Then 
     
    237247  If the specified logfile does not exist, it is created including the headers. 
    238248  If a log file with the specified name does exists, it is checked if the demo 
    239   file used in the logfile corresponds with the demo file used in this benchmark 
    240   run. If the names do not match, or if the logfile cannot be read or written 
    241   to, the demo is executed but no stats are written. Additionaly, an error 
    242   message is written in "Ogre.log". However, if the log file exists and the demo 
    243   name matches, the resulst are appended to the existing logfile, allowing for 
    244   easy comparison of different settings and options. 
     249  file used in the logfile corresponds with the demo file used in this 
     250  benchmark run. If the names do not match, or if the logfile cannot be read or 
     251  written to, the demo is executed but no stats are written. Additionaly, an 
     252  error message is written to "Ogre.log". However, if the log file exists and 
     253  the demo name matches, the resulst are appended to the existing logfile, 
     254  allowing for easy comparison of different settings and options. 
    245255 
    246256BUGS 
    247   Kills my PC occasionally when running a long demo with KTE and CHC in the 
    248   terrain scene. Reason completely mysterious. Happend twice so far. 
     257  Mysterious and serious (sometimes bluescreen) crashes due to an error in the 
     258  nVidia display driver (nv4_disp.dll). Occur with the following combination: 
     259  Direct3D Render Manager + terrain rendering with OCM or KTE +  
     260  hardware occlusion culling enabled (CHC, possibly also SWC) + demo playback. 
     261  Not tested on other hardware (e.g. ATI cards). Not exactly repeatable, 
     262  crashes in different places during playback or not at all. 
    249263 
    250264AUTHOR 
Note: See TracChangeset for help on using the changeset viewer.