[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 | //----------------------------------------------------------------------------
|
---|
| 24 | this->setup(false);
|
---|
| 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 | }
|
---|
| 46 | if (mSampleConfigFile->getBillboardCloudGeneration())
|
---|
| 47 | {
|
---|
| 48 | mLBBCManager->generateBillboardCloud();
|
---|
| 49 | } |
---|
[745] | 50 | |
---|
[747] | 51 | mLBBCManager->shutdown(); |
---|
| 52 | delete mLBBCManager; |
---|
| 53 | mOgreBase->shutdown(); |
---|
| 54 | delete mOgreBase; |
---|
[745] | 55 | //---------------------------------------------------------------------------- |
---|
| 56 | this->setup(true);
|
---|
[731] | 57 | mLBBCManager = new LBBC::LBBCManager();
|
---|
| 58 | mLBBCManager->setSampleConfigFile(mSampleConfigFile);
|
---|
[721] | 59 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
|
---|
[745] | 60 | mLBBCManager->initialize();
|
---|
[751] | 61 | //mLBBCManager->loadBillboardCloudMergedXML();
|
---|
| 62 | mLBBCManager->loadBillboardCloudGroupedXML();
|
---|
[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 | {
|
---|
| 145 | mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
|
---|
| 146 |
|
---|
| 147 | mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();
|
---|
[731] | 148 |
|
---|
[778] | 149 | if (mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasGeneration())
|
---|
[721] | 150 | {
|
---|
[751] | 151 | LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
|
---|
| 152 | textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
| 153 | textureAtlasFrameListenerMode->chooseSceneManager();
|
---|
| 154 | textureAtlasFrameListenerMode->createCamera();
|
---|
| 155 | textureAtlasFrameListenerMode->createViewports();
|
---|
| 156 | textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
|
---|
| 157 | textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
|
---|
| 158 | textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
|
---|
| 159 | textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName());
|
---|
| 160 | textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasName());
|
---|
| 161 | textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
| 162 |
|
---|
| 163 | mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
|
---|
| 164 | textureAtlasFrameListenerMode->createScene();
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[778] | 167 | if (mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration())
|
---|
[751] | 168 | {
|
---|
[778] | 169 | LBBC::BillboardCloudDiffuseColorTextureViewMode *anotherFrameListenerMode;
|
---|
| 170 | anotherFrameListenerMode = new LBBC::BillboardCloudDiffuseColorTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[721] | 171 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 172 | anotherFrameListenerMode->createCamera();
|
---|
| 173 | anotherFrameListenerMode->createViewports();
|
---|
[751] | 174 | anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize());
|
---|
| 175 | anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureSize());
|
---|
| 176 | anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasBitRange());
|
---|
| 177 | anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasName());
|
---|
| 178 | anotherFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName());
|
---|
[745] | 179 | anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
[751] | 180 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
[778] | 181 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
[751] | 182 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug());
|
---|
[721] | 183 | anotherFrameListenerMode->createScene();
|
---|
| 184 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[778] | 187 | if (mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration())
|
---|
[747] | 188 | {
|
---|
[778] | 189 | LBBC::BillboardCloudIndirectTextureViewMode *anotherFrameListenerMode;
|
---|
| 190 | anotherFrameListenerMode = new LBBC::BillboardCloudIndirectTextureViewMode(mWindow, mFrameListener->getNumFrameListenerModes());
|
---|
| 191 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 192 | anotherFrameListenerMode->createCamera();
|
---|
| 193 | anotherFrameListenerMode->createViewports();
|
---|
| 194 | anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasSize());
|
---|
| 195 | anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureSize());
|
---|
| 196 | anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasBitRange());
|
---|
| 197 | anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasName());
|
---|
| 198 | anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
| 199 | anotherFrameListenerMode->setBillboardCloudPointClustersName(mSampleConfigFile->getBillboardCloudIndirectPointMeshName());
|
---|
| 200 | anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName());
|
---|
| 201 | anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
| 202 | anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug());
|
---|
| 203 | anotherFrameListenerMode->createScene();
|
---|
| 204 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | {
|
---|
[751] | 208 | LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
| 209 | anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[747] | 210 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 211 | anotherFrameListenerMode->createCamera();
|
---|
| 212 | anotherFrameListenerMode->createViewports();
|
---|
[751] | 213 | //anotherFrameListenerMode->setBillboardCloudMeshName(mSampleConfigFile->getBillboardCloudGroupedMeshName());
|
---|
[747] | 214 | anotherFrameListenerMode->createScene();
|
---|
| 215 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 216 | }
|
---|
[745] | 217 |
|
---|
[747] | 218 | {
|
---|
[751] | 219 | LBBC::ClusterViewMode *anotherFrameListenerMode;
|
---|
| 220 | anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[747] | 221 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 222 | anotherFrameListenerMode->createCamera();
|
---|
| 223 | anotherFrameListenerMode->createViewports();
|
---|
[751] | 224 | //anotherFrameListenerMode->setEntityClustersMeshName(mSampleConfigFile->getEntityClustersGroupedMeshName());
|
---|
[747] | 225 | anotherFrameListenerMode->createScene();
|
---|
| 226 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 227 | }
|
---|
[731] | 228 |
|
---|
[721] | 229 | mFrameListener->removeFrameListenerMode(0);
|
---|
[731] | 230 | mFrameListener->setEnabledFrameListenerMode(0);
|
---|
[721] | 231 |
|
---|
| 232 | mRoot->addFrameListener(mFrameListener);
|
---|
| 233 | } |
---|