Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 700)
@@ -0,0 +1,84 @@
+#ifndef _LBBCSAMPLECONFIGFILE_H
+#define _LBBCSAMPLECONFIGFILE_H
+
+#include <BBC.h>
+
+namespace LBBC {
+
+class _BBCExport SampleConfigFile : public Ogre::ConfigFile {
+  public:
+    SampleConfigFile();
+	
+    ~SampleConfigFile();
+
+	bool getEntityDistributionMerged();
+
+	Ogre::String getEntityDistributionSplittedMaterialPrefixName();
+
+	Ogre::String getEntityDistributionMergedMaterialPrefixName();
+
+	bool getEntityDistributionSplitted();
+
+	Ogre::String getEntitySampleMeshPrefixFilename();
+
+	bool getEntityDistributionGeneration();
+
+	Ogre::String getEntityDistributionFolder();
+
+	Ogre::String getEntityDistributionXMLPrefixFilename();
+
+	Ogre::String getEntitiesFolder();
+
+	bool getEntitySampleMeshGeneration();
+
+	Ogre::String getEntitiesMeshPrefixFilename();
+
+	bool getEntityClustersGeneration();
+
+	float getEntityClustersAlpha();
+
+	unsigned int getEntityClustersMaxClusters();
+
+	unsigned int getEntityClustersNumIterations();
+
+	Ogre::String getEntityClustersFolder();
+
+	bool getEntityClustersMergedClusters();
+
+	bool getEntityClustersSplittedClusters();
+
+	Ogre::String getEntityClustersMeshPrefixFilename();
+
+	Ogre::String getEntityClustersMaterialPrefixFilename();
+
+	bool getBillboardCloudMergedBillboards();
+
+	bool getBillboardCloudSplittedBillboards();
+
+	bool getBillboardCloudGeneration();
+
+	Ogre::String getBillboardCloudFolder();
+
+	Ogre::String getBillboardCloudMeshPrefixFilename();
+
+	Ogre::String getBillboardCloudMaterialPrefixFilename();
+
+	Ogre::String getBillboardCloudXMLPrefixFilename();
+
+	bool getBillboardCloudDiffuseColorTextureAtlasGeneration();
+
+	unsigned int getBillboardCloudDiffuseColorTextureSize();
+
+	unsigned int getBillboardCloudDiffuseColorTextureAtlasSize();
+
+	bool getBillboardCloudIndirectTextureAtlasGeneration();
+
+	unsigned int getBillboardCloudIndirectTextureSize();
+
+	unsigned int getBillboardCloudIndirectTextureAtlasSize();
+
+};
+
+}
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaf.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaf.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaf.h	(revision 700)
@@ -0,0 +1,88 @@
+#ifndef _LBBCLEAF_H
+#define _LBBCLEAF_H
+
+
+#include "BBCEntity.h"
+
+namespace LBBC {
+
+class _BBCExport Leaf : public BBC::Entity {
+  protected:
+    Ogre::Vector3 mPosition;
+
+    Ogre::Quaternion mOrientation;
+
+	float mLeafD;
+
+    float mPlaneD;
+
+    Ogre::Vector3 mPlaneNormal;
+
+	Ogre::Vector3 mLeafNormal;
+
+	std::vector<Ogre::Vector3> mFacesNormals;
+
+	//typedef std::set<unsigned int,std::greater<unsigned int> > ID_FACESet;
+	//typedef std::hash_set <unsigned int, hash<unsigned int >, equal_to<unsigned int > > ID_FACESet;
+	// Working version...
+	//std::hash_set<int, std::hash_compare<int, std::greater<unsigned int> > > subTri;
+	typedef stdext::hash_set <unsigned int> ID_FACESet;
+	ID_FACESet mFacesEntitySet;
+
+  public:
+    bool hasFace(unsigned int value);
+
+	void addFace(unsigned int value);
+
+	void removeFace(unsigned int value);
+
+	unsigned int getFace(unsigned int value);
+
+	unsigned int getNumFaces();
+
+	void addFaceNormal(Ogre::Vector3 value);
+
+	void removeFaceNormal(unsigned int value);
+
+	Ogre::Vector3 getFaceNormal(unsigned int value);
+   
+    void setPlaneD(float value);
+
+    float getPlaneD();
+
+	void setPlaneNormal(Ogre::Vector3 value);
+
+	Ogre::Vector3 getPlaneNormal();
+
+	void setPosition(Ogre::Vector3 value);
+
+	Ogre::Vector3 getPosition();
+
+	Ogre::Quaternion getOrientation();
+
+	void setOrientation(const Ogre::Quaternion & Quaternion);
+
+	unsigned int getNumLeafNormals();
+	
+	void setLeafNormal(Ogre::Vector3 normal);
+
+	Ogre::Vector3 getLeafNormal();
+
+	void setLeafD(float leafD);
+
+	float getLeafD();
+
+	void addFaceInfo(BBC::UniqueVertex v0, BBC::UniqueVertex v1, BBC::UniqueVertex v2);
+
+	void readLeaf(TiXmlNode *leafNode);
+
+	void writeLeaf(TiXmlNode *leafNode);
+
+    Leaf();
+
+    ~Leaf();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistribution.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistribution.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistribution.h	(revision 700)
@@ -0,0 +1,42 @@
+#ifndef _LBBCLEAFDISTRIBUTION_H
+#define _LBBCLEAFDISTRIBUTION_H
+
+
+#include "BBCEntityDistribution.h"
+#include "LBBCLeaf.h"
+
+namespace LBBC {
+
+class _BBCExport LeafDistribution : public BBC::EntityDistribution {
+  protected:
+	float mMinD;
+	float mMaxD;
+	Ogre::Vector3 mMinNormal;
+	Ogre::Vector3 mMaxNormal;
+
+  public:
+
+    LeafDistribution();
+
+    ~LeafDistribution();
+
+	void setMinD(float value);
+
+	void setMaxD(float value);
+
+	float getMinD();
+
+	float getMaxD();
+
+	void setMinNormal(Ogre::Vector3 value);
+
+	Ogre::Vector3 getMinNormal();
+
+	void setMaxNormal(Ogre::Vector3 value);
+
+	Ogre::Vector3 getMaxNormal();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h	(revision 700)
@@ -0,0 +1,19 @@
+#ifndef _LBBCKMEANSCLUSTERSERIALIZER_H
+#define _LBBCKMEANSCLUSTERSERIALIZER_H
+
+#include <BBC.h>
+
+namespace LBBC {
+
+class _BBCExport KMeansClusterSerializer : public BBC::BillboardCloudSerializer {
+  public:
+    KMeansClusterSerializer();
+
+    ~KMeansClusterSerializer();
+
+    void writeBillboardCloud(TiXmlDocument *document);
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h	(revision 700)
@@ -0,0 +1,22 @@
+#ifndef _LBBCKDTREECLUSTERSERIALIZER_H
+#define _LBBCKDTREECLUSTERSERIALIZER_H
+
+#include <BBC.h>
+#include <LBBCBillboardKdTreeClusterData.h>
+
+#include <string>
+
+namespace LBBC {
+
+class _BBCExport KdTreeClusterSerializer : public BBC::BillboardCloudSerializer {
+  public:
+    KdTreeClusterSerializer();
+
+    ~KdTreeClusterSerializer();
+
+	virtual void writeBillboardCloud(TiXmlDocument *document);
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 700)
@@ -0,0 +1,78 @@
+#ifndef _LBBCMANAGER_H
+#define _LBBCMANAGER_H
+
+#include <BBC.h>
+#include <LBBCPrerequisites.h>
+#include <LBBCLeaves.h>
+#include <LBBCLeafDistribution.h>
+#include <LBBCLeafDistributionGenerator.h>
+#include <LBBCLeafDistributionSerializer.h>
+#include <LBBCKdTreeClusterGenerator.h>
+#include <LBBCKMeansClusterGenerator.h>
+#include <LBBCKdTreeClusterSerializer.h>
+#include <LBBCKMeansClusterSerializer.h>
+#include <LBBCSampleConfigFile.h>
+
+namespace LBBC {
+
+class _BBCExport Manager : public BBC::Manager {
+  public:
+    Manager();
+
+    ~Manager();
+
+	void runSample(Ogre::String sampleConfigFile);
+
+	SampleConfigFile* getSampleConfigFile();
+
+	void generateEntityDistribution();
+
+	void loadEntityDistribution();
+
+	void saveEntityDistributionSplitted();
+
+	void createEntityDistribution();
+
+	void saveEntityDistributionXML();		
+
+	void generateEntityClusters();
+
+	void createEntityClusters();
+
+	void saveEntityClusters();
+
+	void saveSingleEntity();
+	
+	void generateBillboardCloud();
+
+	void saveBillboardCloudSplitted();
+
+	void saveBillboardCloudMerged();
+
+	void saveBillboardCloudXML();
+
+	Leaves* getLeaves();
+
+  protected:
+
+	LBBC::Leaves *mLeaves;
+
+	LBBC::LeafDistributionSerializer *mLeafDistributionSerializer;
+
+	LBBC::LeafDistributionGenerator *mLeafDistributionGenerator;
+
+	BBC::BillboardCloudGenerator *mBillboardCloudGenerator;
+
+	BBC::BillboardCloudSerializer *mBillboardCloudSerializer;
+
+	BBC::BillboardCloudUVMapper *mBillboardCloudUVMapper;
+
+	BBC::OgreMeshSerializer *mOgreMeshSerializer;
+
+	SampleConfigFile mSampleCf;
+
+	Ogre::ConfigFile mCf;
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h	(revision 700)
@@ -0,0 +1,27 @@
+#ifndef _LBBCLEAFDISTRIBUTIONGENERATOR_H
+#define _LBBCLEAFDISTRIBUTIONGENERATOR_H
+
+#include <BBC.h>
+#include <LBBCLeaf.h>
+#include <LBBCLeafDistribution.h>
+
+namespace LBBC {
+
+class _BBCExport LeafDistributionGenerator : public BBC::EntityDistributionGenerator {
+	
+  public:
+
+    LeafDistributionGenerator();
+
+    ~LeafDistributionGenerator();
+
+	void generateAverageLeafNormal(Leaf *leaf);
+
+	void generateNormalDThreshold(float &minD, float &maxD, Ogre::Vector3 &minNormal, Ogre::Vector3 &maxNormal);
+
+	void generate();
+ 	
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h	(revision 700)
@@ -0,0 +1,10 @@
+#ifndef _LBBC_H
+#define _LBBC_H
+
+#include <LBBCPrerequisites.h>
+#include <LBBCManager.h>
+#include <LBBCLeaves.h>
+#include <LBBCLeafKdTreeClusterData.h>
+#include <LBBCSampleConfigFile.h>
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaves.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaves.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaves.h	(revision 700)
@@ -0,0 +1,56 @@
+#ifndef _LBBCLEAVES_H
+#define _LBBCLEAVES_H
+
+#include <BBC.h>
+#include <LBBCLeafDistribution.h>
+
+namespace LBBC {
+
+class _BBCExport Leaves {
+  public:
+    Leaves();
+
+    ~Leaves();
+
+  protected:
+    bool mMeshLoaded;
+
+	Ogre::Mesh *mMesh;
+
+	BBC::BillboardCloud *mBillboardCloud;
+
+  public:
+	Ogre::Mesh* getMesh();
+
+	void setMesh(Ogre::Mesh * value);
+
+    void load();
+
+    void unload();
+
+	void setBillboardCloud(BBC::BillboardCloud *value);
+
+	BBC::BillboardCloud* getBillboardCloud();
+
+  protected:
+    LeafDistribution *mLeafDistribution;
+	
+  public:	
+
+    void addLeaf(const Leaf & value);
+
+    void removeLeaf(unsigned int value);
+
+    void initLeavesDistribution();
+
+    void initBillboardCloud();
+
+	LeafDistribution* getDistribution();
+
+	 void setDistribution(LeafDistribution* leafDistribution);
+
+};
+
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h	(revision 700)
@@ -0,0 +1,17 @@
+#ifndef _LBBCBILLBOARDKMEANSCLUSTERDATA_H
+#define _LBBCBILLBOARDKMEANSCLUSTERDATA_H
+
+#include <BBC.h>
+
+namespace LBBC {
+
+class _BBCExport BillboardKMeansClusterData : public BBC::BillboardClusterData {
+  public:
+    BillboardKMeansClusterData();
+
+    ~BillboardKMeansClusterData();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKdTreeClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKdTreeClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKdTreeClusterData.h	(revision 700)
@@ -0,0 +1,25 @@
+#ifndef _LBBCBILLBOARDKDTREECLUSTERDATA_H
+#define _LBBCBILLBOARDKDTREECLUSTERDATA_H
+
+#include <BBC.h>
+#include <LBBCLeafKdTreeClusterData.h>
+#include <LBBCLeaf.h>
+
+namespace LBBC {
+
+class _BBCExport BillboardKdTreeClusterData : public BBC::BillboardClusterData {
+  public:
+    BillboardKdTreeClusterData();
+
+    ~BillboardKdTreeClusterData();
+
+	virtual void readBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void writeBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void generateBillboardBoundingQuad();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterGenerator.h	(revision 700)
@@ -0,0 +1,80 @@
+#ifndef _LBBCKMEANSCLUSTERGENERATOR_H
+#define _LBBCKMEANSCLUSTERGENERATOR_H
+
+
+#include <BBC.h>
+
+namespace LBBC {
+
+class _BBCExport KMeansClusterGenerator : public BBC::BillboardCloudGenerator {
+  public:
+    void generate();
+
+    void init();
+
+    KMeansClusterGenerator();
+
+    ~KMeansClusterGenerator();
+
+  protected:
+
+	class Cell
+	{
+		protected:
+		Cell *right;
+		Cell *left;
+		Ogre::Vector4 min;
+		Ogre::Vector4 max;
+		
+		public:
+		Cell()
+		{
+			right = NULL;
+			left = NULL;
+		}
+
+		void setLeftChild(Cell *lChild)
+		{
+			left = lChild;
+		}
+
+		void setRightChild(Cell *rChild)
+		{
+			right = rChild;
+		}
+
+		Cell* getRightChild()
+		{
+			return right;
+		}
+		
+		Cell* getLeftChild()
+		{
+			return left;
+		}
+		
+		Ogre::Vector4 getMin()
+		{
+			return min;
+		}
+		
+		Ogre::Vector4 getMax()
+		{
+			return max;
+		}	
+
+		void setMax(Ogre::Vector4 vmax)
+		{
+			max = vmax;
+		}
+
+		void setMin(Ogre::Vector4 vmin)
+		{
+			min = vmin;
+		}
+	};
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterGenerator.h	(revision 700)
@@ -0,0 +1,62 @@
+#ifndef _LBBCKDTREECLUSTERGENERATOR_H
+#define _LBBCKDTREECLUSTERGENERATOR_H
+
+#include <BBC.h>
+#include <LBBCLeafKdTreeClusterData.h>
+#include <LBBCBillboardKdTreeClusterData.h>
+#include <LBBCLeaf.h>
+#include <LBBCLeafDistribution.h>
+
+namespace LBBC {
+
+class _BBCExport KdTreeClusterGenerator : public BBC::BillboardCloudGenerator {
+  public:
+    void generate();
+
+    void init();
+
+	void setAlpha(float value);
+
+	float getAlpha();
+
+	void initializeBillboardCloud();
+
+	BBC::Billboard* createBillboard();
+
+	void initializeBillboardClusterData(BBC::Billboard *billboard);
+	
+	void initializeRandomBillboard(BBC::Billboard *billboard);
+
+	void splitLeafDistribution();
+
+	void assignLeafBillboard(Leaf *leaf, BBC::Billboard *billboard);
+
+	void recomputeBillboardCloud();
+
+	void recomputeBillboard(BBC::Billboard *billboard);
+
+	void iterativeRecomputeBillboardCloud();
+
+	unsigned int findBestBillboard(Leaf *leaf);
+
+	void generateBillboardCloudBounds();
+
+	void setNumIterations(unsigned int value);
+
+	unsigned int getNumIterations();
+
+    KdTreeClusterGenerator();
+
+    ~KdTreeClusterGenerator();
+
+  protected:
+
+    float mAlpha;
+
+	float mEpsilonYN;
+
+	float mNumIterations;
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionSerializer.h	(revision 700)
@@ -0,0 +1,34 @@
+#ifndef _LBBCLEAFDISTRIBUTIONSERIALIZER_H
+#define _LBBCLEAFDISTRIBUTIONSERIALIZER_H
+
+
+#include <BBC.h>
+#include <LBBCLeafDistribution.h>
+#include <LBBCLeaf.h>
+
+namespace LBBC {
+
+class _BBCExport LeafDistributionSerializer : public BBC::EntityDistributionSerializer {
+  public:
+    LeafDistributionSerializer();
+
+    ~LeafDistributionSerializer();
+
+
+  public:
+	void writeLeafDistribution(TiXmlDocument *document);
+
+	void readLeafDistribution(TiXmlDocument *document);
+
+	void addFacesInfo(Leaf *leaf);
+
+	void setLeafDistribution(LeafDistribution *value);
+
+	LeafDistribution* getLeafDistribution();
+
+  protected:
+	LeafDistribution *mLeafDistribution;
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKMeansClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKMeansClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKMeansClusterData.h	(revision 700)
@@ -0,0 +1,17 @@
+#ifndef _LBBCLEAFKMEANSCLUSTERDATA_H
+#define _LBBCLEAFKMEANSCLUSTERDATA_H
+
+#include <BBCEntityClusterData.h>
+
+namespace LBBC {
+
+class _BBCExport LeafKMeansClusterData : public BBC::EntityClusterData {
+  public:
+    LeafKMeansClusterData();
+
+    ~LeafKMeansClusterData();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKdTreeClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKdTreeClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKdTreeClusterData.h	(revision 700)
@@ -0,0 +1,19 @@
+#ifndef _LBBCLEAFKDTREECLUSTERDATA_H
+#define _LBBCLEAFKDTREECLUSTERDATA_H
+
+#include <BBCEntityClusterData.h>
+
+namespace LBBC {
+
+class _BBCExport LeafKdTreeClusterData : public BBC::EntityClusterData {
+  public:
+    LeafKdTreeClusterData();
+
+    ~LeafKdTreeClusterData();
+
+  protected:
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCPrerequisites.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCPrerequisites.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCPrerequisites.h	(revision 700)
@@ -0,0 +1,6 @@
+#ifndef _LBBCPREREQUISITES_H
+#define _LBBCPREREQUISITES_H
+
+#include <BBC.h>
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionGenerator.h	(revision 700)
@@ -0,0 +1,33 @@
+#ifndef _BBCENTITYDISTRIBUTIONGENERATOR_H
+#define _BBCENTITYDISTRIBUTIONGENERATOR_H
+
+#include <BBCPrerequisites.h>
+#include <BBCEntityDistribution.h>
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport EntityDistributionGenerator {
+  protected:
+
+	EntityDistribution *mEntityDistribution;
+
+    Entity *mEntity;
+
+  public:
+    void generate();
+
+    void init();
+
+	Entity* getEntity();
+
+	void setEntity(Entity *value);
+
+	void setDistribution(EntityDistribution *value);
+
+	EntityDistribution* getDistribution();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h	(revision 700)
@@ -0,0 +1,134 @@
+#ifndef _BBCSUBENTITY_H
+#define _BBCSUBENTITY_H
+
+#include <BBCPrerequisites.h>
+
+namespace BBC {
+
+class _BBCExport UniqueVertex
+{
+public:
+    Ogre::Vector3 position;
+    Ogre::Vector3 normal;
+    Ogre::Vector3 uv[OGRE_MAX_TEXTURE_COORD_SETS];
+    Ogre::RGBA colour;
+    // The index of the next component with the same base details
+    // but with some variation
+    size_t nextIndex;
+
+    UniqueVertex();
+    bool operator==(const UniqueVertex& rhs) const;
+
+};
+
+typedef std::vector<UniqueVertex> UniqueVertexList;
+
+class _BBCExport SubEntity {
+  public:
+
+	typedef std::vector<unsigned short int> TextureCoordSetsDimensions;
+	typedef std::vector<Ogre::Vector3> Indices;
+
+  protected:
+
+	UniqueVertexList mUniqueVertexList;
+
+	TextureCoordSetsDimensions mTextureCoordSetsDimensions;
+	
+	Indices mIndices;
+	
+	bool mHasTangents;
+	
+	bool mHasVertexColours;
+	
+	bool mHasNormals;
+
+	bool mHasTextureCoords;
+
+	Ogre::String mName;
+
+	Ogre::String mMaterialName;
+
+	Ogre::AxisAlignedBox mAABBox;
+    	
+  public:
+
+    SubEntity();
+
+    ~SubEntity();
+
+	void enableTangents(bool value);
+	
+	bool hasTangents();
+
+	void enableNormals(bool value);
+
+	bool hasNormals();
+
+	void enableTextureCoords(bool value);
+
+	bool hasVertexColours();
+
+	void enableVertexColours(bool value);
+
+	void setVertexColour(unsigned int index, Ogre::RGBA value);
+
+	Ogre::RGBA getVertexColour(unsigned int index);
+
+	unsigned int getNumTexCoordSets();
+
+	unsigned int getTexCoordDimensions(unsigned int value);
+
+	void addTextureCoordSet(unsigned int numTexCoords);
+
+	unsigned int getNumTexCoords();
+
+	unsigned int getNumVertices();
+
+	void setPosition(unsigned int index, Ogre::Vector3 value);
+
+	Ogre::Vector3 getPosition(unsigned int index);
+
+	void setNormal(unsigned int index, Ogre::Vector3 value);
+
+	Ogre::Vector3 getNormal(unsigned int index);
+
+	void setTexCoord(unsigned int index, unsigned int set, Ogre::Vector3 value);
+
+	Ogre::Vector3 getTexCoord(unsigned int index, unsigned int set, unsigned int value);	
+
+	void addFaceVerticesIDs(Ogre::Vector3 value);
+
+	void removeFaceVerticesIDs(unsigned int value);
+
+	Ogre::Vector3 getFaceVerticesIDs(unsigned int value);
+
+	unsigned int getNumFaces();
+
+	Ogre::String getName();
+
+	void setName(Ogre::String value);
+
+	Ogre::String getMaterialName();
+
+	void setMaterialName(Ogre::String value);
+
+	//void createUniqueVertices();
+
+	UniqueVertexList* getUniqueVertices();
+
+	void addUniqueVertex(UniqueVertex uniqueVertex);
+
+	void removeUniqueVertex(unsigned int index);
+
+	UniqueVertex getUniqueVertex(unsigned int index);
+
+	const Ogre::AxisAlignedBox &getAABBox();
+
+	void setAABBox(Ogre::AxisAlignedBox box);
+
+	void generateAABBox();
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h	(revision 700)
@@ -0,0 +1,73 @@
+#ifndef _BBCBILLBOARDCLUSTERDATA_H
+#define _BBCBILLBOARDCLUSTERDATA_H
+
+#include <BBCEntityCluster.h>
+
+namespace BBC {
+
+class _BBCExport BillboardClusterData {
+  public:
+    BillboardClusterData();
+
+    ~BillboardClusterData();
+
+	void setNormal(Ogre::Vector3 value);
+
+	Ogre::Vector3 getNormal();
+
+	void setD(float value);
+
+	float getD();
+
+    EntityCluster* getEntityCluster();
+
+	void setEntityCluster(EntityCluster *value);
+
+	virtual void readBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void writeBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void generateBillboardBoundingQuad();
+
+	Ogre::Vector3 getQuadTopLeftCorner();
+
+	Ogre::Vector3 getQuadTopRightCorner();
+
+	Ogre::Vector3 getQuadBottomLeftCorner();
+
+	Ogre::Vector3 getQuadBottomRightCorner();
+
+	Ogre::Vector3 getAxisX();
+
+	Ogre::Vector3 getAxisY();
+
+	Ogre::Vector3 getAxisZ();
+
+
+
+protected:
+	EntityCluster *mEntityCluster;
+	
+	Ogre::Vector3 mAxisX;
+
+	Ogre::Vector3 mAxisY;
+
+	Ogre::Vector3 mAxisZ;
+
+    enum BoundingQuadVertex {
+        QUAD_TOP_LEFT,
+        QUAD_TOP_RIGHT,
+        QUAD_BOTTOM_RIGHT,
+        QUAD_BOTTOM_LEFT
+    };
+
+	Ogre::Vector3 mBillboardCorners[4];
+
+	Ogre::Vector3 mNormal;
+
+	float mD;
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h	(revision 700)
@@ -0,0 +1,39 @@
+#ifndef _BBCBILLBOARDCLOUDGENERATOR_H
+#define _BBCBILLBOARDCLOUDGENERATOR_H
+
+#include <BBCUtil.h>
+#include <BBCEntity.h>
+#include <BBCEntityDistribution.h>
+#include <BBCBillboardCloud.h>
+
+namespace BBC {
+
+class _BBCExport BillboardCloudGenerator {
+  public:
+    void generate();
+
+	void init();
+
+	void setMaxNumBillboards(unsigned int value);
+
+	unsigned int getMaxNumBillboards();
+
+	void setDistribution(EntityDistribution *value); 
+
+	EntityDistribution* getDistribution(); 
+
+	void setBillboardCloud(BillboardCloud *value);
+
+	BillboardCloud* getBillboardCloud();
+
+  protected:
+
+    unsigned int mMaxNumBillboards;
+
+	EntityDistribution *mEntityDistribution;
+
+	BillboardCloud *mBillboardCloud;
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCXmlSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCXmlSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCXmlSerializer.h	(revision 700)
@@ -0,0 +1,29 @@
+#ifndef _BBCXMLSERIALIZER_H
+#define _BBCXMLSERIALIZER_H
+
+#include <BBCPrerequisites.h>
+
+namespace BBC {
+
+class _BBCExport XmlSerializer 
+{
+  public:
+    XmlSerializer();
+
+    ~XmlSerializer();
+
+  protected:
+    Ogre::String mFilename;
+	TiXmlDocument *mFile;
+    bool mLoaded;
+
+  public:
+	  TiXmlDocument* load(Ogre::String filename);
+
+ 	  void save();
+
+	  TiXmlDocument* create(Ogre::String filename);
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboard.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboard.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboard.h	(revision 700)
@@ -0,0 +1,38 @@
+#ifndef _BBCBILLBOARD_H
+#define _BBCBILLBOARD_H
+
+#include <BBCBillboardClusterData.h>
+
+namespace BBC {
+
+class _BBCExport Billboard {
+  public:
+    Billboard();
+
+    ~Billboard();
+
+
+  protected:
+    unsigned int mBillboardHandle;
+
+
+  public:
+    unsigned int getBillboardHandle();
+
+    void setBillboardHandle(unsigned int value);
+
+
+  protected:
+
+	BillboardClusterData *mBillboardClusterData;
+
+  public:
+
+	void setBillboardClusterData(BillboardClusterData *value);
+
+	BillboardClusterData* getBillboardClusterData();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h	(revision 700)
@@ -0,0 +1,59 @@
+#ifndef _BBCBILLBOARDCLOUDUVMAPPER_H
+#define _BBCBILLBOARDCLOUDUVMAPPER_H
+
+#include "IMGBsp.h"
+#include "IMGClusterList.h"
+#include "BBCBillboardCloud.h"
+
+namespace BBC {
+
+class BillboardCloudUVMapper {
+  protected:
+    IMG::Bsp mBsp;
+
+    IMG::ClusterList mClusterList;
+
+    unsigned short int mTextureWidth;
+
+    unsigned short int mTextureHeight;
+
+	unsigned short int mTextureAtlasWidth;
+
+	unsigned short int mTextureAtlasHeight;
+
+    BillboardCloud * mBillboardCloud;
+
+
+  public:
+    void initialize();
+
+    void setTextureAtlasWidth(unsigned short int width);
+
+    unsigned short int getTextureAtlasWidth();
+
+    void setTextureAtlasHeight(unsigned short int height);
+
+    unsigned short int getTextureAtlasHeight();
+
+    void setTextureWidth(unsigned short int width);
+
+    unsigned short int getTextureWidth();
+
+    void setTextureHeight(unsigned short int height);
+
+    unsigned short int getTextureHeight();
+
+    void BillboardCloudUVMapper::generateTextureAtlasTextureCoords(bool mergeBillboards); 
+
+    void setBillboardCloud(BillboardCloud *billboardCloud);
+
+    BillboardCloud* getBillboardCloud();
+
+    BillboardCloudUVMapper();
+
+    ~BillboardCloudUVMapper();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSingleton.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSingleton.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSingleton.h	(revision 700)
@@ -0,0 +1,35 @@
+#ifndef __SINGLETON_H__
+#define __SINGLETON_H__
+
+namespace BBC {
+
+
+template <typename T> class _BBCExport CSingleton
+{
+    protected:
+
+        static T* ms_Singleton;
+
+    public:
+        CSingleton( void )
+        {
+            assert( !ms_Singleton );
+#if defined( _MSC_VER ) && _MSC_VER < 1200	 
+            int offset = (int)(T*)1 - (int)(CSingleton <T>*)(T*)1;
+            ms_Singleton = (T*)((int)this + offset);
+#else
+	    ms_Singleton = static_cast< T* >( this );
+#endif
+        }
+        ~CSingleton( void )
+            {  assert( ms_Singleton );  ms_Singleton = 0;  }
+        static T& getSingleton( void )
+		{	assert( ms_Singleton );  return ( *ms_Singleton ); }
+        static T* getSingletonPtr( void )
+		{ return ms_Singleton; }
+};
+
+
+}
+
+#endif // ! defined __SINGLETON_H__
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCOgreMeshSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCOgreMeshSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCOgreMeshSerializer.h	(revision 700)
@@ -0,0 +1,42 @@
+#ifndef __BBCOGREMESHEXPORTER_H__
+#define __BBCOGREMESHEXPORTER_H__
+
+#include <BBCPrerequisites.h>
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport OgreMeshSerializer
+{
+    public:
+        OgreMeshSerializer();
+
+        virtual ~OgreMeshSerializer();
+
+		void setEntity(Entity *entity);
+
+		Entity* getEntity();
+
+		void exportMesh(const Ogre::String& fileName, bool mergeSubMeshes, bool tangents);
+
+    protected:
+
+		Entity *mEntity;
+		
+		void buildMesh(Ogre::Mesh* pMesh, bool mergeSubmeshes);
+		
+		void generateEntityAABB(Ogre::Mesh* pMesh);
+		
+		void exportSubMeshes(Ogre::Mesh* pMesh);
+        
+		void exportSubMesh(Ogre::Mesh* pMesh, SubEntity *subEntity);
+        
+		template <typename T> void writeIndexes(T* buf, SubEntity *subEntity);
+        
+		void createVertexBuffer(Ogre::VertexData* vd, unsigned short bufIdx, UniqueVertexList *uniqueVertexList);
+
+	};
+
+}
+#endif
+
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCPrerequisites.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCPrerequisites.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCPrerequisites.h	(revision 700)
@@ -0,0 +1,38 @@
+#ifndef _BBCPREREQUISITES_H
+#define _BBCPREREQUISITES_H
+
+#include <Ogre.h>
+#include <OgreMatrix3.h>
+#include <OgreXMLMeshSerializer.h>
+#include <OgreXMLSkeletonSerializer.h>
+#include <OgreSkeletonSerializer.h>
+#include <OgreXMLPrerequisites.h>
+#include <OgreDefaultHardwareBufferManager.h>
+#include <OgrePrerequisites.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreColourValue.h>
+#include <OgreMesh.h>
+#include <OgreException.h>
+#include <OgreLogManager.h>
+#include <OgreMeshManager.h>
+#include <OgreSubMesh.h>
+#include <OgreMeshManager.h>
+#include <OgreMeshSerializer.h>
+#include <OgreHardwareBufferManager.h>
+#include <OgreVertexBoneAssignment.h>
+#include <OgreAxisAlignedBox.h>
+
+#include <OgreKeyEvent.h>
+#include <OgreEventListeners.h>
+#include <OgreStringConverter.h>
+#include <OgreException.h>
+#include <OgreHardwarePixelBuffer.h>
+#include <OgrePixelFormat.h>
+#include <OgreGpuProgram.h>
+
+//#include <ospace/stl/hashset.h>
+#include <hash_set>
+
+#define _BBCExport __declspec( dllexport )
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionSerializer.h	(revision 700)
@@ -0,0 +1,30 @@
+#ifndef _BBCENTITYDISTRIBUTIONSERIALIZER_H
+#define _BBCENTITYDISTRIBUTIONSERIALIZER_H
+
+#include <BBCPrerequisites.h>
+#include <BBCXmlSerializer.h>
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport EntityDistributionSerializer: public BBC::XmlSerializer {
+  protected:
+	Entity* mEntity;
+
+  public:
+    Entity* getEntity();
+
+    void setEntity(Entity * value);
+
+    void generate();
+
+    void init();
+
+    EntityDistributionSerializer();
+
+    ~EntityDistributionSerializer();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h	(revision 700)
@@ -0,0 +1,22 @@
+#ifndef _BILLBOARDGROUP_H
+#define _BILLBOARDGROUP_H
+
+
+#include <vector>
+using namespace std;
+
+namespace BBC {
+
+class BillboardGroup {
+  protected:
+    vector<int> mBillboardHandleList;
+
+  public:
+    int getBillboardHandle();
+
+    void setBillboardHandle();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityClusterData.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityClusterData.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityClusterData.h	(revision 700)
@@ -0,0 +1,24 @@
+#ifndef _BBCENTITYCLUSTERDATA_H
+#define _BBCENTITYCLUSTERDATA_H
+
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport EntityClusterData {
+  public:
+    EntityClusterData();
+
+    ~EntityClusterData();
+
+	void setEntity(Entity *value);
+
+	Entity* getEntity();
+
+  protected:
+	Entity *mEntity;
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudTextureGenerator.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudTextureGenerator.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudTextureGenerator.h	(revision 700)
@@ -0,0 +1,12 @@
+#ifndef _BBCBILLBOARDCLOUDTEXTUREGENERATOR_H
+#define _BBCBILLBOARDCLOUDTEXTUREGENERATOR_H
+
+
+namespace BBC {
+
+/*
+class _BBCExport BillboardCloudTextureGenerator {
+};
+*/
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h	(revision 700)
@@ -0,0 +1,58 @@
+#ifndef _BBCMANAGER_H
+#define _BBCMANAGER_H
+
+#include <BBCPrerequisites.h>
+#include <BBCSingleton.h>
+
+//#include <ExampleFrameListener.h>
+
+namespace BBC {
+
+class _BBCExport Manager : public CSingleton<Manager> {
+  public:
+    Manager();
+	
+    ~Manager();
+
+	static Manager& getSingleton(void);
+    
+	static Manager* getSingletonPtr(void);
+
+	void initRenderWindow();
+
+	Ogre::Mesh* loadMesh(Ogre::String name);
+
+	Ogre::Mesh* loadXMLMesh(Ogre::String name);
+
+	void loadResources();
+
+	void saveMesh(Ogre::String name);
+
+	void saveXMLMesh(Ogre::String name);
+
+	void initialize(void);
+
+	void shutdown(void);
+
+	Ogre::MeshSerializer* getMeshSerializer(void);
+
+	Ogre::XMLMeshSerializer* getXMLMeshSerializer(void);
+
+  protected:
+	  Ogre::Root* mOgreRoot;
+	  Ogre::MeshSerializer *mMeshSerializer;
+	  Ogre::XMLMeshSerializer *mXMLMeshSerializer;
+	  Ogre::DefaultHardwareBufferManager *mDefaultHardwareBufferManager;
+	  Ogre::RenderWindow *mWnd;
+	  Ogre::SceneManager *mScene;
+	  Ogre::RenderSystem *mRSys;
+	  Ogre::Camera *mCam;
+	  Ogre::Viewport *mView;
+	  Ogre::Math *mMath;
+	  //ExampleFrameListener *mFrameListener;
+};
+
+}
+
+#endif
+
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudSerializer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudSerializer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudSerializer.h	(revision 700)
@@ -0,0 +1,37 @@
+#ifndef _BBCBILLBOARDCLOUDSERIALIZER_H
+#define _BBCBILLBOARDCLOUDSERIALIZER_H
+
+#include <BBCPrerequisites.h>
+#include <BBCXmlSerializer.h>
+#include <BBCBillboardCloud.h>
+#include <BBCBillboard.h>
+#include <BBCEntityCluster.h>
+#include <BBCBillboardClusterData.h>
+
+#include <string>
+
+namespace BBC {
+
+class _BBCExport BillboardCloudSerializer : public XmlSerializer {
+  public:
+    BillboardCloudSerializer();
+
+    ~BillboardCloudSerializer();
+
+
+  protected:
+	BillboardCloud * mBillboardCloud;
+
+
+  public:
+
+    void setBillboardCloud(BillboardCloud *value);
+
+	BillboardCloud * getBillboardCloud();
+
+	virtual void writeBillboardCloud(TiXmlDocument *document);
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistribution.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistribution.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistribution.h	(revision 700)
@@ -0,0 +1,23 @@
+#ifndef _BBCENTITYDISTRIBUTION_H
+#define _BBCENTITYDISTRIBUTION_H
+
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport EntityDistribution {
+  protected:
+	std::vector<Entity*> mEntityList;
+
+  public:
+	Entity* getEntity(unsigned int value);
+
+	void addEntity(Entity *value);
+
+	void removeEntity(unsigned int value);
+
+	unsigned int getNumEntities(void);
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntity.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntity.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntity.h	(revision 700)
@@ -0,0 +1,68 @@
+#ifndef _BBCENTITY_H
+#define _BBCENTITY_H
+
+#include <BBCPrerequisites.h>
+#include <BBCSubEntity.h>
+
+namespace BBC {
+
+class _BBCExport Entity 
+{
+  protected:
+
+	typedef std::vector<SubEntity*> SubEntityList;
+
+	unsigned int mEntityHandle;
+
+    unsigned int mBillboardHandle;
+
+	SubEntityList mSubEntityList;
+
+	Ogre::Mesh *mMesh;
+	
+  public:
+
+    Entity();
+
+    ~Entity();
+
+	void createSubEntity();
+
+	void addSubEntity(SubEntity *value);
+
+	SubEntity* getSubEntity(unsigned int index);
+
+	void removeSubEntity(unsigned int index);
+
+	virtual Ogre::Mesh* getMesh();
+
+	virtual void setMesh(Ogre::Mesh *value);
+
+	void loadMesh(bool mergeSubMeshes);
+
+	void getMeshPositions(Ogre::Vector3 position, Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes);
+
+	void getMeshNormals(Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes);
+
+	void getMeshVertexColours(bool mergeSubMeshes);
+
+	void getMeshTexCoords(bool mergeSubMeshes);
+
+	void getMeshFacesVerticesID(bool mergeSubMeshes);
+
+	void setSubEntitiesDistinctVertexColours();
+
+    unsigned int getEntityHandle();
+
+    void setEntityHandle(unsigned int value);
+
+	void sincronizeNumSubEntities();
+
+	unsigned int getNumSubEntities();
+
+	void mergeSubEntities();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCUtil.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCUtil.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCUtil.h	(revision 700)
@@ -0,0 +1,32 @@
+#ifndef _BBCUTIL_H
+#define _BBCUTIL_H
+
+#include <BBCPrerequisites.h>
+
+namespace BBC {
+/*
+extern "C" _BBCExport double fround(double n, unsigned d)
+{ 
+	return floor(n * pow((double)10.,(int) d) + .5) / pow((double)10.,(int) d);
+}
+
+extern "C" _BBCExport int iround(double x)
+{
+      return (int)floor(x + 0.5);
+}
+
+extern "C" _BBCExport unsigned int getUpperPowerOfTwo(unsigned int powerOfTwo)
+{
+	unsigned int icount = 0;
+	unsigned int depth = 1;
+	while (icount < powerOfTwo)
+	{
+		depth = depth << 1;
+		icount++;
+	}
+	return depth;
+}
+*/
+}
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityCluster.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityCluster.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityCluster.h	(revision 700)
@@ -0,0 +1,58 @@
+#ifndef _BBCENTITYCLUSTER_H
+#define _BBCENTITYCLUSTER_H
+
+#include <BBCPrerequisites.h>
+#include <BBCEntity.h>
+#include <BBCEntityClusterData.h>
+#include <BBCEntityDistribution.h>
+
+#include <vector>
+
+namespace BBC {
+
+class _BBCExport EntityCluster {
+  public:
+    EntityCluster();
+
+    ~EntityCluster();
+
+	EntityClusterData* getEntityClusterData(unsigned int value);
+
+	void addEntityClusterData(EntityClusterData *value);
+
+	void removeEntitClusterData(unsigned int value);
+
+	EntityDistribution* getEntityDistribution();
+
+	void setEntityDistribution(EntityDistribution *value);
+
+  protected:
+
+	EntityDistribution *mEntityDistribution;
+	
+	std::vector<EntityClusterData*> mEntityClusterDataList;
+    
+	std::vector<unsigned int> mBillboarHandle;
+
+	Entity *mEntity;
+
+	unsigned int mBillboardHandle;
+
+  public:
+
+	Entity* getEntity();
+
+	void setEntity(Entity* value);
+
+	unsigned int getNumEntitiesClusterData();
+
+    unsigned int getBillboardHandle();
+
+    void setBillboardHandle(unsigned int value);
+
+    void generateEntityCluster(); 
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBC.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBC.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBC.h	(revision 700)
@@ -0,0 +1,25 @@
+#ifndef _BBC_H
+#define _BBC_H
+
+#include <BBCPrerequisites.h>
+#include <BBCManager.h>
+#include <BBCBillboardCloudUVMapper.h>
+#include <BBCSingleton.h>
+#include <BBCEntity.h>
+#include <BBCSubEntity.h>
+#include <BBCUtil.h>
+#include <BBCBillboard.h>
+#include <BBCBillboardCloud.h>
+#include <BBCBillboardCloudGenerator.h>
+#include <BBCEntityDistributionGenerator.h>
+#include <BBCEntityCluster.h>
+#include <BBCEntityClusterData.h>
+#include <BBCBillboardClusterData.h>
+#include <BBCXmlSerializer.h>
+#include <BBCEntityDistributionSerializer.h>
+#include <BBCXmlSerializer.h>
+#include <BBCBillboardCloudSerializer.h>
+#include <BBCOgreMeshSerializer.h>
+#include <BBCTimer.h>
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCTimer.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCTimer.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCTimer.h	(revision 700)
@@ -0,0 +1,29 @@
+#ifndef _BBCTIMER_H
+#define _BBCTIMER_H
+
+#include <BBCPrerequisites.h>
+#include <BBCSingleton.h>
+#include <BBCEntity.h>
+
+namespace BBC {
+
+class _BBCExport Timer
+{
+  protected:
+	time_t mTimer;
+	struct tm *mInitTime;
+	struct tm *mEndTime;
+
+  public:
+	void start();
+
+	void stop();
+
+	void printStartTime();
+
+	void printStopTime();
+};
+
+}
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h	(revision 700)
@@ -0,0 +1,51 @@
+#ifndef _BBCBILLBOARDCLOUD_H
+#define _BBCBILLBOARDCLOUD_H
+
+#include <BBCBillboardGroup.h>
+#include <BBCBillboard.h>
+#include <BBCEntityCluster.h>
+#include <BBCEntity.h>
+
+#include <vector>
+
+namespace BBC {
+
+class _BBCExport BillboardCloud {
+  public:
+    BillboardCloud();
+
+    ~BillboardCloud();
+
+
+  protected:
+    vector<Billboard*> mBillboardList;
+
+
+  public:
+    vector<Billboard*>* getBillboardList();
+
+    void setBillboardList(vector<Billboard*> &value);
+
+    void addBillboard(Billboard* value);
+
+    void removeBillboard(unsigned int value);
+
+	Billboard* getBillboard(unsigned int value);	
+
+	unsigned int BillboardCloud::getNumBillboards();
+
+	void generateBillboardCloud(bool mergeBillboards);
+
+  protected:
+	Entity *mEntity;
+
+
+  public:
+	Entity* getEntity();
+
+	void setEntity(Entity *value);
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h	(revision 700)
@@ -0,0 +1,45 @@
+#ifndef _IMGCLUSTERLIST_H
+#define _IMGCLUSTERLIST_H
+
+
+#include "IMGCluster.h"
+
+namespace IMG {
+
+//*
+//	ClusterList
+//*
+class ClusterList {
+  public:
+    inline ClusterList() {
+      	list.reserve(100);
+      };
+
+    //std::vector<Polygon*> * GetList() { return &list;}	//return the pointer to the list of voxels
+    inline std::vector<Cluster> * GetList() { return &list;};
+
+    //return the pointer to the list of voxels
+    inline int GetSize() const { return list.size(); }
+
+    //return the number of elements of list
+    inline Cluster * Get(unsigned int i) {
+        if (i <= list.size()) return &list[i];
+        //if (i <= list.size()) return list[i];
+        return NULL;
+      };
+
+    bool Insert(Cluster * p);
+
+    void Print();
+
+
+  private:
+    std::vector<Cluster> list;
+
+  public:
+    ~ClusterList();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxel.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxel.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxel.h	(revision 700)
@@ -0,0 +1,111 @@
+#ifndef _IMGVOXEL_H
+#define _IMGVOXEL_H
+
+
+#include "IMGBBox.h"
+
+namespace IMG {
+
+#define VOXEL_FACE_LEFT   0
+#define VOXEL_FACE_RIGHT  1
+#define VOXEL_FACE_BEHIND 2
+#define VOXEL_FACE_FRONT  3
+#define VOXEL_FACE_UNDER  4
+#define VOXEL_FACE_OVER   5
+#define VOXEL_NO_FACE	  -1
+
+//*
+//	Voxel
+//*
+class Voxel : public BBox {
+  public:
+    //Voxel(Ogre::AxisAlignedBox &box);
+    Voxel(BBox & box);
+
+    Voxel();
+
+    Voxel(const Voxel & v);
+
+    inline ~Voxel() {};
+
+    //the real voxel's id from scene, for indexing purpose
+    inline unsigned int GetIdVoxel() const { return idvoxel;                };
+
+    //return the number of polygons in the voxel
+    // Gametools -- Isma 17/08/2005
+    //int GetSizePolygonList()       const { return polygonlistid.GetSize(); }
+    //int GetSizePatchList()       const { return patchlistid.GetSize(); }
+    //return pointer to list_id_obspoly;
+    //std::vector<unsigned int> * GetIdObsPolyList() { return &list_id_obspoly; }
+    //bool InsertPolygon();
+    //set the boundbox of the voxel
+    //inline void SetBoundBox(Ogre::AxisAlignedBox *b)
+    inline void SetBoundBox(BBox * b) {
+        BBox::StartBoundingBox();
+        mMinimum = b->getMinimum();
+        mMaximum = b->getMaximum();
+      };
+
+    inline void SetBoundBox(float x1, float y1, float z1, float x2, float y2, float z2) {
+        BBox::StartBoundingBox();
+        BBox::AddBoundingVector3(x1, y1, z1);
+        BBox::AddBoundingVector3(x2, y2, z2);
+      };
+
+    void Print();
+
+    //print voxel info
+	inline Ogre::Vector3 * GetVector3(int i) {
+        	return BBox::GetCorner(i);
+      };
+
+    // Gametools -- Isma 17/08/2005
+    //unsigned int GetNextPatch()	//return the id to next patch in the voxel
+    //{
+    //  if (index < GetSizePatchList()) return patchlistid.Get(index++);
+    //  //return -1;
+    //  return 0;
+    //}
+    // Gametools -- Isma 17/08/2005
+    //unsigned int GetPatch(unsigned int i) { if (i < GetSizePatchList()) return patchlistid.Get(i); else return 0;}
+    // Gametools -- Isma 17/08/2005
+    //unsigned int GetPolygon(unsigned int i) { if (i < GetSizePolygonList())return polygonlistid.Get(i); else return 0; }
+    // Gametools -- Isma 17/08/2005
+    //unsigned int GetNextObsPoly() 	//return the id to next obspoly in the voxel
+    //{
+    //  if (index_obspoly < GetSizePolygonList()) return polygonlistid.Get(index_obspoly++);
+    //  //return -1;
+    //  return 0;
+    //}
+    bool AddPatch(unsigned int id);
+
+    //add one patch (only the id) to list_id_patch
+    bool AddPoly(unsigned int id);
+
+    //add one patch (only the id) to list_id_obspoly
+    //reset the index of the patch list
+    inline void ResetIndex() { index = 0; };
+
+    //reset the index of the obspolylist
+    inline void ResetIndexObsPoly() { index_obspoly = 0; };
+
+
+  private:
+    static unsigned int ID_VOXELS;
+
+    unsigned int idvoxel;
+
+    //for GetNextPatch()
+    unsigned int index;
+
+    //for GetNextObsPoly	
+    unsigned int index_obspoly;
+
+    std::vector<unsigned int> list_id_obspoly;
+
+    std::vector<unsigned int > list_id_patch;
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBox2d.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBox2d.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBox2d.h	(revision 700)
@@ -0,0 +1,91 @@
+#ifndef _IMGBOX2D_H
+#define _IMGBOX2D_H
+
+#include "IMGBBox.h"
+
+namespace IMG {
+
+//* this class represents a 2d bound box for a texture 
+class Box2d {
+  public:
+    inline Box2d() {
+    		mMinimum.x =  BOUNDINGBOX_MAXVALUE;
+    		mMinimum.y =  BOUNDINGBOX_MAXVALUE;
+    		
+    		mMaximum.x = -BOUNDINGBOX_MAXVALUE;
+    		mMaximum.y = -BOUNDINGBOX_MAXVALUE;		
+    	};
+
+    // GametoolsError -- Isma 17/08/2005
+    inline Box2d & operator =(const Box2d & p) {
+    		mMinimum = p.mMinimum;
+    		mMaximum = p.mMaximum;
+    	};
+
+	inline Ogre::Vector2 GetMinimum() { 
+    		return mMinimum;
+    	};
+
+	inline Ogre::Vector2 GetMaximum() { 
+    		return mMaximum; 
+    	};
+
+    inline void SetBoundBox(float x, float y, float X, float Y) {
+    		mMinimum.x = x;
+    		mMinimum.y = y;
+    		mMaximum.x = X;
+    		mMaximum.y = Y;
+    	};
+
+    inline void AddBoundingVector3(float x, float y) {
+        		if (x < mMinimum.x) mMinimum.x = x; if (x > mMaximum.x) mMaximum.x = x;
+        		if (y < mMinimum.y) mMinimum.y = y; if (y > mMaximum.y) mMaximum.y = y;
+      	};
+
+    inline void Print() {
+    		printf("\nValor de la Caixa: (%.4f, %.4f) - (%.4f, %.4f)", mMinimum.x, mMinimum.y, mMaximum.x, mMaximum.y);
+    	};
+
+	inline Ogre::Vector2 * GetCorner(int corner) const {
+       
+    		//if (corner < 0 || corner > 7) return Ogre::Vector3 (-1111111111, -1111111111, -1111111111);
+    		//return Ogre::AxisAlignedBox::getAllCorners ()[corner];
+    		//printf("\nGetCorner: %d", corner);
+    		
+    		if (corner < 0 || corner > 4) return NULL;
+    		    		
+			Ogre::Vector2 *vector;
+    		switch (corner)
+    		{		
+    			case BOX_CORNER_xy: vector = new Ogre::Vector2(mMinimum.x, mMinimum.y ); break;
+    			case BOX_CORNER_xY: vector = new Ogre::Vector2(mMinimum.x, mMaximum.y ); break;
+    			case BOX_CORNER_Xy: vector = new Ogre::Vector2(mMaximum.x, mMinimum.y ); break;
+    			case BOX_CORNER_XY: vector = new Ogre::Vector2(mMaximum.x, mMaximum.y ); break;
+    			
+    		}
+    		
+    		return vector;
+      	 };
+
+    inline bool In(int w, int h) {
+    		if (w <= (mMaximum.x - mMinimum.x) &&
+    		    h <= (mMaximum.y - mMinimum.y)) return true;
+    		   
+    		return false;
+    	};
+
+    inline bool FitPerfect(int w, int h) {	
+    		if (w == (mMaximum.x - mMinimum.x) &&
+    		    h == (mMaximum.y - mMinimum.y)) return true;
+    		  
+    		return false;
+    	};
+
+    ~Box2d();
+
+	private:
+		Ogre::Vector2 mMinimum, mMaximum;
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMG.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMG.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMG.h	(revision 700)
@@ -0,0 +1,10 @@
+#ifndef _LBBC_H
+#define _LBBC_H
+
+#include <LBBCPrerequisites.h>
+#include <LBBCRoot.h>
+#include <LBBCLeaves.h>
+#include <LBBCLeafKdTreeClusterData.h>
+#include <LBBCSampleConfigFile.h>
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster.h	(revision 700)
@@ -0,0 +1,144 @@
+#ifndef _IMGCLUSTER_H
+#define _IMGCLUSTER_H
+
+#include "IMGPrerequisites.h"
+#include "IMGBBox.h"
+#include "IMGBox2d.h"
+#include "IMGPlane3.h"
+
+namespace IMG { class Cluster2d; } 
+
+namespace IMG {
+
+class Cluster {
+  public:
+    Cluster();
+
+    Cluster & operator =(const Cluster & p);
+
+    Cluster(const Cluster & p);
+
+    // Gametools -- Isma 17/08/2005
+    //void Insert (Triangle *t);
+    // Gametools -- Isma 17/08/2005
+    //* return the patchs that the point is in
+    //int CalculaPatch (Vector3 &point);
+	inline void SetNormal(Ogre::Vector3* n) { normal = *n; };
+
+	inline Ogre::Vector3* GetNormal() { return &normal; };
+
+    inline BBox* GetBound() { return bound; };
+
+    inline Box2d* GetBspNodeBound() { return bspnodebound; };
+
+    inline void SetBspNodeBound(Box2d* box) {
+    		bspnodebound = box;
+    	};
+
+    void Print();
+
+    //* return the dominant normal axis, for calculate the 2d projection
+    int AxisProjected();
+
+    inline int GetId() const { return id; };
+
+    inline void SetId(int id_) { id = id;};
+
+    //Vector3 * GetVector3s() const{ return Vector3s;}
+    //Vector3 * GetVector3s();
+    //Vector3 * GetVector3s() { return Vector3s_triangle_text; }
+	inline std::vector<Ogre::Vector3>* GetVector3sVector() { return &Vector3s_vector; };
+
+	inline Ogre::Vector3* GetVector3sTex() const { return Vector3s_triangle_text;};
+
+    // Gametools -- Isma 17/08/2005
+    //bool CreatePatches(bool dinamic = false);
+    // Gametools -- Isma 17/08/2005
+    //Listid *GetPatchList() { return &patchlistid;}
+    //Listid *GetTriangleList(){ return &trianglelistid; }
+    // Gametools -- Isma 17/08/2005
+    //int GetIdPatch (unsigned int i)
+    //{
+    //	if (i > patchlistid.GetSize()) return -1;
+    //	
+    //	return patchlistid.Get(i);
+    //}
+    // Gametools -- Isma 17/08/2005
+    //int GetIdTriangle  (unsigned int i)
+    //{
+    //	if (i > trianglelistid.GetSize()) return -1;
+    //	
+    //	return trianglelistid.Get(i);
+    //}
+    void Finish();
+
+	inline void SetPlane(Ogre::Vector3* normal, Ogre::Vector3 * point) {
+    		plane.normal = *normal;
+    		plane.normal = -plane.normal;
+    		plane.d = -normal->dotProduct (*point);		
+    		//plane.d = normal->dotProduct (*point);		
+    	};
+
+    inline Plane3 * GetPlane() { return &plane; };
+
+    //* Return the increment in U (lumel increment in x). For patchs calculation 
+	Ogre::Vector3 GetIncU();
+
+    //* Return the increment in V (lumel increment in x). For patchs calculation 
+	Ogre::Vector3 GetIncV();
+
+    //* Return the origin. For patchs calculation 
+	Ogre::Vector3 GetOrigin();
+
+    //
+    //	void CreateVector3s()
+    //	{ 
+    //		
+    //		//Vector3s = new Vector3[4];
+    //		//Vector3s_triangle_text = new Vector3[4];
+    //	}
+    //	
+	bool PointIn(Ogre::Vector3 & point);
+
+	Ogre::Real *pointeru[4]; //coordentate u for obscurancemap
+	Ogre::Real *pointerv[4]; //coordentate v for obscurancemap
+	Ogre::Vector2 *uv;	//Vector3 coordenates for the original texture
+
+  private:
+    BBox * bound;
+
+    Box2d * bspnodebound;
+
+    static unsigned int ID_CLUSTER;
+
+	Ogre::Vector3 normal;
+
+    unsigned int id;
+
+	std::vector<Ogre::Vector3> Vector3s_vector;
+	Ogre::Vector3 *Vector3s;
+	Ogre::Vector3 *Vector3s_triangle_text;
+
+    int axisproj;
+
+    int order;
+
+    Cluster2d * triangle2d_text;
+
+	Ogre::Vector3 lumel_origin, lumel_x_axis, lumel_y_axis;
+	
+    Plane3 plane;
+
+    // Gametools -- Isma 17/08/2005
+    //Listid patchlistid;
+    //Listid trianglelistid;
+	int CalcPatch(Ogre::Vector3 & point);
+
+
+  public:
+    ~Cluster();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPlane3.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPlane3.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPlane3.h	(revision 700)
@@ -0,0 +1,50 @@
+#ifndef _IMGPLANE3_H
+#define _IMGPLANE3_H
+
+#include "IMGPrerequisites.h"
+
+namespace IMG {
+
+class Plane3: public Ogre::Plane {
+  public:
+    //a plane's interface
+    //Plane();
+    //~Plane();
+    inline Plane3 & operator =(const Plane3 & p) {
+    		normal.x = p.normal.x;
+    		normal.y = p.normal.y;
+    		normal.z = p.normal.z;
+    		d = p.d;		
+    		return *this;
+    	};
+
+	inline Ogre::Vector3 * GetNormal() {
+		Ogre::Vector3 *v = new Ogre::Vector3;
+    		v->x = normal.x;
+    		v->y = normal.y;
+    		v->z = normal.z;
+    		return v;
+    	};
+
+    inline void SetNormal(float x, float y, float z) {
+    		normal.x = x;
+    		normal.y = y;
+    		normal.z = z;		
+    	};
+
+    inline void SetDistance(float dist) {
+    		d = dist;
+    	};
+
+    inline float GetDistance() const { return d;};
+
+    inline void Print() {
+    		printf("\nPrintant pla: (%.4f, %.4f, %.4f, %.4f)", normal.x, normal.y, normal.z, d);
+    	};
+
+    ~Plane3();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBsp.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBsp.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBsp.h	(revision 700)
@@ -0,0 +1,83 @@
+#ifndef _IMGBSP_H
+#define _IMGBSP_H
+
+
+#include "IMGNodeBsp.h"
+
+namespace IMG {
+
+class Bsp {
+  public:
+    inline Bsp() : root(NULL), countleaf(0), counttotal(0){};
+
+    inline void SetRoot(NodeBsp * node) {
+    		root = node;
+    		counttotal++;
+    	};
+
+    inline void Print() {
+    		printf("\nImprimint Arbre BSP, num nodes leaf: %d, totals: %d", countleaf, counttotal);
+    		Print(root);
+    	};
+
+    inline void PrintLeaf() {
+    		PrintLeaf(root);
+    	};
+
+    inline NodeBsp * Insert(int w, int h, int idcluster) {
+    		//printf("\nInsret dins Bsp: %d, %d", w, h);
+    		
+    		NodeBsp *node = root->Insert (w,h);
+    		
+    		//printf("\nNode on s'insertarÃ  finalment Ã©S: "); node->Print();
+    		
+    		if (idcluster != -1)
+    		{
+    			node->SetId (idcluster);
+    			countleaf++;			
+    		}
+    		else counttotal++;
+    		
+    		//Copiar pixels de la imatge al node
+    		
+    		return node;
+    	};
+
+    inline NodeBsp * Get(int i) {
+    		return root->Get (root, i);
+    	};
+
+
+  private:
+    NodeBsp * root;
+
+    int countleaf;
+
+    int counttotal;
+
+    inline void Print(NodeBsp * node) {
+    		if (!node) return;
+    		node->Print();
+    		Print(node->GetChild(0));
+    		Print(node->GetChild(1));
+    	};
+
+    inline void PrintLeaf(NodeBsp * node) {
+    		if (!node) return;
+    		
+    		
+    		if (node->GetChild(0) == NULL && node->GetChild(1) == NULL) node->Print();
+    		
+    		PrintLeaf (node->GetChild(0));
+    		PrintLeaf (node->GetChild(1));
+    		
+    	};
+
+
+  public:
+    ~Bsp();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPrerequisites.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPrerequisites.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPrerequisites.h	(revision 700)
@@ -0,0 +1,11 @@
+#ifndef _IMGPREREQUISITES_H
+#define _IMGPREREQUISITES_H
+
+#include <Ogre.h>
+#include <OgreCommon.h>
+#include <OgreVector3.h>
+#include <OgreVector2.h>
+#include <OgrePlane.h>
+#include <OgreAxisAlignedBox.h> 
+
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster2d.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster2d.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster2d.h	(revision 700)
@@ -0,0 +1,46 @@
+#ifndef _IMGCLUSTER2D_H
+#define _IMGCLUSTER2D_H
+
+#include "IMGCluster.h"
+
+namespace IMG {
+
+class Cluster2d {
+  public:
+    inline Cluster2d() {
+    		Vector3s = NULL;
+    		cluster =NULL;
+    		normal = NULL;
+    	};
+
+    //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal.
+    //			
+    //	 
+    int Create2d(Cluster * cluster, int type, int type_vertexs);
+
+    void Print();
+
+	inline Ogre::Vector2 * GetVector3s() { return Vector3s; }
+
+	inline std::vector<Ogre::Vector2> * GetVector3sVector() { return &Vector3s2_vector; } 
+
+	inline Ogre::Vector3 * GetNormal() { return normal; }
+
+
+  private:
+    unsigned int id;
+
+    Cluster * cluster;
+
+	Ogre::Vector2 *Vector3s;
+	std::vector<Ogre::Vector2> Vector3s2_vector;
+
+	Ogre::Vector3 *normal;
+
+  public:
+    ~Cluster2d();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxelList.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxelList.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxelList.h	(revision 700)
@@ -0,0 +1,93 @@
+#ifndef _IMGVOXELLIST_H
+#define _IMGVOXELLIST_H
+
+#include "IMGVoxel.h"
+#include "IMGPrerequisites.h"
+
+namespace IMG {
+
+//*
+//	this class represents a scene voxels list
+//*
+class VoxelList {
+  public:
+    VoxelList();
+
+    //VoxelList(Ogre::AxisAlignedBox *);
+	VoxelList(Ogre::Box * );
+
+    //~Voxels();
+	inline std::vector<Voxel> * GetList() { return &list;};
+
+    //return the pointer to the list of voxels
+    //bool SetBoundBox (Ogre::AxisAlignedBox *);				//set the boundbox
+	bool SetBoundBox(Ogre::Box * );
+
+    //set the boundbox
+    bool SetBoundBox(float , float , float , float , float , float );
+
+    //Ogre::AxisAlignedBox * GetBoundBox() { return &boundbox;   }	//return pointer to boundbox of scene
+	inline Ogre::Box * GetBoundBox() { return &boundbox; };
+
+    //return pointer to boundbox of scene
+    inline int GetSize() const { return list.size(); }
+
+    //return the number of elements of list
+    Voxel * GetVoxel(unsigned int );
+
+    //return pointer to voxel(i)
+    void Print();
+
+    //print stats
+    //bool AddPatch2Voxel(Patch *);				//add patch to voxels
+    //this function also add the obspoly to voxels
+    //int CalculateVoxel(Ogre::Vector3 *);		//calculate the voxel that Vector3 go into, called by AddPatch2Voxel  
+	int CalculateVoxel(Ogre::Vector3 * );
+
+    //display the voxels in wireframe mode
+    bool CreateVoxels();
+
+
+  private:
+    //scene voxels list
+    std::vector<Voxel> list;
+	Ogre::Box boundbox;	//bounding box of the scene
+
+    int Under(unsigned int );
+
+    //return the under voxel, -1 if not exist
+    int Over(unsigned int );
+
+    //return the over voxel, -1 if not exist
+    int Right(unsigned int );
+
+    //return the Right voxel, -1 if not exist
+    int Left(unsigned int );
+
+    //return the Left voxel, -1 if not exist
+    int Front(unsigned int );
+
+    //return the Front voxel, -1 if not exist
+    int Behind(unsigned int );
+
+    //return the Behind voxel, -1 if not exist
+    bool FirstX(unsigned int );
+
+    bool FirstY(unsigned int );
+
+    bool FirstZ(unsigned int );
+
+    bool LastX(unsigned int );
+
+    bool LastY(unsigned int );
+
+    bool LastZ(unsigned int );
+
+
+  public:
+    ~VoxelList();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBBox.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBBox.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBBox.h	(revision 700)
@@ -0,0 +1,124 @@
+#ifndef _IMGBBOX_H
+#define _IMGBBOX_H
+
+#include "IMGPrerequisites.h"
+
+
+namespace IMG {
+
+#define BOUNDINGBOX_MAXVALUE 1000000000.
+#define BOX_CORNER_xyz 0
+#define BOX_CORNER_xyZ 1
+#define BOX_CORNER_xYz 2
+#define BOX_CORNER_xYZ 3
+#define BOX_CORNER_Xyz 4
+#define BOX_CORNER_XyZ 5
+#define BOX_CORNER_XYz 6
+#define BOX_CORNER_XYZ 7
+
+#define BOX_CORNER_xy 0
+#define BOX_CORNER_xY 2
+#define BOX_CORNER_Xy 4
+#define BOX_CORNER_XY 6
+
+//*
+//	this class encaplusalte the ogre::AxisAlignedBox
+//*
+class BBox: public Ogre::AxisAlignedBox {
+  public:
+    inline BBox() { BBox::StartBoundingBox(); }
+
+    inline void StartBoundingBox() {
+		 mMinimum.x =  BOUNDINGBOX_MAXVALUE;
+         mMinimum.y =  BOUNDINGBOX_MAXVALUE;
+         mMinimum.z =  BOUNDINGBOX_MAXVALUE;
+         mMaximum.x = -BOUNDINGBOX_MAXVALUE;
+         mMaximum.y = -BOUNDINGBOX_MAXVALUE;
+         mMaximum.z = -BOUNDINGBOX_MAXVALUE;
+       };
+
+	inline Ogre::Vector3 GetMinimum() { return mMinimum; }
+
+    //  
+    //  Vector3 * GetMinimum()
+    //  { 
+    //  	Vector3 *Vector3;
+    //	
+    //	Ogre::Vector3 v = mMinimum;	
+    //	Vector3.x = v.x;
+    //	Vector3.y = v.y;
+    //	Vector3.z = v.z;
+    //	
+    //	return v;
+    //  }
+    
+	inline Ogre::Vector3 GetMaximum() { return mMaximum;};
+
+    //
+    //  Vector3 GetMaximum()
+    //  { 
+    //  
+    //  	Vector3 Vector3;
+    //	Ogre::Vector3 v = mMaximum;	
+    //	Vector3.x = v.x;
+    //	Vector3.y = v.y;
+    //	Vector3.z = v.z;
+    //  	return Vector3;
+    //  }
+    //  
+    inline void AddBoundingVector3(float x, float y, float z) {
+        if (x < mMinimum.x) mMinimum.x = x; if (x > mMaximum.x) mMaximum.x = x;
+        if (y < mMinimum.y) mMinimum.y = y; if (y > mMaximum.y) mMaximum.y = y;
+        if (z < mMinimum.z) mMinimum.z = z; if (z > mMaximum.z) mMaximum.z = z;
+      };
+
+    inline void Print() {
+      	printf("\nValor de la Caixa: (%.4f, %.4f, %.4f) - (%.4f, %.4f, %.4f)\n\n", mMinimum.x, mMinimum.y, mMinimum.z, mMaximum.x, mMaximum.y, mMaximum.z);
+      };
+
+    //Ogre::Vector3* GetCorner (int corner) const
+	inline Ogre::Vector3 * GetCorner(int corner) const {
+       
+       	//if (corner < 0 || corner > 7) return Ogre::Vector3 (-1111111111, -1111111111, -1111111111);
+    	//return Ogre::AxisAlignedBox::getAllCorners ()[corner];
+    	//printf("\nGetCorner: %d", corner);
+    	
+    	if (corner < 0 || corner > 7) return NULL;
+    	
+    	Ogre::Vector3 *vector;    	
+    	switch (corner)
+    	{
+    		/*
+    		case BOX_CORNER_xyz: return vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z );
+    		case BOX_CORNER_xyZ: return vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z );
+    		case BOX_CORNER_xYz: return vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z );
+    		case BOX_CORNER_xYZ: return vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z );
+    		case BOX_CORNER_Xyz: return vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z );
+    		case BOX_CORNER_XyZ: return vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z );
+    		case BOX_CORNER_XYz: return vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z );
+    		case BOX_CORNER_XYZ: return vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z );
+    		*/
+			case BOX_CORNER_xyz: vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z ); break;
+    		case BOX_CORNER_xyZ: vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z ); break;
+    		case BOX_CORNER_xYz: vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z ); break;
+    		case BOX_CORNER_xYZ: vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z ); break;
+    		case BOX_CORNER_Xyz: vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z ); break;
+    		case BOX_CORNER_XyZ: vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z ); break;
+    		case BOX_CORNER_XYz: vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z ); break;
+    		case BOX_CORNER_XYZ: vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z ); break;
+    	}
+    	
+    	//vector->Print();
+    	return vector;
+       };
+
+    inline bool intersects(Ogre::Vector3 * v) {
+        	return Ogre::AxisAlignedBox::intersects(*v); 
+        };
+
+    ~BBox();
+
+};
+
+}
+#endif
Index: /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h
===================================================================
--- /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h	(revision 700)
+++ /GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h	(revision 700)
@@ -0,0 +1,61 @@
+#ifndef _IMGNODEBSP_H
+#define _IMGNODEBSP_H
+
+#include "IMGPrerequisites.h"
+#include "IMGBox2d.h"
+
+namespace IMG {
+
+class NodeBsp {
+  public:
+    NodeBsp();
+
+    Box2d * GetBound();
+
+    inline void SetBound(Box2d * box) { bound = box; };
+
+    inline NodeBsp * GetChild(int i) { return child[i]; };
+
+    inline void SetId(int id_) { id = id_; };
+
+    inline unsigned int GetId() const { return id; };
+
+    inline void SetChild(NodeBsp * node, int i) { child[i] = node; };
+
+    void Print();
+
+    //void SetPlane (Plane3 *pla) { plane = pla; }
+    //Plane3 * GetPlane () { return plane; }
+    NodeBsp * Insert(int w, int h);
+
+    inline NodeBsp * Get(NodeBsp * node, int i) {
+    		if (!node) return NULL;
+    		if (node->GetId() == i ) return node;
+    		
+    		NodeBsp *nod; 
+    		if (nod = node->GetChild(0)->Get (node->GetChild(0), i)) return nod;
+    		
+    		return node->GetChild(0)->Get (node->GetChild(1), i);
+    		
+    	};
+
+
+  private:
+    bool fit;
+
+    Box2d * bound;
+
+    NodeBsp * child[2];
+
+    static unsigned int ID;
+
+    int id;
+
+
+  public:
+    ~NodeBsp();
+
+};
+
+}
+#endif
