Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp	(revision 731)
@@ -4,6 +4,6 @@
 namespace LBBC {
 
-Manager::Manager() 
-	: BBC::Manager() 
+LBBCManager::LBBCManager() 
+	: BBC::BBCManager() 
 {
 	mBillboardCloudSerializer = new KMeansClusterSerializer();
@@ -15,5 +15,5 @@
 }
 
-Manager::~Manager() 
+LBBCManager::~LBBCManager() 
 {
 	if (mOgreMeshSerializer)
@@ -21,8 +21,9 @@
 		delete mOgreMeshSerializer;
 	}
-	if (mSampleConfigFile)
-	{
-		delete mSampleConfigFile;
-	}
+	// Gametools -- BUG: 06/04/2006
+	//if (mSampleConfigFile)
+	//{
+	//	delete mSampleConfigFile;
+	//}
 	if (mLeafDistributionSerializer)
 	{
@@ -52,15 +53,15 @@
 }
 
-SampleConfigFile* Manager::getSampleConfigFile()
+SampleConfigFile* LBBCManager::getSampleConfigFile()
 {
 	return mSampleConfigFile;
 }
 
-void Manager::setSampleConfigFile(SampleConfigFile *sampleConfigFile)
+void LBBCManager::setSampleConfigFile(SampleConfigFile *sampleConfigFile)
 {
 	mSampleConfigFile = sampleConfigFile;
 }
 
-void Manager::loadSampleConfigFile(Ogre::String sampleConfigFile)
+void LBBCManager::loadSampleConfigFile(Ogre::String sampleConfigFile)
 {
 	mSampleConfigFile = new SampleConfigFile();
@@ -68,10 +69,10 @@
 }
 
-void Manager::runSampleConfigFile()
+void LBBCManager::runSampleConfigFile()
 {
 	mLeaves = new Leaves();
 	
 	BBC::EntityPtr entityLeaves(new BBC::Entity);
-	BBC::MeshPtr meshLeaves(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + ".mesh")) );
+	BBC::MeshPtr meshLeaves(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixName() + ".mesh")) );
 	entityLeaves->setMesh(meshLeaves);	
 	mLeaves->setEntity(entityLeaves);
@@ -87,4 +88,9 @@
 	}
 	
+	if (mSampleConfigFile->getEntitySampleMeshGeneration())
+	{
+		saveSingleEntity();
+	}
+
 	if (mSampleConfigFile->getEntityClustersGeneration())
 	{
@@ -96,7 +102,8 @@
 		generateBillboardCloud();
 	}	
-}
-
-void Manager::createEntityDistribution()
+
+}
+
+void LBBCManager::createEntityDistribution()
 {
 	mLeafDistributionGenerator->setDistribution(mLeaves->getDistribution());
@@ -105,5 +112,5 @@
 }
 
-void Manager::saveEntityDistributionSplitted()
+void LBBCManager::saveEntityDistributionSplitted()
 {
 	BBC::EntityPtr entity;
@@ -143,8 +150,8 @@
 			mOgreMeshSerializer->setEntity(entity);
 			mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() +
-				mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false);
+				mSampleConfigFile->getEntityClustersMeshPrefixName() + "Splitted.mesh", false, false);
 			
-			OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh");
-			//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh().get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh" + ".xml");			
+			OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixName() + "Splitted.mesh");
+			//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh().get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixName() + "Splitted.mesh" + ".xml");			
 		}
 	}
@@ -157,18 +164,16 @@
 		mOgreMeshSerializer->setEntity(entity);
 		mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() +
-			mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false);
-		
-		OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh");
-		//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh" + ".xml");		
-
-		//Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh");
-	}
-}
-
-void Manager::saveEntityDistributionXML()
+			mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh", false, false);
+		
+		OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixName() + "Merged.mesh");
+		//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixName() + "Merged.mesh" + ".xml");				
+	}
+}
+
+void LBBCManager::saveEntityDistributionXML()
 {
 	TiXmlDocument *document = mLeafDistributionSerializer->create(
 									mSampleConfigFile->getEntityDistributionFolder() +
-									mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml");
+									mSampleConfigFile->getEntityDistributionXMLPrefixName() + ".xml");
 	mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution());
 	mLeafDistributionSerializer->writeLeafDistribution(document);	
@@ -176,9 +181,9 @@
 }
 
