source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp @ 731

Revision 731, 5.2 KB checked in by igarcia, 18 years ago (diff)
Line 
1
2#include "IBRBillboardCloudTreeApplication.h"
3
4IBRBillboardCloudTreeApplication::IBRBillboardCloudTreeApplication()
5{
6}
7
8IBRBillboardCloudTreeApplication::~IBRBillboardCloudTreeApplication()
9{       
10        // Gametools -- BUG: 31/03/2006
11        //if (mLBBCManager)
12        //{
13        //      delete mLBBCManager;
14        //}
15}
16
17void IBRBillboardCloudTreeApplication::initialize()
18{
19        for (unsigned int i = 0; i < 1; i++)
20        {
21                mSampleConfigFile = new LBBC::SampleConfigFile();
22                mSampleConfigFile->load(mOpts.cfg);
23
24                this->setup(false);
25                mLBBCManager = new LBBC::LBBCManager();
26                mLBBCManager->setSampleConfigFile(mSampleConfigFile);   
27                //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
28                mLBBCManager->runSampleConfigFile();   
29                mLBBCManager->shutdown();
30                delete mLBBCManager;
31                mOgreBase->shutdown();         
32                delete mOgreBase;
33                //----------------------------------------------------------------------------
34                this->setup(true);
35                this->go();     
36                for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++)
37                {
38                        mFrameListener->getFrameListenerMode(iFrameListenerMode)->destroyScene();
39                }
40                mRoot->shutdown();     
41                mWindow->destroy();             
42                delete mRoot;
43                delete mSampleConfigFile;
44        }
45
46}
47
48int IBRBillboardCloudTreeApplication::findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,
49                                                Ogre::BinaryOptionList& binOptList)
50{
51    int startIndex = 1;
52    for (int i = 1; i < numargs; ++i)
53    {
54                Ogre::String tmp(argv[i]);
55                if (Ogre::StringUtil::startsWith(tmp, "-"))
56        {
57                        Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
58            if(ui != unaryOptList.end())
59            {
60                ui->second = true;
61                ++startIndex;
62                continue;
63            }
64                        Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]);
65            if(bi != binOptList.end())
66            {
67                bi->second = argv[i+1];
68                startIndex += 2;
69                ++i;
70                continue;
71            }
72
73            // Invalid option
74                        std::cout<<"Invalid option "<<tmp<<std::endl;
75
76        }
77    }
78    return startIndex;
79}
80
81void IBRBillboardCloudTreeApplication::help()
82{
83        std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl;
84}
85
86void IBRBillboardCloudTreeApplication::parseArgs(int numArgs, char **args)
87{
88        if (numArgs < 2)
89    {
90        help();
91        exit(-1);
92    }
93        else
94        {
95                Ogre::UnaryOptionList unOpt;
96                Ogre::BinaryOptionList binOpt;
97
98                binOpt["-cfg"] = "";
99           
100                int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
101                Ogre::UnaryOptionList::iterator ui;
102                Ogre::BinaryOptionList::iterator bi;
103               
104                bi = binOpt.find("-cfg");
105                if (!bi->second.empty())
106                {
107                        mOpts.cfg = bi->second;
108                }       
109        }
110}
111
112void IBRBillboardCloudTreeApplication::createFrameListener(void)
113{
114        mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
115       
116        mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();   
117
118        {
119                LBBC::ClusterViewMode *anotherFrameListenerMode;
120                anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
121                anotherFrameListenerMode->chooseSceneManager();
122                anotherFrameListenerMode->createCamera();
123                anotherFrameListenerMode->createViewports();
124                anotherFrameListenerMode->createScene();
125                mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
126        }
127
128        //{
129        //      LBBC::BillboardViewMode *anotherFrameListenerMode;
130        //      anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
131        //      anotherFrameListenerMode->chooseSceneManager();
132        //      anotherFrameListenerMode->createCamera();
133        //      anotherFrameListenerMode->createViewports();
134        //      anotherFrameListenerMode->createScene();
135        //      mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
136        //}
137
138        {
139                LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
140                textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
141                textureAtlasFrameListenerMode->chooseSceneManager();
142                textureAtlasFrameListenerMode->createCamera();
143                textureAtlasFrameListenerMode->createViewports();
144                textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
145                textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
146                textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
147                textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTexturePrefixName());
148                textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasPrefixName());
149                textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
150
151                mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
152                textureAtlasFrameListenerMode->createScene();
153        }
154
155        mFrameListener->removeFrameListenerMode(0);
156        mFrameListener->setEnabledFrameListenerMode(0);
157
158    mRoot->addFrameListener(mFrameListener);
159}
Note: See TracBrowser for help on using the repository browser.