[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);
|
---|
| 23 |
|
---|
[721] | 24 | this->setup(false);
|
---|
[731] | 25 | mLBBCManager = new LBBC::LBBCManager();
|
---|
| 26 | mLBBCManager->setSampleConfigFile(mSampleConfigFile);
|
---|
[721] | 27 | //mLBBCManager->loadSampleConfigFile(mOpts.cfg);
|
---|
| 28 | mLBBCManager->runSampleConfigFile(); |
---|
| 29 | mLBBCManager->shutdown(); |
---|
| 30 | delete mLBBCManager; |
---|
| 31 | mOgreBase->shutdown(); |
---|
| 32 | delete mOgreBase; |
---|
| 33 | //---------------------------------------------------------------------------- |
---|
| 34 | this->setup(true);
|
---|
| 35 | this->go(); |
---|
[731] | 36 | for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++) |
---|
| 37 | { |
---|
| 38 | mFrameListener->getFrameListenerMode(iFrameListenerMode)->destroyScene(); |
---|
| 39 | } |
---|
[721] | 40 | mRoot->shutdown(); |
---|
| 41 | mWindow->destroy(); |
---|
| 42 | delete mRoot; |
---|
[731] | 43 | delete mSampleConfigFile; |
---|
[721] | 44 | } |
---|
[731] | 45 | |
---|
[721] | 46 | } |
---|
| 47 | |
---|
| 48 | int IBRBillboardCloudTreeApplication::findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,
|
---|
| 49 | Ogre::BinaryOptionList& binOptList)
|
---|
| 50 | {
|
---|
| 51 | int startIndex = 1;
|
---|
| 52 | for (int i = 1; i < numargs; ++i)
|
---|
| 53 | {
|
---|
| 54 | Ogre::String tmp(argv[i]);
|
---|
| 55 | if (Ogre::StringUtil::startsWith(tmp, "-"))
|
---|
| 56 | {
|
---|
| 57 | Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]);
|
---|
| 58 | if(ui != unaryOptList.end())
|
---|
| 59 | {
|
---|
| 60 | ui->second = true;
|
---|
| 61 | ++startIndex;
|
---|
| 62 | continue;
|
---|
| 63 | }
|
---|
| 64 | Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]);
|
---|
| 65 | if(bi != binOptList.end())
|
---|
| 66 | {
|
---|
| 67 | bi->second = argv[i+1];
|
---|
| 68 | startIndex += 2;
|
---|
| 69 | ++i;
|
---|
| 70 | continue;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | // Invalid option
|
---|
| 74 | std::cout<<"Invalid option "<<tmp<<std::endl;
|
---|
| 75 |
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | return startIndex;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | void IBRBillboardCloudTreeApplication::help()
|
---|
| 82 | {
|
---|
| 83 | std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void IBRBillboardCloudTreeApplication::parseArgs(int numArgs, char **args)
|
---|
| 87 | {
|
---|
| 88 | if (numArgs < 2)
|
---|
| 89 | {
|
---|
| 90 | help();
|
---|
| 91 | exit(-1);
|
---|
| 92 | }
|
---|
| 93 | else
|
---|
| 94 | {
|
---|
| 95 | Ogre::UnaryOptionList unOpt;
|
---|
| 96 | Ogre::BinaryOptionList binOpt;
|
---|
| 97 |
|
---|
| 98 | binOpt["-cfg"] = "";
|
---|
| 99 |
|
---|
| 100 | int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
|
---|
| 101 | Ogre::UnaryOptionList::iterator ui;
|
---|
| 102 | Ogre::BinaryOptionList::iterator bi;
|
---|
| 103 |
|
---|
| 104 | bi = binOpt.find("-cfg");
|
---|
| 105 | if (!bi->second.empty())
|
---|
| 106 | {
|
---|
| 107 | mOpts.cfg = bi->second;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | void IBRBillboardCloudTreeApplication::createFrameListener(void)
|
---|
| 113 | {
|
---|
| 114 | mFrameListener = new IBRBillboardCloudTreeFrameListener(mWindow);
|
---|
| 115 |
|
---|
| 116 | mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();
|
---|
[731] | 117 |
|
---|
[721] | 118 | {
|
---|
[731] | 119 | LBBC::ClusterViewMode *anotherFrameListenerMode;
|
---|
| 120 | anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
[721] | 121 | anotherFrameListenerMode->chooseSceneManager();
|
---|
| 122 | anotherFrameListenerMode->createCamera();
|
---|
| 123 | anotherFrameListenerMode->createViewports();
|
---|
| 124 | anotherFrameListenerMode->createScene();
|
---|
| 125 | mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[731] | 128 | //{
|
---|
| 129 | // LBBC::BillboardViewMode *anotherFrameListenerMode;
|
---|
| 130 | // anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
| 131 | // anotherFrameListenerMode->chooseSceneManager();
|
---|
| 132 | // anotherFrameListenerMode->createCamera();
|
---|
| 133 | // anotherFrameListenerMode->createViewports();
|
---|
| 134 | // anotherFrameListenerMode->createScene();
|
---|
| 135 | // mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
|
---|
| 136 | //}
|
---|
| 137 |
|
---|
[721] | 138 | {
|
---|
[731] | 139 | LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
|
---|
| 140 | textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
|
---|
| 141 | textureAtlasFrameListenerMode->chooseSceneManager();
|
---|
| 142 | textureAtlasFrameListenerMode->createCamera();
|
---|
| 143 | textureAtlasFrameListenerMode->createViewports();
|
---|
| 144 | textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
|
---|
| 145 | textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
|
---|
| 146 | textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
|
---|
| 147 | textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTexturePrefixName());
|
---|
| 148 | textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasPrefixName());
|
---|
| 149 | textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
|
---|
| 150 |
|
---|
| 151 | mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
|
---|
| 152 | textureAtlasFrameListenerMode->createScene();
|
---|
[721] | 153 | }
|
---|
| 154 |
|
---|
| 155 | mFrameListener->removeFrameListenerMode(0);
|
---|
[731] | 156 | mFrameListener->setEnabledFrameListenerMode(0);
|
---|
[721] | 157 |
|
---|
| 158 | mRoot->addFrameListener(mFrameListener);
|
---|
| 159 | } |
---|