-void Manager::loadEntityDistribution()
+void LBBCManager::loadEntityDistribution()
 {
 	TiXmlDocument *document = mLeafDistributionSerializer->load(
 									mSampleConfigFile->getEntityDistributionFolder() +
-									mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml");
+									mSampleConfigFile->getEntityDistributionXMLPrefixName() + ".xml");
 	mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution());
 	mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getEntity()->getMesh());
@@ -188,5 +193,5 @@
 	BBC::EntityDistribution *entityDistribution;
 
-	BBC::MeshPtr pMeshLeavesSplitted(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh")));
+	BBC::MeshPtr pMeshLeavesSplitted(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixName() + "Splitted.mesh")));
 	entity = BBC::EntityPtr(new BBC::Entity());
 	entity->setMesh(pMeshLeavesSplitted);
@@ -211,5 +216,5 @@
 }
 
-void Manager::generateEntityDistribution()
+void LBBCManager::generateEntityDistribution()
 {
 	if (mSampleConfigFile->getEntityDistributionGeneration())
@@ -221,10 +226,10 @@
 }
 
-void Manager::saveBillboardCloudGrouped()
+void LBBCManager::saveBillboardCloudGrouped()
 {
 	for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++)
 	{
 		BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);
-		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename());
+		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudBillboardGroupMaterialPrefixName());
 	}
 	mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity());
@@ -232,18 +237,16 @@
 	Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities()));
 	mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() +
-				mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh",false, false);
-	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh");
-	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh.xml");
-
-	//Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh");
-}
-
-
-void Manager::saveBillboardCloudSplitted()
+				mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Grouped.mesh",false, false);
+	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Grouped.mesh");
+	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Grouped.mesh.xml");
+}
+
+
+void LBBCManager::saveBillboardCloudSplitted()
 {	
 	for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++)
 	{
 		BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);
-		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename());
+		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudBillboardMaterialPrefixName());
 	}
 
@@ -253,20 +256,20 @@
 
 	mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() +
-				mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false);
-
-	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh");
-
-	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh.xml");
-}
-
-void Manager::saveBillboardCloudMerged()
+				mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Splitted.mesh",false, false);
+
+	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Splitted.mesh");
+
+	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Splitted.mesh.xml");
+}
+
+void LBBCManager::saveBillboardCloudMerged()
 {	
-	//mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename());
+	//mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixName());
 	//mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity());
 	//mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() +
-	//			mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleConfigFile->getBillboardCloudMergedBillboards(), false);
+	//			mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh", mSampleConfigFile->getBillboardCloudMergedBillboards(), false);
 	//OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), 
-	//			mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh");
-	//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml");
+	//			mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh");
+	//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh.xml");
 	
 
@@ -274,5 +277,5 @@
 	{
 		BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);
-		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename());
+		subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudBillboardGroupMaterialPrefixName());
 	}
 	mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity());
@@ -280,17 +283,15 @@
 	Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities()));
 	mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() +
-				mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh",false, false);
-	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh");	
-	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml");
-	
-	//Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh");
-}
-
-void Manager::saveBillboardCloudXML()
+				mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh",false, false);
+	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh");	
+	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixName() + "Merged.mesh.xml");	
+}
+
+void LBBCManager::saveBillboardCloudXML()
 {
 	//saveBillboardCloud()
 	TiXmlDocument *document2 = mBillboardCloudSerializer->create(
 									mSampleConfigFile->getBillboardCloudFolder() + 
-									mSampleConfigFile->getBillboardCloudXMLPrefixFilename() + ".xml");
+									mSampleConfigFile->getBillboardCloudXMLPrefixName() + ".xml");
 	mBillboardCloudSerializer->setBillboardCloud(mLeaves->getBillboardCloud());
 	mBillboardCloudSerializer->writeBillboardCloud(document2);	
@@ -298,5 +299,5 @@
 }
 
-void Manager::saveEntityClusters()
+void LBBCManager::saveEntityClusters()
 {
 	BBC::BillboardClusterDataPtr billboardClusterData;
@@ -315,16 +316,14 @@
 			{					
 				BBC::EntityPtr entityClusterized = entityCluster->getEntity();
-				entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename());
+				entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixName());
 				mOgreMeshSerializer->setEntity(entityClusterized);
 				mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() +
-					mSampleConfigFile->getEntityClustersMeshPrefixFilename() +
+					mSampleConfigFile->getEntityClustersMeshPrefixName() +
 					Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleConfigFile->getEntityClustersSplittedClusters()), false);
 				OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entityClusterized->getMesh()->get(),
 					mSampleConfigFile->getEntityClustersFolder() +
