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