Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 731)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 745)
@@ -52,5 +52,7 @@
 	Ogre::String getEntityClustersMeshPrefixName();
 
-	Ogre::String getEntityClustersMaterialPrefixName();
+	Ogre::String getEntityClustersMergedMaterialPrefixName();
+
+	Ogre::String getEntityClustersSplittedMaterialPrefixName();
 
 	bool getBillboardCloudMergedBillboards();
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 731)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 745)
@@ -21,9 +21,9 @@
     ~LBBCManager();
 
-	void runSampleConfigFile();
-
 	void loadSampleConfigFile(Ogre::String sampleConfigFile);
 
 	SampleConfigFile* getSampleConfigFile();
+
+	void initialize();
 
 	void setSampleConfigFile(SampleConfigFile *sampleConfigFile);
@@ -57,5 +57,16 @@
 	void saveBillboardCloudXML();
 
+	void saveBillboardCloudMergedXML();
+
+	void saveBillboardCloudGroupedXML();
+
 	Leaves* getLeaves();
+
+	void loadBillboardCloudXML();
+
+	void loadBillboardCloudGroupedXML();
+
+	void loadBillboardCloudMergedXML();
+
 
   protected:
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h	(revision 745)
@@ -15,6 +15,7 @@
     virtual ~KMeansClusterSerializer();
 
-	virtual void writeBillboardCloud(TiXmlDocument *document);
+	virtual void writeBillboardCloud(TiXmlDocument *document, bool groupedBillboards);
 
+	virtual void readBillboardCloud(TiXmlDocument *document, bool groupedBillboards);
 };
 
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h	(revision 745)
@@ -12,5 +12,7 @@
     virtual ~KdTreeClusterSerializer();
 
-    void writeBillboardCloud(TiXmlDocument *document);
+    virtual void writeBillboardCloud(TiXmlDocument *document, bool groupedBillboards);
+
+	virtual void readBillboardCloud(TiXmlDocument *document, bool groupedBillboards);
 
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h	(revision 731)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h	(revision 745)
@@ -10,3 +10,4 @@
 #include <LBBCClusterViewMode.h>
 #include <LBBCEntityTextureAtlasViewMode.h>
+#include <LBBCBillboardCloudTextureViewMode.h>
 #endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCEntityTextureAtlasViewMode.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCEntityTextureAtlasViewMode.h	(revision 731)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCEntityTextureAtlasViewMode.h	(revision 745)
@@ -40,6 +40,4 @@
 		virtual ~EntityTextureAtlasViewMode();		
 
-		void setTextureAtlasFolder(Ogre::String textureAtlasFolder);
-
 		unsigned int nextPowerOf2(unsigned int nPlanes);
 
@@ -58,4 +56,6 @@
 		void setTextureAtlasName(Ogre::String textureAtlasName);
 
+		void setTextureAtlasFolder(Ogre::String textureAtlasFolder);
+
 		void setTextureAtlasSize(unsigned int size);
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h	(revision 745)
@@ -14,7 +14,7 @@
     virtual ~BillboardKMeansClusterData();
 
-	virtual void readBillboardClusterData(TiXmlNode *parentNode);
+	virtual void readBillboardClusterData(TiXmlNode *parentNode, int iBillboardGroup);
 
