#pragma once
#include "OSG/OsgST_PreReqs.h"
#include "OSG/OsgST_ForwardDeclare.h"
#include "OSG/OsgST_TreeType.h"
#include "OSG/OsgST_VegetationFwdDeclare.h"
#include "OSG/OsgST_TreeInstanceDesc.h"

#include <osg/Vec3d>
#include <osg/Vec4d>
#include <osg/BoundingBox>

//Rev 157174 had a if'd out code for using signals. Look there to put back in boost signals if they are ever needed.

namespace makOsgSpeedTree
{
   class Forest;
   class TreeType;

   typedef SpeedTree::signal1<const TreeInstance*> SignalFromInstance;  // Instance created, and initialized properly
   typedef SpeedTree::signal1<const TreeInstance*> SignalFromInstance;// Instance De-Initialized
   typedef SpeedTree::signal1<const TreeInstance*> SignalFromInstance;// Instance Transform changed

   class OsgSTExport TreeInstance
   {
   public:
      TreeInstance();
      TreeInstance(Forest* parent, const TreeInstanceDescriptor& desc);
      void _Init(Forest* parent, const TreeInstanceDescriptor& desc);
      
      virtual ~TreeInstance();

      void                SetPosition(const osg::Vec3d& vPos);
      void                SetOrientation(const osg::Vec3d& vUpVector, const osg::Vec3d& vRightVector);
      void                SetScale(float32 fScalar);

      osg::Vec3d          GetPosition(void) const;
      void                GetOrientation(osg::Vec3d& vUpVector, osg::Vec3d& vRightVector) const;
      float32             GetScale(void) const;

      osg::BoundingBoxd   GetAABB(void) const;
      osg::BoundingBoxd   GetWorldAABB(void) const;

      osg::Vec3d          GetUpVector(void) const;
      osg::Vec3d          GetRightVector(void) const;

      const std::string   & GetTreeTypeName(void) const;

      void                SetVisible(bool bVisible);
      bool                GetVisible(void) const;

      void                ShowBoundingBox(bool show);
      bool                GetShowBoundingBox(void) const;		

      void					  Initialize(void);
      bool					  IsInitialized(void) const;
      void					  DeInitialize(void);

      const TreeType*	  GetTreeType(void) const;

      SpeedTree::CTreeInstance*        GetSpeedTreeInstance(void){return m_pSpeedTreeInstance;}
      const SpeedTree::CTreeInstance*  GetSpeedTreeInstance(void) const {return m_pSpeedTreeInstance;}

      //Rev 157174 had a if'd out code for using signals. Look there to put back in boost signals if they are ever needed.

      // An optional id to associate an instance with a cell/page/etc
      UniqueID GetCellID(void) const {return m_Desc.cellID;}
      // An optional id to uniquely identify this instance
      UniqueID GetID(void) const {return m_Desc.ID;}

   private:
      Forest* m_Forest;
      TreeInstanceDescriptor m_Desc;

      bool m_IsInitialized;

      SpeedTree::CTreeInstance* m_pSpeedTreeInstance;

      TreeType* m_TreeType;

      void InitInternalInstance(void);
      void DeInitInternalInstance(void);

#pragma message("PPP: TO DO")
#if 0
      Ogre::WireBoundingBox* m_pWireBoundingBox;
#endif
   };
}
