1 | |
---|
2 | #include "IBRBillboardCloudTreeApplication.h" |
---|
3 | |
---|
4 | IBRBillboardCloudTreeApplication::IBRBillboardCloudTreeApplication() |
---|
5 | { |
---|
6 | } |
---|
7 | |
---|
8 | IBRBillboardCloudTreeApplication::~IBRBillboardCloudTreeApplication() |
---|
9 | { |
---|
10 | // Gametools -- BUG: 31/03/2006 |
---|
11 | //if (mLBBCManager) |
---|
12 | //{ |
---|
13 | // delete mLBBCManager; |
---|
14 | //} |
---|
15 | } |
---|
16 | |
---|
17 | void IBRBillboardCloudTreeApplication::initialize() |
---|
18 | {
|
---|
19 | for (unsigned int i = 0; i < 1; i++)
|
---|
20 | {
|
---|
21 | this->setup(false);
|
---|
22 | mLBBCManager = new LBBC::Manager();
|
---|
23 | LBBC::SampleConfigFile *sampleConfigFile = new LBBC::SampleConfigFile(); |
---|
24 | sampleConfigFile->load(mOpts.cfg);
|
---|
25 | mLBBCManager->setSampleConfigFile(sampleConfigFile);
|
---|
26 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
|
---|
27 | mLBBCManager->runSampleConfigFile(); |
---|
28 | mLBBCManager->shutdown(); |
---|
29 | delete mLBBCManager; |
---|
30 | mOgreBase->shutdown(); |
---|
31 | delete mOgreBase; |
---|
32 | //---------------------------------------------------------------------------- |
---|
33 | this->setup(true);
|
---|
34 | this->go(); |
---|
35 | mRoot->shutdown(); |
---|
36 | mWindow->destroy(); |
---|
37 | delete mRoot; |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | int IBRBillboardCloudTreeApplication::findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,
|
---|
42 | Ogre::BinaryOptionList& binOptList)
|
---|
43 | {
|
---|
44 | int startIndex = 1;
|
---|
45 | for (int i = 1; i < numargs; ++i)
|
---|
46 | {
|
---|
47 | Ogre::String tmp(argv[i]);
|
---|
48 | if (Ogre::StringUtil::startsWith(tmp, "-"))
|
---|
49 | {
|
---|
50 | Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
|
---|
51 | if(ui != unaryOptList.end())
|
---|
52 | {
|
---|
53 | ui->second = true;
|
---|
54 | ++startIndex;
|
---|
55 | continue;
|
---|
56 | }
|
---|
57 | Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]);
|
---|
58 | if(bi != binOptList.end())
|
---|
59 | {
|
---|
60 | bi->second = argv[i+1];
|
---|
61 | startIndex += 2;
|
---|
62 | ++i;
|
---|
63 | continue;
|
---|
64 | }
|
---|
65 |
|
---|
66 | // Invalid option
|
---|
67 | std::cout<<"Invalid option "<<tmp<<std::endl;
|
---|
68 |
|
---|
69 | }
|
---|
70 | }
|
---|
71 | return startIndex;
|
---|
72 | }
|
---|
73 |
|
---|
74 | void IBRBillboardCloudTreeApplication::help()
|
---|
75 | {
|
---|
76 | std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl;
|
---|
77 | }
|
---|
78 |
|
---|
79 | void IBRBillboardCloudTreeApplication::parseArgs(int numArgs, char **args)
|
---|
80 | {
|
---|
81 | if (numArgs < 2)
|
---|
82 | {
|
---|
83 | help();
|
---|
84 | exit(-1);
|
---|
85 | }
|
---|
86 | else
|
---|
87 | {
|
---|
88 | Ogre::UnaryOptionList unOpt;
|
---|
89 | Ogre::BinaryOptionList binOpt;
|
---|
90 |
|
---|
91 | binOpt["-cfg"] = "";
|
---|
92 |
|
---|
93 | int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
|
---|
94 | Ogre::UnaryOptionList::iterator ui;
|
---|
95 | Ogre::BinaryOptionList::iterator bi;
|
---|
96 |
|
---|
97 | bi = binOpt.find("-cfg");
|
---|
98 | if (!bi->second.empty())
|
---|
99 | {
|
---|
100 | mOpts.cfg = bi->second;
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | void IBRBillboardCloudTreeApplication::createFrameListener(void)
|
---|
106 | {
|
---|
107 | mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
|
---|
108 |
|
---|
109 | mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();
|
---|
110 | {
|
---|
111 | LBBC::ClustersViewMode *anotherFrameListenerMode;
|
---|
112 | anotherFrameListenerMode = new LBBC::ClustersViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
113 | anotherFrameListenerMode->chooseSceneManager();
|
---|
114 | anotherFrameListenerMode->createCamera();
|
---|
115 | anotherFrameListenerMode->createViewports();
|
---|
116 | anotherFrameListenerMode->createScene();
|
---|
117 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
118 | }
|
---|
119 |
|
---|
120 | {
|
---|
121 | LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
122 | anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
123 | anotherFrameListenerMode->chooseSceneManager();
|
---|
124 | anotherFrameListenerMode->createCamera();
|
---|
125 | anotherFrameListenerMode->createViewports();
|
---|
126 | anotherFrameListenerMode->createScene();
|
---|
127 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
128 | }
|
---|
129 |
|
---|
130 | mFrameListener->setEnabledFrameListenerMode(1);
|
---|
131 | mFrameListener->removeFrameListenerMode(0);
|
---|
132 |
|
---|
133 | mRoot->addFrameListener(mFrameListener);
|
---|
134 | } |
---|