-	virtual void writeBillboardClusterData(TiXmlNode *parentNode);
+	virtual void writeBillboardClusterData(TiXmlNode *parentNode, int iBillboardGroup);
 
 	virtual void generateBillboardBoundingQuad();
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardCloudTextureViewMode.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardCloudTextureViewMode.h	(revision 745)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardCloudTextureViewMode.h	(revision 745)
@@ -0,0 +1,151 @@
+#ifndef _LBBCBILLBOARDCLOUDTEXTUREVIEWMODE_H
+#define _LBBCBILLBOARDCLOUDTEXTUREVIEWMODE_H
+
+#include <LBBCPrerequisites.h>
+#include <LBBCManager.h>
+#include <IMG.h>
+#include <OBAOgreFrameListenerMode.h>
+
+namespace LBBC {
+
+class _BBCExport ClusterTextureListener : public Ogre::RenderTargetListener
+{
+protected:
+	IMG::TextureAtlasPtr mTextureAtlas;
+
+	IMG::TexturePtr mTexture;
+
+	unsigned int mNumTextures;
+
+	unsigned int mCurrentTexture;
+
+	unsigned int mSubEntityVisible;
+
+	Ogre::Entity *mEntity;
+
+public:
+	
+	void setEntity(Ogre::Entity *entity)
+	{
+		mEntity = entity;
+	}
+
+	void setSubEntityVisible(unsigned int iSubEntity)
+	{
+		mSubEntityVisible = iSubEntity;
+	}
+
+	void setTexture(IMG::TexturePtr texture)
+	{
+		mTexture = texture;
+	}
+
+	void setTextureAtlas(IMG::TextureAtlasPtr textureAtlas)
+	{
+		mTextureAtlas = textureAtlas;
+	}
+
+	void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
+    {
+		if (mCurrentTexture < mNumTextures)
+		{
+			//calculateProjectionMatrix(unsigned int iSubEntity, Ogre::Camera *cam);
+			//initializeShaderParameters(unsigned int iSubEntity);
+			mTexture->getRectangle2D()->setVisible(false);
+			mTextureAtlas->getRectangle2D()->setVisible(false);
+		}
+    }
+
+	void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
+    {   
+
+    }
+
+	void setNumTextures(unsigned int numTextures)
+	{
+		mNumTextures = numTextures;
+		mCurrentTexture = 0;
+	}
+
+
+};
+
+class _BBCExport TextureAtlasListener : public Ogre::RenderTargetListener
+{
+public:
+	void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
+    {
+		//configureTexture( unsigned int iSubEntity );
+    }
+
+	void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
+    {
+		
+    }
+};
+
+class _BBCExport BillboardCloudTextureViewMode : public OBA::OgreFrameListenerMode 
+{
+	protected:
+		unsigned int mFrame;
+
+		Ogre::SceneNode *mClusterizedEntitiesMergedSceneNode;
+		
+		Ogre::Entity *mClusterizedEntities;
+
+		ClusterTextureListener mClusterTextureListener;
+
+		TextureAtlasListener mTextureAtlasListener;
+
+		IMG::TexturePtr mClusterTexture;
+
+		IMG::TextureAtlasPtr mTextureAtlas;
+
+		unsigned int mNumTextures;
+
+		unsigned int mCurrentTexture;
+
+		unsigned int mTextureAtlasSize;
+
+		unsigned int mTextureSize;
+
+		Ogre::PixelFormat mTexturePixelFormat;
+
+		Ogre::String mEntityName;
+
+		unsigned int mBitRange;
+
+		Ogre::PixelFormat mSrcPixelFormat;
+
+		Ogre::PixelFormat mDestPixelFormat;
+
+		Ogre::String mTextureAtlasName;
+
+		Ogre::String mTextureAtlasFolder;
+
+	public:
+		BillboardCloudTextureViewMode(Ogre::RenderWindow* win, unsigned int ogreFrameListenerModeHandle, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
+
+		virtual ~BillboardCloudTextureViewMode();		
+
+		virtual bool frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader);
+
+		virtual void createScene();
+
+		virtual void destroyScene();
+		
+		void setTextureAtlasSize(unsigned int size);
+
+		void setTextureSize(unsigned int size);
+
+		void setEntityName(Ogre::String entityName);
+
+		void setTextureAtlasName(Ogre::String textureAtlasName);
+
+		void setTextureAtlasFolder(Ogre::String textureAtlasFolder);
+
+		void setTextureAtlasBitRange(unsigned int bitRange);
+};
+
+}
+#endif
