Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp	(revision 731)
@@ -19,9 +19,10 @@
 	for (unsigned int i = 0; i < 1; i++)
 	{
+		mSampleConfigFile = new LBBC::SampleConfigFile();
+		mSampleConfigFile->load(mOpts.cfg);
+
 		this->setup(false);
-		mLBBCManager = new LBBC::Manager();	
-		LBBC::SampleConfigFile *sampleConfigFile = new LBBC::SampleConfigFile();
-		sampleConfigFile->load(mOpts.cfg);
-		mLBBCManager->setSampleConfigFile(sampleConfigFile);	
+		mLBBCManager = new LBBC::LBBCManager();	
+		mLBBCManager->setSampleConfigFile(mSampleConfigFile);	
 		//mLBBCManager->loadSampleConfigFile(mOpts.cfg);
 		mLBBCManager->runSampleConfigFile();	
@@ -33,8 +34,14 @@
 		this->setup(true);
 		this->go();	
+		for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++)
+		{
+			mFrameListener->getFrameListenerMode(iFrameListenerMode)->destroyScene();
+		}
 		mRoot->shutdown();	
 		mWindow->destroy();		
 		delete mRoot;
+		delete mSampleConfigFile;
 	}
+
 }
 
@@ -108,7 +115,8 @@
 	
 	mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();	
+
 	{
-		LBBC::ClustersViewMode *anotherFrameListenerMode;
-		anotherFrameListenerMode = new LBBC::ClustersViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
+		LBBC::ClusterViewMode *anotherFrameListenerMode;
+		anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
 		anotherFrameListenerMode->chooseSceneManager();
 		anotherFrameListenerMode->createCamera();
@@ -118,16 +126,33 @@
 	}
 
+	//{
+	//	LBBC::BillboardViewMode *anotherFrameListenerMode;
+	//	anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
+	//	anotherFrameListenerMode->chooseSceneManager();
+	//	anotherFrameListenerMode->createCamera();
+	//	anotherFrameListenerMode->createViewports();
+	//	anotherFrameListenerMode->createScene();
+	//	mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
+	//}
+
 	{
-		LBBC::BillboardViewMode *anotherFrameListenerMode;
-		anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
-		anotherFrameListenerMode->chooseSceneManager();
-		anotherFrameListenerMode->createCamera();
-		anotherFrameListenerMode->createViewports();
-		anotherFrameListenerMode->createScene();
-		mFrameListener->addFrameListenerMode(anotherFrameListenerMode);
+		LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode;
+		textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes());
+		textureAtlasFrameListenerMode->chooseSceneManager();
+		textureAtlasFrameListenerMode->createCamera();
+		textureAtlasFrameListenerMode->createViewports();
+		textureAtlasFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasSize());
+		textureAtlasFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasBitRange());
+		textureAtlasFrameListenerMode->setTextureAtlasNumSamples(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples());
+		textureAtlasFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTexturePrefixName());
+		textureAtlasFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasPrefixName());
+		textureAtlasFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());
+
+		mFrameListener->addFrameListenerMode(textureAtlasFrameListenerMode);
+		textureAtlasFrameListenerMode->createScene();
 	}
 
-	mFrameListener->setEnabledFrameListenerMode(1);
 	mFrameListener->removeFrameListenerMode(0);
+	mFrameListener->setEnabledFrameListenerMode(0);
 
     mRoot->addFrameListener(mFrameListener);
