Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreBase.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreBase.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreBase.h	(revision 721)
@@ -0,0 +1,68 @@
+#ifndef _OBAOGREBASE_H
+#define _OBAOGREBASE_H
+
+#include <OBAPrerequisites.h>
+#include <OBASingleton.h>
+
+namespace OBA {
+
+/** Specialisation of ArchiveFactory for FileSystem files. */
+class _OBAExport FileSystemArchiveFactory : public Ogre::ArchiveFactory
+{
+public:
+    virtual ~FileSystemArchiveFactory() {}
+
+	/// @copydoc FactoryObj::getType
+	const Ogre::String& getType(void) const
+    {
+		static Ogre::String name = "FileSystem";
+        return name;
+    }
+
+    /// @copydoc FactoryObj::createInstance
+	Ogre::Archive *createInstance( const Ogre::String& name ) 
+    {
+		return new Ogre::FileSystemArchive(name, "FileSystem");
+    }
+
+	/// @copydoc FactoryObj::destroyInstance
+	void destroyInstance( Ogre::Archive* arch) { delete arch; }
+};
+
+class _OBAExport OgreBase: public CSingleton<OgreBase> 
+{
+  protected:
+	  Ogre::ArchiveManager *mArchiveManager;
+	  Ogre::ResourceGroupManager *mResourceGroupManager;
+	  Ogre::DefaultHardwareBufferManager *mDefaultHardwareBufferManager;
+	  Ogre::MeshSerializer *mMeshSerializer;
+	  Ogre::XMLMeshSerializer *mXMLMeshSerializer;
+	  Ogre::MaterialManager *mMaterialManager;
+	  Ogre::LogManager *mLogManager;
+	  Ogre::MeshManager *mMeshManager;
+	  FileSystemArchiveFactory *mFileSystemArchiveFactory;
+	  Ogre::Math *mMath;
+
+  public:
+
+	static OgreBase& getSingleton(void);
+    
+	static OgreBase* getSingletonPtr(void);
+
+    OgreBase();
+
+    ~OgreBase();
+
+	Ogre::XMLMeshSerializer* getXMLMeshSerializer();
+	
+	Ogre::MeshSerializer* getMeshSerializer();
+
+	Ogre::MeshManager* getMeshManager();
+
+	void initialize();
+
+	void shutdown();
+};
+
+}
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListener.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListener.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListener.h	(revision 721)
@@ -0,0 +1,59 @@
+#ifndef _OBAOGREFRAMELISTENER_H
+#define _OBAOGREFRAMELISTENER_H
+
+#include <OBAPrerequisites.h>
+#include <OBAOgreFrameListenerMode.h>
+
+namespace OBA {
+
+class _OBAExport OgreFrameListener: public Ogre::FrameListener, public Ogre::KeyListener 
+{
+protected:
+	
+    void updateStats(void);
+
+	void keyClicked(Ogre::KeyEvent* e);
+
+	void keyPressed(Ogre::KeyEvent* e);
+
+	void keyReleased(Ogre::KeyEvent* e);
+
+public:
+    // Constructor takes a RenderWindow because it uses that to determine input context
+	OgreFrameListener(Ogre::RenderWindow *win, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
+
+	virtual ~OgreFrameListener();
+
+	void addFrameListenerMode(OgreFrameListenerMode *ogreFrameListenerMode);
+
+	void removeFrameListenerMode(unsigned int iOgreFrameListenerMode);
+
+	void setEnabledFrameListenerMode(unsigned int iOgreFrameListenerMode);
+
+	OgreFrameListenerMode* getEnabledFrameListenerMode();
+
+	unsigned int getNumFrameListenerModes();
+
+	OgreFrameListenerMode* getFrameListenerMode(unsigned int iOgreFrameListenerMode);
+
+    // Override frameStarted event to process that (don't care about frameEnded)
+	bool frameStarted(const Ogre::FrameEvent& evt);
+
+	bool frameEnded(const Ogre::FrameEvent& evt);
+
+	bool processUnbufferedKeyInput(const Ogre::FrameEvent& evt);
+
+protected:
+	Ogre::EventProcessor* mEventProcessor;
+    Ogre::InputReader* mInputDevice;
+	OgreFrameListenerMode *mDefaultOgreFrameListenerMode;
+	std::vector<OgreFrameListenerMode*> mOgreFrameListenerModeList;
+	bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
+	Ogre::Real mTimeUntilNextToggle;
+	Ogre::RenderWindow* mWindow;
+	unsigned int mCurrentOgreFrameListenerMode;
+
+};
+
+}
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBA.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBA.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBA.h	(revision 721)
@@ -0,0 +1,11 @@
+#ifndef _OBA_H
+#define _OBA_H
+
+#include <OBAPrerequisites.h>
+#include <OBAOgreApplication.h>
+#include <OBAOgreFrameListener.h>
+#include <OBAOgreFrameListenerMode.h>
+#include <OBAOgreBase.h>
+#include <OBASingleton.h>
+
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreApplication.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreApplication.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreApplication.h	(revision 721)
@@ -0,0 +1,56 @@
+#ifndef _OBAOGREAPPLICATION_H
+#define _OBAOGREAPPLICATION_H
+
+#include <OBAPrerequisites.h>
+#include <OBAOgreBase.h>
+#include <OBAOgreFrameListener.h>
+#include <OBAOgreApplication.h>
+
+namespace OBA {
+
+/** Base class which manages the standard startup of an Ogre application.
+    Designed to be subclassed for specific examples if required.
+*/
+class _OBAExport OgreApplication {
+  public:
+
+    /// Standard constructor
+    OgreApplication();
+
+	/// Standard destructor
+	virtual ~OgreApplication();
+
+    /// Start the example
+    virtual void go(void);
+
+protected:
+	OgreBase *mOgreBase;
+	Ogre::Root *mRoot;
+    Ogre::Camera* mCamera;
+    Ogre::SceneManager* mSceneMgr;
+    OgreFrameListener* mFrameListener;
+	Ogre::RenderWindow* mWindow;
+
+    // These internal methods package up the stages in the startup process
+    /** Sets up the application - returns false if the user chooses to abandon configuration. */
+    virtual bool setup(bool createOgreRoot);
+ 
+    /** Configures the application - returns false if the user chooses to abandon configuration. */
+    virtual bool configure(bool createOgreRoot);
+   
+    virtual void createFrameListener(void);
+ 
+	/// Method which will define the source of resources (other than current folder)
+	virtual void setupResources(void);
+
+	/// Optional override method where you can create resource listeners (e.g. for loading screens)
+	virtual void createResourceListener(void);
+	
+	/// Optional override method where you can perform resource group loading
+	/// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+	virtual void loadResources(void);
+
+};
+
+}
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListenerMode.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListenerMode.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListenerMode.h	(revision 721)
@@ -0,0 +1,79 @@
+#ifndef _OBAOGREFRAMELISTENERMODE_H
+#define _OBAOGREFRAMELISTENERMODE_H
+
+#include <OBAPrerequisites.h>
+
+namespace OBA {
+
+class _OBAExport OgreFrameListenerMode: public Ogre::KeyListener
+{
+  protected:
+	Ogre::Real mMoveSpeed;
+	Ogre::Degree mRotateSpeed;
+	Ogre::Overlay* mDebugOverlay;	
+    Ogre::Camera* mCamera;
+    Ogre::Vector3 mTranslateVector;
+    Ogre::RenderWindow* mWindow;
+    Ogre::Degree mRotScale;
+    // just to stop toggles flipping too fast
+    Ogre::Real mTimeUntilNextToggle ;
+    Ogre::Radian mRotX, mRotY;
+    Ogre::TextureFilterOptions mFiltering;
+	Ogre::SceneManager *mSceneMgr;
+    int mAniso;
+	int mSceneDetailIndex;
+    bool mStatsOn;
+	bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
+    float mMoveScale;
+	unsigned int mNumScreenShots;
+	unsigned int mOgreFrameListenerModeHandle;
+	
+	Ogre::InputReader *mInputDevice;
+
+  public:
+
+    OgreFrameListenerMode(Ogre::RenderWindow* win, unsigned int ogreFrameListenerModeHandle, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
+
+    virtual ~OgreFrameListenerMode();
+
+    virtual void chooseSceneManager(void);
+
+	virtual Ogre::SceneManager* getSceneManager(void);
+
+    virtual void createCamera(void);
+
+	virtual void createViewports(void);
+
+	virtual Ogre::Camera* getCamera();
+
+	virtual bool frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader);
+
+	virtual bool frameEnded(const Ogre::FrameEvent& evt);
+
+    virtual void switchMouseMode();
+
+    virtual void switchKeyMode();
+
+	virtual void keyClicked(Ogre::KeyEvent* e);
+
+	virtual void keyPressed(Ogre::KeyEvent* e);
+
+	virtual void keyReleased(Ogre::KeyEvent* e);
+
+	virtual bool processUnbufferedKeyInput(const Ogre::FrameEvent& evt);
+
+	virtual bool processUnbufferedMouseInput(const Ogre::FrameEvent& evt);
+
+    virtual void moveCamera();
+
+    virtual void showDebugOverlay(bool show);
+
+	virtual void updateStats(void);
+
+	virtual void createScene(void);    // pure virtual - this has to be overridden
+
+	virtual void destroyScene(void);    // Optional to override this
+};
+
+}
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBASingleton.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBASingleton.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBASingleton.h	(revision 721)
@@ -0,0 +1,35 @@
+#ifndef __OBASINGLETON_H__
+#define __OBASINGLETON_H__
+
+namespace OBA {
+
+
+template <typename T> class _OBAExport 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/OBA/OBAPrerequisites.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAPrerequisites.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAPrerequisites.h	(revision 721)
@@ -0,0 +1,27 @@
+#ifndef _OBAPREREQUISITES_H
+#define _OBAPREREQUISITES_H
+
+#include <Ogre.h>
+#include <OgreXMLPrerequisites.h>
+#include <OgreXMLMeshSerializer.h>
+#include <OgreMeshSerializer.h>
+#include <OgreRenderWindow.h>
+#include <OgreConfigFile.h>
+#include <OgreKeyEvent.h>
+#include <OgreEventListeners.h>
+#include <OgreStringConverter.h>
+#include <OgreException.h>
+#include <OgreDefaultHardwareBufferManager.h>
+#include <OgreArchive.h>
+#include <OgreArchiveFactory.h>
+#include <OgreFileSystem.h>
+
+#   	if defined( OBA_LIB_BUILD )
+#       	define _OBAExport __declspec( dllexport )			
+#   	else
+#       	define _OBAExport
+#   	endif
+
+
+
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h	(revision 721)
@@ -10,5 +10,5 @@
     SampleConfigFile();
 	
-    ~SampleConfigFile();
+    virtual ~SampleConfigFile();
 
 	bool getEntityDistributionMerged();
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 721)
@@ -81,5 +81,5 @@
     Leaf();
 
-    ~Leaf();
+    virtual ~Leaf();
 
 };
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 721)
@@ -19,5 +19,5 @@
     LeafDistribution();
 
