[721] | 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 | {
|
---|
[731] | 21 | mSampleConfigFile = new LBBC::SampleConfigFile(); |
---|
| 22 | mSampleConfigFile->load(mOpts.cfg);
|
---|
[747] | 23 | //----------------------------------------------------------------------------
|
---|
[900] | 24 | this->setup(false,"IBR Billboard Cloud Tree Generator", 512, 512, false);
|
---|
[747] | 25 | mLBBCManager = new LBBC::LBBCManager();
|
---|
| 26 | mLBBCManager->setSampleConfigFile(mSampleConfigFile); |
---|
| 27 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg); |
---|
| 28 | mLBBCManager->initialize();
|
---|
[731] | 29 |
|
---|
[747] | 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 | }
|
---|
[900] | 46 | if ( (mSampleConfigFile->getBillboardCloudGroupedIndirectTexturingBillboards()) || (mSampleConfigFile->getBillboardCloudGroupedDiffuseColorBillboards()) )
|
---|
[747] | 47 | {
|
---|
| 48 | mLBBCManager->generateBillboardCloud();
|
---|
| 49 | } |
---|
[950] | 50 | |
---|
[747] | 51 | mLBBCManager->shutdown(); |
---|
| 52 | delete mLBBCManager; |
---|
[950] | 53 | |
---|
[747] | 54 | mOgreBase->shutdown(); |
---|
| 55 | delete mOgreBase; |
---|
[950] | 56 | |
---|
[745] | 57 | //---------------------------------------------------------------------------- |
---|
[900] | 58 | this->setup(true,"IBR Billboard Cloud Tree Generator", 512, 512, false);
|
---|
[731] | 59 | mLBBCManager = new LBBC::LBBCManager();
|
---|
| 60 | mLBBCManager->setSampleConfigFile(mSampleConfigFile);
|
---|
[721] | 61 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
|
---|
[900] | 62 | mLBBCManager->initialize();
|
---|
[721] | 63 | this->go(); |
---|
[731] | 64 | for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++) |
---|
| 65 | { |
---|
| 66 | mFrameListener->getFrameListenerMode(iFrameListenerMode)->destroyScene(); |
---|
| 67 | } |
---|
[747] | 68 | mLBBCManager->shutdown(); |
---|
| 69 | delete mLBBCManager; |
---|
[721] | 70 | mRoot->shutdown(); |
---|
[745] | 71 | mWindow->destroy(); |
---|
[721] | 72 | delete mRoot; |
---|
[731] | 73 | delete mSampleConfigFile; |
---|
[721] | 74 | } |
---|
[731] | 75 | |
---|
[745] | 76 | |
---|
[721] | 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 | {
|
---|
[900] | 145 | mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
|
---|
[731] | 146 |
|
---|
[778] | 147 | if (mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration())
|
---|
[751] | 148 | {
|
---|
[778] | 149 | LBBC::BillboardCloudDiffuseColorTextureViewMode *anotherFrameListenerMode;
|
---|
| 150 | anotherFrameListenerMode = new LBBC::BillboardCloudDiffuseColorTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[721] | 151 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 152 | anotherFrameListenerMode->createCamera();
|
---|
| 153 | anotherFrameListenerMode->createViewports();
|
---|
[751] | 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());
|
---|
[745] | 159 | anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
[751] | 160 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
[778] | 161 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
[751] | 162 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug());
|
---|
[721] | 163 | anotherFrameListenerMode->createScene();
|
---|
| 164 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[778] | 167 | if (mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration())
|
---|
[747] | 168 | {
|
---|
[778] | 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());
|
---|
[967] | 179 | anotherFrameListenerMode->setBillboardCloudPointClustersName(mSampleConfigFile->getBillboardCloudDiffuseColorPointClustersMeshName());
|
---|
[778] | 180 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
| 181 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
| 182 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug());
|
---|
| 183 | anotherFrameListenerMode->createScene();
|
---|
| 184 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[900] | 187 | if (mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasGeneration())
|
---|
[778] | 188 | {
|
---|
[861] | 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 |
|
---|
[900] | 201 | textureAtlasFrameListenerMode->createScene();
|
---|
[861] | 202 | mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
|
---|
[900] | 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);
|
---|
[861] | 219 | textureAtlasFrameListenerMode->createScene();
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | {
|
---|
[751] | 223 | LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
| 224 | anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[747] | 225 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 226 | anotherFrameListenerMode->createCamera();
|
---|
| 227 | anotherFrameListenerMode->createViewports();
|
---|
[900] | 228 | anotherFrameListenerMode->setBillboardCloudMeshName(mSampleConfigFile->getBillboardCloudGroupedDiffuseColorMeshName());
|
---|
[747] | 229 | anotherFrameListenerMode->createScene();
|
---|
| 230 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 231 | }
|
---|
[745] | 232 |
|
---|
[747] | 233 | {
|
---|
[900] | 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 | {
|
---|
[751] | 245 | LBBC::ClusterViewMode *anotherFrameListenerMode;
|
---|
| 246 | anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[747] | 247 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 248 | anotherFrameListenerMode->createCamera();
|
---|
| 249 | anotherFrameListenerMode->createViewports();
|
---|
[861] | 250 | anotherFrameListenerMode->setEntityClustersMeshName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
[747] | 251 | anotherFrameListenerMode->createScene();
|
---|
| 252 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 253 | }
|
---|
[731] | 254 |
|
---|
[961] | 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 |
|
---|
[721] | 268 | mFrameListener->removeFrameListenerMode(0);
|
---|
[731] | 269 | mFrameListener->setEnabledFrameListenerMode(0);
|
---|
[721] | 270 |
|
---|
| 271 | mRoot->addFrameListener(mFrameListener);
|
---|
| 272 | } |
---|