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 | mSampleConfigFile = new LBBC::SampleConfigFile(); |
---|
22 | mSampleConfigFile->load(mOpts.cfg);
|
---|
23 | //----------------------------------------------------------------------------
|
---|
24 | this->setup(false,"IBR Billboard Cloud Tree Generator", 512, 512, false);
|
---|
25 | mLBBCManager = new LBBC::LBBCManager();
|
---|
26 | mLBBCManager->setSampleConfigFile(mSampleConfigFile); |
---|
27 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg); |
---|
28 | mLBBCManager->initialize();
|
---|
29 |
|
---|
30 | if (mSampleConfigFile->getEntityDistributionGeneration())
|
---|
31 | {
|
---|
32 | mLBBCManager->generateEntityDistribution();
|
---|
33 | }
|
---|
34 | else
|
---|
35 | {
|
---|
36 | mLBBCManager->loadEntityDistribution();
|
---|
37 | }
|
---|
38 | if (mSampleConfigFile->getEntitySampleMeshGeneration())
|
---|
39 | {
|
---|
40 | mLBBCManager->saveSingleEntity();
|
---|
41 | }
|
---|
42 | if (mSampleConfigFile->getEntityClustersGeneration())
|
---|
43 | {
|
---|
44 | mLBBCManager->generateEntityClusters();
|
---|
45 | }
|
---|
46 | if ( (mSampleConfigFile->getBillboardCloudGroupedIndirectTexturingBillboards()) || (mSampleConfigFile->getBillboardCloudGroupedDiffuseColorBillboards()) )
|
---|
47 | {
|
---|
48 | mLBBCManager->generateBillboardCloud();
|
---|
49 | } |
---|
50 | |
---|
51 | mLBBCManager->shutdown(); |
---|
52 | delete mLBBCManager; |
---|
53 | |
---|
54 | mOgreBase->shutdown(); |
---|
55 | delete mOgreBase; |
---|
56 | |
---|
57 | //---------------------------------------------------------------------------- |
---|
58 | this->setup(true,"IBR Billboard Cloud Tree Generator", 512, 512, false);
|
---|
59 | mLBBCManager = new LBBC::LBBCManager();
|
---|
60 | mLBBCManager->setSampleConfigFile(mSampleConfigFile);
|
---|
61 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
|
---|
62 | mLBBCManager->initialize();
|
---|
63 | this->go(); |
---|
64 | for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++) |
---|
65 | { |
---|
66 | mFrameListener->getFrameListenerMode(iFrameListenerMode)->destroyScene(); |
---|
67 | } |
---|
68 | mLBBCManager->shutdown(); |
---|
69 | delete mLBBCManager; |
---|
70 | mRoot->shutdown(); |
---|
71 | mWindow->destroy(); |
---|
72 | delete mRoot; |
---|
73 | delete mSampleConfigFile; |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | } |
---|
78 | |
---|
79 | int IBRBillboardCloudTreeApplication::findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,
|
---|
80 | Ogre::BinaryOptionList& binOptList)
|
---|
81 | {
|
---|
82 | int startIndex = 1;
|
---|
83 | for (int i = 1; i < numargs; ++i)
|
---|
84 | {
|
---|
85 | Ogre::String tmp(argv[i]);
|
---|
86 | if (Ogre::StringUtil::startsWith(tmp, "-"))
|
---|
87 | {
|
---|
88 | Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
|
---|
89 | if(ui != unaryOptList.end())
|
---|
90 | {
|
---|
91 | ui->second = true;
|
---|
92 | ++startIndex;
|
---|
93 | continue;
|
---|
94 | }
|
---|
95 | Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]);
|
---|
96 | if(bi != binOptList.end())
|
---|
97 | {
|
---|
98 | bi->second = argv[i+1];
|
---|
99 | startIndex += 2;
|
---|
100 | ++i;
|
---|
101 | continue;
|
---|
102 | }
|
---|
103 |
|
---|
104 | // Invalid option
|
---|
105 | std::cout<<"Invalid option "<<tmp<<std::endl;
|
---|
106 |
|
---|
107 | }
|
---|
108 | }
|
---|
109 | return startIndex;
|
---|
110 | }
|
---|
111 |
|
---|
112 | void IBRBillboardCloudTreeApplication::help()
|
---|
113 | {
|
---|
114 | std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl;
|
---|
115 | }
|
---|
116 |
|
---|
117 | void IBRBillboardCloudTreeApplication::parseArgs(int numArgs, char **args)
|
---|
118 | {
|
---|
119 | if (numArgs < 2)
|
---|
120 | {
|
---|
121 | help();
|
---|
122 | exit(-1);
|
---|
123 | }
|
---|
124 | else
|
---|
125 | {
|
---|
126 | Ogre::UnaryOptionList unOpt;
|
---|
127 | Ogre::BinaryOptionList binOpt;
|
---|
128 |
|
---|
129 | binOpt["-cfg"] = "";
|
---|
130 |
|
---|
131 | int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
|
---|
132 | Ogre::UnaryOptionList::iterator ui;
|
---|
133 | Ogre::BinaryOptionList::iterator bi;
|
---|
134 |
|
---|
135 | bi = binOpt.find("-cfg");
|
---|
136 | if (!bi->second.empty())
|
---|
137 | {
|
---|
138 | mOpts.cfg = bi->second;
|
---|
139 | }
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | void IBRBillboardCloudTreeApplication::createFrameListener(void)
|
---|
144 | {
|
---|
145 | mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
|
---|
146 |
|
---|
147 | if (mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration())
|
---|
148 | {
|
---|
149 | LBBC::BillboardCloudDiffuseColorTextureViewMode *anotherFrameListenerMode;
|
---|
150 | anotherFrameListenerMode = new LBBC::BillboardCloudDiffuseColorTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
151 | anotherFrameListenerMode->chooseSceneManager();
|
---|
152 | anotherFrameListenerMode->createCamera();
|
---|
153 | anotherFrameListenerMode->createViewports();
|
---|
154 | anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize());
|
---|
155 | anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureSize());
|
---|
156 | anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasBitRange());
|
---|
157 | anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasName());
|
---|
158 | anotherFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName());
|
---|
159 | anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
160 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
161 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
162 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug());
|
---|
163 | anotherFrameListenerMode->createScene();
|
---|
164 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
165 | }
|
---|
166 |
|
---|
167 | if (mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration())
|
---|
168 | {
|
---|
169 | LBBC::BillboardCloudIndirectTextureViewMode *anotherFrameListenerMode;
|
---|
170 | anotherFrameListenerMode = new LBBC::BillboardCloudIndirectTextureViewMode(mWindow, mFrameListener->getNumFrameListenerModes());
|
---|
171 | anotherFrameListenerMode->chooseSceneManager();
|
---|
172 | anotherFrameListenerMode->createCamera();
|
---|
173 | anotherFrameListenerMode->createViewports();
|
---|
174 | anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasSize());
|
---|
175 | anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureSize());
|
---|
176 | anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasBitRange());
|
---|
177 | anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasName());
|
---|
178 | anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
179 | anotherFrameListenerMode->setBillboardCloudPointClustersName(mSampleConfigFile->getBillboardCloudDiffuseColorPointClustersMeshName());
|
---|
180 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
181 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
182 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug());
|
---|
183 | anotherFrameListenerMode->createScene();
|
---|
184 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
185 | }
|
---|
186 |
|
---|
187 | if (mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasGeneration())
|
---|
188 | {
|
---|
189 | LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
|
---|
190 | textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
191 | textureAtlasFrameListenerMode->chooseSceneManager();
|
---|
192 | textureAtlasFrameListenerMode->createCamera();
|
---|
193 | textureAtlasFrameListenerMode->createViewports();
|
---|
194 | textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
|
---|
195 | textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
|
---|
196 | textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
|
---|
197 | textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName());
|
---|
198 | textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasName());
|
---|
199 | textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
200 |
|
---|
201 | textureAtlasFrameListenerMode->createScene();
|
---|
202 | mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
|
---|
203 | }
|
---|
204 |
|
---|
205 | {
|
---|
206 | LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
|
---|
207 | textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
208 | textureAtlasFrameListenerMode->chooseSceneManager();
|
---|
209 | textureAtlasFrameListenerMode->createCamera();
|
---|
210 | textureAtlasFrameListenerMode->createViewports();
|
---|
211 | textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
|
---|
212 | textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
|
---|
213 | textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
|
---|
214 | textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName());
|
---|
215 | textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasName());
|
---|
216 | textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
217 |
|
---|
218 | mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
|
---|
219 | textureAtlasFrameListenerMode->createScene();
|
---|
220 | }
|
---|
221 |
|
---|
222 | {
|
---|
223 | LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
224 | anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
225 | anotherFrameListenerMode->chooseSceneManager();
|
---|
226 | anotherFrameListenerMode->createCamera();
|
---|
227 | anotherFrameListenerMode->createViewports();
|
---|
228 | anotherFrameListenerMode->setBillboardCloudMeshName(mSampleConfigFile->getBillboardCloudGroupedDiffuseColorMeshName());
|
---|
229 | anotherFrameListenerMode->createScene();
|
---|
230 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
231 | }
|
---|
232 |
|
---|
233 | {
|
---|
234 | LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
235 | anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
236 | anotherFrameListenerMode->chooseSceneManager();
|
---|
237 | anotherFrameListenerMode->createCamera();
|
---|
238 | anotherFrameListenerMode->createViewports();
|
---|
239 | anotherFrameListenerMode->setBillboardCloudMeshName(mSampleConfigFile->getBillboardCloudGroupedIndirectTexturingMeshName());
|
---|
240 | anotherFrameListenerMode->createScene();
|
---|
241 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
242 | }
|
---|
243 |
|
---|
244 | {
|
---|
245 | LBBC::ClusterViewMode *anotherFrameListenerMode;
|
---|
246 | anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
247 | anotherFrameListenerMode->chooseSceneManager();
|
---|
248 | anotherFrameListenerMode->createCamera();
|
---|
249 | anotherFrameListenerMode->createViewports();
|
---|
250 | anotherFrameListenerMode->setEntityClustersMeshName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
251 | anotherFrameListenerMode->createScene();
|
---|
252 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
253 | }
|
---|
254 |
|
---|
255 | {
|
---|
256 | LBBC::SceneViewMode *anotherFrameListenerMode;
|
---|
257 | anotherFrameListenerMode = new LBBC::SceneViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
258 | anotherFrameListenerMode->chooseSceneManager();
|
---|
259 | anotherFrameListenerMode->createCamera();
|
---|
260 | anotherFrameListenerMode->createViewports();
|
---|
261 | anotherFrameListenerMode->createScene();
|
---|
262 | //anotherFrameListenerMode->loadScene("../../media/scene/scene.OSM");
|
---|
263 | ////anotherFrameListenerMode->loadScene("../../media/scene/sceneLeaves.OSM");
|
---|
264 | //anotherFrameListenerMode->loadScene("../../media/scene/scenePointLeaves.OSM");
|
---|
265 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
266 | }
|
---|
267 |
|
---|
268 | mFrameListener->removeFrameListenerMode(0);
|
---|
269 | mFrameListener->setEnabledFrameListenerMode(0);
|
---|
270 |
|
---|
271 | mRoot->addFrameListener(mFrameListener);
|
---|
272 | } |
---|