-    ~LeafDistribution();
+    virtual ~LeafDistribution();
 
 	void setMinD(float value);
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 721)
@@ -1,6 +1,9 @@
-#ifndef _LBBCKMEANSCLUSTERSERIALIZER_H
-#define _LBBCKMEANSCLUSTERSERIALIZER_H
+#ifndef _LBBCKMeansCLUSTERSERIALIZER_H
+#define _LBBCKMeansCLUSTERSERIALIZER_H
 
 #include <BBC.h>
+#include <LBBCBillboardKMeansClusterData.h>
+
+#include <string>
 
 namespace LBBC {
@@ -10,7 +13,7 @@
     KMeansClusterSerializer();
 
-    ~KMeansClusterSerializer();
+    virtual ~KMeansClusterSerializer();
 
-    void writeBillboardCloud(TiXmlDocument *document);
+	virtual void writeBillboardCloud(TiXmlDocument *document);
 
 };
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 721)
@@ -1,9 +1,6 @@
-#ifndef _LBBCKDTREECLUSTERSERIALIZER_H
-#define _LBBCKDTREECLUSTERSERIALIZER_H
+#ifndef _LBBCKdTreeCLUSTERSERIALIZER_H
+#define _LBBCKdTreeCLUSTERSERIALIZER_H
 
 #include <BBC.h>
-#include <LBBCBillboardKdTreeClusterData.h>
-
-#include <string>
 
 namespace LBBC {
@@ -13,7 +10,7 @@
     KdTreeClusterSerializer();
 
-    ~KdTreeClusterSerializer();
+    virtual ~KdTreeClusterSerializer();
 
-	virtual void writeBillboardCloud(TiXmlDocument *document);
+    void writeBillboardCloud(TiXmlDocument *document);
 
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h	(revision 721)
@@ -2,5 +2,4 @@
 #define _LBBCMANAGER_H
 
-#include <BBC.h>
 #include <LBBCPrerequisites.h>
 #include <LBBCLeaves.h>
@@ -22,7 +21,11 @@
     ~Manager();
 
-	void runSample(Ogre::String sampleConfigFile);
+	void runSampleConfigFile();
+
+	void loadSampleConfigFile(Ogre::String sampleConfigFile);
 
 	SampleConfigFile* getSampleConfigFile();
+
+	void setSampleConfigFile(SampleConfigFile *sampleConfigFile);
 
 	void generateEntityDistribution();
@@ -72,7 +75,8 @@
 	BBC::OgreMeshSerializer *mOgreMeshSerializer;
 
-	SampleConfigFile mSampleCf;
+	SampleConfigFile *mSampleConfigFile;
 
-	Ogre::ConfigFile mCf;
+	Ogre::ConfigFile *mConfigFile;
+
 };
 
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 721)
@@ -14,5 +14,5 @@
     LeafDistributionGenerator();
 
-    ~LeafDistributionGenerator();
+    virtual ~LeafDistributionGenerator();
 
 	void generateAverageLeafNormal(Leaf *leaf);
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 721)
@@ -7,4 +7,6 @@
 #include <LBBCLeafKdTreeClusterData.h>
 #include <LBBCSampleConfigFile.h>