-					mSampleConfigFile->getEntityClustersMeshPrefixFilename() +
+					mSampleConfigFile->getEntityClustersMeshPrefixName() +
 					Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh");
 				//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityClusterized->getMesh(), entityClusterized->getMesh()->getName() + ".xml");
-
-				//Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh");
 
 				numSerializedBillboards++;
@@ -347,5 +346,5 @@
 			{			
 				BBC::EntityPtr entityClusterized = entityCluster->getEntity();
-				entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename());
+				entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixName());
 				BBC::SubEntityPtr subEntity = entityClusterized->getSubEntity(0);
 
@@ -371,16 +370,14 @@
 		mOgreMeshSerializer->setEntity(entity);
 		mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() +
-			mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false);
-		
-		OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh");
-		//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh" + ".xml");
-
-		//Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh");
-
-		Ogre::LogManager::getSingleton().logMessage("Before deleting:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh");	
-	}
-}
-
-void Manager::createEntityClusters()
+			mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh", false, false);
+		
+		OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh");
+		//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh" + ".xml");
+
+		Ogre::LogManager::getSingleton().logMessage("Before deleting:" + mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh");	
+	}
+}
+
+void LBBCManager::createEntityClusters()
 {
 	mBillboardCloudGenerator->setDistribution(mLeaves->getDistribution());
@@ -392,27 +389,23 @@
 }
 
-void Manager::saveSingleEntity()
-{
-	if (mSampleConfigFile->getEntitySampleMeshGeneration())
-	{
-		BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2);
-		entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename());
-		mOgreMeshSerializer->setEntity(entityLeaf);
-		mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() +
-			mSampleConfigFile->getEntitySampleMeshPrefixFilename(), mSampleConfigFile->getEntityClustersMergedClusters(), false);
-		//OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh(), entityLeaf->getMesh()->getName() + ".xml");
-
-	}
-}
-
-void Manager::generateEntityClusters()
-{
-	Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename());
+void LBBCManager::saveSingleEntity()
+{
+	BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2);
+	entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntitySampleMaterialPrefixName());
+	mOgreMeshSerializer->setEntity(entityLeaf);
+	mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() +
+		mSampleConfigFile->getEntitySampleMeshPrefixName(), false, false);
+	OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entityLeaf->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitySampleMeshPrefixName() + ".mesh");
+	OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitySampleMeshPrefixName() + ".mesh.xml");	
+}
+
+void LBBCManager::generateEntityClusters()
+{
+	Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixName());
 	createEntityClusters();
-	saveEntityClusters();
-	saveSingleEntity();	
-}
-
-void Manager::generateBillboardCloud()
+	saveEntityClusters();	
+}
+
+void LBBCManager::generateBillboardCloud()
 {
 	if (mSampleConfigFile->getBillboardCloudMergedBillboards())
@@ -422,12 +415,12 @@
 		mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1);
 
-		if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration())
+		if (mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasGeneration())
 		{
 			mBillboardCloudUVMapper->shutdown();
 			mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud());
-			mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
-			mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
+			mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize());
+			mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize());
+			mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize());
+			mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize());
 			mBillboardCloudUVMapper->initialize();
 
@@ -446,12 +439,12 @@
 		mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups());
 		
-		if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration())
+		if (mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasGeneration())
 		{
 			mBillboardCloudUVMapper->shutdown();
 			mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud());
-			mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
-			mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
+			mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureSize());
+			mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureSize());
+			mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasSize());
+			mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasSize());
 			mBillboardCloudUVMapper->initialize();
 			mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups()); 
@@ -466,15 +459,15 @@
 	{		
 		mLeaves->getBillboardCloud()->generateBillboardCloud(false);
-		if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration())
-		{
-			mBillboardCloudUVMapper->shutdown();
-			mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud());
-			mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
-			mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
-			mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
-			mBillboardCloudUVMapper->initialize();
-			mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false); 
-		}
+		//if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration())
+		//{
+		//	mBillboardCloudUVMapper->shutdown();
+		//	mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud());
+		//	mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
+		//	mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize());
+		//	mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
+		//	mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize());
+		//	mBillboardCloudUVMapper->initialize();
+		//	mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false); 
+		//}
 		saveBillboardCloudSplitted();
 	}
@@ -483,5 +476,5 @@
 }
 
-Leaves* Manager::getLeaves()
+Leaves* LBBCManager::getLeaves()
 {
 	return mLeaves;
