Ignore:
Timestamp:
08/18/06 17:25:57 (18 years ago)
Author:
szydlowski
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp

    r1215 r1220  
    3030                                .addOpt("l","logfile", ARGUMENT_REQUIRED) 
    3131                                .addOpt("d","demomode", ARGUMENT_NONE) 
     32                                .addOpt("","buildmode", ARGUMENT_REQUIRED) 
    3233                                .addOpt("","maxdepth", ARGUMENT_REQUIRED) 
    3334                                .addOpt("","kt", ARGUMENT_REQUIRED) 
     
    4950                        std::stringstream s; 
    5051 
     52                        if (cmdparser.getOpt("buildmode", tmp)) 
     53                        { 
     54                                int bm = KdTree::KDBM_NOTSET; 
     55                                for (int i = 0; i < KdTree::KDBM_SIZE; i ++) 
     56                                { 
     57                                        if (tmp == KdTreeAppListener::BUILDMETHOD[i]) 
     58                                                bm = i; 
     59                                } 
     60                                if (bm != KdTree::KDBM_NOTSET) 
     61                                { 
     62                                        options.mBuildMethod = bm; 
     63                                } 
     64                                else 
     65                                { 
     66                                        MessageBox(NULL, ("Invalid argument for option --buildmode: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 
     67                                        return -1; 
     68                                } 
     69                        } 
     70 
    5171                        if (cmdparser.getOpt("maxdepth", tmp)) 
    5272                        { 
     
    7292                        if (cmdparser.getOpt("r",tmp)) 
    7393                        { 
    74                                 if (tmp == "INT" || tmp == "VFC" || tmp == "SWC" || tmp == "CHC") 
    75                                 { 
    76                                         options.mRenderMethod = tmp; 
     94                                int rm = KdTree::KDRM_NOTSET; 
     95                                for (int i = 0; i < KdTree::KDRM_SIZE; i ++) 
     96                                { 
     97                                        if (tmp == KdTreeAppListener::RENDERMETHOD[i]) 
     98                                                rm = i; 
     99                                } 
     100                                if (rm != KdTree::KDRM_NOTSET) 
     101                                { 
     102                                        options.mRenderMethod = rm; 
    77103                                } 
    78104                                else 
    79105                                { 
    80                                         MessageBox(NULL, ("Invalid argument for option --rendermethod: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 
     106                                        MessageBox(NULL, ("Invalid argument for option --rendermode: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 
    81107                                        return -1; 
    82108                                } 
     
    85111                        if (cmdparser.getOpt("s",tmp)) 
    86112                        { 
    87                                 if (tmp == "KDT" || tmp == "OCT" || tmp == "OCM" || tmp == "GEN") 
    88                                 { 
    89                                         options.mSceneManager = tmp; 
     113                                int sm = KdTreeAppListener::SM_NOTSET; 
     114                                for (int i = 0; i < KdTreeAppListener::SM_SIZE; i ++) 
     115                                { 
     116                                        if (tmp == KdTreeAppListener::SCENEMANAGER[i]) 
     117                                                sm = i; 
     118                                } 
     119                                if (sm != KdTreeAppListener::SM_NOTSET) 
     120                                { 
     121                                        options.mSceneManager = sm; 
    90122                                } 
    91123                                else 
     
    149181        cfDeath.load("testKdTree.cfg"); 
    150182 
    151         mSelectedSceneManager = cfDeath.getSetting("scenemanager"); 
    152183        mSceneFiles = cfDeath.getSetting("scene"); 
    153184 
     
    194225                mOptions.mDemoOutfileName = cfDeath.getSetting("demooutfile"); 
    195226 
    196         // set default demo output name to avoid SNAFUs 
    197         //if (mOptions.mDemoOutfileName.empty()) 
    198         //      mOptions.mDemoOutfileName = "demo.bin"; 
    199  
    200227        if (mOptions.mDemoLogfileName.empty()) 
    201228                mOptions.mDemoLogfileName = cfDeath.getSetting("demologfile"); 
    202  
    203         // set default demo logfile name to avoid SNAFUs 
    204         //if (mOptions.mDemoLogfileName.empty()) 
    205         //      mOptions.mDemoLogfileName = "demo.csv"; 
    206  
    207         // override scene manager set in config file 
    208         if (!mOptions.mSceneManager.empty()) 
    209         { 
    210                 if (mOptions.mSceneManager == "KDT") 
    211                         mSelectedSceneManager = "KdTreeSceneManager"; 
    212                 else if (mOptions.mSceneManager == "OCT") 
    213                         mSelectedSceneManager = "OctreeSceneManager"; 
    214                 else if (mOptions.mSceneManager == "OCM") 
    215                         mSelectedSceneManager = "OcclusionCullingSceneManager"; 
    216                 else if (mOptions.mSceneManager == "GEN") 
    217                         mSelectedSceneManager = "DefaultSceneManager"; 
    218         } 
    219         // the other way round for log 
    220         else 
    221         { 
    222                 if (mSelectedSceneManager == "KdTreeSceneManager") 
    223                         mOptions.mSceneManager = "KDT"; 
    224                 else if (mSelectedSceneManager == "OctreeSceneManager") 
    225                         mOptions.mSceneManager = "OCT"; 
    226                 else if (mSelectedSceneManager == "OcclusionCullingSceneManager") 
    227                         mOptions.mSceneManager = "OCM"; 
    228                 else if (mSelectedSceneManager == "DefaultSceneManager") 
    229                         mOptions.mSceneManager = "GEN"; 
    230         } 
    231229 
    232230        ExampleApplication::setupResources(); 
     
    416414{ 
    417415        // Get the SceneManager 
    418         mSceneMgr = mRoot->createSceneManager(mSelectedSceneManager,"MySceneManager"); 
    419         // set params 
    420         mSceneMgr->setOption("KdTreeMaxDepth", &mOptions.mMaxDepth); 
    421         mSceneMgr->setOption("KT", &mOptions.mKT); 
    422         mSceneMgr->setOption("KI", &mOptions.mKI); 
    423         mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 
    424         mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility); 
     416        mSceneMgr = mRoot->createSceneManager( 
     417                KdTreeAppListener::SCENEMANAGERNAME[mOptions.mSceneManager], 
     418                "MySceneManager"); 
     419        // set params depending on scene manager 
     420        if (mOptions.mSceneManager == KdTreeAppListener::SM_KDT) 
     421        { 
     422                mSceneMgr->setOption("BuildMethod", &mOptions.mBuildMethod); 
     423                mSceneMgr->setOption("KdTreeMaxDepth", &mOptions.mMaxDepth); 
     424                mSceneMgr->setOption("KT", &mOptions.mKT); 
     425                mSceneMgr->setOption("KI", &mOptions.mKI); 
     426                mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 
     427                mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility); 
     428        } 
     429        // set algorithm when scene manager is OCM - numbering is different though 
     430        if (mOptions.mSceneManager == KdTreeAppListener::SM_OCM) 
     431        { 
     432                int alg = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod); 
     433                mSceneMgr->setOption("Algorithm", &alg); 
     434        } 
    425435} 
    426436 
     
    452462        mTopCam->setDirection(0,0,-1); 
    453463        mTopCam->pitch(Radian(-Math::HALF_PI)); 
    454         //mTopCam->setCullingFrustum(mCamera); 
     464        mTopCam->setCullingFrustum(mCamera); 
    455465        mTopCam->setNearClipDistance(1); 
    456466 
Note: See TracChangeset for help on using the changeset viewer.