+#include <LBBCBillboardViewMode.h>
+#include <LBBCClusterViewMode.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 721)
@@ -11,17 +11,17 @@
     Leaves();
 
-    ~Leaves();
+    virtual ~Leaves();
 
   protected:
     bool mMeshLoaded;
 
-	Ogre::Mesh *mMesh;
+	BBC::EntityPtr mEntity;
 
 	BBC::BillboardCloud *mBillboardCloud;
 
   public:
-	Ogre::Mesh* getMesh();
+	BBC::EntityPtr getEntity();
 
-	void setMesh(Ogre::Mesh * value);
+	void setEntity(BBC::EntityPtr value);
 
     void load();
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 721)
@@ -1,6 +1,8 @@
-#ifndef _LBBCBILLBOARDKMEANSCLUSTERDATA_H
-#define _LBBCBILLBOARDKMEANSCLUSTERDATA_H
+#ifndef _LBBCBILLBOARDKMeansCLUSTERDATA_H
+#define _LBBCBILLBOARDKMeansCLUSTERDATA_H
 
 #include <BBC.h>
+#include <LBBCLeafKMeansClusterData.h>
+#include <LBBCLeaf.h>
 
 namespace LBBC {
@@ -10,5 +12,11 @@
     BillboardKMeansClusterData();
 
-    ~BillboardKMeansClusterData();
+    virtual ~BillboardKMeansClusterData();
+
+	virtual void readBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void writeBillboardClusterData(TiXmlNode *parentNode);
+
+	virtual void generateBillboardBoundingQuad();
 
 };
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 721)
@@ -1,8 +1,6 @@
-#ifndef _LBBCBILLBOARDKDTREECLUSTERDATA_H
-#define _LBBCBILLBOARDKDTREECLUSTERDATA_H
+#ifndef _LBBCBILLBOARDKdTreeCLUSTERDATA_H
+#define _LBBCBILLBOARDKdTreeCLUSTERDATA_H
 
 #include <BBC.h>
-#include <LBBCLeafKdTreeClusterData.h>
-#include <LBBCLeaf.h>
 
 namespace LBBC {
@@ -12,11 +10,5 @@
     BillboardKdTreeClusterData();
 
-    ~BillboardKdTreeClusterData();
-
-	virtual void readBillboardClusterData(TiXmlNode *parentNode);
-
-	virtual void writeBillboardClusterData(TiXmlNode *parentNode);
-
-	virtual void generateBillboardBoundingQuad();
+    virtual ~BillboardKdTreeClusterData();
 
 };
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 721)
@@ -1,11 +1,15 @@
-#ifndef _LBBCKMEANSCLUSTERGENERATOR_H
-#define _LBBCKMEANSCLUSTERGENERATOR_H
-
+#ifndef _LBBCKMeansCLUSTERGENERATOR_H
+#define _LBBCKMeansCLUSTERGENERATOR_H
 
 #include <BBC.h>
+#include <LBBCLeafKMeansClusterData.h>
+#include <LBBCBillboardKMeansClusterData.h>
+#include <LBBCLeaf.h>
+#include <LBBCLeafDistribution.h>
 
 namespace LBBC {
 
-class _BBCExport KMeansClusterGenerator : public BBC::BillboardCloudGenerator {
+class _BBCExport KMeansClusterGenerator: public BBC::BillboardCloudGenerator 
+{
   public:
     void generate();
@@ -13,66 +17,45 @@
     void init();
 
+	void setAlpha(float value);
+
+	float getAlpha();
+
+	void initializeBillboardCloud();
+
+	BBC::BillboardPtr createBillboard();
+
+	void initializeBillboardClusterData(BBC::BillboardPtr billboard);
+	
+	void initializeRandomBillboard(BBC::BillboardPtr billboard);
+
+	void splitLeafDistribution();
+
+	void assignLeafBillboard(Leaf *leaf, BBC::BillboardPtr billboard);
+
+	void recomputeBillboardCloud();
+
+	void recomputeBillboard(BBC::BillboardPtr billboard);
+
+	void iterativeRecomputeBillboardCloud();
+
+	unsigned int findBestBillboard(Leaf *leaf);
+
+	void generateBillboardCloudBounds();
+
+	void setNumIterations(unsigned int value);
+
+	unsigned int getNumIterations();
+
     KMeansClusterGenerator();
 
-    ~KMeansClusterGenerator();
+    virtual ~KMeansClusterGenerator();
 
   protected:
 
-	class Cell
-	{
-		protected:
-		Cell *right;
-		Cell *left;
-		Ogre::Vector4 min;
-		Ogre::Vector4 max;
-		
-		public:
-		Cell()
-		{
-			right = NULL;
-			left = NULL;
-		}
+    float mAlpha;
 
-		void setLeftChild(Cell *lChild)
-		{
-			left = lChild;
-		}
+	float mEpsilonYN;
 
-		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;
-		}
-	};
-
+	float mNumIterations;
 };
 
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 721)
@@ -1,10 +1,7 @@
-#ifndef _LBBCKDTREECLUSTERGENERATOR_H
-#define _LBBCKDTREECLUSTERGENERATOR_H
+#ifndef _LBBCKdTreeCLUSTERGENERATOR_H
+#define _LBBCKdTreeCLUSTERGENERATOR_H
+
 
 #include <BBC.h>
-#include <LBBCLeafKdTreeClusterData.h>
-#include <LBBCBillboardKdTreeClusterData.h>
-#include <LBBCLeaf.h>
-#include <LBBCLeafDistribution.h>
 
 namespace LBBC {
@@ -16,45 +13,66 @@
     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();
+    virtual ~KdTreeClusterGenerator();
 
   protected:
 
-    float mAlpha;
+	class Cell
+	{
+		protected:
+		Cell *right;
+		Cell *left;
+		Ogre::Vector4 min;
+		Ogre::Vector4 max;
+		
+		public:
+		Cell()
+		{
+			right = NULL;
+			left = NULL;
+		}
 
-	float mEpsilonYN;
+		void setLeftChild(Cell *lChild)
+		{
+			left = lChild;
+		}
 
-	float mNumIterations;
+		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;
+		}
+	};
+
 };
 
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 721)
@@ -13,5 +13,5 @@
     LeafDistributionSerializer();
 
-    ~LeafDistributionSerializer();
+    virtual ~LeafDistributionSerializer();
 
 
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 721)
@@ -1,4 +1,4 @@
-#ifndef _LBBCLEAFKMEANSCLUSTERDATA_H
-#define _LBBCLEAFKMEANSCLUSTERDATA_H
+#ifndef _LBBCLEAFKMeansCLUSTERDATA_H
+#define _LBBCLEAFKMeansCLUSTERDATA_H
 
 #include <BBCEntityClusterData.h>
@@ -10,5 +10,7 @@
     LeafKMeansClusterData();
 
-    ~LeafKMeansClusterData();
+    virtual ~LeafKMeansClusterData();
+
+  protected:
 
 };
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 721)
@@ -1,4 +1,4 @@
-#ifndef _LBBCLEAFKDTREECLUSTERDATA_H
-#define _LBBCLEAFKDTREECLUSTERDATA_H
+#ifndef _LBBCLEAFKdTreeCLUSTERDATA_H
+#define _LBBCLEAFKdTreeCLUSTERDATA_H
 
 #include <BBCEntityClusterData.h>
@@ -10,7 +10,5 @@
     LeafKdTreeClusterData();
 
-    ~LeafKdTreeClusterData();
-
-  protected:
+    virtual ~LeafKdTreeClusterData();
 
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeFrameListener.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeFrameListener.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeFrameListener.h	(revision 721)
@@ -0,0 +1,30 @@
+#ifndef _IBRBILLBOARDCLOUDTREESFRAMELISTENER_H
+#define _IBRBILLBOARDCLOUDTREESFRAMELISTENER_H
+
+#include <OBAPrerequisites.h>
+#include <OBAOgreFrameListener.h>
+
+class IBRBillboardCloudTreeFrameListener : public OBA::OgreFrameListener 
+{
+
+protected:
+
+public:
+	IBRBillboardCloudTreeFrameListener(Ogre::RenderWindow *win, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false)
+        : OgreFrameListener(win, useBufferedInputKeys, useBufferedInputMouse)
+    {
+    }
+
+	~IBRBillboardCloudTreeFrameListener()        
+    {
+    }
+
+	bool frameStarted(const Ogre::FrameEvent& evt)
+    {
+        // Call default
+        return OgreFrameListener::frameStarted(evt);        
+    }
+
+};
+
+#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 721)
@@ -13,5 +13,5 @@
 	EntityDistribution *mEntityDistribution;
 
-    Entity *mEntity;
+    EntityPtr mEntity;
 
   public:
@@ -20,7 +20,7 @@
     void init();
 
-	Entity* getEntity();
+	EntityPtr getEntity();
 
-	void setEntity(Entity *value);
+	void setEntity(EntityPtr value);
 
 	void setDistribution(EntityDistribution *value);
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 721)
@@ -5,5 +5,5 @@
 
 namespace BBC {
-
+ 
 class _BBCExport UniqueVertex
 {
@@ -24,11 +24,27 @@
 typedef std::vector<UniqueVertex> UniqueVertexList;
 
-class _BBCExport SubEntity {
-  public:
+// Fordward declaration
+class SubEntity;
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(SubEntity * p);
+    void intrusive_ptr_release(SubEntity * p);
+};
+
+class _BBCExport SubEntity
+{
+  private:
+    long references;
+
+    friend void boost::intrusive_ptr_add_ref(SubEntity * p);
+
+    friend void boost::intrusive_ptr_release(SubEntity * p);
+
+  protected:
 
 	typedef std::vector<unsigned short int> TextureCoordSetsDimensions;
+
 	typedef std::vector<Ogre::Vector3> Indices;
-
-  protected:
 
 	UniqueVertexList mUniqueVertexList;
@@ -56,5 +72,5 @@
     SubEntity();
 
-    ~SubEntity();
+    virtual ~SubEntity();
 
 	void enableTangents(bool value);
@@ -129,5 +145,30 @@
 
 	void generateAABBox();
+
+	const char *GetClassName(void) const;
+
 };
+
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+  inline void intrusive_ptr_add_ref(SubEntity * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+  inline void intrusive_ptr_release(SubEntity * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<SubEntity> SubEntityPtr;
 
 }
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 721)
@@ -6,9 +6,24 @@
 namespace BBC {
 
-class _BBCExport BillboardClusterData {
+// Fordward declaration...
+class BillboardClusterData;
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(BillboardClusterData * p);
+    void intrusive_ptr_release(BillboardClusterData * p);
+};
+
+class _BBCExport BillboardClusterData 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(BillboardClusterData * p);
+    friend void boost::intrusive_ptr_release(BillboardClusterData * p);
+
   public:
     BillboardClusterData();
 
-    ~BillboardClusterData();
+    virtual ~BillboardClusterData();
 
 	void setNormal(Ogre::Vector3 value);
@@ -20,7 +35,7 @@
 	float getD();
 
-    EntityCluster* getEntityCluster();
+    EntityClusterPtr getEntityCluster();
 
-	void setEntityCluster(EntityCluster *value);
+	void setEntityCluster(EntityClusterPtr value);
 
 	virtual void readBillboardClusterData(TiXmlNode *parentNode);
@@ -47,5 +62,5 @@
 
 protected:
-	EntityCluster *mEntityCluster;
+	EntityClusterPtr mEntityCluster;
 	
 	Ogre::Vector3 mAxisX;
@@ -70,4 +85,26 @@
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(BillboardClusterData * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(BillboardClusterData * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<BillboardClusterData> BillboardClusterDataPtr;
+
 }
 #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 721)
@@ -11,4 +11,9 @@
 class _BBCExport BillboardCloudGenerator {
   public:
+
+    BillboardCloudGenerator();
+
+	virtual ~BillboardCloudGenerator();
+
     void generate();
 
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 721)
@@ -11,9 +11,11 @@
     XmlSerializer();
 
-    ~XmlSerializer();
+    virtual ~XmlSerializer();
 
   protected:
     Ogre::String mFilename;
+
 	TiXmlDocument *mFile;
+
     bool mLoaded;
 
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 721)
@@ -6,9 +6,25 @@
 namespace BBC {
 
-class _BBCExport Billboard {
+// Forward declarations
+class Billboard;
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(Billboard * p);
+    void intrusive_ptr_release(Billboard * p);
+};
+
+
+class _BBCExport Billboard 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(Billboard * p);
+    friend void boost::intrusive_ptr_release(Billboard * p);
+
   public:
     Billboard();
 
-    ~Billboard();
+    virtual ~Billboard();
 
 
@@ -25,14 +41,36 @@
   protected:
 
-	BillboardClusterData *mBillboardClusterData;
+	BillboardClusterDataPtr mBillboardClusterData;
 
   public:
 
-	void setBillboardClusterData(BillboardClusterData *value);
+	void setBillboardClusterData(BillboardClusterDataPtr value);
 
-	BillboardClusterData* getBillboardClusterData();
+	BillboardClusterDataPtr getBillboardClusterData();
 
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(Billboard * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(Billboard * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<Billboard> BillboardPtr;
+
 }
 #endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h	(revision 721)
@@ -66,5 +66,5 @@
 	void removeClusterList(unsigned int iClusterList);
 
-	void clear();
+	void shutdown();
 
 	unsigned int getNumClusterLists();
@@ -74,5 +74,5 @@
     BillboardCloudUVMapper();
 
-    ~BillboardCloudUVMapper();
+    virtual ~BillboardCloudUVMapper();
 
 };
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 721)
@@ -1,4 +1,4 @@
-#ifndef __SINGLETON_H__
-#define __SINGLETON_H__
+#ifndef __BBCSINGLETON_H__
+#define __BBCSINGLETON_H__
 
 namespace BBC {
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 721)
@@ -4,4 +4,5 @@
 #include <BBCPrerequisites.h>
 #include <BBCEntity.h>
+#include <BBCMesh.h>
 
 namespace BBC {
@@ -14,7 +15,7 @@
         virtual ~OgreMeshSerializer();
 
-		void setEntity(Entity *entity);
+		void setEntity(EntityPtr entity);
 
-		Entity* getEntity();
+		EntityPtr getEntity();
 
 		void exportMesh(const Ogre::String& fileName, bool mergeSubMeshes, bool tangents);
@@ -22,15 +23,15 @@
     protected:
 
-		Entity *mEntity;
+		EntityPtr mEntity;
 		
-		void buildMesh(Ogre::Mesh* pMesh, bool mergeSubmeshes);
+		void buildMesh(MeshPtr pMesh, bool mergeSubmeshes);
 		
-		void generateEntityAABB(Ogre::Mesh* pMesh);
+		void generateEntityAABB(MeshPtr pMesh);
 		
-		void exportSubMeshes(Ogre::Mesh* pMesh);
+		void exportSubMeshes(MeshPtr pMesh);
         
-		void exportSubMesh(Ogre::Mesh* pMesh, SubEntity *subEntity);
+		void exportSubMesh(MeshPtr pMesh, SubEntityPtr subEntity);
         
-		template <typename T> void writeIndexes(T* buf, SubEntity *subEntity);
+		template <typename T> void writeIndexes(T* buf, SubEntityPtr subEntity);
         
 		void createVertexBuffer(Ogre::VertexData* vd, unsigned short bufIdx, UniqueVertexList *uniqueVertexList);
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 721)
@@ -23,5 +23,4 @@
 #include <OgreVertexBoneAssignment.h>
 #include <OgreAxisAlignedBox.h>
-
 #include <OgreKeyEvent.h>
 #include <OgreEventListeners.h>
@@ -31,4 +30,9 @@
 #include <OgrePixelFormat.h>
 #include <OgreGpuProgram.h>
+#include <OgreSharedPtr.h>
+
+#include <OBA.h>
+
+#include <boost/smart_ptr.hpp>
 
 //#include <ospace/stl/hashset.h>
@@ -36,3 +40,4 @@
 
 #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 721)
@@ -10,10 +10,10 @@
 class _BBCExport EntityDistributionSerializer: public BBC::XmlSerializer {
   protected:
-	Entity* mEntity;
+	EntityPtr mEntity;
 
   public:
-    Entity* getEntity();
+    EntityPtr getEntity();
 
-    void setEntity(Entity * value);
+    void setEntity(EntityPtr value);
 
     void generate();
@@ -23,5 +23,5 @@
     EntityDistributionSerializer();
 
-    ~EntityDistributionSerializer();
+    virtual ~EntityDistributionSerializer();
 
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h	(revision 721)
@@ -6,9 +6,39 @@
 namespace BBC {
 
-class BillboardGroup {
+typedef struct
+{
+	unsigned int billboardHandle;
+	unsigned int width;
+	unsigned int height;
+	Ogre::Vector2 min;
+	Ogre::Vector2 max; 
+} BillboardGroupedInfo;
+
+// Forward declarations
+class BillboardGroup;
+
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(BillboardGroup * p);
+    void intrusive_ptr_release(BillboardGroup * p);
+};
+
+class BillboardGroup 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(BillboardGroup * p);
+    friend void boost::intrusive_ptr_release(BillboardGroup * p);
+
   protected:
 	std::vector<unsigned int> mBillboardHandleList;
 
   public:
+
+    BillboardGroup();
+
+	virtual ~BillboardGroup();
+
     unsigned int getBillboardHandle(unsigned int iBillboard);
 
@@ -19,4 +49,26 @@
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(BillboardGroup * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(BillboardGroup * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<BillboardGroup> BillboardGroupPtr;
+
 }
 #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 721)
@@ -6,19 +6,56 @@
 namespace BBC {
 
-class _BBCExport EntityClusterData {
+// Fordward declaration...
+class EntityClusterData;
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(EntityClusterData * p);
+    void intrusive_ptr_release(EntityClusterData * p);
+};
+
+class _BBCExport EntityClusterData 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(EntityClusterData * p);
+    friend void boost::intrusive_ptr_release(EntityClusterData * p);
+
   public:
     EntityClusterData();
 
-    ~EntityClusterData();
+    virtual ~EntityClusterData();
 
-	void setEntity(Entity *value);
+	void setEntity(EntityPtr value);
 
-	Entity* getEntity();
+	EntityPtr getEntity();
 
   protected:
-	Entity *mEntity;
+	EntityPtr mEntity;
 
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(EntityClusterData * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(EntityClusterData * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<EntityClusterData> EntityClusterDataPtr;
+
 }
 #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 721)
@@ -4,6 +4,4 @@
 #include <BBCPrerequisites.h>
 #include <BBCSingleton.h>
-
-//#include <ExampleFrameListener.h>
 
 namespace BBC {
@@ -19,11 +17,7 @@
 	static Manager* getSingletonPtr(void);
 
-	void initRenderWindow();
-
-	Ogre::Mesh* loadMesh(Ogre::String name);
+	Ogre::Mesh* loadMesh(Ogre::String folderName, Ogre::String fileName);
 
 	Ogre::Mesh* loadXMLMesh(Ogre::String name);
-
-	void loadResources();
 
 	void saveMesh(Ogre::String name);
@@ -40,15 +34,5 @@
 
   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;
+
 };
 
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 721)
@@ -17,5 +17,5 @@
     BillboardCloudSerializer();
 
-    ~BillboardCloudSerializer();
+    virtual ~BillboardCloudSerializer();
 
 
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 721)
@@ -6,12 +6,32 @@
 namespace BBC {
 
-class _BBCExport EntityDistribution {
+// Forward declarations
+class EntityDistribution;
+
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(EntityDistribution * p);
+    void intrusive_ptr_release(EntityDistribution * p);
+};
+
+class _BBCExport EntityDistribution 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(EntityDistribution * p);
+    friend void boost::intrusive_ptr_release(EntityDistribution * p);
+
   protected:
-	std::vector<Entity*> mEntityList;
+	std::vector<EntityPtr> mEntityList;
 
   public:
-	Entity* getEntity(unsigned int value);
+    EntityDistribution();
 
-	void addEntity(Entity *value);
+	virtual ~EntityDistribution();
+
+	EntityPtr getEntity(unsigned int value);
+
+	void addEntity(EntityPtr value);
 
 	void removeEntity(unsigned int value);
@@ -20,4 +40,27 @@
 };
 
+
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(EntityDistribution * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(EntityDistribution * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<EntityDistribution> EntityDistributionPtr;
+
 }
 #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 721)
@@ -4,12 +4,28 @@
 #include <BBCPrerequisites.h>
 #include <BBCSubEntity.h>
+#include <BBCMesh.h>
 
 namespace BBC {
 
+// Forward declarations
+class Entity;
+
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(Entity * p);
+    void intrusive_ptr_release(Entity * p);
+};
+
 class _BBCExport Entity 
 {
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(Entity * p);
+    friend void boost::intrusive_ptr_release(Entity * p);
+
   protected:
 
-	typedef std::vector<SubEntity*> SubEntityList;
+	typedef std::vector<SubEntityPtr> SubEntityList;
 
 	unsigned int mEntityHandle;
@@ -19,5 +35,5 @@
 	SubEntityList mSubEntityList;
 
-	Ogre::Mesh *mMesh;
+	MeshPtr mMesh;
 	
   public:
@@ -25,17 +41,17 @@
     Entity();
 
-    ~Entity();
+    virtual ~Entity();
 
 	void createSubEntity();
 
-	void addSubEntity(SubEntity *value);
+	void addSubEntity(SubEntityPtr value);
 
-	SubEntity* getSubEntity(unsigned int index);
+	SubEntityPtr getSubEntity(unsigned int index);
 
 	void removeSubEntity(unsigned int index);
 
-	virtual Ogre::Mesh* getMesh();
+	virtual MeshPtr getMesh();
 
-	virtual void setMesh(Ogre::Mesh *value);
+	virtual void setMesh(MeshPtr value);
 
 	void loadMesh(bool mergeSubMeshes);
@@ -65,4 +81,26 @@
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(Entity * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(Entity * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<Entity> EntityPtr;
+
 }
 #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 721)
@@ -11,29 +11,47 @@
 namespace BBC {
 
-class _BBCExport EntityCluster {
+// Forward declarations
+class EntityCluster;
+
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(EntityCluster * p);
+    void intrusive_ptr_release(EntityCluster * p);
+};
+
+class _BBCExport EntityCluster 
+{
+private:
+    long references;
+    friend void boost::intrusive_ptr_add_ref(EntityCluster * p);
+    friend void boost::intrusive_ptr_release(EntityCluster * p);
+
   public:
     EntityCluster();
 
-    ~EntityCluster();
+    virtual ~EntityCluster();
 
-	EntityClusterData* getEntityClusterData(unsigned int value);
+	void removeEntityClusterData(unsigned int value);
 
-	void addEntityClusterData(EntityClusterData *value);
+	EntityClusterDataPtr getEntityClusterData(unsigned int value);
+
+	void addEntityClusterData(EntityClusterDataPtr value);
 
 	void removeEntitClusterData(unsigned int value);
 
-	EntityDistribution* getEntityDistribution();
+	EntityDistributionPtr getEntityDistribution();
 
-	void setEntityDistribution(EntityDistribution *value);
+	void setEntityDistribution(EntityDistributionPtr value);
 
   protected:
 
-	EntityDistribution *mEntityDistribution;
+	EntityDistributionPtr mEntityDistribution;
 	
-	std::vector<EntityClusterData*> mEntityClusterDataList;
+	std::vector<EntityClusterDataPtr> mEntityClusterDataList;
     
 	std::vector<unsigned int> mBillboarHandle;
 
-	Entity *mEntity;
+	EntityPtr mEntity;
 
 	unsigned int mBillboardHandle;
@@ -41,7 +59,7 @@
   public:
 
-	Entity* getEntity();
+	EntityPtr getEntity();
 
-	void setEntity(Entity* value);
+	void setEntity(EntityPtr value);
 
 	unsigned int getNumEntitiesClusterData();
@@ -55,4 +73,27 @@
 };
 
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+ inline void intrusive_ptr_add_ref(EntityCluster * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+ inline void intrusive_ptr_release(EntityCluster * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
+
+typedef ::boost::intrusive_ptr<EntityCluster> EntityClusterPtr;
+
+
 }
 #endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h	(revision 721)
@@ -13,22 +13,22 @@
     BillboardCloud();
 
-    ~BillboardCloud();
+    virtual ~BillboardCloud();
 
 
   protected:
-	  std::vector<Billboard*> mBillboardList;
+	  std::vector<BillboardPtr> mBillboardList;
 	  
-	  std::vector<BillboardGroup*> mBillboardGroupList;
+	  std::vector<BillboardGroupPtr> mBillboardGroupList;
 
   public:
-	std::vector<Billboard*>* getBillboardList();
+	std::vector<BillboardPtr>* getBillboardList();
 
-	void setBillboardList(std::vector<Billboard*> &value);
+	void setBillboardList(std::vector<BillboardPtr> &value);
 
-    void addBillboard(Billboard* value);
+    void addBillboard(BillboardPtr value);
 
     void removeBillboard(unsigned int value);
 
-	Billboard* getBillboard(unsigned int value);	
+	BillboardPtr getBillboard(unsigned int value);	
 
 	unsigned int BillboardCloud::getNumBillboards();
@@ -42,18 +42,18 @@
 	unsigned int getNumBillboardGroups();
 
-	BillboardGroup* getBillboardGroup(unsigned int iBillboardGroup);
+	BillboardGroupPtr getBillboardGroup(unsigned int iBillboardGroup);
 
-	void addBillboardGroup(BillboardGroup *value); 
+	void addBillboardGroup(BillboardGroupPtr value); 
 
 	void removeBillboardGroup(unsigned int value);
 
   protected:
-	Entity *mEntity;
+	EntityPtr mEntity;
 
 
   public:
-	Entity* getEntity();
+	EntityPtr getEntity();
 
-	void setEntity(Entity *value);
+	void setEntity(EntityPtr value);
 
 };
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeApplication.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeApplication.h	(revision 721)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IBRBillboardCloudTreeApplication.h	(revision 721)
@@ -0,0 +1,41 @@
+#ifndef _IBRBILLBOARDCLOUDTREEAPPLICATION_H
+#define _IBRBILLBOARDCLOUDTREEAPPLICATION_H
+
+#include <OBAOgreApplication.h>
+#include <LBBC.h>
+#include <IBRBillboardCloudTreeFrameListener.h>
+
+struct CommandLineOptions
+{
+	Ogre::String cfg;
+};
+
+class IBRBillboardCloudTreeApplication : public OBA::OgreApplication 
+{	
+protected:
+	
+	CommandLineOptions mOpts;
+	
+	LBBC::Manager* mLBBCManager;
+
+	int findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList, Ogre::BinaryOptionList& binOptList);
+	
+public:
+
+	IBRBillboardCloudTreeApplication();
+
+	virtual ~IBRBillboardCloudTreeApplication();
+
+	// Create new frame listener
+    void createFrameListener(void);
+
+	void parseArgs(int numArgs, char **args);
+
+	void initialize();
+
+	void help();
+	
+
+};
+
+#endif
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h	(revision 709)
+++ GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h	(revision 721)
@@ -7,25 +7,18 @@
 namespace IMG {
 
-//*
-//	ClusterList
-//*
-class ClusterList {
+class ClusterList 
+{
   public:
-    inline ClusterList() {
-      	list.reserve(100);
-      };
+    ClusterList();
 
-    //std::vector<Polygon*> * GetList() { return &list;}	//return the pointer to the list of voxels
-    inline std::vector<Cluster> * GetList() { return &list;};
+    virtual ~ClusterList();
+    
+    std::vector<Cluster> * GetList();
 
     //return the pointer to the list of voxels
-    inline unsigned int GetSize() const { return list.size(); }
+    unsigned int GetSize() const;
 
     //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;
-      };
+    Cluster * Get(unsigned int i);
 
     bool Insert(Cluster * p);
@@ -34,9 +27,7 @@
 
 
-  private:
+  protected:
+
     std::vector<Cluster> list;
-
-  public:
-    ~ClusterList();
 
 };
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 721)
@@ -2,87 +2,41 @@
 #define _IMGBOX2D_H
 
-#include "IMGBBox.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;		
-    	};
+class Box2d 
+{
+	public:
+		Box2d();
 
-    // GametoolsError -- Isma 17/08/2005
-    inline Box2d & operator =(const Box2d & p) {
-    		mMinimum = p.mMinimum;
-    		mMaximum = p.mMaximum;
-    	};
+		~Box2d();
 
-	inline Ogre::Vector2 GetMinimum() { 
-    		return mMinimum;
-    	};
+		// GametoolsError -- Isma 17/08/2005
+		Box2d & Box2d::operator =(const Box2d & p)
+		{
+			mMinimum = p.mMinimum;
+			mMaximum = p.mMaximum;
+			return (*this);
+		}
 
-	inline Ogre::Vector2 GetMaximum() { 
-    		return mMaximum; 
-    	};
+		Ogre::Vector2 GetMinimum();
 
-    inline void SetBoundBox(float x, float y, float X, float Y) {
-    		mMinimum.x = x;
-    		mMinimum.y = y;
-    		mMaximum.x = X;
-    		mMaximum.y = Y;
-    	};
+		Ogre::Vector2 GetMaximum(); 
 
-    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;
-      	};
+		void SetBoundBox(float x, float y, float X, float Y); 
 
-    inline void Print() {
-    		printf("\nValor de la Caixa: (%.4f, %.4f) - (%.4f, %.4f)", mMinimum.x, mMinimum.y, mMaximum.x, mMaximum.y);
-    	};
+		void AddBoundingVector3(float x, float 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;
-      	 };
+		void Print(); 
 
-    inline bool In(int w, int h) {
-    		if (w <= (mMaximum.x - mMinimum.x) &&
-    		    h <= (mMaximum.y - mMinimum.y)) return true;
-    		   
-    		return false;
-    	};
+		Ogre::Vector2 GetCorner(int corner) const;
 
-    inline bool FitPerfect(int w, int h) {	
-    		if (w == (mMaximum.x - mMinimum.x) &&
-    		    h == (mMaximum.y - mMinimum.y)) return true;
-    		  
-    		return false;
-    	};
+		bool In(int w, int h); 
 
-    ~Box2d();
+		bool FitPerfect(int w, int h);
 
-	private:
+	protected:
 		Ogre::Vector2 mMinimum, mMaximum;
 };
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 721)
@@ -1,10 +1,4 @@
-#ifndef _LBBC_H
-#define _LBBC_H
-
-#include <LBBCPrerequisites.h>
-#include <LBBCRoot.h>
-#include <LBBCLeaves.h>
-#include <LBBCLeafKdTreeClusterData.h>
-#include <LBBCSampleConfigFile.h>
+#ifndef _IMG_H
+#define _IMG_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 721)
@@ -2,14 +2,15 @@
 #define _IMGCLUSTER_H
 
-#include "IMGPrerequisites.h"
-#include "IMGBBox.h"
-#include "IMGBox2d.h"
-#include "IMGPlane3.h"
+#include <IMGPrerequisites.h>
+#include <IMGBBox.h>
+#include <IMGBox2d.h>
+#include <IMGPlane3.h>
+#include <IMGCluster2d.h>
 
-namespace IMG { class Cluster2d; } 
+namespace IMG 
+{
 
-namespace IMG {
-
-class Cluster {
+class Cluster 
+{
   public:
     Cluster();
@@ -19,20 +20,13 @@
     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; };
+	void SetNormal(Ogre::Vector3* n);
 
-	inline Ogre::Vector3* GetNormal() { return &normal; };
+	Ogre::Vector3* GetNormal();
 
-    inline BBox* GetBound() { return bound; };
+    BBox* GetBound();
 
-    inline Box2d* GetBspNodeBound() { return bspnodebound; };
+    Box2d* GetBspNodeBound();
 
-    inline void SetBspNodeBound(Box2d* box) {
-    		bspnodebound = box;
-    	};
+    void SetBspNodeBound(Box2d* box);
 
     void Print();
@@ -41,44 +35,17 @@
     int AxisProjected();
 
-    inline int GetId() const { return id; };
+    int GetId() const;
 
-    inline void SetId(int id_) { id = id;};
+    void SetId(int id_);
 
-    //Vector3 * GetVector3s() const{ return Vector3s;}
-    //Vector3 * GetVector3s();
-    //Vector3 * GetVector3s() { return Vector3s_triangle_text; }
-	inline std::vector<Ogre::Vector3>* GetVector3sVector() { return &Vector3s_vector; };
+	std::vector<Ogre::Vector3>* GetVector3sVector();
 
-	inline Ogre::Vector3* GetVector3sTex() const { return Vector3s_triangle_text;};
+	Ogre::Vector3* GetVector3sTex() const;
 
-    // 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);		
-    	};
+	void SetPlane(Ogre::Vector3* normal, Ogre::Vector3 * point);
 
-    inline Plane3 * GetPlane() { return &plane; };
+    Plane3 * GetPlane();
 
     //* Return the increment in U (lumel increment in x). For patchs calculation 
@@ -91,22 +58,16 @@
 	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
+	Ogre::Real *pointeru[4]; 
+
+	Ogre::Real *pointerv[4]; 
+
+	Ogre::Vector2 *uv;
 
   private:
-    BBox * bound;
+    BBox bound;
 
-    Box2d * bspnodebound;
+    Box2d bspnodebound;
 
     static unsigned int ID_CLUSTER;
@@ -117,5 +78,7 @@
 
 	std::vector<Ogre::Vector3> Vector3s_vector;
+
 	Ogre::Vector3 *Vector3s;
+
 	Ogre::Vector3 *Vector3s_triangle_text;
 
@@ -130,12 +93,6 @@
     Plane3 plane;
 
-    // Gametools -- Isma 17/08/2005
-    //Listid patchlistid;
-    //Listid trianglelistid;
-	int CalcPatch(Ogre::Vector3 & point);
-
-
   public:
-    ~Cluster();
+    virtual ~Cluster();
 
 };
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 721)
@@ -2,5 +2,5 @@
 #define _IMGPLANE3_H
 
-#include "IMGPrerequisites.h"
+#include <IMGPrerequisites.h>
 
 namespace IMG {
@@ -9,39 +9,19 @@
   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;
-    	};
+    Plane3();
 
-	inline Ogre::Vector3 * GetNormal() {
-		Ogre::Vector3 *v = new Ogre::Vector3;
-    		v->x = normal.x;
-    		v->y = normal.y;
-    		v->z = normal.z;
-    		return v;
-    	};
+    virtual ~Plane3();
 
-    inline void SetNormal(float x, float y, float z) {
-    		normal.x = x;
-    		normal.y = y;
-    		normal.z = z;		
-    	};
+    Plane3 & operator =(const Plane3 & p);
 
-    inline void SetDistance(float dist) {
-    		d = dist;
-    	};
+	Ogre::Vector3 * GetNormal();
 
-    inline float GetDistance() const { return d;};
+    void SetNormal(float x, float y, float z);
 
-    inline void Print() {
-    		printf("\nPrintant pla: (%.4f, %.4f, %.4f, %.4f)", normal.x, normal.y, normal.z, d);
-    	};
+    void SetDistance(float dist);
 
-    ~Plane3();
+    float GetDistance() const;
+
+    void Print();
 
 };
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 721)
@@ -9,46 +9,20 @@
 class Bsp {
   public:
-    inline Bsp() : root(NULL), countleaf(0), counttotal(0){};
+    Bsp();
 
-    inline void SetRoot(NodeBsp * node) {
-    		root = node;
-    		counttotal++;
-    	};
+    virtual ~Bsp();
 
-    inline void Print() {
-    		printf("\nImprimint Arbre BSP, num nodes leaf: %d, totals: %d", countleaf, counttotal);
-    		Print(root);
-    	};
+    void SetRoot(NodeBspPtr node);
 
-    inline void PrintLeaf() {
-    		PrintLeaf(root);
-    	};
+    void Print();
 
-    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;
-    	};
+    void PrintLeaf(); 
 
-    inline NodeBsp * Get(int i) {
-    		return root->Get (root, i);
-    	};
+    NodeBspPtr Insert(int w, int h, int idcluster);
 
+    NodeBspPtr Get(int i);
 
-  private:
-    NodeBsp * root;
+  protected:
+    NodeBspPtr root;
 
     int countleaf;
@@ -56,25 +30,7 @@
     int counttotal;
 
-    inline void Print(NodeBsp * node) {
-    		if (!node) return;
-    		node->Print();
-    		Print(node->GetChild(0));
-    		Print(node->GetChild(1));
-    	};
+    void Print(NodeBspPtr node);
 
-    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();
+    void PrintLeaf(NodeBspPtr node);
 
 };
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 721)
@@ -9,3 +9,5 @@
 #include <OgreAxisAlignedBox.h> 
 
+#include <boost/smart_ptr.hpp>
+
 #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 721)
@@ -2,15 +2,15 @@
 #define _IMGCLUSTER2D_H
 
-#include "IMGCluster.h"
+#include <IMGPrerequisites.h>
 
 namespace IMG {
 
+class Cluster;
+
 class Cluster2d {
   public:
-    inline Cluster2d() {
-    		Vector3s = NULL;
-    		cluster =NULL;
-    		normal = NULL;
-    	};
+    Cluster2d();
+
+	virtual ~Cluster2d();
 
     //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal.
@@ -21,12 +21,12 @@
     void Print();
 
-	inline Ogre::Vector2 * GetVector3s() { return Vector3s; }
+	Ogre::Vector2 * GetVector3s();
 
-	inline std::vector<Ogre::Vector2> * GetVector3sVector() { return &Vector3s2_vector; } 
+	std::vector<Ogre::Vector2> * GetVector3sVector();
 
-	inline Ogre::Vector3 * GetNormal() { return normal; }
+	Ogre::Vector3 * GetNormal();
 
+  protected:
 
-  private:
     unsigned int id;
 
@@ -34,10 +34,8 @@
 
 	Ogre::Vector2 *Vector3s;
+
 	std::vector<Ogre::Vector2> Vector3s2_vector;
 
 	Ogre::Vector3 *normal;
-
-  public:
-    ~Cluster2d();
 
 };
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 721)
@@ -27,95 +27,21 @@
 class BBox: public Ogre::AxisAlignedBox {
   public:
-    inline BBox() { BBox::StartBoundingBox(); }
+    BBox();
 
-    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;
-       };
+	~BBox();
 
-	inline Ogre::Vector3 GetMinimum() { return mMinimum; }
+    void StartBoundingBox();
 
-    //  
-    //  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;};
+	Ogre::Vector3 GetMinimum();
 
-    //
-    //  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;
-      };
+	Ogre::Vector3 GetMaximum();
 
-    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);
-      };
+    void AddBoundingVector3(float x, float y, float 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;
-       };
+    void Print();
 
-    inline bool intersects(Ogre::Vector3 * v) {
-        	return Ogre::AxisAlignedBox::intersects(*v); 
-        };
+	Ogre::Vector3 GetCorner(int corner) const;
 
-    ~BBox();
+    bool intersects(Ogre::Vector3 v);
 
 };
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 721)
@@ -7,44 +7,47 @@
 namespace IMG {
 
-class NodeBsp {
+// Fordward declaration...
+class NodeBsp;
+
+typedef ::boost::intrusive_ptr<NodeBsp> NodeBspPtr;
+
+namespace boost
+{
+    void intrusive_ptr_add_ref(NodeBsp * p);
+    void intrusive_ptr_release(NodeBsp * p);
+};
+
+class NodeBsp 
+{
   public:
     NodeBsp();
 
-    Box2d * GetBound();
+    virtual ~NodeBsp();
 
-    inline void SetBound(Box2d * box) { bound = box; };
+    Box2d* GetBound();
 
-    inline NodeBsp * GetChild(int i) { return child[i]; };
+    void SetBound(Box2d *box);
 
-    inline void SetId(int id_) { id = id_; };
+    NodeBspPtr GetChild(int i);
 
-    inline unsigned int GetId() const { return id; };
+    void SetId(int id_);
 
-    inline void SetChild(NodeBsp * node, int i) { child[i] = node; };
+    unsigned int GetId() const;
+
+    void SetChild(NodeBspPtr node, int i);
 
     void Print();
 
-    //void SetPlane (Plane3 *pla) { plane = pla; }
-    //Plane3 * GetPlane () { return plane; }
-    NodeBsp * Insert(int w, int h);
+    NodeBspPtr 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);
-    		
-    	};
+    NodeBspPtr Get(NodeBspPtr node, int i);
 
+  protected:
 
-  private:
     bool fit;
 
-    Box2d * bound;
+    Box2d bound;
 
-    NodeBsp * child[2];
+    NodeBspPtr child[2];
 
     static unsigned int ID;
@@ -52,9 +55,32 @@
     int id;
 
+private:
+    
+	long references;
 
-  public:
-    ~NodeBsp();
+    friend void boost::intrusive_ptr_add_ref(NodeBsp * p);
 
+    friend void boost::intrusive_ptr_release(NodeBsp * p);
 };
+
+// class specific addref/release implementation
+// the two function overloads must be in the boost namespace on most compilers:
+namespace boost
+{
+  inline void intrusive_ptr_add_ref(NodeBsp * p)
+  {
+    // increment reference count of object *p
+    ++(p->references);
+  }
+
+
+
+  inline void intrusive_ptr_release(NodeBsp * p)
+  {
+   // decrement reference count, and delete object when reference count reaches 0
+   if (--(p->references) == 0)
+     delete p;
+  } 
+} // namespace boost
 
 }
Index: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxel.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxel.h	(revision 700)
+++ 	(revision )
@@ -1,111 +1,0 @@
-#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/IMGVoxelList.h
===================================================================
--- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGVoxelList.h	(revision 700)
+++ 	(revision )
@@ -1,93 +1,0 @@
-#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
