Ignore:
Timestamp:
03/31/06 17:29:32 (18 years ago)
Author:
igarcia
Message:
 
Location:
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE
Files:
20 added
4 deleted
85 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboard.h

    r700 r721  
    66namespace BBC { 
    77 
    8 class _BBCExport Billboard { 
     8// Forward declarations 
     9class Billboard; 
     10 
     11namespace boost 
     12{ 
     13    void intrusive_ptr_add_ref(Billboard * p); 
     14    void intrusive_ptr_release(Billboard * p); 
     15}; 
     16 
     17 
     18class _BBCExport Billboard  
     19{ 
     20private: 
     21    long references; 
     22    friend void boost::intrusive_ptr_add_ref(Billboard * p); 
     23    friend void boost::intrusive_ptr_release(Billboard * p); 
     24 
    925  public: 
    1026    Billboard(); 
    1127 
    12     ~Billboard(); 
     28    virtual ~Billboard(); 
    1329 
    1430 
     
    2541  protected: 
    2642 
    27         BillboardClusterData *mBillboardClusterData; 
     43        BillboardClusterDataPtr mBillboardClusterData; 
    2844 
    2945  public: 
    3046 
    31         void setBillboardClusterData(BillboardClusterData *value); 
     47        void setBillboardClusterData(BillboardClusterDataPtr value); 
    3248 
    33         BillboardClusterData* getBillboardClusterData(); 
     49        BillboardClusterDataPtr getBillboardClusterData(); 
    3450 
    3551}; 
    3652 
     53// class specific addref/release implementation 
     54// the two function overloads must be in the boost namespace on most compilers: 
     55namespace boost 
     56{ 
     57 inline void intrusive_ptr_add_ref(Billboard * p) 
     58  { 
     59    // increment reference count of object *p 
     60    ++(p->references); 
     61  } 
     62 
     63 
     64 
     65 inline void intrusive_ptr_release(Billboard * p) 
     66  { 
     67   // decrement reference count, and delete object when reference count reaches 0 
     68   if (--(p->references) == 0) 
     69     delete p; 
     70  }  
     71} // namespace boost 
     72 
     73typedef ::boost::intrusive_ptr<Billboard> BillboardPtr; 
     74 
    3775} 
    3876#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h

    r709 r721  
    1313    BillboardCloud(); 
    1414 
    15     ~BillboardCloud(); 
     15    virtual ~BillboardCloud(); 
    1616 
    1717 
    1818  protected: 
    19           std::vector<Billboard*> mBillboardList; 
     19          std::vector<BillboardPtr> mBillboardList; 
    2020           
    21           std::vector<BillboardGroup*> mBillboardGroupList; 
     21          std::vector<BillboardGroupPtr> mBillboardGroupList; 
    2222 
    2323  public: 
    24         std::vector<Billboard*>* getBillboardList(); 
     24        std::vector<BillboardPtr>* getBillboardList(); 
    2525 
    26         void setBillboardList(std::vector<Billboard*> &value); 
     26        void setBillboardList(std::vector<BillboardPtr> &value); 
    2727 
    28     void addBillboard(Billboard* value); 
     28    void addBillboard(BillboardPtr value); 
    2929 
    3030    void removeBillboard(unsigned int value); 
    3131 
    32         Billboard* getBillboard(unsigned int value);     
     32        BillboardPtr getBillboard(unsigned int value);   
    3333 
    3434        unsigned int BillboardCloud::getNumBillboards(); 
     
    4242        unsigned int getNumBillboardGroups(); 
    4343 
    44         BillboardGroup* getBillboardGroup(unsigned int iBillboardGroup); 
     44        BillboardGroupPtr getBillboardGroup(unsigned int iBillboardGroup); 
    4545 
    46         void addBillboardGroup(BillboardGroup *value);  
     46        void addBillboardGroup(BillboardGroupPtr value);  
    4747 
    4848        void removeBillboardGroup(unsigned int value); 
    4949 
    5050  protected: 
    51         Entity *mEntity; 
     51        EntityPtr mEntity; 
    5252 
    5353 
    5454  public: 
    55         Entity* getEntity(); 
     55        EntityPtr getEntity(); 
    5656 
    57         void setEntity(Entity *value); 
     57        void setEntity(EntityPtr value); 
    5858 
    5959}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h

    r700 r721  
    1111class _BBCExport BillboardCloudGenerator { 
    1212  public: 
     13 
     14    BillboardCloudGenerator(); 
     15 
     16        virtual ~BillboardCloudGenerator(); 
     17 
    1318    void generate(); 
    1419 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudSerializer.h

    r700 r721  
    1717    BillboardCloudSerializer(); 
    1818 
    19     ~BillboardCloudSerializer(); 
     19    virtual ~BillboardCloudSerializer(); 
    2020 
    2121 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h

    r709 r721  
    6666        void removeClusterList(unsigned int iClusterList); 
    6767 
    68         void clear(); 
     68        void shutdown(); 
    6969 
    7070        unsigned int getNumClusterLists(); 
     
    7474    BillboardCloudUVMapper(); 
    7575 
    76     ~BillboardCloudUVMapper(); 
     76    virtual ~BillboardCloudUVMapper(); 
    7777 
    7878}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h

    r700 r721  
    66namespace BBC { 
    77 
    8 class _BBCExport BillboardClusterData { 
     8// Fordward declaration... 
     9class BillboardClusterData; 
     10 
     11namespace boost 
     12{ 
     13    void intrusive_ptr_add_ref(BillboardClusterData * p); 
     14    void intrusive_ptr_release(BillboardClusterData * p); 
     15}; 
     16 
     17class _BBCExport BillboardClusterData  
     18{ 
     19private: 
     20    long references; 
     21    friend void boost::intrusive_ptr_add_ref(BillboardClusterData * p); 
     22    friend void boost::intrusive_ptr_release(BillboardClusterData * p); 
     23 
    924  public: 
    1025    BillboardClusterData(); 
    1126 
    12     ~BillboardClusterData(); 
     27    virtual ~BillboardClusterData(); 
    1328 
    1429        void setNormal(Ogre::Vector3 value); 
     
    2035        float getD(); 
    2136 
    22     EntityCluster* getEntityCluster(); 
     37    EntityClusterPtr getEntityCluster(); 
    2338 
    24         void setEntityCluster(EntityCluster *value); 
     39        void setEntityCluster(EntityClusterPtr value); 
    2540 
    2641        virtual void readBillboardClusterData(TiXmlNode *parentNode); 
     
    4762 
    4863protected: 
    49         EntityCluster *mEntityCluster; 
     64        EntityClusterPtr mEntityCluster; 
    5065         
    5166        Ogre::Vector3 mAxisX; 
     
    7085}; 
    7186 
     87// class specific addref/release implementation 
     88// the two function overloads must be in the boost namespace on most compilers: 
     89namespace boost 
     90{ 
     91 inline void intrusive_ptr_add_ref(BillboardClusterData * p) 
     92  { 
     93    // increment reference count of object *p 
     94    ++(p->references); 
     95  } 
     96 
     97 
     98 
     99 inline void intrusive_ptr_release(BillboardClusterData * p) 
     100  { 
     101   // decrement reference count, and delete object when reference count reaches 0 
     102   if (--(p->references) == 0) 
     103     delete p; 
     104  }  
     105} // namespace boost 
     106 
     107typedef ::boost::intrusive_ptr<BillboardClusterData> BillboardClusterDataPtr; 
     108 
    72109} 
    73110#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h

    r709 r721  
    66namespace BBC { 
    77 
    8 class BillboardGroup { 
     8typedef struct 
     9{ 
     10        unsigned int billboardHandle; 
     11        unsigned int width; 
     12        unsigned int height; 
     13        Ogre::Vector2 min; 
     14        Ogre::Vector2 max;  
     15} BillboardGroupedInfo; 
     16 
     17// Forward declarations 
     18class BillboardGroup; 
     19 
     20 
     21namespace boost 
     22{ 
     23    void intrusive_ptr_add_ref(BillboardGroup * p); 
     24    void intrusive_ptr_release(BillboardGroup * p); 
     25}; 
     26 
     27class BillboardGroup  
     28{ 
     29private: 
     30    long references; 
     31    friend void boost::intrusive_ptr_add_ref(BillboardGroup * p); 
     32    friend void boost::intrusive_ptr_release(BillboardGroup * p); 
     33 
    934  protected: 
    1035        std::vector<unsigned int> mBillboardHandleList; 
    1136 
    1237  public: 
     38 
     39    BillboardGroup(); 
     40 
     41        virtual ~BillboardGroup(); 
     42 
    1343    unsigned int getBillboardHandle(unsigned int iBillboard); 
    1444 
     
    1949}; 
    2050 
     51// class specific addref/release implementation 
     52// the two function overloads must be in the boost namespace on most compilers: 
     53namespace boost 
     54{ 
     55 inline void intrusive_ptr_add_ref(BillboardGroup * p) 
     56  { 
     57    // increment reference count of object *p 
     58    ++(p->references); 
     59  } 
     60 
     61 
     62 
     63 inline void intrusive_ptr_release(BillboardGroup * p) 
     64  { 
     65   // decrement reference count, and delete object when reference count reaches 0 
     66   if (--(p->references) == 0) 
     67     delete p; 
     68  }  
     69} // namespace boost 
     70 
     71typedef ::boost::intrusive_ptr<BillboardGroup> BillboardGroupPtr; 
     72 
    2173} 
    2274#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntity.h

    r700 r721  
    44#include <BBCPrerequisites.h> 
    55#include <BBCSubEntity.h> 
     6#include <BBCMesh.h> 
    67 
    78namespace BBC { 
    89 
     10// Forward declarations 
     11class Entity; 
     12 
     13 
     14namespace boost 
     15{ 
     16    void intrusive_ptr_add_ref(Entity * p); 
     17    void intrusive_ptr_release(Entity * p); 
     18}; 
     19 
    920class _BBCExport Entity  
    1021{ 
     22private: 
     23    long references; 
     24    friend void boost::intrusive_ptr_add_ref(Entity * p); 
     25    friend void boost::intrusive_ptr_release(Entity * p); 
     26 
    1127  protected: 
    1228 
    13         typedef std::vector<SubEntity*> SubEntityList; 
     29        typedef std::vector<SubEntityPtr> SubEntityList; 
    1430 
    1531        unsigned int mEntityHandle; 
     
    1935        SubEntityList mSubEntityList; 
    2036 
    21         Ogre::Mesh *mMesh; 
     37        MeshPtr mMesh; 
    2238         
    2339  public: 
     
    2541    Entity(); 
    2642 
    27     ~Entity(); 
     43    virtual ~Entity(); 
    2844 
    2945        void createSubEntity(); 
    3046 
    31         void addSubEntity(SubEntity *value); 
     47        void addSubEntity(SubEntityPtr value); 
    3248 
    33         SubEntity* getSubEntity(unsigned int index); 
     49        SubEntityPtr getSubEntity(unsigned int index); 
    3450 
    3551        void removeSubEntity(unsigned int index); 
    3652 
    37         virtual Ogre::Mesh* getMesh(); 
     53        virtual MeshPtr getMesh(); 
    3854 
    39         virtual void setMesh(Ogre::Mesh *value); 
     55        virtual void setMesh(MeshPtr value); 
    4056 
    4157        void loadMesh(bool mergeSubMeshes); 
     
    6581}; 
    6682 
     83// class specific addref/release implementation 
     84// the two function overloads must be in the boost namespace on most compilers: 
     85namespace boost 
     86{ 
     87 inline void intrusive_ptr_add_ref(Entity * p) 
     88  { 
     89    // increment reference count of object *p 
     90    ++(p->references); 
     91  } 
     92 
     93 
     94 
     95 inline void intrusive_ptr_release(Entity * p) 
     96  { 
     97   // decrement reference count, and delete object when reference count reaches 0 
     98   if (--(p->references) == 0) 
     99     delete p; 
     100  }  
     101} // namespace boost 
     102 
     103typedef ::boost::intrusive_ptr<Entity> EntityPtr; 
     104 
    67105} 
    68106#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityCluster.h

    r700 r721  
    1111namespace BBC { 
    1212 
    13 class _BBCExport EntityCluster { 
     13// Forward declarations 
     14class EntityCluster; 
     15 
     16 
     17namespace boost 
     18{ 
     19    void intrusive_ptr_add_ref(EntityCluster * p); 
     20    void intrusive_ptr_release(EntityCluster * p); 
     21}; 
     22 
     23class _BBCExport EntityCluster  
     24{ 
     25private: 
     26    long references; 
     27    friend void boost::intrusive_ptr_add_ref(EntityCluster * p); 
     28    friend void boost::intrusive_ptr_release(EntityCluster * p); 
     29 
    1430  public: 
    1531    EntityCluster(); 
    1632 
    17     ~EntityCluster(); 
     33    virtual ~EntityCluster(); 
    1834 
    19         EntityClusterData* getEntityClusterData(unsigned int value); 
     35        void removeEntityClusterData(unsigned int value); 
    2036 
    21         void addEntityClusterData(EntityClusterData *value); 
     37        EntityClusterDataPtr getEntityClusterData(unsigned int value); 
     38 
     39        void addEntityClusterData(EntityClusterDataPtr value); 
    2240 
    2341        void removeEntitClusterData(unsigned int value); 
    2442 
    25         EntityDistribution* getEntityDistribution(); 
     43        EntityDistributionPtr getEntityDistribution(); 
    2644 
    27         void setEntityDistribution(EntityDistribution *value); 
     45        void setEntityDistribution(EntityDistributionPtr value); 
    2846 
    2947  protected: 
    3048 
    31         EntityDistribution *mEntityDistribution; 
     49        EntityDistributionPtr mEntityDistribution; 
    3250         
    33         std::vector<EntityClusterData*> mEntityClusterDataList; 
     51        std::vector<EntityClusterDataPtr> mEntityClusterDataList; 
    3452     
    3553        std::vector<unsigned int> mBillboarHandle; 
    3654 
    37         Entity *mEntity; 
     55        EntityPtr mEntity; 
    3856 
    3957        unsigned int mBillboardHandle; 
     
    4159  public: 
    4260 
    43         Entity* getEntity(); 
     61        EntityPtr getEntity(); 
    4462 
    45         void setEntity(Entity* value); 
     63        void setEntity(EntityPtr value); 
    4664 
    4765        unsigned int getNumEntitiesClusterData(); 
     
    5573}; 
    5674 
     75// class specific addref/release implementation 
     76// the two function overloads must be in the boost namespace on most compilers: 
     77namespace boost 
     78{ 
     79 inline void intrusive_ptr_add_ref(EntityCluster * p) 
     80  { 
     81    // increment reference count of object *p 
     82    ++(p->references); 
     83  } 
     84 
     85 
     86 
     87 inline void intrusive_ptr_release(EntityCluster * p) 
     88  { 
     89   // decrement reference count, and delete object when reference count reaches 0 
     90   if (--(p->references) == 0) 
     91     delete p; 
     92  }  
     93} // namespace boost 
     94 
     95typedef ::boost::intrusive_ptr<EntityCluster> EntityClusterPtr; 
     96 
     97 
    5798} 
    5899#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityClusterData.h

    r700 r721  
    66namespace BBC { 
    77 
    8 class _BBCExport EntityClusterData { 
     8// Fordward declaration... 
     9class EntityClusterData; 
     10 
     11namespace boost 
     12{ 
     13    void intrusive_ptr_add_ref(EntityClusterData * p); 
     14    void intrusive_ptr_release(EntityClusterData * p); 
     15}; 
     16 
     17class _BBCExport EntityClusterData  
     18{ 
     19private: 
     20    long references; 
     21    friend void boost::intrusive_ptr_add_ref(EntityClusterData * p); 
     22    friend void boost::intrusive_ptr_release(EntityClusterData * p); 
     23 
    924  public: 
    1025    EntityClusterData(); 
    1126 
    12     ~EntityClusterData(); 
     27    virtual ~EntityClusterData(); 
    1328 
    14         void setEntity(Entity *value); 
     29        void setEntity(EntityPtr value); 
    1530 
    16         Entity* getEntity(); 
     31        EntityPtr getEntity(); 
    1732 
    1833  protected: 
    19         Entity *mEntity; 
     34        EntityPtr mEntity; 
    2035 
    2136}; 
    2237 
     38// class specific addref/release implementation 
     39// the two function overloads must be in the boost namespace on most compilers: 
     40namespace boost 
     41{ 
     42 inline void intrusive_ptr_add_ref(EntityClusterData * p) 
     43  { 
     44    // increment reference count of object *p 
     45    ++(p->references); 
     46  } 
     47 
     48 
     49 
     50 inline void intrusive_ptr_release(EntityClusterData * p) 
     51  { 
     52   // decrement reference count, and delete object when reference count reaches 0 
     53   if (--(p->references) == 0) 
     54     delete p; 
     55  }  
     56} // namespace boost 
     57 
     58typedef ::boost::intrusive_ptr<EntityClusterData> EntityClusterDataPtr; 
     59 
    2360} 
    2461#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistribution.h

    r700 r721  
    66namespace BBC { 
    77 
    8 class _BBCExport EntityDistribution { 
     8// Forward declarations 
     9class EntityDistribution; 
     10 
     11 
     12namespace boost 
     13{ 
     14    void intrusive_ptr_add_ref(EntityDistribution * p); 
     15    void intrusive_ptr_release(EntityDistribution * p); 
     16}; 
     17 
     18class _BBCExport EntityDistribution  
     19{ 
     20private: 
     21    long references; 
     22    friend void boost::intrusive_ptr_add_ref(EntityDistribution * p); 
     23    friend void boost::intrusive_ptr_release(EntityDistribution * p); 
     24 
    925  protected: 
    10         std::vector<Entity*> mEntityList; 
     26        std::vector<EntityPtr> mEntityList; 
    1127 
    1228  public: 
    13         Entity* getEntity(unsigned int value); 
     29    EntityDistribution(); 
    1430 
    15         void addEntity(Entity *value); 
     31        virtual ~EntityDistribution(); 
     32 
     33        EntityPtr getEntity(unsigned int value); 
     34 
     35        void addEntity(EntityPtr value); 
    1636 
    1737        void removeEntity(unsigned int value); 
     
    2040}; 
    2141 
     42 
     43// class specific addref/release implementation 
     44// the two function overloads must be in the boost namespace on most compilers: 
     45namespace boost 
     46{ 
     47 inline void intrusive_ptr_add_ref(EntityDistribution * p) 
     48  { 
     49    // increment reference count of object *p 
     50    ++(p->references); 
     51  } 
     52 
     53 
     54 
     55 inline void intrusive_ptr_release(EntityDistribution * p) 
     56  { 
     57   // decrement reference count, and delete object when reference count reaches 0 
     58   if (--(p->references) == 0) 
     59     delete p; 
     60  }  
     61} // namespace boost 
     62 
     63typedef ::boost::intrusive_ptr<EntityDistribution> EntityDistributionPtr; 
     64 
    2265} 
    2366#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionGenerator.h

    r700 r721  
    1313        EntityDistribution *mEntityDistribution; 
    1414 
    15     Entity *mEntity; 
     15    EntityPtr mEntity; 
    1616 
    1717  public: 
     
    2020    void init(); 
    2121 
    22         Entity* getEntity(); 
     22        EntityPtr getEntity(); 
    2323 
    24         void setEntity(Entity *value); 
     24        void setEntity(EntityPtr value); 
    2525 
    2626        void setDistribution(EntityDistribution *value); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionSerializer.h

    r700 r721  
    1010class _BBCExport EntityDistributionSerializer: public BBC::XmlSerializer { 
    1111  protected: 
    12         Entity* mEntity; 
     12        EntityPtr mEntity; 
    1313 
    1414  public: 
    15     Entity* getEntity(); 
     15    EntityPtr getEntity(); 
    1616 
    17     void setEntity(Entity * value); 
     17    void setEntity(EntityPtr value); 
    1818 
    1919    void generate(); 
     
    2323    EntityDistributionSerializer(); 
    2424 
    25     ~EntityDistributionSerializer(); 
     25    virtual ~EntityDistributionSerializer(); 
    2626 
    2727}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h

    r700 r721  
    44#include <BBCPrerequisites.h> 
    55#include <BBCSingleton.h> 
    6  
    7 //#include <ExampleFrameListener.h> 
    86 
    97namespace BBC { 
     
    1917        static Manager* getSingletonPtr(void); 
    2018 
    21         void initRenderWindow(); 
    22  
    23         Ogre::Mesh* loadMesh(Ogre::String name); 
     19        Ogre::Mesh* loadMesh(Ogre::String folderName, Ogre::String fileName); 
    2420 
    2521        Ogre::Mesh* loadXMLMesh(Ogre::String name); 
    26  
    27         void loadResources(); 
    2822 
    2923        void saveMesh(Ogre::String name); 
     
    4034 
    4135  protected: 
    42           Ogre::Root* mOgreRoot; 
    43           Ogre::MeshSerializer *mMeshSerializer; 
    44           Ogre::XMLMeshSerializer *mXMLMeshSerializer; 
    45           Ogre::DefaultHardwareBufferManager *mDefaultHardwareBufferManager; 
    46           Ogre::RenderWindow *mWnd; 
    47           Ogre::SceneManager *mScene; 
    48           Ogre::RenderSystem *mRSys; 
    49           Ogre::Camera *mCam; 
    50           Ogre::Viewport *mView; 
    51           Ogre::Math *mMath; 
    52           //ExampleFrameListener *mFrameListener; 
     36 
    5337}; 
    5438 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCOgreMeshSerializer.h

    r700 r721  
    44#include <BBCPrerequisites.h> 
    55#include <BBCEntity.h> 
     6#include <BBCMesh.h> 
    67 
    78namespace BBC { 
     
    1415        virtual ~OgreMeshSerializer(); 
    1516 
    16                 void setEntity(Entity *entity); 
     17                void setEntity(EntityPtr entity); 
    1718 
    18                 Entity* getEntity(); 
     19                EntityPtr getEntity(); 
    1920 
    2021                void exportMesh(const Ogre::String& fileName, bool mergeSubMeshes, bool tangents); 
     
    2223    protected: 
    2324 
    24                 Entity *mEntity; 
     25                EntityPtr mEntity; 
    2526                 
    26                 void buildMesh(Ogre::Mesh* pMesh, bool mergeSubmeshes); 
     27                void buildMesh(MeshPtr pMesh, bool mergeSubmeshes); 
    2728                 
    28                 void generateEntityAABB(Ogre::Mesh* pMesh); 
     29                void generateEntityAABB(MeshPtr pMesh); 
    2930                 
    30                 void exportSubMeshes(Ogre::Mesh* pMesh); 
     31                void exportSubMeshes(MeshPtr pMesh); 
    3132         
    32                 void exportSubMesh(Ogre::Mesh* pMesh, SubEntity *subEntity); 
     33                void exportSubMesh(MeshPtr pMesh, SubEntityPtr subEntity); 
    3334         
    34                 template <typename T> void writeIndexes(T* buf, SubEntity *subEntity); 
     35                template <typename T> void writeIndexes(T* buf, SubEntityPtr subEntity); 
    3536         
    3637                void createVertexBuffer(Ogre::VertexData* vd, unsigned short bufIdx, UniqueVertexList *uniqueVertexList); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCPrerequisites.h

    r700 r721  
    2323#include <OgreVertexBoneAssignment.h> 
    2424#include <OgreAxisAlignedBox.h> 
    25  
    2625#include <OgreKeyEvent.h> 
    2726#include <OgreEventListeners.h> 
     
    3130#include <OgrePixelFormat.h> 
    3231#include <OgreGpuProgram.h> 
     32#include <OgreSharedPtr.h> 
     33 
     34#include <OBA.h> 
     35 
     36#include <boost/smart_ptr.hpp> 
    3337 
    3438//#include <ospace/stl/hashset.h> 
     
    3640 
    3741#define _BBCExport __declspec( dllexport ) 
     42 
    3843#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSingleton.h

    r700 r721  
    1 #ifndef __SINGLETON_H__ 
    2 #define __SINGLETON_H__ 
     1#ifndef __BBCSINGLETON_H__ 
     2#define __BBCSINGLETON_H__ 
    33 
    44namespace BBC { 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h

    r700 r721  
    55 
    66namespace BBC { 
    7  
     7  
    88class _BBCExport UniqueVertex 
    99{ 
     
    2424typedef std::vector<UniqueVertex> UniqueVertexList; 
    2525 
    26 class _BBCExport SubEntity { 
    27   public: 
     26// Fordward declaration 
     27class SubEntity; 
     28 
     29namespace boost 
     30{ 
     31    void intrusive_ptr_add_ref(SubEntity * p); 
     32    void intrusive_ptr_release(SubEntity * p); 
     33}; 
     34 
     35class _BBCExport SubEntity 
     36{ 
     37  private: 
     38    long references; 
     39 
     40    friend void boost::intrusive_ptr_add_ref(SubEntity * p); 
     41 
     42    friend void boost::intrusive_ptr_release(SubEntity * p); 
     43 
     44  protected: 
    2845 
    2946        typedef std::vector<unsigned short int> TextureCoordSetsDimensions; 
     47 
    3048        typedef std::vector<Ogre::Vector3> Indices; 
    31  
    32   protected: 
    3349 
    3450        UniqueVertexList mUniqueVertexList; 
     
    5672    SubEntity(); 
    5773 
    58     ~SubEntity(); 
     74    virtual ~SubEntity(); 
    5975 
    6076        void enableTangents(bool value); 
     
    129145 
    130146        void generateAABBox(); 
     147 
     148        const char *GetClassName(void) const; 
     149 
    131150}; 
     151 
     152// class specific addref/release implementation 
     153// the two function overloads must be in the boost namespace on most compilers: 
     154namespace boost 
     155{ 
     156  inline void intrusive_ptr_add_ref(SubEntity * p) 
     157  { 
     158    // increment reference count of object *p 
     159    ++(p->references); 
     160  } 
     161 
     162 
     163 
     164  inline void intrusive_ptr_release(SubEntity * p) 
     165  { 
     166   // decrement reference count, and delete object when reference count reaches 0 
     167   if (--(p->references) == 0) 
     168     delete p; 
     169  }  
     170} // namespace boost 
     171 
     172typedef ::boost::intrusive_ptr<SubEntity> SubEntityPtr; 
    132173 
    133174} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCXmlSerializer.h

    r700 r721  
    1111    XmlSerializer(); 
    1212 
    13     ~XmlSerializer(); 
     13    virtual ~XmlSerializer(); 
    1414 
    1515  protected: 
    1616    Ogre::String mFilename; 
     17 
    1718        TiXmlDocument *mFile; 
     19 
    1820    bool mLoaded; 
    1921 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMG.h

    r700 r721  
    1 #ifndef _LBBC_H 
    2 #define _LBBC_H 
    3  
    4 #include <LBBCPrerequisites.h> 
    5 #include <LBBCRoot.h> 
    6 #include <LBBCLeaves.h> 
    7 #include <LBBCLeafKdTreeClusterData.h> 
    8 #include <LBBCSampleConfigFile.h> 
     1#ifndef _IMG_H 
     2#define _IMG_H 
    93 
    104#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBBox.h

    r700 r721  
    2727class BBox: public Ogre::AxisAlignedBox { 
    2828  public: 
    29     inline BBox() { BBox::StartBoundingBox(); } 
     29    BBox(); 
    3030 
    31     inline void StartBoundingBox() { 
    32                  mMinimum.x =  BOUNDINGBOX_MAXVALUE; 
    33          mMinimum.y =  BOUNDINGBOX_MAXVALUE; 
    34          mMinimum.z =  BOUNDINGBOX_MAXVALUE; 
    35          mMaximum.x = -BOUNDINGBOX_MAXVALUE; 
    36          mMaximum.y = -BOUNDINGBOX_MAXVALUE; 
    37          mMaximum.z = -BOUNDINGBOX_MAXVALUE; 
    38        }; 
     31        ~BBox(); 
    3932 
    40         inline Ogre::Vector3 GetMinimum() { return mMinimum; } 
     33    void StartBoundingBox(); 
    4134 
    42     //   
    43     //  Vector3 * GetMinimum() 
    44     //  {  
    45     //          Vector3 *Vector3; 
    46     //   
    47     //  Ogre::Vector3 v = mMinimum;      
    48     //  Vector3.x = v.x; 
    49     //  Vector3.y = v.y; 
    50     //  Vector3.z = v.z; 
    51     //   
    52     //  return v; 
    53     //  } 
    54      
    55         inline Ogre::Vector3 GetMaximum() { return mMaximum;}; 
     35        Ogre::Vector3 GetMinimum(); 
    5636 
    57     // 
    58     //  Vector3 GetMaximum() 
    59     //  {  
    60     //   
    61     //          Vector3 Vector3; 
    62     //  Ogre::Vector3 v = mMaximum;      
    63     //  Vector3.x = v.x; 
    64     //  Vector3.y = v.y; 
    65     //  Vector3.z = v.z; 
    66     //          return Vector3; 
    67     //  } 
    68     //   
    69     inline void AddBoundingVector3(float x, float y, float z) { 
    70         if (x < mMinimum.x) mMinimum.x = x; if (x > mMaximum.x) mMaximum.x = x; 
    71         if (y < mMinimum.y) mMinimum.y = y; if (y > mMaximum.y) mMaximum.y = y; 
    72         if (z < mMinimum.z) mMinimum.z = z; if (z > mMaximum.z) mMaximum.z = z; 
    73       }; 
     37        Ogre::Vector3 GetMaximum(); 
    7438 
    75     inline void Print() { 
    76         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); 
    77       }; 
     39    void AddBoundingVector3(float x, float y, float z); 
    7840 
    79     //Ogre::Vector3* GetCorner (int corner) const 
    80         inline Ogre::Vector3 * GetCorner(int corner) const { 
    81         
    82         //if (corner < 0 || corner > 7) return Ogre::Vector3 (-1111111111, -1111111111, -1111111111); 
    83         //return Ogre::AxisAlignedBox::getAllCorners ()[corner]; 
    84         //printf("\nGetCorner: %d", corner); 
    85          
    86         if (corner < 0 || corner > 7) return NULL; 
    87          
    88         Ogre::Vector3 *vector;           
    89         switch (corner) 
    90         { 
    91                 /* 
    92                 case BOX_CORNER_xyz: return vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z ); 
    93                 case BOX_CORNER_xyZ: return vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z ); 
    94                 case BOX_CORNER_xYz: return vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z ); 
    95                 case BOX_CORNER_xYZ: return vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z ); 
    96                 case BOX_CORNER_Xyz: return vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z ); 
    97                 case BOX_CORNER_XyZ: return vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z ); 
    98                 case BOX_CORNER_XYz: return vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z ); 
    99                 case BOX_CORNER_XYZ: return vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z ); 
    100                 */ 
    101                         case BOX_CORNER_xyz: vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z ); break; 
    102                 case BOX_CORNER_xyZ: vector = new Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z ); break; 
    103                 case BOX_CORNER_xYz: vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z ); break; 
    104                 case BOX_CORNER_xYZ: vector = new Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z ); break; 
    105                 case BOX_CORNER_Xyz: vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z ); break; 
    106                 case BOX_CORNER_XyZ: vector = new Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z ); break; 
    107                 case BOX_CORNER_XYz: vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z ); break; 
    108                 case BOX_CORNER_XYZ: vector = new Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z ); break; 
    109         } 
    110          
    111         //vector->Print(); 
    112         return vector; 
    113        }; 
     41    void Print(); 
    11442 
    115     inline bool intersects(Ogre::Vector3 * v) { 
    116                 return Ogre::AxisAlignedBox::intersects(*v);  
    117         }; 
     43        Ogre::Vector3 GetCorner(int corner) const; 
    11844 
    119     ~BBox(); 
     45    bool intersects(Ogre::Vector3 v); 
    12046 
    12147}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBox2d.h

    r700 r721  
    22#define _IMGBOX2D_H 
    33 
    4 #include "IMGBBox.h" 
     4#include <IMGBBox.h> 
    55 
    66namespace IMG { 
    77 
    88//* this class represents a 2d bound box for a texture  
    9 class Box2d { 
    10   public: 
    11     inline Box2d() { 
    12                 mMinimum.x =  BOUNDINGBOX_MAXVALUE; 
    13                 mMinimum.y =  BOUNDINGBOX_MAXVALUE; 
    14                  
    15                 mMaximum.x = -BOUNDINGBOX_MAXVALUE; 
    16                 mMaximum.y = -BOUNDINGBOX_MAXVALUE;              
    17         }; 
     9class Box2d  
     10{ 
     11        public: 
     12                Box2d(); 
    1813 
    19     // GametoolsError -- Isma 17/08/2005 
    20     inline Box2d & operator =(const Box2d & p) { 
    21                 mMinimum = p.mMinimum; 
    22                 mMaximum = p.mMaximum; 
    23         }; 
     14                ~Box2d(); 
    2415 
    25         inline Ogre::Vector2 GetMinimum() {  
    26                 return mMinimum; 
    27         }; 
     16                // GametoolsError -- Isma 17/08/2005 
     17                Box2d & Box2d::operator =(const Box2d & p) 
     18                { 
     19                        mMinimum = p.mMinimum; 
     20                        mMaximum = p.mMaximum; 
     21                        return (*this); 
     22                } 
    2823 
    29         inline Ogre::Vector2 GetMaximum() {  
    30                 return mMaximum;  
    31         }; 
     24                Ogre::Vector2 GetMinimum(); 
    3225 
    33     inline void SetBoundBox(float x, float y, float X, float Y) { 
    34                 mMinimum.x = x; 
    35                 mMinimum.y = y; 
    36                 mMaximum.x = X; 
    37                 mMaximum.y = Y; 
    38         }; 
     26                Ogre::Vector2 GetMaximum();  
    3927 
    40     inline void AddBoundingVector3(float x, float y) { 
    41                         if (x < mMinimum.x) mMinimum.x = x; if (x > mMaximum.x) mMaximum.x = x; 
    42                         if (y < mMinimum.y) mMinimum.y = y; if (y > mMaximum.y) mMaximum.y = y; 
    43         }; 
     28                void SetBoundBox(float x, float y, float X, float Y);  
    4429 
    45     inline void Print() { 
    46                 printf("\nValor de la Caixa: (%.4f, %.4f) - (%.4f, %.4f)", mMinimum.x, mMinimum.y, mMaximum.x, mMaximum.y); 
    47         }; 
     30                void AddBoundingVector3(float x, float y); 
    4831 
    49         inline Ogre::Vector2 * GetCorner(int corner) const { 
    50         
    51                 //if (corner < 0 || corner > 7) return Ogre::Vector3 (-1111111111, -1111111111, -1111111111); 
    52                 //return Ogre::AxisAlignedBox::getAllCorners ()[corner]; 
    53                 //printf("\nGetCorner: %d", corner); 
    54                  
    55                 if (corner < 0 || corner > 4) return NULL; 
    56                                  
    57                         Ogre::Vector2 *vector; 
    58                 switch (corner) 
    59                 {                
    60                         case BOX_CORNER_xy: vector = new Ogre::Vector2(mMinimum.x, mMinimum.y ); break; 
    61                         case BOX_CORNER_xY: vector = new Ogre::Vector2(mMinimum.x, mMaximum.y ); break; 
    62                         case BOX_CORNER_Xy: vector = new Ogre::Vector2(mMaximum.x, mMinimum.y ); break; 
    63                         case BOX_CORNER_XY: vector = new Ogre::Vector2(mMaximum.x, mMaximum.y ); break; 
    64                          
    65                 } 
    66                  
    67                 return vector; 
    68          }; 
     32                void Print();  
    6933 
    70     inline bool In(int w, int h) { 
    71                 if (w <= (mMaximum.x - mMinimum.x) && 
    72                     h <= (mMaximum.y - mMinimum.y)) return true; 
    73                     
    74                 return false; 
    75         }; 
     34                Ogre::Vector2 GetCorner(int corner) const; 
    7635 
    77     inline bool FitPerfect(int w, int h) {       
    78                 if (w == (mMaximum.x - mMinimum.x) && 
    79                     h == (mMaximum.y - mMinimum.y)) return true; 
    80                    
    81                 return false; 
    82         }; 
     36                bool In(int w, int h);  
    8337 
    84     ~Box2d(); 
     38                bool FitPerfect(int w, int h); 
    8539 
    86         private: 
     40        protected: 
    8741                Ogre::Vector2 mMinimum, mMaximum; 
    8842}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBsp.h

    r700 r721  
    99class Bsp { 
    1010  public: 
    11     inline Bsp() : root(NULL), countleaf(0), counttotal(0){}; 
     11    Bsp(); 
    1212 
    13     inline void SetRoot(NodeBsp * node) { 
    14                 root = node; 
    15                 counttotal++; 
    16         }; 
     13    virtual ~Bsp(); 
    1714 
    18     inline void Print() { 
    19                 printf("\nImprimint Arbre BSP, num nodes leaf: %d, totals: %d", countleaf, counttotal); 
    20                 Print(root); 
    21         }; 
     15    void SetRoot(NodeBspPtr node); 
    2216 
    23     inline void PrintLeaf() { 
    24                 PrintLeaf(root); 
    25         }; 
     17    void Print(); 
    2618 
    27     inline NodeBsp * Insert(int w, int h, int idcluster) { 
    28                 //printf("\nInsret dins Bsp: %d, %d", w, h); 
    29                  
    30                 NodeBsp *node = root->Insert (w,h); 
    31                  
    32                 //printf("\nNode on s'insertarà finalment éS: "); node->Print(); 
    33                  
    34                 if (idcluster != -1) 
    35                 { 
    36                         node->SetId (idcluster); 
    37                         countleaf++;                     
    38                 } 
    39                 else counttotal++; 
    40                  
    41                 //Copiar pixels de la imatge al node 
    42                  
    43                 return node; 
    44         }; 
     19    void PrintLeaf();  
    4520 
    46     inline NodeBsp * Get(int i) { 
    47                 return root->Get (root, i); 
    48         }; 
     21    NodeBspPtr Insert(int w, int h, int idcluster); 
    4922 
     23    NodeBspPtr Get(int i); 
    5024 
    51   private: 
    52     NodeBsp * root; 
     25  protected: 
     26    NodeBspPtr root; 
    5327 
    5428    int countleaf; 
     
    5630    int counttotal; 
    5731 
    58     inline void Print(NodeBsp * node) { 
    59                 if (!node) return; 
    60                 node->Print(); 
    61                 Print(node->GetChild(0)); 
    62                 Print(node->GetChild(1)); 
    63         }; 
     32    void Print(NodeBspPtr node); 
    6433 
    65     inline void PrintLeaf(NodeBsp * node) { 
    66                 if (!node) return; 
    67                  
    68                  
    69                 if (node->GetChild(0) == NULL && node->GetChild(1) == NULL) node->Print(); 
    70                  
    71                 PrintLeaf (node->GetChild(0)); 
    72                 PrintLeaf (node->GetChild(1)); 
    73                  
    74         }; 
    75  
    76  
    77   public: 
    78     ~Bsp(); 
     34    void PrintLeaf(NodeBspPtr node); 
    7935 
    8036}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster.h

    r700 r721  
    22#define _IMGCLUSTER_H 
    33 
    4 #include "IMGPrerequisites.h" 
    5 #include "IMGBBox.h" 
    6 #include "IMGBox2d.h" 
    7 #include "IMGPlane3.h" 
     4#include <IMGPrerequisites.h> 
     5#include <IMGBBox.h> 
     6#include <IMGBox2d.h> 
     7#include <IMGPlane3.h> 
     8#include <IMGCluster2d.h> 
    89 
    9 namespace IMG { class Cluster2d; }  
     10namespace IMG  
     11{ 
    1012 
    11 namespace IMG { 
    12  
    13 class Cluster { 
     13class Cluster  
     14{ 
    1415  public: 
    1516    Cluster(); 
     
    1920    Cluster(const Cluster & p); 
    2021 
    21     // Gametools -- Isma 17/08/2005 
    22     //void Insert (Triangle *t); 
    23     // Gametools -- Isma 17/08/2005 
    24     //* return the patchs that the point is in 
    25     //int CalculaPatch (Vector3 &point); 
    26         inline void SetNormal(Ogre::Vector3* n) { normal = *n; }; 
     22        void SetNormal(Ogre::Vector3* n); 
    2723 
    28         inline Ogre::Vector3* GetNormal() { return &normal; }; 
     24        Ogre::Vector3* GetNormal(); 
    2925 
    30     inline BBox* GetBound() { return bound; }; 
     26    BBox* GetBound(); 
    3127 
    32     inline Box2d* GetBspNodeBound() { return bspnodebound; }; 
     28    Box2d* GetBspNodeBound(); 
    3329 
    34     inline void SetBspNodeBound(Box2d* box) { 
    35                 bspnodebound = box; 
    36         }; 
     30    void SetBspNodeBound(Box2d* box); 
    3731 
    3832    void Print(); 
     
    4135    int AxisProjected(); 
    4236 
    43     inline int GetId() const { return id; }; 
     37    int GetId() const; 
    4438 
    45     inline void SetId(int id_) { id = id;}; 
     39    void SetId(int id_); 
    4640 
    47     //Vector3 * GetVector3s() const{ return Vector3s;} 
    48     //Vector3 * GetVector3s(); 
    49     //Vector3 * GetVector3s() { return Vector3s_triangle_text; } 
    50         inline std::vector<Ogre::Vector3>* GetVector3sVector() { return &Vector3s_vector; }; 
     41        std::vector<Ogre::Vector3>* GetVector3sVector(); 
    5142 
    52         inline Ogre::Vector3* GetVector3sTex() const { return Vector3s_triangle_text;}; 
     43        Ogre::Vector3* GetVector3sTex() const; 
    5344 
    54     // Gametools -- Isma 17/08/2005 
    55     //bool CreatePatches(bool dinamic = false); 
    56     // Gametools -- Isma 17/08/2005 
    57     //Listid *GetPatchList() { return &patchlistid;} 
    58     //Listid *GetTriangleList(){ return &trianglelistid; } 
    59     // Gametools -- Isma 17/08/2005 
    60     //int GetIdPatch (unsigned int i) 
    61     //{ 
    62     //  if (i > patchlistid.GetSize()) return -1; 
    63     //   
    64     //  return patchlistid.Get(i); 
    65     //} 
    66     // Gametools -- Isma 17/08/2005 
    67     //int GetIdTriangle  (unsigned int i) 
    68     //{ 
    69     //  if (i > trianglelistid.GetSize()) return -1; 
    70     //   
    71     //  return trianglelistid.Get(i); 
    72     //} 
    7345    void Finish(); 
    7446 
    75         inline void SetPlane(Ogre::Vector3* normal, Ogre::Vector3 * point) { 
    76                 plane.normal = *normal; 
    77                 plane.normal = -plane.normal; 
    78                 plane.d = -normal->dotProduct (*point);          
    79                 //plane.d = normal->dotProduct (*point);                 
    80         }; 
     47        void SetPlane(Ogre::Vector3* normal, Ogre::Vector3 * point); 
    8148 
    82     inline Plane3 * GetPlane() { return &plane; }; 
     49    Plane3 * GetPlane(); 
    8350 
    8451    //* Return the increment in U (lumel increment in x). For patchs calculation  
     
    9158        Ogre::Vector3 GetOrigin(); 
    9259 
    93     // 
    94     //  void CreateVector3s() 
    95     //  {  
    96     //           
    97     //          //Vector3s = new Vector3[4]; 
    98     //          //Vector3s_triangle_text = new Vector3[4]; 
    99     //  } 
    100     //   
    10160        bool PointIn(Ogre::Vector3 & point); 
    10261 
    103         Ogre::Real *pointeru[4]; //coordentate u for obscurancemap 
    104         Ogre::Real *pointerv[4]; //coordentate v for obscurancemap 
    105         Ogre::Vector2 *uv;      //Vector3 coordenates for the original texture 
     62        Ogre::Real *pointeru[4];  
     63 
     64        Ogre::Real *pointerv[4];  
     65 
     66        Ogre::Vector2 *uv; 
    10667 
    10768  private: 
    108     BBox * bound; 
     69    BBox bound; 
    10970 
    110     Box2d * bspnodebound; 
     71    Box2d bspnodebound; 
    11172 
    11273    static unsigned int ID_CLUSTER; 
     
    11778 
    11879        std::vector<Ogre::Vector3> Vector3s_vector; 
     80 
    11981        Ogre::Vector3 *Vector3s; 
     82 
    12083        Ogre::Vector3 *Vector3s_triangle_text; 
    12184 
     
    13093    Plane3 plane; 
    13194 
    132     // Gametools -- Isma 17/08/2005 
    133     //Listid patchlistid; 
    134     //Listid trianglelistid; 
    135         int CalcPatch(Ogre::Vector3 & point); 
    136  
    137  
    13895  public: 
    139     ~Cluster(); 
     96    virtual ~Cluster(); 
    14097 
    14198}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster2d.h

    r700 r721  
    22#define _IMGCLUSTER2D_H 
    33 
    4 #include "IMGCluster.h" 
     4#include <IMGPrerequisites.h> 
    55 
    66namespace IMG { 
    77 
     8class Cluster; 
     9 
    810class Cluster2d { 
    911  public: 
    10     inline Cluster2d() { 
    11                 Vector3s = NULL; 
    12                 cluster =NULL; 
    13                 normal = NULL; 
    14         }; 
     12    Cluster2d(); 
     13 
     14        virtual ~Cluster2d(); 
    1515 
    1616    //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal. 
     
    2121    void Print(); 
    2222 
    23         inline Ogre::Vector2 * GetVector3s() { return Vector3s; } 
     23        Ogre::Vector2 * GetVector3s(); 
    2424 
    25         inline std::vector<Ogre::Vector2> * GetVector3sVector() { return &Vector3s2_vector; }  
     25        std::vector<Ogre::Vector2> * GetVector3sVector(); 
    2626 
    27         inline Ogre::Vector3 * GetNormal() { return normal; } 
     27        Ogre::Vector3 * GetNormal(); 
    2828 
     29  protected: 
    2930 
    30   private: 
    3131    unsigned int id; 
    3232 
     
    3434 
    3535        Ogre::Vector2 *Vector3s; 
     36 
    3637        std::vector<Ogre::Vector2> Vector3s2_vector; 
    3738 
    3839        Ogre::Vector3 *normal; 
    39  
    40   public: 
    41     ~Cluster2d(); 
    4240 
    4341}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h

    r709 r721  
    77namespace IMG { 
    88 
    9 //* 
    10 //      ClusterList 
    11 //* 
    12 class ClusterList { 
     9class ClusterList  
     10{ 
    1311  public: 
    14     inline ClusterList() { 
    15         list.reserve(100); 
    16       }; 
     12    ClusterList(); 
    1713 
    18     //std::vector<Polygon*> * GetList() { return &list;}        //return the pointer to the list of voxels 
    19     inline std::vector<Cluster> * GetList() { return &list;}; 
     14    virtual ~ClusterList(); 
     15     
     16    std::vector<Cluster> * GetList(); 
    2017 
    2118    //return the pointer to the list of voxels 
    22     inline unsigned int GetSize() const { return list.size(); } 
     19    unsigned int GetSize() const; 
    2320 
    2421    //return the number of elements of list 
    25     inline Cluster * Get(unsigned int i) { 
    26         if (i <= list.size()) return &list[i]; 
    27         //if (i <= list.size()) return list[i]; 
    28         return NULL; 
    29       }; 
     22    Cluster * Get(unsigned int i); 
    3023 
    3124    bool Insert(Cluster * p); 
     
    3427 
    3528 
    36   private: 
     29  protected: 
     30 
    3731    std::vector<Cluster> list; 
    38  
    39   public: 
    40     ~ClusterList(); 
    4132 
    4233}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h

    r700 r721  
    77namespace IMG { 
    88 
    9 class NodeBsp { 
     9// Fordward declaration... 
     10class NodeBsp; 
     11 
     12typedef ::boost::intrusive_ptr<NodeBsp> NodeBspPtr; 
     13 
     14namespace boost 
     15{ 
     16    void intrusive_ptr_add_ref(NodeBsp * p); 
     17    void intrusive_ptr_release(NodeBsp * p); 
     18}; 
     19 
     20class NodeBsp  
     21{ 
    1022  public: 
    1123    NodeBsp(); 
    1224 
    13     Box2d * GetBound(); 
     25    virtual ~NodeBsp(); 
    1426 
    15     inline void SetBound(Box2d * box) { bound = box; }; 
     27    Box2d* GetBound(); 
    1628 
    17     inline NodeBsp * GetChild(int i) { return child[i]; }; 
     29    void SetBound(Box2d *box); 
    1830 
    19     inline void SetId(int id_) { id = id_; }; 
     31    NodeBspPtr GetChild(int i); 
    2032 
    21     inline unsigned int GetId() const { return id; }; 
     33    void SetId(int id_); 
    2234 
    23     inline void SetChild(NodeBsp * node, int i) { child[i] = node; }; 
     35    unsigned int GetId() const; 
     36 
     37    void SetChild(NodeBspPtr node, int i); 
    2438 
    2539    void Print(); 
    2640 
    27     //void SetPlane (Plane3 *pla) { plane = pla; } 
    28     //Plane3 * GetPlane () { return plane; } 
    29     NodeBsp * Insert(int w, int h); 
     41    NodeBspPtr Insert(int w, int h); 
    3042 
    31     inline NodeBsp * Get(NodeBsp * node, int i) { 
    32                 if (!node) return NULL; 
    33                 if (node->GetId() == i ) return node; 
    34                  
    35                 NodeBsp *nod;  
    36                 if (nod = node->GetChild(0)->Get (node->GetChild(0), i)) return nod; 
    37                  
    38                 return node->GetChild(0)->Get (node->GetChild(1), i); 
    39                  
    40         }; 
     43    NodeBspPtr Get(NodeBspPtr node, int i); 
    4144 
     45  protected: 
    4246 
    43   private: 
    4447    bool fit; 
    4548 
    46     Box2d * bound; 
     49    Box2d bound; 
    4750 
    48     NodeBsp * child[2]; 
     51    NodeBspPtr child[2]; 
    4952 
    5053    static unsigned int ID; 
     
    5255    int id; 
    5356 
     57private: 
     58     
     59        long references; 
    5460 
    55   public: 
    56     ~NodeBsp(); 
     61    friend void boost::intrusive_ptr_add_ref(NodeBsp * p); 
    5762 
     63    friend void boost::intrusive_ptr_release(NodeBsp * p); 
    5864}; 
     65 
     66// class specific addref/release implementation 
     67// the two function overloads must be in the boost namespace on most compilers: 
     68namespace boost 
     69{ 
     70  inline void intrusive_ptr_add_ref(NodeBsp * p) 
     71  { 
     72    // increment reference count of object *p 
     73    ++(p->references); 
     74  } 
     75 
     76 
     77 
     78  inline void intrusive_ptr_release(NodeBsp * p) 
     79  { 
     80   // decrement reference count, and delete object when reference count reaches 0 
     81   if (--(p->references) == 0) 
     82     delete p; 
     83  }  
     84} // namespace boost 
    5985 
    6086} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPlane3.h

    r700 r721  
    22#define _IMGPLANE3_H 
    33 
    4 #include "IMGPrerequisites.h" 
     4#include <IMGPrerequisites.h> 
    55 
    66namespace IMG { 
     
    99  public: 
    1010    //a plane's interface 
    11     //Plane(); 
    12     //~Plane(); 
    13     inline Plane3 & operator =(const Plane3 & p) { 
    14                 normal.x = p.normal.x; 
    15                 normal.y = p.normal.y; 
    16                 normal.z = p.normal.z; 
    17                 d = p.d;                 
    18                 return *this; 
    19         }; 
     11    Plane3(); 
    2012 
    21         inline Ogre::Vector3 * GetNormal() { 
    22                 Ogre::Vector3 *v = new Ogre::Vector3; 
    23                 v->x = normal.x; 
    24                 v->y = normal.y; 
    25                 v->z = normal.z; 
    26                 return v; 
    27         }; 
     13    virtual ~Plane3(); 
    2814 
    29     inline void SetNormal(float x, float y, float z) { 
    30                 normal.x = x; 
    31                 normal.y = y; 
    32                 normal.z = z;            
    33         }; 
     15    Plane3 & operator =(const Plane3 & p); 
    3416 
    35     inline void SetDistance(float dist) { 
    36                 d = dist; 
    37         }; 
     17        Ogre::Vector3 * GetNormal(); 
    3818 
    39     inline float GetDistance() const { return d;}; 
     19    void SetNormal(float x, float y, float z); 
    4020 
    41     inline void Print() { 
    42                 printf("\nPrintant pla: (%.4f, %.4f, %.4f, %.4f)", normal.x, normal.y, normal.z, d); 
    43         }; 
     21    void SetDistance(float dist); 
    4422 
    45     ~Plane3(); 
     23    float GetDistance() const; 
     24 
     25    void Print(); 
    4626 
    4727}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPrerequisites.h

    r700 r721  
    99#include <OgreAxisAlignedBox.h>  
    1010 
     11#include <boost/smart_ptr.hpp> 
     12 
    1113#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h

    r700 r721  
    77#include <LBBCLeafKdTreeClusterData.h> 
    88#include <LBBCSampleConfigFile.h> 
     9#include <LBBCBillboardViewMode.h> 
     10#include <LBBCClusterViewMode.h> 
    911 
    1012#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h

    r700 r721  
    1 #ifndef _LBBCBILLBOARDKMEANSCLUSTERDATA_H 
    2 #define _LBBCBILLBOARDKMEANSCLUSTERDATA_H 
     1#ifndef _LBBCBILLBOARDKMeansCLUSTERDATA_H 
     2#define _LBBCBILLBOARDKMeansCLUSTERDATA_H 
    33 
    44#include <BBC.h> 
     5#include <LBBCLeafKMeansClusterData.h> 
     6#include <LBBCLeaf.h> 
    57 
    68namespace LBBC { 
     
    1012    BillboardKMeansClusterData(); 
    1113 
    12     ~BillboardKMeansClusterData(); 
     14    virtual ~BillboardKMeansClusterData(); 
     15 
     16        virtual void readBillboardClusterData(TiXmlNode *parentNode); 
     17 
     18        virtual void writeBillboardClusterData(TiXmlNode *parentNode); 
     19 
     20        virtual void generateBillboardBoundingQuad(); 
    1321 
    1422}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKdTreeClusterData.h

    r700 r721  
    1 #ifndef _LBBCBILLBOARDKDTREECLUSTERDATA_H 
    2 #define _LBBCBILLBOARDKDTREECLUSTERDATA_H 
     1#ifndef _LBBCBILLBOARDKdTreeCLUSTERDATA_H 
     2#define _LBBCBILLBOARDKdTreeCLUSTERDATA_H 
    33 
    44#include <BBC.h> 
    5 #include <LBBCLeafKdTreeClusterData.h> 
    6 #include <LBBCLeaf.h> 
    75 
    86namespace LBBC { 
     
    1210    BillboardKdTreeClusterData(); 
    1311 
    14     ~BillboardKdTreeClusterData(); 
    15  
    16         virtual void readBillboardClusterData(TiXmlNode *parentNode); 
    17  
    18         virtual void writeBillboardClusterData(TiXmlNode *parentNode); 
    19  
    20         virtual void generateBillboardBoundingQuad(); 
     12    virtual ~BillboardKdTreeClusterData(); 
    2113 
    2214}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterGenerator.h

    r700 r721  
    1 #ifndef _LBBCKMEANSCLUSTERGENERATOR_H 
    2 #define _LBBCKMEANSCLUSTERGENERATOR_H 
    3  
     1#ifndef _LBBCKMeansCLUSTERGENERATOR_H 
     2#define _LBBCKMeansCLUSTERGENERATOR_H 
    43 
    54#include <BBC.h> 
     5#include <LBBCLeafKMeansClusterData.h> 
     6#include <LBBCBillboardKMeansClusterData.h> 
     7#include <LBBCLeaf.h> 
     8#include <LBBCLeafDistribution.h> 
    69 
    710namespace LBBC { 
    811 
    9 class _BBCExport KMeansClusterGenerator : public BBC::BillboardCloudGenerator { 
     12class _BBCExport KMeansClusterGenerator: public BBC::BillboardCloudGenerator  
     13{ 
    1014  public: 
    1115    void generate(); 
     
    1317    void init(); 
    1418 
     19        void setAlpha(float value); 
     20 
     21        float getAlpha(); 
     22 
     23        void initializeBillboardCloud(); 
     24 
     25        BBC::BillboardPtr createBillboard(); 
     26 
     27        void initializeBillboardClusterData(BBC::BillboardPtr billboard); 
     28         
     29        void initializeRandomBillboard(BBC::BillboardPtr billboard); 
     30 
     31        void splitLeafDistribution(); 
     32 
     33        void assignLeafBillboard(Leaf *leaf, BBC::BillboardPtr billboard); 
     34 
     35        void recomputeBillboardCloud(); 
     36 
     37        void recomputeBillboard(BBC::BillboardPtr billboard); 
     38 
     39        void iterativeRecomputeBillboardCloud(); 
     40 
     41        unsigned int findBestBillboard(Leaf *leaf); 
     42 
     43        void generateBillboardCloudBounds(); 
     44 
     45        void setNumIterations(unsigned int value); 
     46 
     47        unsigned int getNumIterations(); 
     48 
    1549    KMeansClusterGenerator(); 
    1650 
    17     ~KMeansClusterGenerator(); 
     51    virtual ~KMeansClusterGenerator(); 
    1852 
    1953  protected: 
    2054 
    21         class Cell 
    22         { 
    23                 protected: 
    24                 Cell *right; 
    25                 Cell *left; 
    26                 Ogre::Vector4 min; 
    27                 Ogre::Vector4 max; 
    28                  
    29                 public: 
    30                 Cell() 
    31                 { 
    32                         right = NULL; 
    33                         left = NULL; 
    34                 } 
     55    float mAlpha; 
    3556 
    36                 void setLeftChild(Cell *lChild) 
    37                 { 
    38                         left = lChild; 
    39                 } 
     57        float mEpsilonYN; 
    4058 
    41                 void setRightChild(Cell *rChild) 
    42                 { 
    43                         right = rChild; 
    44                 } 
    45  
    46                 Cell* getRightChild() 
    47                 { 
    48                         return right; 
    49                 } 
    50                  
    51                 Cell* getLeftChild() 
    52                 { 
    53                         return left; 
    54                 } 
    55                  
    56                 Ogre::Vector4 getMin() 
    57                 { 
    58                         return min; 
    59                 } 
    60                  
    61                 Ogre::Vector4 getMax() 
    62                 { 
    63                         return max; 
    64                 }        
    65  
    66                 void setMax(Ogre::Vector4 vmax) 
    67                 { 
    68                         max = vmax; 
    69                 } 
    70  
    71                 void setMin(Ogre::Vector4 vmin) 
    72                 { 
    73                         min = vmin; 
    74                 } 
    75         }; 
    76  
     59        float mNumIterations; 
    7760}; 
    7861 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h

    r700 r721  
    1 #ifndef _LBBCKMEANSCLUSTERSERIALIZER_H 
    2 #define _LBBCKMEANSCLUSTERSERIALIZER_H 
     1#ifndef _LBBCKMeansCLUSTERSERIALIZER_H 
     2#define _LBBCKMeansCLUSTERSERIALIZER_H 
    33 
    44#include <BBC.h> 
     5#include <LBBCBillboardKMeansClusterData.h> 
     6 
     7#include <string> 
    58 
    69namespace LBBC { 
     
    1013    KMeansClusterSerializer(); 
    1114 
    12     ~KMeansClusterSerializer(); 
     15    virtual ~KMeansClusterSerializer(); 
    1316 
    14     void writeBillboardCloud(TiXmlDocument *document); 
     17        virtual void writeBillboardCloud(TiXmlDocument *document); 
    1518 
    1619}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterGenerator.h

    r700 r721  
    1 #ifndef _LBBCKDTREECLUSTERGENERATOR_H 
    2 #define _LBBCKDTREECLUSTERGENERATOR_H 
     1#ifndef _LBBCKdTreeCLUSTERGENERATOR_H 
     2#define _LBBCKdTreeCLUSTERGENERATOR_H 
     3 
    34 
    45#include <BBC.h> 
    5 #include <LBBCLeafKdTreeClusterData.h> 
    6 #include <LBBCBillboardKdTreeClusterData.h> 
    7 #include <LBBCLeaf.h> 
    8 #include <LBBCLeafDistribution.h> 
    96 
    107namespace LBBC { 
     
    1613    void init(); 
    1714 
    18         void setAlpha(float value); 
    19  
    20         float getAlpha(); 
    21  
    22         void initializeBillboardCloud(); 
    23  
    24         BBC::Billboard* createBillboard(); 
    25  
    26         void initializeBillboardClusterData(BBC::Billboard *billboard); 
    27          
    28         void initializeRandomBillboard(BBC::Billboard *billboard); 
    29  
    30         void splitLeafDistribution(); 
    31  
    32         void assignLeafBillboard(Leaf *leaf, BBC::Billboard *billboard); 
    33  
    34         void recomputeBillboardCloud(); 
    35  
    36         void recomputeBillboard(BBC::Billboard *billboard); 
    37  
    38         void iterativeRecomputeBillboardCloud(); 
    39  
    40         unsigned int findBestBillboard(Leaf *leaf); 
    41  
    42         void generateBillboardCloudBounds(); 
    43  
    44         void setNumIterations(unsigned int value); 
    45  
    46         unsigned int getNumIterations(); 
    47  
    4815    KdTreeClusterGenerator(); 
    4916 
    50     ~KdTreeClusterGenerator(); 
     17    virtual ~KdTreeClusterGenerator(); 
    5118 
    5219  protected: 
    5320 
    54     float mAlpha; 
     21        class Cell 
     22        { 
     23                protected: 
     24                Cell *right; 
     25                Cell *left; 
     26                Ogre::Vector4 min; 
     27                Ogre::Vector4 max; 
     28                 
     29                public: 
     30                Cell() 
     31                { 
     32                        right = NULL; 
     33                        left = NULL; 
     34                } 
    5535 
    56         float mEpsilonYN; 
     36                void setLeftChild(Cell *lChild) 
     37                { 
     38                        left = lChild; 
     39                } 
    5740 
    58         float mNumIterations; 
     41                void setRightChild(Cell *rChild) 
     42                { 
     43                        right = rChild; 
     44                } 
     45 
     46                Cell* getRightChild() 
     47                { 
     48                        return right; 
     49                } 
     50                 
     51                Cell* getLeftChild() 
     52                { 
     53                        return left; 
     54                } 
     55                 
     56                Ogre::Vector4 getMin() 
     57                { 
     58                        return min; 
     59                } 
     60                 
     61                Ogre::Vector4 getMax() 
     62                { 
     63                        return max; 
     64                }        
     65 
     66                void setMax(Ogre::Vector4 vmax) 
     67                { 
     68                        max = vmax; 
     69                } 
     70 
     71                void setMin(Ogre::Vector4 vmin) 
     72                { 
     73                        min = vmin; 
     74                } 
     75        }; 
     76 
    5977}; 
    6078 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h

    r700 r721  
    1 #ifndef _LBBCKDTREECLUSTERSERIALIZER_H 
    2 #define _LBBCKDTREECLUSTERSERIALIZER_H 
     1#ifndef _LBBCKdTreeCLUSTERSERIALIZER_H 
     2#define _LBBCKdTreeCLUSTERSERIALIZER_H 
    33 
    44#include <BBC.h> 
    5 #include <LBBCBillboardKdTreeClusterData.h> 
    6  
    7 #include <string> 
    85 
    96namespace LBBC { 
     
    1310    KdTreeClusterSerializer(); 
    1411 
    15     ~KdTreeClusterSerializer(); 
     12    virtual ~KdTreeClusterSerializer(); 
    1613 
    17         virtual void writeBillboardCloud(TiXmlDocument *document); 
     14    void writeBillboardCloud(TiXmlDocument *document); 
    1815 
    1916}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaf.h

    r700 r721  
    8181    Leaf(); 
    8282 
    83     ~Leaf(); 
     83    virtual ~Leaf(); 
    8484 
    8585}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistribution.h

    r700 r721  
    1919    LeafDistribution(); 
    2020 
    21     ~LeafDistribution(); 
     21    virtual ~LeafDistribution(); 
    2222 
    2323        void setMinD(float value); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h

    r700 r721  
    1414    LeafDistributionGenerator(); 
    1515 
    16     ~LeafDistributionGenerator(); 
     16    virtual ~LeafDistributionGenerator(); 
    1717 
    1818        void generateAverageLeafNormal(Leaf *leaf); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionSerializer.h

    r700 r721  
    1313    LeafDistributionSerializer(); 
    1414 
    15     ~LeafDistributionSerializer(); 
     15    virtual ~LeafDistributionSerializer(); 
    1616 
    1717 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKMeansClusterData.h

    r700 r721  
    1 #ifndef _LBBCLEAFKMEANSCLUSTERDATA_H 
    2 #define _LBBCLEAFKMEANSCLUSTERDATA_H 
     1#ifndef _LBBCLEAFKMeansCLUSTERDATA_H 
     2#define _LBBCLEAFKMeansCLUSTERDATA_H 
    33 
    44#include <BBCEntityClusterData.h> 
     
    1010    LeafKMeansClusterData(); 
    1111 
    12     ~LeafKMeansClusterData(); 
     12    virtual ~LeafKMeansClusterData(); 
     13 
     14  protected: 
    1315 
    1416}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKdTreeClusterData.h

    r700 r721  
    1 #ifndef _LBBCLEAFKDTREECLUSTERDATA_H 
    2 #define _LBBCLEAFKDTREECLUSTERDATA_H 
     1#ifndef _LBBCLEAFKdTreeCLUSTERDATA_H 
     2#define _LBBCLEAFKdTreeCLUSTERDATA_H 
    33 
    44#include <BBCEntityClusterData.h> 
     
    1010    LeafKdTreeClusterData(); 
    1111 
    12     ~LeafKdTreeClusterData(); 
    13  
    14   protected: 
     12    virtual ~LeafKdTreeClusterData(); 
    1513 
    1614}; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaves.h

    r700 r721  
    1111    Leaves(); 
    1212 
    13     ~Leaves(); 
     13    virtual ~Leaves(); 
    1414 
    1515  protected: 
    1616    bool mMeshLoaded; 
    1717 
    18         Ogre::Mesh *mMesh; 
     18        BBC::EntityPtr mEntity; 
    1919 
    2020        BBC::BillboardCloud *mBillboardCloud; 
    2121 
    2222  public: 
    23         Ogre::Mesh* getMesh(); 
     23        BBC::EntityPtr getEntity(); 
    2424 
    25         void setMesh(Ogre::Mesh * value); 
     25        void setEntity(BBC::EntityPtr value); 
    2626 
    2727    void load(); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h

    r709 r721  
    22#define _LBBCMANAGER_H 
    33 
    4 #include <BBC.h> 
    54#include <LBBCPrerequisites.h> 
    65#include <LBBCLeaves.h> 
     
    2221    ~Manager(); 
    2322 
    24         void runSample(Ogre::String sampleConfigFile); 
     23        void runSampleConfigFile(); 
     24 
     25        void loadSampleConfigFile(Ogre::String sampleConfigFile); 
    2526 
    2627        SampleConfigFile* getSampleConfigFile(); 
     28 
     29        void setSampleConfigFile(SampleConfigFile *sampleConfigFile); 
    2730 
    2831        void generateEntityDistribution(); 
     
    7275        BBC::OgreMeshSerializer *mOgreMeshSerializer; 
    7376 
    74         SampleConfigFile mSampleCf; 
     77        SampleConfigFile *mSampleConfigFile; 
    7578 
    76         Ogre::ConfigFile mCf; 
     79        Ogre::ConfigFile *mConfigFile; 
     80 
    7781}; 
    7882 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h

    r709 r721  
    1010    SampleConfigFile(); 
    1111         
    12     ~SampleConfigFile(); 
     12    virtual ~SampleConfigFile(); 
    1313 
    1414        bool getEntityDistributionMerged(); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGenerator.vcproj

    r698 r721  
    2020                        <Tool 
    2121                                Name="VCCLCompilerTool" 
    22                                 AdditionalOptions="/D &quot;TIXML_USE_STL&quot;" 
     22                                AdditionalOptions="/D &quot;TIXML_USE_STL&quot; /D &quot;OBA_LIB_BUILD&quot;" 
    2323                                Optimization="0" 
    24                                 AdditionalIncludeDirectories="&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Samples/Common/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;../include/IMG;../include/BBC;../include/LBBC" 
     24                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Samples/Common/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;../include/IMG;../include/BBC;../include/LBBC;../include/OBA;D:\design_04_11_2005\svn\NonGTP\Boost" 
    2525                                PreprocessorDefinitions="WIN32;_DEBUG;_USRDLL;_MT" 
    2626                                MinimalRebuild="TRUE" 
     
    5353                                Name="VCMIDLTool"/> 
    5454                        <Tool 
    55                                 Name="VCPostBuildEventTool" 
    56                                 CommandLine="copy ..\bin\debug\LeavesBillboardCloudGenerator_d.dll ..\..\..\..\..\..\App\Tools\IBRTreesModuleTools\LeavesBillboardCloudMayaToolkit\bin\debug 
    57 copy ..\bin\debug\LeavesBillboardCloudGenerator_d.dll ..\..\..\..\..\..\App\Tools\IBRTreesModuleTools\LeavesBillboardCloudCommandLine\bin\debug 
    58 "/> 
     55                                Name="VCPostBuildEventTool"/> 
    5956                        <Tool 
    6057                                Name="VCPreBuildEventTool"/> 
     
    8279                        <Tool 
    8380                                Name="VCCLCompilerTool" 
    84                                 AdditionalOptions="/D &quot;TIXML_USE_STL&quot;" 
    85                                 AdditionalIncludeDirectories="&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;&quot;$(OGRE_PATH)/Samples/Common/include&quot;;../include/IMG;../include/BBC;../include/LBBC" 
     81                                AdditionalOptions="/D &quot;TIXML_USE_STL&quot; /D &quot;TIXML_USE_STL&quot; /D &quot;OBA_LIB_BUILD&quot;" 
     82                                AdditionalIncludeDirectories="&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;&quot;$(OGRE_PATH)/Samples/Common/include&quot;;../include/IMG;../include/BBC;../include/LBBC;../include/OBA;D:\design_04_11_2005\svn\NonGTP\Boost" 
    8683                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 
    8784                                RuntimeLibrary="2" 
     
    108105                                Name="VCMIDLTool"/> 
    109106                        <Tool 
    110                                 Name="VCPostBuildEventTool" 
    111                                 CommandLine="copy ..\bin\release\LeavesBillboardCloudGenerator.dll ..\..\..\..\..\..\App\Tools\IBRTreesModuleTools\LeavesBillboardCloudMayaToolkit\bin\release 
    112 copy ..\bin\release\LeavesBillboardCloudGenerator.dll ..\..\..\..\..\..\App\Tools\IBRTreesModuleTools\LeavesBillboardCloudCommandLine\bin\release 
    113 "/> 
     107                                Name="VCPostBuildEventTool"/> 
    114108                        <Tool 
    115109                                Name="VCPreBuildEventTool"/> 
     
    138132                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 
    139133                        <File 
    140                                 RelativePath="..\src\BBCBillboard.cpp"> 
    141                         </File> 
    142                         <File 
    143                                 RelativePath="..\src\BBCBillboardCloud.cpp"> 
    144                         </File> 
    145                         <File 
    146                                 RelativePath="..\src\BBCBillboardCloudGenerator.cpp"> 
    147                         </File> 
    148                         <File 
    149                                 RelativePath="..\src\BBCBillboardCloudSerializer.cpp"> 
    150                         </File> 
    151                         <File 
    152                                 RelativePath="..\src\BBCBillboardCloudTextureGenerator.cpp"> 
    153                         </File> 
    154                         <File 
    155                                 RelativePath="..\src\BBCBillboardCloudUVMapper.cpp"> 
    156                         </File> 
    157                         <File 
    158                                 RelativePath="..\src\BBCBillboardClusterData.cpp"> 
    159                         </File> 
    160                         <File 
    161                                 RelativePath="..\src\BBCBillboardGroup.cpp"> 
    162                         </File> 
    163                         <File 
    164                                 RelativePath="..\src\BBCEntity.cpp"> 
    165                         </File> 
    166                         <File 
    167                                 RelativePath="..\src\BBCEntityCluster.cpp"> 
    168                         </File> 
    169                         <File 
    170                                 RelativePath="..\src\BBCEntityClusterData.cpp"> 
    171                         </File> 
    172                         <File 
    173                                 RelativePath="..\src\BBCEntityDistribution.cpp"> 
    174                         </File> 
    175                         <File 
    176                                 RelativePath="..\src\BBCEntityDistributionGenerator.cpp"> 
    177                         </File> 
    178                         <File 
    179                                 RelativePath="..\src\BBCEntityDistributionSerializer.cpp"> 
    180                         </File> 
    181                         <File 
    182                                 RelativePath="..\src\BBCManager.cpp"> 
    183                         </File> 
    184                         <File 
    185                                 RelativePath="..\src\BBCOgreMeshSerializer.cpp"> 
    186                         </File> 
    187                         <File 
    188                                 RelativePath="..\src\BBCSubEntity.cpp"> 
    189                         </File> 
    190                         <File 
    191                                 RelativePath="..\src\BBCTimer.cpp"> 
    192                         </File> 
    193                         <File 
    194                                 RelativePath="..\src\BBCXmlSerializer.cpp"> 
    195                         </File> 
    196                         <File 
    197                                 RelativePath="..\src\IMGBBox.cpp"> 
    198                         </File> 
    199                         <File 
    200                                 RelativePath="..\src\IMGBox2d.cpp"> 
    201                         </File> 
    202                         <File 
    203                                 RelativePath="..\src\IMGBsp.cpp"> 
    204                         </File> 
    205                         <File 
    206                                 RelativePath="..\src\IMGCluster.cpp"> 
    207                         </File> 
    208                         <File 
    209                                 RelativePath="..\src\IMGCluster2d.cpp"> 
    210                         </File> 
    211                         <File 
    212                                 RelativePath="..\src\IMGClusterList.cpp"> 
    213                         </File> 
    214                         <File 
    215                                 RelativePath="..\src\IMGNodeBsp.cpp"> 
    216                         </File> 
    217                         <File 
    218                                 RelativePath="..\src\IMGPlane3.cpp"> 
    219                         </File> 
    220                         <File 
    221                                 RelativePath="..\src\IMGVoxel.cpp"> 
    222                         </File> 
    223                         <File 
    224                                 RelativePath="..\src\IMGVoxelList.cpp"> 
    225                         </File> 
    226                         <File 
    227                                 RelativePath="..\src\LBBCBillboardKdTreeClusterData.cpp"> 
    228                         </File> 
    229                         <File 
    230                                 RelativePath="..\src\LBBCBillboardKMeansClusterData.cpp"> 
    231                         </File> 
    232                         <File 
    233                                 RelativePath="..\src\LBBCKdTreeClusterGenerator.cpp"> 
    234                         </File> 
    235                         <File 
    236                                 RelativePath="..\src\LBBCKdTreeClusterSerializer.cpp"> 
    237                         </File> 
    238                         <File 
    239                                 RelativePath="..\src\LBBCKMeansClusterGenerator.cpp"> 
    240                         </File> 
    241                         <File 
    242                                 RelativePath="..\src\LBBCKMeansClusterSerializer.cpp"> 
    243                         </File> 
    244                         <File 
    245                                 RelativePath="..\src\LBBCLeaf.cpp"> 
    246                         </File> 
    247                         <File 
    248                                 RelativePath="..\src\LBBCLeafDistribution.cpp"> 
    249                         </File> 
    250                         <File 
    251                                 RelativePath="..\src\LBBCLeafDistributionGenerator.cpp"> 
    252                         </File> 
    253                         <File 
    254                                 RelativePath="..\src\LBBCLeafDistributionSerializer.cpp"> 
    255                         </File> 
    256                         <File 
    257                                 RelativePath="..\src\LBBCLeafKdTreeClusterData.cpp"> 
    258                         </File> 
    259                         <File 
    260                                 RelativePath="..\src\LBBCLeafKMeansClusterData.cpp"> 
    261                         </File> 
    262                         <File 
    263                                 RelativePath="..\src\LBBCLeaves.cpp"> 
    264                         </File> 
    265                         <File 
    266                                 RelativePath="..\src\LBBCManager.cpp"> 
    267                         </File> 
    268                         <File 
    269                                 RelativePath="..\src\LBBCSampleConfigFile.cpp"> 
    270                         </File> 
    271                         <File 
    272134                                RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\src\OgreXMLMeshSerializer.cpp"> 
    273135                        </File> 
     
    284146                                RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\src\tinyxmlparser.cpp"> 
    285147                        </File> 
     148                        <Filter 
     149                                Name="BBC" 
     150                                Filter=""> 
     151                                <File 
     152                                        RelativePath="..\src\BBCBillboard.cpp"> 
     153                                </File> 
     154                                <File 
     155                                        RelativePath="..\src\BBCBillboardCloud.cpp"> 
     156                                </File> 
     157                                <File 
     158                                        RelativePath="..\src\BBCBillboardCloudGenerator.cpp"> 
     159                                </File> 
     160                                <File 
     161                                        RelativePath="..\src\BBCBillboardCloudSerializer.cpp"> 
     162                                </File> 
     163                                <File 
     164                                        RelativePath="..\src\BBCBillboardCloudTextureGenerator.cpp"> 
     165                                </File> 
     166                                <File 
     167                                        RelativePath="..\src\BBCBillboardCloudUVMapper.cpp"> 
     168                                </File> 
     169                                <File 
     170                                        RelativePath="..\src\BBCBillboardClusterData.cpp"> 
     171                                </File> 
     172                                <File 
     173                                        RelativePath="..\src\BBCBillboardGroup.cpp"> 
     174                                </File> 
     175                                <File 
     176                                        RelativePath="..\src\BBCEntity.cpp"> 
     177                                </File> 
     178                                <File 
     179                                        RelativePath="..\src\BBCEntityCluster.cpp"> 
     180                                </File> 
     181                                <File 
     182                                        RelativePath="..\src\BBCEntityClusterData.cpp"> 
     183                                </File> 
     184                                <File 
     185                                        RelativePath="..\src\BBCEntityDistribution.cpp"> 
     186                                </File> 
     187                                <File 
     188                                        RelativePath="..\src\BBCEntityDistributionGenerator.cpp"> 
     189                                </File> 
     190                                <File 
     191                                        RelativePath="..\src\BBCEntityDistributionSerializer.cpp"> 
     192                                </File> 
     193                                <File 
     194                                        RelativePath="..\src\BBCManager.cpp"> 
     195                                </File> 
     196                                <File 
     197                                        RelativePath="..\src\BBCMesh.cpp"> 
     198                                </File> 
     199                                <File 
     200                                        RelativePath="..\src\BBCOgreMeshSerializer.cpp"> 
     201                                </File> 
     202                                <File 
     203                                        RelativePath="..\src\BBCSubEntity.cpp"> 
     204                                </File> 
     205                                <File 
     206                                        RelativePath="..\src\BBCTimer.cpp"> 
     207                                </File> 
     208                                <File 
     209                                        RelativePath="..\src\BBCXmlSerializer.cpp"> 
     210                                </File> 
     211                        </Filter> 
     212                        <Filter 
     213                                Name="LBBC" 
     214                                Filter=""> 
     215                                <File 
     216                                        RelativePath="..\src\LBBCBillboardKdTreeClusterData.cpp"> 
     217                                </File> 
     218                                <File 
     219                                        RelativePath="..\src\LBBCBillboardKMeansClusterData.cpp"> 
     220                                </File> 
     221                                <File 
     222                                        RelativePath="..\src\LBBCBillboardViewMode.cpp"> 
     223                                </File> 
     224                                <File 
     225                                        RelativePath="..\src\LBBCKdTreeClusterGenerator.cpp"> 
     226                                </File> 
     227                                <File 
     228                                        RelativePath="..\src\LBBCKdTreeClusterSerializer.cpp"> 
     229                                </File> 
     230                                <File 
     231                                        RelativePath="..\src\LBBCKMeansClusterGenerator.cpp"> 
     232                                </File> 
     233                                <File 
     234                                        RelativePath="..\src\LBBCKMeansClusterSerializer.cpp"> 
     235                                </File> 
     236                                <File 
     237                                        RelativePath="..\src\LBBCLeaf.cpp"> 
     238                                </File> 
     239                                <File 
     240                                        RelativePath="..\src\LBBCLeafDistribution.cpp"> 
     241                                </File> 
     242                                <File 
     243                                        RelativePath="..\src\LBBCLeafDistributionGenerator.cpp"> 
     244                                </File> 
     245                                <File 
     246                                        RelativePath="..\src\LBBCLeafDistributionSerializer.cpp"> 
     247                                </File> 
     248                                <File 
     249                                        RelativePath="..\src\LBBCLeafKdTreeClusterData.cpp"> 
     250                                </File> 
     251                                <File 
     252                                        RelativePath="..\src\LBBCLeafKMeansClusterData.cpp"> 
     253                                </File> 
     254                                <File 
     255                                        RelativePath="..\src\LBBCLeaves.cpp"> 
     256                                </File> 
     257                                <File 
     258                                        RelativePath="..\src\LBBCManager.cpp"> 
     259                                </File> 
     260                                <File 
     261                                        RelativePath="..\src\LBBCSampleConfigFile.cpp"> 
     262                                </File> 
     263                        </Filter> 
     264                        <Filter 
     265                                Name="IMG" 
     266                                Filter=""> 
     267                                <File 
     268                                        RelativePath="..\src\IMGBBox.cpp"> 
     269                                </File> 
     270                                <File 
     271                                        RelativePath="..\src\IMGBox2d.cpp"> 
     272                                </File> 
     273                                <File 
     274                                        RelativePath="..\src\IMGBsp.cpp"> 
     275                                </File> 
     276                                <File 
     277                                        RelativePath="..\src\IMGCluster.cpp"> 
     278                                </File> 
     279                                <File 
     280                                        RelativePath="..\src\IMGCluster2d.cpp"> 
     281                                </File> 
     282                                <File 
     283                                        RelativePath="..\src\IMGClusterList.cpp"> 
     284                                </File> 
     285                                <File 
     286                                        RelativePath="..\src\IMGNodeBsp.cpp"> 
     287                                </File> 
     288                                <File 
     289                                        RelativePath="..\src\IMGPlane3.cpp"> 
     290                                </File> 
     291                        </Filter> 
     292                        <Filter 
     293                                Name="OBA"> 
     294                                <File 
     295                                        RelativePath="..\src\OBAOgreApplication.cpp"> 
     296                                </File> 
     297                                <File 
     298                                        RelativePath="..\src\OBAOgreBase.cpp"> 
     299                                </File> 
     300                                <File 
     301                                        RelativePath="..\src\OBAOgreFrameListener.cpp"> 
     302                                </File> 
     303                                <File 
     304                                        RelativePath="..\src\OBAOgreFrameListenerMode.cpp"> 
     305                                </File> 
     306                        </Filter> 
    286307                </Filter> 
    287308                <Filter 
     
    290311                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
    291312                        <File 
    292                                 RelativePath="..\include\Bbc\BBC.h"> 
    293                         </File> 
    294                         <File 
    295                                 RelativePath="..\include\Bbc\BBCBillboard.h"> 
    296                         </File> 
    297                         <File 
    298                                 RelativePath="..\include\Bbc\BBCBillboardCloud.h"> 
    299                         </File> 
    300                         <File 
    301                                 RelativePath="..\include\Bbc\BBCBillboardCloudGenerator.h"> 
    302                         </File> 
    303                         <File 
    304                                 RelativePath="..\include\Bbc\BBCBillboardCloudSerializer.h"> 
    305                         </File> 
    306                         <File 
    307                                 RelativePath="..\include\Bbc\BBCBillboardCloudTextureGenerator.h"> 
    308                         </File> 
    309                         <File 
    310                                 RelativePath="..\include\Bbc\BBCBillboardCloudUVMapper.h"> 
    311                         </File> 
    312                         <File 
    313                                 RelativePath="..\include\Bbc\BBCBillboardClusterData.h"> 
    314                         </File> 
    315                         <File 
    316                                 RelativePath="..\include\Bbc\BBCBillboardGroup.h"> 
    317                         </File> 
    318                         <File 
    319                                 RelativePath="..\include\Bbc\BBCEntity.h"> 
    320                         </File> 
    321                         <File 
    322                                 RelativePath="..\include\Bbc\BBCEntityCluster.h"> 
    323                         </File> 
    324                         <File 
    325                                 RelativePath="..\include\Bbc\BBCEntityClusterData.h"> 
    326                         </File> 
    327                         <File 
    328                                 RelativePath="..\include\Bbc\BBCEntityDistribution.h"> 
    329                         </File> 
    330                         <File 
    331                                 RelativePath="..\include\Bbc\BBCEntityDistributionGenerator.h"> 
    332                         </File> 
    333                         <File 
    334                                 RelativePath="..\include\Bbc\BBCEntityDistributionSerializer.h"> 
    335                         </File> 
    336                         <File 
    337                                 RelativePath="..\include\Bbc\BBCManager.h"> 
    338                         </File> 
    339                         <File 
    340                                 RelativePath="..\include\Bbc\BBCOgreMeshSerializer.h"> 
    341                         </File> 
    342                         <File 
    343                                 RelativePath="..\include\Bbc\BBCPrerequisites.h"> 
    344                         </File> 
    345                         <File 
    346                                 RelativePath="..\include\Bbc\BBCSingleton.h"> 
    347                         </File> 
    348                         <File 
    349                                 RelativePath="..\include\Bbc\BBCSubEntity.h"> 
    350                         </File> 
    351                         <File 
    352                                 RelativePath="..\include\Bbc\BBCTimer.h"> 
    353                         </File> 
    354                         <File 
    355                                 RelativePath="..\include\Bbc\BBCUtil.h"> 
    356                         </File> 
    357                         <File 
    358                                 RelativePath="..\include\Bbc\BBCXmlSerializer.h"> 
    359                         </File> 
    360                         <File 
    361                                 RelativePath="..\include\Img\IMG.h"> 
    362                         </File> 
    363                         <File 
    364                                 RelativePath="..\include\Img\IMGBBox.h"> 
    365                         </File> 
    366                         <File 
    367                                 RelativePath="..\include\Img\IMGBox2d.h"> 
    368                         </File> 
    369                         <File 
    370                                 RelativePath="..\include\Img\IMGBsp.h"> 
    371                         </File> 
    372                         <File 
    373                                 RelativePath="..\include\Img\IMGCluster.h"> 
    374                         </File> 
    375                         <File 
    376                                 RelativePath="..\include\Img\IMGCluster2d.h"> 
    377                         </File> 
    378                         <File 
    379                                 RelativePath="..\include\Img\IMGClusterList.h"> 
    380                         </File> 
    381                         <File 
    382                                 RelativePath="..\include\Img\IMGNodeBsp.h"> 
    383                         </File> 
    384                         <File 
    385                                 RelativePath="..\include\Img\IMGPlane3.h"> 
    386                         </File> 
    387                         <File 
    388                                 RelativePath="..\include\Img\IMGPrerequisites.h"> 
    389                         </File> 
    390                         <File 
    391                                 RelativePath="..\include\Img\IMGVoxel.h"> 
    392                         </File> 
    393                         <File 
    394                                 RelativePath="..\include\Img\IMGVoxelList.h"> 
    395                         </File> 
    396                         <File 
    397                                 RelativePath="..\include\Lbbc\LBBC.h"> 
    398                         </File> 
    399                         <File 
    400                                 RelativePath="..\include\Lbbc\LBBCBillboardKdTreeClusterData.h"> 
    401                         </File> 
    402                         <File 
    403                                 RelativePath="..\include\Lbbc\LBBCBillboardKMeansClusterData.h"> 
    404                         </File> 
    405                         <File 
    406                                 RelativePath="..\include\Lbbc\LBBCKdTreeClusterGenerator.h"> 
    407                         </File> 
    408                         <File 
    409                                 RelativePath="..\include\Lbbc\LBBCKdTreeClusterSerializer.h"> 
    410                         </File> 
    411                         <File 
    412                                 RelativePath="..\include\Lbbc\LBBCKMeansClusterGenerator.h"> 
    413                         </File> 
    414                         <File 
    415                                 RelativePath="..\include\Lbbc\LBBCKMeansClusterSerializer.h"> 
    416                         </File> 
    417                         <File 
    418                                 RelativePath="..\include\Lbbc\LBBCLeaf.h"> 
    419                         </File> 
    420                         <File 
    421                                 RelativePath="..\include\Lbbc\LBBCLeafDistribution.h"> 
    422                         </File> 
    423                         <File 
    424                                 RelativePath="..\include\Lbbc\LBBCLeafDistributionGenerator.h"> 
    425                         </File> 
    426                         <File 
    427                                 RelativePath="..\include\Lbbc\LBBCLeafDistributionSerializer.h"> 
    428                         </File> 
    429                         <File 
    430                                 RelativePath="..\include\Lbbc\LBBCLeafKdTreeClusterData.h"> 
    431                         </File> 
    432                         <File 
    433                                 RelativePath="..\include\Lbbc\LBBCLeafKMeansClusterData.h"> 
    434                         </File> 
    435                         <File 
    436                                 RelativePath="..\include\Lbbc\LBBCLeaves.h"> 
    437                         </File> 
    438                         <File 
    439                                 RelativePath="..\include\Lbbc\LBBCManager.h"> 
    440                         </File> 
    441                         <File 
    442                                 RelativePath="..\include\Lbbc\LBBCPrerequisites.h"> 
    443                         </File> 
    444                         <File 
    445                                 RelativePath="..\include\Lbbc\LBBCSampleConfigFile.h"> 
    446                         </File> 
    447                         <File 
    448313                                RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\include\OgreXMLMeshSerializer.h"> 
    449314                        </File> 
     
    457322                                RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\include\tinyxml.h"> 
    458323                        </File> 
     324                        <Filter 
     325                                Name="BBC" 
     326                                Filter=""> 
     327                                <File 
     328                                        RelativePath="..\include\Bbc\BBC.h"> 
     329                                </File> 
     330                                <File 
     331                                        RelativePath="..\include\Bbc\BBCBillboard.h"> 
     332                                </File> 
     333                                <File 
     334                                        RelativePath="..\include\Bbc\BBCBillboardCloud.h"> 
     335                                </File> 
     336                                <File 
     337                                        RelativePath="..\include\Bbc\BBCBillboardCloudGenerator.h"> 
     338                                </File> 
     339                                <File 
     340                                        RelativePath="..\include\Bbc\BBCBillboardCloudSerializer.h"> 
     341                                </File> 
     342                                <File 
     343                                        RelativePath="..\include\Bbc\BBCBillboardCloudTextureGenerator.h"> 
     344                                </File> 
     345                                <File 
     346                                        RelativePath="..\include\Bbc\BBCBillboardCloudUVMapper.h"> 
     347                                </File> 
     348                                <File 
     349                                        RelativePath="..\include\Bbc\BBCBillboardClusterData.h"> 
     350                                </File> 
     351                                <File 
     352                                        RelativePath="..\include\Bbc\BBCBillboardGroup.h"> 
     353                                </File> 
     354                                <File 
     355                                        RelativePath="..\include\Bbc\BBCEntity.h"> 
     356                                </File> 
     357                                <File 
     358                                        RelativePath="..\include\Bbc\BBCEntityCluster.h"> 
     359                                </File> 
     360                                <File 
     361                                        RelativePath="..\include\Bbc\BBCEntityClusterData.h"> 
     362                                </File> 
     363                                <File 
     364                                        RelativePath="..\include\Bbc\BBCEntityDistribution.h"> 
     365                                </File> 
     366                                <File 
     367                                        RelativePath="..\include\Bbc\BBCEntityDistributionGenerator.h"> 
     368                                </File> 
     369                                <File 
     370                                        RelativePath="..\include\Bbc\BBCEntityDistributionSerializer.h"> 
     371                                </File> 
     372                                <File 
     373                                        RelativePath="..\include\Bbc\BBCManager.h"> 
     374                                </File> 
     375                                <File 
     376                                        RelativePath="..\include\Bbc\BBCMesh.h"> 
     377                                </File> 
     378                                <File 
     379                                        RelativePath="..\include\Bbc\BBCOgreMeshSerializer.h"> 
     380                                </File> 
     381                                <File 
     382                                        RelativePath="..\include\Bbc\BBCPrerequisites.h"> 
     383                                </File> 
     384                                <File 
     385                                        RelativePath="..\include\Bbc\BBCSingleton.h"> 
     386                                </File> 
     387                                <File 
     388                                        RelativePath="..\include\Bbc\BBCSubEntity.h"> 
     389                                </File> 
     390                                <File 
     391                                        RelativePath="..\include\Bbc\BBCTimer.h"> 
     392                                </File> 
     393                                <File 
     394                                        RelativePath="..\include\Bbc\BBCUtil.h"> 
     395                                </File> 
     396                                <File 
     397                                        RelativePath="..\include\Bbc\BBCXmlSerializer.h"> 
     398                                </File> 
     399                        </Filter> 
     400                        <Filter 
     401                                Name="LBBC" 
     402                                Filter=""> 
     403                                <File 
     404                                        RelativePath="..\include\Lbbc\LBBC.h"> 
     405                                </File> 
     406                                <File 
     407                                        RelativePath="..\include\Lbbc\LBBCBillboardKdTreeClusterData.h"> 
     408                                </File> 
     409                                <File 
     410                                        RelativePath="..\include\Lbbc\LBBCBillboardKMeansClusterData.h"> 
     411                                </File> 
     412                                <File 
     413                                        RelativePath="..\include\Lbbc\LBBCBillboardViewMode.h"> 
     414                                </File> 
     415                                <File 
     416                                        RelativePath="..\include\Lbbc\LBBCClusterViewMode.h"> 
     417                                </File> 
     418                                <File 
     419                                        RelativePath="..\include\Lbbc\LBBCKdTreeClusterGenerator.h"> 
     420                                </File> 
     421                                <File 
     422                                        RelativePath="..\include\Lbbc\LBBCKdTreeClusterSerializer.h"> 
     423                                </File> 
     424                                <File 
     425                                        RelativePath="..\include\Lbbc\LBBCKMeansClusterGenerator.h"> 
     426                                </File> 
     427                                <File 
     428                                        RelativePath="..\include\Lbbc\LBBCKMeansClusterSerializer.h"> 
     429                                </File> 
     430                                <File 
     431                                        RelativePath="..\include\Lbbc\LBBCLeaf.h"> 
     432                                </File> 
     433                                <File 
     434                                        RelativePath="..\include\Lbbc\LBBCLeafDistribution.h"> 
     435                                </File> 
     436                                <File 
     437                                        RelativePath="..\include\Lbbc\LBBCLeafDistributionGenerator.h"> 
     438                                </File> 
     439                                <File 
     440                                        RelativePath="..\include\Lbbc\LBBCLeafDistributionSerializer.h"> 
     441                                </File> 
     442                                <File 
     443                                        RelativePath="..\include\Lbbc\LBBCLeafKdTreeClusterData.h"> 
     444                                </File> 
     445                                <File 
     446                                        RelativePath="..\include\Lbbc\LBBCLeafKMeansClusterData.h"> 
     447                                </File> 
     448                                <File 
     449                                        RelativePath="..\include\Lbbc\LBBCLeaves.h"> 
     450                                </File> 
     451                                <File 
     452                                        RelativePath="..\include\Lbbc\LBBCManager.h"> 
     453                                </File> 
     454                                <File 
     455                                        RelativePath="..\include\Lbbc\LBBCPrerequisites.h"> 
     456                                </File> 
     457                                <File 
     458                                        RelativePath="..\include\Lbbc\LBBCSampleConfigFile.h"> 
     459                                </File> 
     460                        </Filter> 
     461                        <Filter 
     462                                Name="IMG" 
     463                                Filter=""> 
     464                                <File 
     465                                        RelativePath="..\include\Img\IMG.h"> 
     466                                </File> 
     467                                <File 
     468                                        RelativePath="..\include\Img\IMGBBox.h"> 
     469                                </File> 
     470                                <File 
     471                                        RelativePath="..\include\Img\IMGBox2d.h"> 
     472                                </File> 
     473                                <File 
     474                                        RelativePath="..\include\Img\IMGBsp.h"> 
     475                                </File> 
     476                                <File 
     477                                        RelativePath="..\include\Img\IMGCluster.h"> 
     478                                </File> 
     479                                <File 
     480                                        RelativePath="..\include\Img\IMGCluster2d.h"> 
     481                                </File> 
     482                                <File 
     483                                        RelativePath="..\include\Img\IMGClusterList.h"> 
     484                                </File> 
     485                                <File 
     486                                        RelativePath="..\include\Img\IMGNodeBsp.h"> 
     487                                </File> 
     488                                <File 
     489                                        RelativePath="..\include\Img\IMGPlane3.h"> 
     490                                </File> 
     491                                <File 
     492                                        RelativePath="..\include\Img\IMGPrerequisites.h"> 
     493                                </File> 
     494                        </Filter> 
     495                        <Filter 
     496                                Name="OBA" 
     497                                Filter=""> 
     498                                <File 
     499                                        RelativePath="..\include\Oba\OBA.h"> 
     500                                </File> 
     501                                <File 
     502                                        RelativePath="..\include\Oba\OBAOgreApplication.h"> 
     503                                </File> 
     504                                <File 
     505                                        RelativePath="..\include\Oba\OBAOgreBase.h"> 
     506                                </File> 
     507                                <File 
     508                                        RelativePath="..\include\Oba\OBAOgreFrameListener.h"> 
     509                                </File> 
     510                                <File 
     511                                        RelativePath="..\include\Oba\OBAOgreFrameListenerMode.h"> 
     512                                </File> 
     513                                <File 
     514                                        RelativePath="..\include\Oba\OBAPrerequisites.h"> 
     515                                </File> 
     516                                <File 
     517                                        RelativePath="..\include\Oba\OBASingleton.h"> 
     518                                </File> 
     519                        </Filter> 
    459520                </Filter> 
    460521                <Filter 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGeneratorCommandLine.vcproj

    r709 r721  
    2020                                Name="VCCLCompilerTool" 
    2121                                Optimization="0" 
    22                                 AdditionalIncludeDirectories="../include;../include/BBC;../include/IMG;../include/LBBC;&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;" 
     22                                AdditionalIncludeDirectories="../include;../include/BBC;../include/IMG;../include/OBA;../include/LBBC;&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;D:\design_04_11_2005\svn\NonGTP\Boost" 
    2323                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" 
    2424                                MinimalRebuild="TRUE" 
     
    3333                        <Tool 
    3434                                Name="VCLinkerTool" 
    35                                 AdditionalDependencies="odbc32.lib kernel32.lib odbccp32.lib IBRBillboardCloudTreeGenerator_d.lib OgreMain_d.lib" 
     35                                AdditionalDependencies="IBRBillboardCloudTreeGenerator_d.lib OgreMain_d.lib" 
    3636                                OutputFile="$(OutDir)/IBRBillboardCloudTreeGeneratorCmd_d.exe" 
    3737                                LinkIncremental="2" 
     
    7070                        <Tool 
    7171                                Name="VCCLCompilerTool" 
    72                                 AdditionalIncludeDirectories="../include;../include/BBC;../include/IMG;../include/LBBC;&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;" 
     72                                AdditionalIncludeDirectories="../include;../include/OBA;../include/BBC;../include/IMG;../include/LBBC;&quot;$(OGRE_PATH)/OgreMain/include&quot;;&quot;$(OGRE_PATH)/Tools/XMLConverter/include&quot;;D:\design_04_11_2005\svn\NonGTP\Boost" 
    7373                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 
    7474                                RuntimeLibrary="0" 
     
    8181                        <Tool 
    8282                                Name="VCLinkerTool" 
    83                                 AdditionalDependencies="odbc32.lib kernel32.lib odbccp32.lib IBRBillboardCloudTreeGenerator.lib OgreMain.lib" 
     83                                AdditionalDependencies="IBRBillboardCloudTreeGenerator.lib OgreMain.lib" 
    8484                                OutputFile="$(OutDir)/IBRBillboardCloudTreeGeneratorCmd.exe" 
    8585                                LinkIncremental="1" 
     
    120120                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 
    121121                        <File 
     122                                RelativePath="..\src\IBRBillboardCloudTreeApplication.cpp"> 
     123                        </File> 
     124                        <File 
     125                                RelativePath="..\src\IBRBillboardCloudTreeFrameListener.cpp"> 
     126                        </File> 
     127                        <File 
    122128                                RelativePath="..\src\main.cpp"> 
    123129                        </File> 
     
    127133                        Filter="h;hpp;hxx;hm;inl;inc;xsd" 
    128134                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
     135                        <File 
     136                                RelativePath="..\include\IBRBillboardCloudTreeApplication.h"> 
     137                        </File> 
     138                        <File 
     139                                RelativePath="..\include\IBRBillboardCloudTreeFrameListener.h"> 
     140                        </File> 
     141                        <Filter 
     142                                Name="OBA"> 
     143                                <File 
     144                                        RelativePath="..\include\Oba\OBA.h"> 
     145                                </File> 
     146                                <File 
     147                                        RelativePath="..\include\Oba\OBAOgreApplication.h"> 
     148                                </File> 
     149                                <File 
     150                                        RelativePath="..\include\Oba\OBAOgreBase.h"> 
     151                                </File> 
     152                                <File 
     153                                        RelativePath="..\include\Oba\OBAOgreFrameListener.h"> 
     154                                </File> 
     155                                <File 
     156                                        RelativePath="..\include\Oba\OBAOgreFrameListenerMode.h"> 
     157                                </File> 
     158                                <File 
     159                                        RelativePath="..\include\Oba\OBAPrerequisites.h"> 
     160                                </File> 
     161                                <File 
     162                                        RelativePath="..\include\Oba\OBASingleton.h"> 
     163                                </File> 
     164                        </Filter> 
    129165                </Filter> 
    130166                <Filter 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboard.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 Billboard::Billboard() { 
     6Billboard::Billboard(): references(0) // initialize references to 0   
     7{ 
     8 
    79} 
    810 
    9 Billboard::~Billboard() { 
     11Billboard::~Billboard()  
     12{ 
     13 
    1014} 
    1115 
     
    2024} 
    2125 
    22 void Billboard::setBillboardClusterData(BillboardClusterData *value) 
     26void Billboard::setBillboardClusterData(BillboardClusterDataPtr value) 
    2327{ 
    2428        mBillboardClusterData = value; 
    2529} 
    2630 
    27 BillboardClusterData* Billboard::getBillboardClusterData() 
     31BillboardClusterDataPtr Billboard::getBillboardClusterData() 
    2832{ 
    2933        return mBillboardClusterData; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloud.cpp

    r709 r721  
    66BillboardCloud::BillboardCloud()  
    77{ 
    8         mEntity = new Entity(); 
     8        //mEntity = new Entity(); 
     9        mEntity = 0; 
    910} 
    1011 
    1112BillboardCloud::~BillboardCloud()  
    1213{ 
    13         for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 
    14         { 
    15                 Billboard *billboard = getBillboard(iBillboard); 
    16                 delete billboard; 
    17         } 
    18  
    19         for (unsigned int iBillboardGroup = 0; iBillboardGroup < getNumBillboardGroups(); iBillboardGroup++) 
    20         { 
    21                 BillboardGroup *billboardGroup = getBillboardGroup(iBillboardGroup); 
    22                 delete billboardGroup; 
    23         } 
    24  
    25         delete mEntity; 
    26 } 
    27  
    28 std::vector<Billboard*>* BillboardCloud::getBillboardList()  
     14 
     15} 
     16 
     17std::vector<BillboardPtr>* BillboardCloud::getBillboardList()  
    2918{ 
    3019        return &mBillboardList; 
    3120} 
    3221 
    33 void BillboardCloud::setBillboardList(std::vector<Billboard*> &value)  
     22void BillboardCloud::setBillboardList(std::vector<BillboardPtr> &value)  
    3423{ 
    3524        mBillboardList = value; 
     
    4130} 
    4231 
    43 void BillboardCloud::addBillboard(Billboard *value)  
     32void BillboardCloud::addBillboard(BillboardPtr value)  
    4433{ 
    4534        value->setBillboardHandle((unsigned int)(mBillboardList.size()));        
     
    4938void BillboardCloud::removeBillboard(unsigned int value)  
    5039{ 
    51         Billboard *billboard = mBillboardList[value]; 
     40        BillboardPtr billboard = mBillboardList[value]; 
    5241        mBillboardList.erase(mBillboardList.begin() + value); 
    53         delete billboard; 
    54 } 
    55  
    56 Billboard* BillboardCloud::getBillboard(unsigned int value)  
     42} 
     43 
     44BillboardPtr BillboardCloud::getBillboard(unsigned int value)  
    5745{ 
    5846        return mBillboardList[value]; 
    5947} 
    6048 
    61 Entity* BillboardCloud::getEntity()  
     49EntityPtr BillboardCloud::getEntity()  
    6250{ 
    6351        return mEntity; 
    6452} 
    6553 
    66 void BillboardCloud::setEntity(Entity *value)  
     54void BillboardCloud::setEntity(EntityPtr value)  
    6755{ 
    6856        mEntity = value; 
     
    7159void BillboardCloud::generateBillboardCloud(bool mergeBillboards) 
    7260{ 
    73         if (mEntity != NULL) 
    74         { 
    75                 delete mEntity; 
    76                 mEntity = new Entity(); 
    77         } 
     61        mEntity = EntityPtr(new Entity()); 
    7862 
    7963        unsigned int numGeneratedBillboardClouds = 0; 
    8064        for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 
    8165        { 
    82                 Billboard *billboard = this->getBillboard(iBillboard);           
    83                 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     66                BillboardPtr billboard = this->getBillboard(iBillboard);                 
     67                EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    8468 
    8569                if (entityCluster->getNumEntitiesClusterData() > 0) 
    8670                {                
    87                         SubEntity *subEntity;                    
     71                        SubEntityPtr subEntity;                  
    8872                        if (mergeBillboards) 
    8973                        { 
     
    157141        while (getNumBillboardGroups() > 0) 
    158142        { 
    159                 BillboardGroup *billboardGroup = getBillboardGroup(getNumBillboardGroups()-1); 
     143                BillboardGroupPtr billboardGroup = getBillboardGroup(getNumBillboardGroups()-1); 
    160144                removeBillboardGroup(getNumBillboardGroups()-1); 
    161145        } 
     
    166150        for (iBillboardGroup = 0; iBillboardGroup < numberGroups; iBillboardGroup++) 
    167151        { 
    168                 BillboardGroup *billboardGroup = new BillboardGroup(); 
     152                BillboardGroupPtr billboardGroup = BillboardGroupPtr( new BillboardGroup() ); 
    169153                addBillboardGroup(billboardGroup); 
    170154        } 
    171155 
    172156        Ogre::LogManager::getSingleton().logMessage("New.Num.Billboard Groups:" + Ogre::StringConverter::toString(getNumBillboardGroups())); 
    173         std::cin.get(); 
    174         std::cin.get(); 
    175157 
    176158        unsigned int numGeneratedBillboardClouds = 0; 
    177159        for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 
    178160        { 
    179                 Billboard *billboard = this->getBillboard(iBillboard);           
    180                 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     161                BillboardPtr billboard = this->getBillboard(iBillboard);                 
     162                EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    181163 
    182164                if (entityCluster->getNumEntitiesClusterData() > 0) 
     
    197179        for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 
    198180        { 
    199                 Billboard *billboard = this->getBillboard(iBillboard);           
    200                 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     181                BillboardPtr billboard = this->getBillboard(iBillboard);                 
     182                EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    201183 
    202184                if (entityCluster->getNumEntitiesClusterData() > 0) 
     
    229211void BillboardCloud::generateBillboardCloudGroups() 
    230212{ 
    231         SubEntity *subEntityGroup; 
    232         SubEntity *subEntity; 
    233         Entity *entity = new Entity(); 
     213        SubEntityPtr subEntityGroup; 
     214        SubEntityPtr subEntity; 
     215        EntityPtr entity = EntityPtr(new Entity()); 
    234216        unsigned int numGeneratedBillboardClouds = 0; 
    235217 
     
    244226                subEntityGroup = entity->getSubEntity(iBillboardGroup); 
    245227 
    246                 BillboardGroup *billboardGroup = this->getBillboardGroup(iBillboardGroup); 
     228                BillboardGroupPtr billboardGroup = this->getBillboardGroup(iBillboardGroup); 
    247229 
    248230                Ogre::LogManager::getSingleton().logMessage("BBCG-Num.Billboards:" + Ogre::StringConverter::toString(billboardGroup->getNumBillboards())); 
    249                 std::cin.get(); 
    250                 std::cin.get(); 
    251231 
    252232                for (unsigned int iBillboard = 0; iBillboard < billboardGroup->getNumBillboards(); iBillboard++) 
    253233                { 
    254234                        unsigned int billboardHandle = billboardGroup->getBillboardHandle(iBillboard); 
    255                         Billboard *billboard = this->getBillboard(billboardHandle); 
    256                         EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     235                        BillboardPtr billboard = this->getBillboard(billboardHandle); 
     236                        EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    257237 
    258238                        if (entityCluster->getNumEntitiesClusterData() > 0) 
     
    318298        }        
    319299 
    320         delete mEntity; 
    321300        mEntity = entity; 
    322301        entity->setSubEntitiesDistinctVertexColours(); 
     
    328307} 
    329308 
    330 BillboardGroup* BillboardCloud::getBillboardGroup(unsigned int iBillboardGroup) 
     309BillboardGroupPtr BillboardCloud::getBillboardGroup(unsigned int iBillboardGroup) 
    331310{ 
    332311        return mBillboardGroupList[iBillboardGroup]; 
    333312} 
    334313 
    335 void BillboardCloud::addBillboardGroup(BillboardGroup *value)  
     314void BillboardCloud::addBillboardGroup(BillboardGroupPtr value)  
    336315{ 
    337316        mBillboardGroupList.push_back(value); 
     
    340319void BillboardCloud::removeBillboardGroup(unsigned int value)  
    341320{ 
    342         BillboardGroup *billboardGroup = mBillboardGroupList[value]; 
     321        BillboardGroupPtr billboardGroup = mBillboardGroupList[value]; 
    343322        mBillboardGroupList.erase(mBillboardGroupList.begin() + value); 
    344         delete billboardGroup; 
    345 } 
    346  
    347 } 
     323} 
     324 
     325} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudGenerator.cpp

    r699 r721  
    44 
    55namespace BBC { 
     6 
     7BillboardCloudGenerator::BillboardCloudGenerator() 
     8{ 
     9} 
     10 
     11BillboardCloudGenerator::~BillboardCloudGenerator() 
     12{ 
     13} 
    614 
    715void BillboardCloudGenerator::setBillboardCloud(BillboardCloud *value) 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudUVMapper.cpp

    r709 r721  
    1414BillboardCloudUVMapper::~BillboardCloudUVMapper() 
    1515{ 
    16         clear();  
     16        shutdown();  
    1717} 
    1818 
     
    2121} 
    2222 
    23 void BillboardCloudUVMapper::clear()  
    24 { 
    25         Ogre::LogManager::getSingleton().logMessage("Init.BSP:" + Ogre::StringConverter::toString(getNumBsp())); 
    26  
     23void BillboardCloudUVMapper::shutdown()  
     24{ 
    2725        while (getNumBsp() > 0) 
    2826        { 
     
    3028        } 
    3129 
    32         Ogre::LogManager::getSingleton().logMessage("Clear.BSP:" + Ogre::StringConverter::toString(getNumBsp())); 
    33  
    34         Ogre::LogManager::getSingleton().logMessage("Init.CL:" + Ogre::StringConverter::toString(getNumClusterLists())); 
    35  
    36         //while (getNumClusterLists() > 0) 
    37         //{ 
    38         //      removeBsp(getNumClusterLists()-1); 
    39         //} 
    40         mClusterLists.clear(); 
    41  
    42         Ogre::LogManager::getSingleton().logMessage("Clear.CL:" + Ogre::StringConverter::toString(getNumClusterLists())); 
     30        while (getNumClusterLists() > 0) 
     31        { 
     32                removeClusterList(getNumClusterLists()-1); 
     33        }        
    4334} 
    4435 
     
    8273void BillboardCloudUVMapper::removeClusterList(unsigned int iClusterList) 
    8374{ 
    84         //mClusterLists.erase(mClusterLists.begin() + iClusterList); 
     75        IMG::ClusterList *clusterList = mClusterLists[iClusterList]; 
     76        mClusterLists.erase(mClusterLists.begin() + iClusterList); 
     77        delete clusterList; 
    8578} 
    8679 
     
    142135                "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 
    143136 
    144         SubEntity *subEntity;                                                                                            
     137        SubEntityPtr subEntity;                                                                                          
    145138         
    146139        Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; 
     
    160153        { 
    161154                Ogre::LogManager::getSingleton().logMessage("DontMerge"); 
    162                 subEntity = subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup);                             
     155                subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup);                                 
    163156                 
    164157                // Face A 
     
    285278void BillboardCloudUVMapper::addTextureInBsp(unsigned int iBillboardGroup, unsigned int iBillboard) 
    286279{ 
    287         IMG::NodeBsp *nodeDest; 
     280        IMG::NodeBspPtr nodeDest; 
    288281        IMG::Cluster cluster; 
    289282        Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); 
     
    304297        for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
    305298        { 
    306                 Billboard *billboard = mBillboardCloud->getBillboard(iBillboard);                
    307                 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     299                BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard);              
     300                EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    308301 
    309302                if (entityCluster->getNumEntitiesClusterData() > 0) 
     
    313306                                if (!enabledTextureCoordSet) 
    314307                                { 
    315                                         SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(0);    
     308                                        SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(0);  
    316309                                        subEntity->addTextureCoordSet(2); 
    317310                                        subEntity->enableVertexColours(true); 
     
    323316                                if (groupedBillboards) 
    324317                                { 
    325                                         SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds);  
     318                                        SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds);        
    326319                                        subEntity->addTextureCoordSet(2); 
    327320                                        subEntity->enableVertexColours(true); 
     
    355348        unsigned int iBillboardGroup; 
    356349        for (iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) 
    357         { 
    358                  
    359                 IMG::NodeBsp *node = new IMG::NodeBsp; 
     350        {                
    360351                IMG::Bsp *bsp = new IMG::Bsp(); 
    361                 IMG::Box2d *box = new IMG::Box2d; 
    362352                IMG::ClusterList *clusterList = new IMG::ClusterList(); 
    363  
    364                 box->SetBoundBox(0, 0, mTextureAtlasWidth, mTextureAtlasHeight); 
    365                 node->SetBound(box); 
     353                IMG::NodeBspPtr node = IMG::NodeBspPtr(new IMG::NodeBsp); 
     354 
     355                node->GetBound()->SetBoundBox(0, 0, mTextureAtlasWidth, mTextureAtlasHeight); 
    366356                bsp->SetRoot(node);      
     357 
    367358                addBsp(bsp); 
    368359                addClusterList(clusterList); 
     
    375366                Ogre::LogManager::getSingleton().logMessage("id:" + Ogre::StringConverter::toString(mBillboardCloud->getBillboard(iBillboard)->getBillboardHandle())); 
    376367 
    377                 BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData();               
     368                BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData().get();                 
    378369                 
    379370                if (billboardClusterData != NULL) 
    380371                { 
    381372                        Ogre::LogManager::getSingleton().logMessage("billboardData"); 
    382                         EntityCluster *entityCluster = billboardClusterData->getEntityCluster(); 
     373                        EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 
    383374                        if (entityCluster->getNumEntitiesClusterData() > 0) 
    384375                        {                        
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardClusterData.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 BillboardClusterData::BillboardClusterData() { 
     6BillboardClusterData::BillboardClusterData(): references(0) // initialize references to 0  
     7{ 
    78} 
    89 
    9 BillboardClusterData::~BillboardClusterData() { 
     10BillboardClusterData::~BillboardClusterData()  
     11{ 
    1012} 
    1113 
     
    4547} 
    4648 
    47 void BillboardClusterData::setEntityCluster(EntityCluster *value)  
     49void BillboardClusterData::setEntityCluster(EntityClusterPtr value)  
    4850{ 
    4951  mEntityCluster = value; 
    5052} 
    5153 
    52 EntityCluster* BillboardClusterData::getEntityCluster()  
     54EntityClusterPtr BillboardClusterData::getEntityCluster()  
    5355{ 
    5456  return mEntityCluster; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardGroup.cpp

    r709 r721  
    33 
    44namespace BBC { 
     5 
     6BillboardGroup::BillboardGroup(): references(0) // initialize references to 0  
     7{ 
     8} 
     9 
     10BillboardGroup::~BillboardGroup() 
     11{ 
     12} 
    513 
    614unsigned int BillboardGroup::getBillboardHandle(unsigned int iBillboard)  
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntity.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 Entity::Entity()  
     6Entity::Entity(): references(0) // initialize references to 0  
    77{ 
    88        createSubEntity(); 
     
    1111Entity::~Entity()         
    1212{ 
    13         for (unsigned int iSubEntity = 0; iSubEntity < getNumSubEntities(); iSubEntity++) 
    14         { 
    15                 SubEntity *subEntity = getSubEntity(iSubEntity); 
    16                 delete subEntity; 
    17         } 
     13 
    1814} 
    1915 
    2016void Entity::createSubEntity() 
    2117{ 
    22         SubEntity *subEntity = new SubEntity(); 
    23         mSubEntityList.push_back(subEntity); 
    24 } 
    25  
    26 void Entity::addSubEntity(SubEntity *value) 
     18        SubEntityPtr subEntityPtr((SubEntity*)new SubEntity()); 
     19        mSubEntityList.push_back(subEntityPtr); 
     20} 
     21 
     22void Entity::addSubEntity(SubEntityPtr value) 
    2723{ 
    2824        mSubEntityList.push_back(value); 
    2925} 
    3026 
    31 SubEntity* Entity::getSubEntity(unsigned int index) 
     27SubEntityPtr Entity::getSubEntity(unsigned int index) 
    3228{ 
    3329        return mSubEntityList[index]; 
     
    3632void Entity::removeSubEntity(unsigned int index) 
    3733{ 
    38         SubEntity *subEntity = mSubEntityList[index]; 
    3934        mSubEntityList.erase(mSubEntityList.begin()+index); 
    40         delete subEntity; 
    4135} 
    4236 
     
    5751} 
    5852 
    59 Ogre::Mesh* Entity::getMesh()  
     53MeshPtr Entity::getMesh()  
    6054{ 
    6155        return mMesh; 
    6256} 
    6357 
    64 void Entity::setMesh(Ogre::Mesh *value)  
     58void Entity::setMesh(MeshPtr value)  
    6559{ 
    6660        mMesh = value; 
     
    9387void Entity::sincronizeNumSubEntities() 
    9488{ 
    95         if (this->getNumSubEntities() < mMesh->getNumSubMeshes()) 
    96         { 
    97                 while (this->getNumSubEntities() < mMesh->getNumSubMeshes()) 
     89        if (this->getNumSubEntities() < mMesh->get()->getNumSubMeshes()) 
     90        { 
     91                while (this->getNumSubEntities() < mMesh->get()->getNumSubMeshes()) 
    9892                { 
    9993                        this->createSubEntity(); 
     
    10195        } 
    10296 
    103         if (this->getNumSubEntities() > mMesh->getNumSubMeshes()) 
    104         { 
    105                 while (this->getNumSubEntities() > mMesh->getNumSubMeshes()) 
     97        if (this->getNumSubEntities() > mMesh->get()->getNumSubMeshes()) 
     98        { 
     99                while (this->getNumSubEntities() > mMesh->get()->getNumSubMeshes()) 
    106100                { 
    107101                        this->removeSubEntity(this->getNumSubEntities()-1); 
     
    117111        size_t next_offset = 0; 
    118112 
    119         unsigned int numSubMeshes = mMesh->getNumSubMeshes(); 
     113        unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 
    120114        sincronizeNumSubEntities(); 
    121115         
    122116        added_shared = false; 
    123         for (unsigned short i = 0; i < mMesh->getNumSubMeshes(); i++) 
    124         { 
    125                 Ogre::SubMesh* subMesh = mMesh->getSubMesh(i); 
    126                 Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->sharedVertexData : subMesh->vertexData; 
     117        for (unsigned short i = 0; i < mMesh->get()->getNumSubMeshes(); i++) 
     118        { 
     119                Ogre::SubMesh* subMesh = mMesh->get()->getSubMesh(i); 
     120                Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->get()->sharedVertexData : subMesh->vertexData; 
    127121 
    128122                if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) 
     
    173167        size_t next_offset = 0; 
    174168 
    175         unsigned int numSubMeshes = mMesh->getNumSubMeshes(); 
     169        unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 
    176170        sincronizeNumSubEntities(); 
    177171         
    178172        added_shared = false; 
    179         for (unsigned short i = 0; i < mMesh->getNumSubMeshes(); i++) 
    180         { 
    181                 Ogre::SubMesh* subMesh = mMesh->getSubMesh(i); 
    182                 Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->sharedVertexData : subMesh->vertexData; 
     173        for (unsigned short i = 0; i < mMesh->get()->getNumSubMeshes(); i++) 
     174        { 
     175                Ogre::SubMesh* subMesh = mMesh->get()->getSubMesh(i); 
     176                Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->get()->sharedVertexData : subMesh->vertexData; 
    183177 
    184178                if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) 
     
    223217        size_t next_offset = 0; 
    224218 
    225         unsigned int numSubMeshes = mMesh->getNumSubMeshes(); 
     219        unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 
    226220        sincronizeNumSubEntities(); 
    227221         
    228222        added_shared = false; 
    229         for (unsigned short i = 0; i < mMesh->getNumSubMeshes(); i++) 
    230         { 
    231                 Ogre::SubMesh* subMesh = mMesh->getSubMesh(i); 
    232                 Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->sharedVertexData : subMesh->vertexData; 
     223        for (unsigned short i = 0; i < mMesh->get()->getNumSubMeshes(); i++) 
     224        { 
     225                Ogre::SubMesh* subMesh = mMesh->get()->getSubMesh(i); 
     226                Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->get()->sharedVertexData : subMesh->vertexData; 
    233227 
    234228                if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) 
     
    290284        size_t next_offset = 0; 
    291285 
    292         unsigned int numSubMeshes = mMesh->getNumSubMeshes(); 
     286        unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 
    293287        sincronizeNumSubEntities(); 
    294288         
    295289        added_shared = false; 
    296         for (unsigned short i = 0; i < mMesh->getNumSubMeshes(); i++) 
    297         { 
    298                 Ogre::SubMesh* subMesh = mMesh->getSubMesh(i); 
    299                 Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->sharedVertexData : subMesh->vertexData; 
     290        for (unsigned short i = 0; i < mMesh->get()->getNumSubMeshes(); i++) 
     291        { 
     292                Ogre::SubMesh* subMesh = mMesh->get()->getSubMesh(i); 
     293                Ogre::VertexData* vertexData = subMesh->useSharedVertices ? mMesh->get()->sharedVertexData : subMesh->vertexData; 
    300294 
    301295                if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) 
     
    411405        size_t index_offset = 0; 
    412406 
    413         unsigned int numSubMeshes = mMesh->getNumSubMeshes(); 
     407        unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 
    414408        sincronizeNumSubEntities(); 
    415409 
     
    417411 
    418412        // Run through the submeshes again, adding the data into the arrays 
    419         for ( unsigned short i = 0; i < mMesh->getNumSubMeshes(); ++i) 
    420         { 
    421                 Ogre::SubMesh* submesh = mMesh->getSubMesh(i); 
    422  
    423                 Ogre::VertexData* vertex_data = submesh->useSharedVertices ? mMesh->sharedVertexData : submesh->vertexData; 
     413        for ( unsigned short i = 0; i < mMesh->get()->getNumSubMeshes(); ++i) 
     414        { 
     415                Ogre::SubMesh* submesh = mMesh->get()->getSubMesh(i); 
     416 
     417                Ogre::VertexData* vertex_data = submesh->useSharedVertices ? mMesh->get()->sharedVertexData : submesh->vertexData; 
    424418 
    425419                if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared)) 
     
    497491unsigned int Entity::getNumSubEntities() 
    498492{ 
    499         return static_cast<unsigned int>(mSubEntityList.size()); 
     493        return mSubEntityList.size(); 
    500494} 
    501495 
     
    530524                for (unsigned int iSubEntity = 1; iSubEntity < mSubEntityList.size(); iSubEntity) 
    531525                { 
    532                         SubEntityList::iterator subEntityListIterator = mSubEntityList.begin()+iSubEntity; 
    533                         // Gametools -- 02/03/2006 
    534                         // BUG: If I delete the subentity other entities that reference it will lose it's data... 
    535                         //SubEntity *subEntity = (*subEntityListIterator); 
    536526                        mSubEntityList.erase(mSubEntityList.begin()+iSubEntity); 
    537                         //delete subEntity; 
    538                 } 
    539         } 
    540 } 
    541  
    542 } 
     527                } 
     528        } 
     529} 
     530 
     531} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityCluster.cpp

    r699 r721  
    55namespace BBC { 
    66 
    7 EntityCluster::EntityCluster()  
     7EntityCluster::EntityCluster(): references(0) // initialize references to 0  
    88{ 
    99} 
     
    1111EntityCluster::~EntityCluster()  
    1212{        
    13         for (unsigned int iEntityClusterData = 0; iEntityClusterData < getNumEntitiesClusterData(); iEntityClusterData++) 
    14         { 
    15                 EntityClusterData *entityClusterData = getEntityClusterData(iEntityClusterData); 
    16                 delete entityClusterData; 
    17         } 
    18          
    19         delete mEntity; 
     13        mEntityClusterDataList.clear(); 
    2014} 
    2115 
    22 EntityClusterData* EntityCluster::getEntityClusterData(unsigned int value) 
     16EntityClusterDataPtr EntityCluster::getEntityClusterData(unsigned int value) 
    2317{ 
    2418        return mEntityClusterDataList[value]; 
    2519} 
     20 
     21void EntityCluster::removeEntityClusterData(unsigned int value) 
     22{ 
     23        mEntityClusterDataList.erase(mEntityClusterDataList.begin() + value); 
     24} 
     25 
    2626 
    2727unsigned int EntityCluster::getNumEntitiesClusterData() 
     
    3030} 
    3131 
    32 void EntityCluster::addEntityClusterData(EntityClusterData *value) 
     32void EntityCluster::addEntityClusterData(EntityClusterDataPtr value) 
    3333{ 
    3434        mEntityClusterDataList.push_back(value); 
     
    4040} 
    4141 
    42 Entity* EntityCluster::getEntity()  
     42EntityPtr EntityCluster::getEntity()  
    4343{ 
    4444        return mEntity; 
    4545} 
    4646 
    47 void EntityCluster::setEntity(Entity* value) { 
     47void EntityCluster::setEntity(EntityPtr value) { 
    4848        mEntity = value; 
    4949} 
     
    5757} 
    5858 
    59 void EntityCluster::setEntityDistribution(EntityDistribution *value) 
     59void EntityCluster::setEntityDistribution(EntityDistributionPtr value) 
    6060{ 
    6161        mEntityDistribution = value; 
    6262} 
    6363 
    64 EntityDistribution* EntityCluster::getEntityDistribution() 
     64EntityDistributionPtr EntityCluster::getEntityDistribution() 
    6565{ 
    6666        return mEntityDistribution; 
     
    6969void EntityCluster::generateEntityCluster()  
    7070{ 
    71         mEntity = new BBC::Entity(); 
     71        mEntity = BBC::EntityPtr(new BBC::Entity()); 
    7272 
    7373        mEntity->getSubEntity(0)->addTextureCoordSet(2); 
     
    8484        for (unsigned int iEntityClusterData = 0; iEntityClusterData < getNumEntitiesClusterData(); iEntityClusterData++) 
    8585        {                        
    86                 Entity *entity = getEntityClusterData(iEntityClusterData)->getEntity(); 
     86                EntityPtr entity = getEntityClusterData(iEntityClusterData)->getEntity(); 
    8787 
    8888                for (unsigned int iFace = 0; iFace < entity->getSubEntity(0)->getNumFaces(); iFace++) 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityClusterData.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 EntityClusterData::EntityClusterData() { 
     6EntityClusterData::EntityClusterData(): references(0) // initialize references to 0  
     7{ 
    78} 
    89 
    9 EntityClusterData::~EntityClusterData() { 
     10EntityClusterData::~EntityClusterData()  
     11{ 
     12 
    1013} 
    1114 
    12 void EntityClusterData::setEntity(Entity *value) 
     15void EntityClusterData::setEntity(EntityPtr value) 
    1316{ 
    1417        mEntity = value; 
    1518} 
    1619 
    17 Entity* EntityClusterData::getEntity() 
     20EntityPtr EntityClusterData::getEntity() 
    1821{ 
    1922        return mEntity; 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistribution.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 Entity* EntityDistribution::getEntity(unsigned unsigned int value) 
     6EntityDistribution::EntityDistribution(): references(0) // initialize references to 0  
     7{ 
     8} 
     9 
     10EntityDistribution::~EntityDistribution() 
     11{ 
     12        mEntityList.clear(); 
     13} 
     14 
     15EntityPtr EntityDistribution::getEntity(unsigned unsigned int value) 
    716{ 
    817        return mEntityList[value]; 
    918} 
    1019 
    11 void EntityDistribution::addEntity(Entity *value) 
     20void EntityDistribution::addEntity(EntityPtr value) 
    1221{ 
    1322        mEntityList.push_back(value); 
     
    2130unsigned int EntityDistribution::getNumEntities(void) 
    2231{ 
    23         return static_cast<unsigned int>(mEntityList.size()); 
     32        return mEntityList.size(); 
    2433} 
    2534 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistributionGenerator.cpp

    r699 r721  
    1010} 
    1111 
    12 Entity* EntityDistributionGenerator::getEntity() { 
     12EntityPtr EntityDistributionGenerator::getEntity() { 
    1313        return mEntity; 
    1414} 
    1515 
    16 void EntityDistributionGenerator::setEntity(Entity * value) { 
     16void EntityDistributionGenerator::setEntity(EntityPtr value) { 
    1717        mEntity = value; 
    1818} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistributionSerializer.cpp

    r699 r721  
    44namespace BBC { 
    55 
    6 Entity* EntityDistributionSerializer::getEntity() { 
     6EntityPtr EntityDistributionSerializer::getEntity()  
     7{ 
    78        return mEntity; 
    89} 
    910 
    10 void EntityDistributionSerializer::setEntity(Entity * value) { 
     11void EntityDistributionSerializer::setEntity(EntityPtr value)  
     12{ 
    1113        mEntity = value; 
    1214} 
     
    1820} 
    1921 
    20 EntityDistributionSerializer::EntityDistributionSerializer() { 
     22EntityDistributionSerializer::EntityDistributionSerializer()  
     23{ 
     24        mEntity = BBC::EntityPtr(new BBC::Entity()); 
    2125} 
    2226 
    23 EntityDistributionSerializer::~EntityDistributionSerializer() { 
     27EntityDistributionSerializer::~EntityDistributionSerializer()  
     28{ 
    2429} 
    2530 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCManager.cpp

    r699 r721  
    1717 
    1818Manager::Manager()  
    19 { 
    20    // Change it when the texture generation will be included... 
    21    //mOgreRoot = new Ogre::Root(); 
    22    if (Ogre::Root::getSingletonPtr() == NULL) 
    23    { 
    24                 mOgreRoot = new Ogre::Root("", "ogre.cfg", "Ogre.log");   
    25                 Ogre::LogManager::getSingleton().logMessage("OgreRoot created in LBBC"); 
    26    } 
    27    else 
    28    {     
    29            mOgreRoot = Ogre::Root::getSingletonPtr(); 
    30            Ogre::LogManager::getSingleton().logMessage("OgreRoot assigned in LBCC"); 
    31    } 
    32     
    33    mDefaultHardwareBufferManager = new Ogre::DefaultHardwareBufferManager(); 
    34    mMeshSerializer = new Ogre::MeshSerializer(); 
    35    mXMLMeshSerializer = new Ogre::XMLMeshSerializer(); 
    36    mMath = new Ogre::Math(); 
    37    loadResources();    
    38 } 
    39  
    40 void Manager::loadResources() 
    41 { 
    42         // Load resource paths from config file 
    43         Ogre::ConfigFile cf; 
    44     cf.load("resources.cfg"); 
    45     // Go through all sections & settings in the file 
    46         Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); 
    47  
    48         Ogre::String secName, typeName, archName; 
    49     while (seci.hasMoreElements()) 
    50     { 
    51         secName = seci.peekNextKey(); 
    52                 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); 
    53                 Ogre::ConfigFile::SettingsMultiMap::iterator i; 
    54         for (i = settings->begin(); i != settings->end(); ++i) 
    55         { 
    56             typeName = i->first; 
    57             archName = i->second; 
    58                         Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); 
    59         } 
    60     } 
    61         Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 
    62 } 
    63  
    64 void Manager::initRenderWindow() 
    65 { 
    66     // Change it when the texture generation will be included... 
    67         /* 
    68         // Render system. 
    69         Ogre::LogManager::getSingleton().logMessage("Creating window..."); 
    70         //mOgreRoot->showConfigDialog(); 
    71         // Set parameters of render system (window size, etc.) 
    72         mOgreRoot->restoreConfig(); 
    73          
    74         mWnd = mOgreRoot->initialise(true); 
    75         mWnd->resize(512,512); 
    76  
    77         // Camera. 
    78         mScene = mOgreRoot->getSceneManager(Ogre::ST_GENERIC); 
    79         mRSys = mOgreRoot->getRenderSystem(); 
    80         Ogre::LogManager::getSingleton().logMessage("Creating default camera..."); 
    81         mCam = mScene->createCamera("SubMain Camera"); 
    82         mCam->setPosition(-1, 22, 72); 
    83         mCam->lookAt(0, 22, 0); 
    84         mCam->setNearClipDistance(0.5); 
    85         // Viewports. 
    86         Ogre::LogManager::getSingleton().logMessage("Creating default viewort..."); 
    87         mView = mWnd->addViewport(mCam); 
    88         mView->setBackgroundColour(Ogre::ColourValue(1.0f,1.0f,1.0f,0)); 
    89         // All set up, activate. 
    90         Ogre::LogManager::getSingleton().logMessage("Setting up..."); 
    91         //mWnd->setActive(true); 
    92         mWnd->setActive(false);  
    93         mFrameListener = new ExampleFrameListener(mWnd,mCam,false,false); 
    94         mFrameListener->showDebugOverlay(false); 
    95         mOgreRoot->addFrameListener(mFrameListener); 
    96         */ 
     19{    
    9720} 
    9821 
     
    10326void Manager::shutdown() 
    10427{ 
    105         mOgreRoot->shutdown(); 
    106         delete mOgreRoot; 
    107         delete mMeshSerializer; 
    108         delete mXMLMeshSerializer; 
    109         delete mMath; 
    110         // Not necessary if we have a RenderWindow... 
    111         delete mDefaultHardwareBufferManager;    
    112         // Change it when the texture generation will be included... 
    113         //mWnd->destroy(); 
    114         // Only necessary if we have a RenderWindow... 
    115         //delete mFrameListener; 
    116         //delete mScene; 
    117         //delete mRSys; 
    118         //delete mCam; 
    119         //delete mView; 
    120         //delete mWnd; 
    121          
    122          
    12328} 
    12429 
     
    12732} 
    12833 
    129 Ogre::Mesh* Manager::loadMesh(Ogre::String name) 
     34Ogre::Mesh* Manager::loadMesh(Ogre::String folderName, Ogre::String fileName) 
    13035{        
    131         Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().load(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);   
    132         return meshPtr.getPointer(); 
     36        //std::ifstream ifs; 
     37        //ifs.open(Ogre::String(folderName + fileName).c_str(), std::ios_base::in | std::ios_base::binary); 
     38        //Ogre::DataStreamPtr stream(new Ogre::FileStreamDataStream(folderName + fileName, &ifs, false)); 
     39        //Ogre::MeshPtr mesh = OBA::OgreBase::getSingleton().getMeshManager()->create(fileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
     40        //OBA::OgreBase::getSingleton().getMeshSerializer()->importMesh(stream, mesh.getPointer()); 
     41 
     42        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(folderName, "FileSystem", fileName, false); 
     43 
     44        Ogre::MeshPtr mesh = OBA::OgreBase::getSingleton().getMeshManager()->load(fileName, fileName); 
     45 
     46        return mesh.getPointer(); 
    13347} 
    13448 
     
    14963        } 
    15064 
    151     mXMLMeshSerializer->importMesh(name, colourElementType, newMesh.getPointer()); 
     65    OBA::OgreBase::getSingleton().getXMLMeshSerializer()->importMesh(name, colourElementType, newMesh.getPointer()); 
     66 
    15267        return newMesh.getPointer(); 
    15368} 
     
    15671{ 
    15772        Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(name); 
    158         mMeshSerializer->exportMesh(meshPtr.getPointer(),name); 
     73        OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(meshPtr.getPointer(),name); 
    15974} 
    16075 
     
    16277{ 
    16378        Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(name); 
    164         mXMLMeshSerializer->exportMesh(meshPtr.getPointer(),name + ".xml"); 
    165 } 
    166  
    167 Ogre::MeshSerializer* Manager::getMeshSerializer(void) 
    168 { 
    169         return mMeshSerializer; 
    170 } 
    171  
    172 Ogre::XMLMeshSerializer* Manager::getXMLMeshSerializer(void) 
    173 { 
    174         return mXMLMeshSerializer; 
     79        OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(meshPtr.getPointer(),name + ".xml"); 
    17580} 
    17681 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCOgreMeshSerializer.cpp

    r699 r721  
    2525    } 
    2626 
    27         void OgreMeshSerializer::setEntity(Entity *entity) 
     27        void OgreMeshSerializer::setEntity(EntityPtr entity) 
    2828        { 
    2929                mEntity = entity; 
    3030        } 
    3131 
    32         Entity* OgreMeshSerializer::getEntity() 
     32        EntityPtr OgreMeshSerializer::getEntity() 
    3333        { 
    3434                return mEntity; 
     
    5050        // Derive the scene root 
    5151 
    52         // Construct mesh 
    53         Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().createManual(fileName,  
    54                         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
    55  
    56                 mEntity->setMesh(pMesh.getPointer()); 
     52        // Construct mesh                
     53                BBC::MeshPtr pMesh(new BBC::Mesh(Ogre::MeshManager::getSingleton().createManual(fileName, fileName).getPointer())); 
     54                 
     55                Ogre::MeshPtr mesh = OBA::OgreBase::getSingleton().getMeshManager()->load(fileName, fileName); 
     56 
     57                Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mEntity->getNumSubEntities())); 
     58 
     59                mEntity->setMesh(pMesh); 
    5760 
    5861                // write the data into a mesh 
    59                 buildMesh(pMesh.getPointer(), mergeSubMeshes); 
     62                buildMesh(pMesh, mergeSubMeshes); 
    6063 
    6164        if(tangents) 
     
    6366            Ogre::LogManager::getSingleton().logMessage("Calculating tangents"); 
    6467            unsigned short src, dest; 
    65             if (pMesh->suggestTangentVectorBuildParams(src, dest)) 
     68            if (pMesh->get()->suggestTangentVectorBuildParams(src, dest)) 
    6669            { 
    67                 pMesh->buildTangentVectors(src, dest); 
     70                pMesh->get()->buildTangentVectors(src, dest); 
    6871            } 
    6972            else 
     
    7679    } 
    7780  
    78         void OgreMeshSerializer::buildMesh(Ogre::Mesh* pMesh, bool mergeSubmeshes) 
     81        void OgreMeshSerializer::buildMesh(MeshPtr pMesh, bool mergeSubmeshes) 
    7982        { 
    8083                if (!mergeSubmeshes) 
     
    99102        } 
    100103  
    101         void OgreMeshSerializer::generateEntityAABB(Ogre::Mesh* pMesh) 
     104        void OgreMeshSerializer::generateEntityAABB(MeshPtr pMesh) 
    102105        { 
    103106                // Bounds calculation 
     
    132135                Ogre::AxisAlignedBox box; 
    133136        box.setExtents(min, max); 
    134         box.merge(pMesh->getBounds()); 
    135         pMesh->_setBounds(box); 
    136         pMesh->_setBoundingSphereRadius( 
     137        box.merge(pMesh->get()->getBounds()); 
     138        pMesh->get()->_setBounds(box); 
     139        pMesh->get()->_setBoundingSphereRadius( 
    137140                        std::max( 
    138                                 pMesh->getBoundingSphereRadius(),  
     141                                pMesh->get()->getBoundingSphereRadius(),  
    139142                                Ogre::Math::Sqrt(squaredRadius)));       
    140143 
    141                 Ogre::LogManager::getSingleton().logMessage("Bounds:" + Ogre::StringConverter::toString(pMesh->getBoundingSphereRadius()) + " -- Generated:" + Ogre::StringConverter::toString(pMesh->getBounds().isNull())); 
    142         } 
    143   
    144         void OgreMeshSerializer::exportSubMeshes(Ogre::Mesh* pMesh) 
     144                Ogre::LogManager::getSingleton().logMessage("Bounds:" + Ogre::StringConverter::toString(pMesh->get()->getBoundingSphereRadius()) + " -- Generated:" + Ogre::StringConverter::toString(pMesh->get()->getBounds().isNull())); 
     145        } 
     146  
     147        void OgreMeshSerializer::exportSubMeshes(MeshPtr pMesh) 
    145148        { 
    146149                for (unsigned int iSubEntity = 0; iSubEntity < mEntity->getNumSubEntities(); iSubEntity++) 
     
    150153        } 
    151154  
    152         void OgreMeshSerializer::exportSubMesh(Ogre::Mesh* pMesh, SubEntity *subEntity) 
     155        void OgreMeshSerializer::exportSubMesh(MeshPtr pMesh, SubEntityPtr subEntity) 
    153156        {                
    154157        Ogre::SubMesh* sm = 0; 
    155158        if (subEntity->getName() == "") 
    156159        { 
    157             sm = pMesh->createSubMesh(); 
     160            sm = pMesh->get()->createSubMesh(); 
    158161        } 
    159162        else 
    160163        { 
    161             sm = pMesh->createSubMesh(subEntity->getName()); 
     164            sm = pMesh->get()->createSubMesh(subEntity->getName()); 
    162165        } 
    163166        // Set material 
     
    231234  
    232235    template <typename T>  
    233     void OgreMeshSerializer::writeIndexes(T* buf, SubEntity *subEntity) 
     236    void OgreMeshSerializer::writeIndexes(T* buf, SubEntityPtr subEntity) 
    234237    { 
    235238        for (unsigned int i = 0;  i < subEntity->getNumFaces(); i++) 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCSubEntity.cpp

    r709 r721  
    44namespace BBC { 
    55 
    6 SubEntity::SubEntity()  
     6SubEntity::SubEntity(): references(0) // initialize references to 0 
    77{ 
    88        mHasTangents = false; 
     
    1414SubEntity::~SubEntity()  
    1515{ 
     16        mUniqueVertexList.clear(); 
     17        mIndices.clear(); 
     18        mTextureCoordSetsDimensions.clear(); 
     19 
    1620} 
    1721 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCXmlSerializer.cpp

    r699 r721  
    1111        if (mLoaded) 
    1212        { 
    13                 delete mFile; 
     13                if (mFile) 
     14                { 
     15                        delete mFile; 
     16                } 
    1417                mLoaded = false; 
    1518        } 
     
    2629        else 
    2730        { 
    28                 delete mFile; 
     31                if (mFile) 
     32                { 
     33                        delete mFile; 
     34                } 
    2935                mFile = new TiXmlDocument(filename.c_str()); 
    3036        } 
     
    5157        else 
    5258        { 
    53                 delete mFile; 
     59                if (mFile) 
     60                { 
     61                        delete mFile; 
     62                } 
    5463                mFile = new TiXmlDocument(filename.c_str()); 
    5564        } 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBBox.cpp

    r699 r721  
    11 
    2 #include "IMGBBox.h" 
     2#include <IMGBBox.h> 
    33 
    44namespace IMG { 
    55 
    6 BBox::~BBox() { 
     6BBox::BBox() 
     7{  
     8        BBox::StartBoundingBox();  
    79} 
    810 
     11BBox::~BBox()  
     12{ 
     13} 
     14 
     15void BBox::StartBoundingBox() 
     16{ 
     17        mMinimum.x =  BOUNDINGBOX_MAXVALUE; 
     18    mMinimum.y =  BOUNDINGBOX_MAXVALUE; 
     19    mMinimum.z =  BOUNDINGBOX_MAXVALUE; 
     20    mMaximum.x = -BOUNDINGBOX_MAXVALUE; 
     21    mMaximum.y = -BOUNDINGBOX_MAXVALUE; 
     22    mMaximum.z = -BOUNDINGBOX_MAXVALUE; 
     23} 
     24 
     25Ogre::Vector3 BBox::GetMinimum()  
     26{  
     27        return mMinimum;  
     28} 
     29 
     30Ogre::Vector3 BBox::GetMaximum() 
     31{  
     32        return mMaximum; 
     33} 
     34 
     35void BBox::AddBoundingVector3(float x, float y, float z) 
     36{ 
     37    if (x < mMinimum.x) 
     38        { 
     39                mMinimum.x = x;  
     40        } 
     41         
     42        if (x > mMaximum.x) 
     43        { 
     44                mMaximum.x = x; 
     45        } 
     46 
     47    if (y < mMinimum.y) 
     48        { 
     49                mMinimum.y = y; 
     50        } 
     51         
     52        if (y > mMaximum.y) 
     53        { 
     54                mMaximum.y = y; 
     55        } 
     56 
     57    if (z < mMinimum.z) 
     58        { 
     59                mMinimum.z = z; 
     60        } 
     61         
     62        if (z > mMaximum.z) 
     63        { 
     64                mMaximum.z = z; 
     65        } 
     66} 
     67 
     68void BBox::Print()  
     69{ 
     70        Ogre::LogManager::getSingleton().logMessage("\nValor de la Caixa: (" + Ogre::StringConverter::toString(mMinimum) + ") - (" + + ") " + Ogre::StringConverter::toString(mMaximum)); 
     71} 
     72 
     73Ogre::Vector3 BBox::GetCorner(int corner) const  
     74{ 
     75    Ogre::Vector3 vector;        
     76    switch (corner) 
     77    { 
     78                case BOX_CORNER_xyz: vector = Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z ); break; 
     79        case BOX_CORNER_xyZ: vector = Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z ); break; 
     80        case BOX_CORNER_xYz: vector = Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z ); break; 
     81        case BOX_CORNER_xYZ: vector = Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z ); break; 
     82        case BOX_CORNER_Xyz: vector = Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z ); break; 
     83        case BOX_CORNER_XyZ: vector = Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z ); break; 
     84        case BOX_CORNER_XYz: vector = Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z ); break; 
     85        case BOX_CORNER_XYZ: vector = Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z ); break; 
     86    } 
     87     
     88    return vector; 
     89} 
     90 
     91bool BBox::intersects(Ogre::Vector3 v)  
     92{ 
     93        return Ogre::AxisAlignedBox::intersects(v);  
     94} 
    995 
    1096} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBox2d.cpp

    r699 r721  
    11 
    2 #include "IMGBox2d.h" 
     2#include <IMGBox2d.h> 
    33 
    4 namespace IMG { 
     4namespace IMG  
     5{ 
    56 
    6 Box2d::~Box2d() { 
     7Box2d::Box2d() 
     8{ 
     9    mMinimum.x =  BOUNDINGBOX_MAXVALUE; 
     10    mMinimum.y =  BOUNDINGBOX_MAXVALUE; 
     11     
     12    mMaximum.x = -BOUNDINGBOX_MAXVALUE; 
     13    mMaximum.y = -BOUNDINGBOX_MAXVALUE;          
    714} 
    815 
     16Box2d::~Box2d()  
     17{ 
     18} 
     19 
     20Ogre::Vector2 Box2d::GetMinimum()  
     21{  
     22    return mMinimum; 
     23} 
     24 
     25Ogre::Vector2 Box2d::GetMaximum()  
     26{  
     27    return mMaximum;  
     28} 
     29 
     30void Box2d::SetBoundBox(float x, float y, float X, float Y)  
     31{ 
     32    mMinimum.x = x; 
     33    mMinimum.y = y; 
     34    mMaximum.x = X; 
     35    mMaximum.y = Y; 
     36} 
     37 
     38void Box2d::AddBoundingVector3(float x, float y) 
     39{ 
     40    if (x < mMinimum.x) 
     41        { 
     42                mMinimum.x = x;  
     43        } 
     44         
     45        if (x > mMaximum.x) 
     46        { 
     47                mMaximum.x = x; 
     48        } 
     49 
     50    if (y < mMinimum.y) 
     51        { 
     52                mMinimum.y = y; 
     53        } 
     54         
     55        if (y > mMaximum.y) 
     56        { 
     57                mMaximum.y = y; 
     58        } 
     59} 
     60 
     61void Box2d::Print() 
     62{ 
     63        Ogre::LogManager::getSingleton().logMessage("Valor de la Caixa: (" + Ogre::StringConverter::toString(Ogre::Vector3(mMinimum.x, mMinimum.y, 0)) + ") - (" + Ogre::StringConverter::toString(Ogre::Vector3(mMaximum.x, mMaximum.y, 0)) + ")"); 
     64} 
     65 
     66Ogre::Vector2 Box2d::GetCorner(int corner) const  
     67{ 
     68        Ogre::Vector2 vector; 
     69 
     70    switch (corner) 
     71    {            
     72        case BOX_CORNER_xy: vector = Ogre::Vector2(mMinimum.x, mMinimum.y ); break; 
     73        case BOX_CORNER_xY: vector = Ogre::Vector2(mMinimum.x, mMaximum.y ); break; 
     74        case BOX_CORNER_Xy: vector = Ogre::Vector2(mMaximum.x, mMinimum.y ); break; 
     75        case BOX_CORNER_XY: vector = Ogre::Vector2(mMaximum.x, mMaximum.y ); break;              
     76    } 
     77         
     78    return vector; 
     79} 
     80 
     81bool Box2d::In(int w, int h)  
     82{ 
     83    if (w <= (mMaximum.x - mMinimum.x) && h <= (mMaximum.y - mMinimum.y)) 
     84        { 
     85                return true; 
     86        } 
     87                 
     88    return false; 
     89} 
     90 
     91bool Box2d::FitPerfect(int w, int h) 
     92{        
     93    if (w == (mMaximum.x - mMinimum.x) && h == (mMaximum.y - mMinimum.y)) 
     94        { 
     95                return true; 
     96        } 
     97 
     98    return false; 
     99} 
    9100 
    10101} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBsp.cpp

    r709 r721  
    11 
    2 #include "IMGBsp.h" 
     2#include <IMGBsp.h> 
    33 
    4 namespace IMG { 
     4namespace IMG  
     5{ 
     6 
     7Bsp::Bsp() : root(NULL), countleaf(0), counttotal(0) 
     8{ 
     9} 
    510 
    611Bsp::~Bsp()  
    712{ 
    8         delete root; 
     13 
    914} 
    1015 
     16void Bsp::SetRoot(NodeBspPtr node)  
     17{ 
     18    root = node; 
     19    counttotal++; 
     20} 
     21 
     22void Bsp::Print()  
     23{ 
     24        Ogre::LogManager::getSingleton().logMessage("\nImprimint Arbre BSP, num nodes leaf: " + Ogre::StringConverter::toString(countleaf) + ", totals: " + Ogre::StringConverter::toString(counttotal)); 
     25    Print(root); 
     26} 
     27 
     28void Bsp::PrintLeaf() 
     29{ 
     30        PrintLeaf(root); 
     31} 
     32 
     33NodeBspPtr Bsp::Insert(int w, int h, int idcluster)  
     34{ 
     35    NodeBspPtr node = root->Insert(w,h); 
     36 
     37        if (idcluster != -1) 
     38    { 
     39        node->SetId (idcluster); 
     40        countleaf++;                     
     41    } 
     42    else 
     43        { 
     44                counttotal++; 
     45        } 
     46         
     47    return node; 
     48} 
     49 
     50NodeBspPtr Bsp::Get(int i)  
     51{ 
     52        return root->Get(root, i); 
     53} 
     54 
     55void Bsp::Print(NodeBspPtr node)  
     56{ 
     57    node->Print(); 
     58    Print(node->GetChild(0)); 
     59    Print(node->GetChild(1)); 
     60} 
     61 
     62void Bsp::PrintLeaf(NodeBspPtr node)  
     63{        
     64    if (node->GetChild(0) == NULL && node->GetChild(1) == NULL) 
     65        { 
     66                node->Print(); 
     67        } 
     68         
     69    PrintLeaf (node->GetChild(0)); 
     70    PrintLeaf (node->GetChild(1));       
     71} 
    1172 
    1273} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGCluster.cpp

    r699 r721  
    11 
    2 #include "IMGCluster.h" 
    3 #include "IMGCluster2d.h" 
     2#include <IMGCluster.h> 
     3#include <IMGCluster2d.h> 
    44 
    55namespace IMG { 
     
    77Cluster::Cluster(){ 
    88        id = Cluster::ID_CLUSTER++; 
    9         bound = new BBox; 
    10         bspnodebound = NULL; 
    11         //CreateVector3s(); 
    12 } 
    13  
    14 Cluster & Cluster::operator =(const Cluster & p) { 
    15         //      printf("\nConstructor d'assignació de cluster"); 
    16         // GametoolsError -- Isma 17/08/2005 
    17         //vertexs = p.vertexs; 
    18         //vertexs_vector = p.vertexs_vector; 
    19         //vertexs_triangle_text = p.vertexs_triangle_text; 
     9} 
     10 
     11Cluster::~Cluster()  
     12{ 
     13} 
     14 
     15void Cluster::SetNormal(Ogre::Vector3* n)  
     16{  
     17        normal = *n;  
     18} 
     19 
     20Ogre::Vector3* Cluster::GetNormal()  
     21{  
     22        return &normal;  
     23} 
     24 
     25BBox* Cluster::GetBound()  
     26{  
     27        return &bound;  
     28} 
     29 
     30Box2d* Cluster::GetBspNodeBound()  
     31{  
     32        return &bspnodebound;  
     33} 
     34 
     35void Cluster::SetBspNodeBound(Box2d* box)  
     36{ 
     37        bspnodebound = (*box); 
     38} 
     39 
     40int Cluster::GetId() const  
     41{  
     42        return id;  
     43} 
     44 
     45void Cluster::SetId(int id_)  
     46{  
     47        id = id; 
     48} 
     49 
     50        std::vector<Ogre::Vector3>* Cluster::GetVector3sVector()  
     51{  
     52        return &Vector3s_vector;  
     53} 
     54 
     55Ogre::Vector3* Cluster::GetVector3sTex() const  
     56{  
     57        return Vector3s_triangle_text; 
     58} 
     59 
     60void Cluster::SetPlane(Ogre::Vector3* normal, Ogre::Vector3 * point)  
     61{ 
     62    plane.normal = *normal; 
     63    plane.normal = -plane.normal; 
     64    plane.d = -normal->dotProduct (*point);              
     65} 
     66 
     67Plane3 * Cluster::GetPlane() 
     68{  
     69        return &plane;  
     70} 
     71 
     72Cluster & Cluster::operator =(const Cluster & p)  
     73{ 
    2074        uv = p.uv; 
    2175        id = p.id; 
    2276 
    23         //get the lumel_origin becaus if get Inc[0] the value is not correct     
    24          
     77        //get the lumel_origin becaus if get Inc[0] the value is not correct             
    2578        lumel_origin = p.lumel_origin; 
    2679        lumel_x_axis = p.lumel_x_axis; 
    2780        lumel_y_axis = p.lumel_y_axis; 
    28          
    29         //patchlistid = p.patchlistid; 
    30         //plane = p.plane; 
    31          
     81                 
    3282        axisproj = p.axisproj; 
    3383        order = p.order; 
     
    3989} 
    4090 
    41 Cluster::Cluster(const Cluster & p){ 
    42         ///printf("\nConstructor per copia de cluster"); 
    43         // GametoolsError -- Isma 17/08/2005 
    44         //vertexs = p.vertexs; 
    45         //vertexs_triangle_text = p.vertexs_triangle_text; 
    46         //vertexs_vector = p.vertexs_vector; 
    47         //printf("\nnombre de vertexs origens: %d", p.vertexs_vector.size()); 
    48         //printf("\nnombre de vertexs copiats: %d", vertexs_vector.size()); 
     91Cluster::Cluster(const Cluster & p) 
     92{ 
    4993        uv = p.uv; 
    5094        id = p.id; 
     
    5599        lumel_x_axis = p.lumel_x_axis; 
    56100        lumel_y_axis = p.lumel_y_axis; 
    57          
    58         //patchlistid = p.patchlistid; 
    59         //plane = p.plane; 
    60101         
    61102        axisproj = p.axisproj; 
     
    65106        normal = p.normal; 
    66107        bspnodebound = p.bspnodebound; 
    67          
    68         //trianglelistid = p.trianglelistid; 
    69          
    70 } 
    71  
    72 // Gametools -- Isma 17/08/2005 
    73 //void Cluster::Insert (Triangle *t) 
    74 //{ 
    75 //      int axis = t->AxisProjected(); 
    76 //       
    77 //      //printf("\nAxis: %d", axis); 
    78 //      //t->Print(); 
    79 //      Vector3 *v = t->GetVector3s(); 
    80 //      //std::vector<Vector3> v = *t->GetVector3sVector(); 
    81 //       
    82 //      for (int i = 0; i < 3; i++) 
    83 //      { 
    84 //              //printf("\ntriangle a transformar : (%.4f, %.4f, %.4f)", v[i].x, v[i].y, v[i].z); 
    85 //               
    86 //              vertexs_vector.push_back (v[i]); 
    87 //              //bound->AddBoundingVector3 (v[i].x, v[i].y, v[i].z); 
    88 //              /* 
    89 //              switch (axis) 
    90 //              { 
    91 //                      case 0: bound->AddBoundingVector3 (v[i].z, v[i].y, 0);break; 
    92 //                      case 1: bound->AddBoundingVector3 (v[i].x, v[i].z, 0);break; 
    93 //                      case 2: bound->AddBoundingVector3 (v[i].x, v[i].y, 0);break;     
    94 //              } 
    95 //              */ 
    96 //      } 
    97 //       
    98 //      plane = *t->GetPlane(); 
    99 //} 
    100  
    101 void Cluster::Print() { 
    102         printf("\n\nCluster: %d, axisproj: %d, order: %d", id, axisproj, order); 
    103         //Vector3 *normal = plane.GetNormal(); 
    104         //printf("\nPlane: (%.4f, %.4f, %.4f)", normal->x, normal->y, normal->z); 
     108} 
     109 
     110void Cluster::Print()  
     111{ 
     112        Ogre::LogManager::getSingleton().logMessage("\n\nCluster: " + Ogre::StringConverter::toString(id) + ", axisproj: " + Ogre::StringConverter::toString(axisproj)  + ", order: " + Ogre::StringConverter::toString(order)); 
     113         
    105114        plane.Print(); 
    106         printf("\nOrigin (%.4f, %.4f, %.4f) \n", lumel_origin.x, lumel_origin.y, lumel_origin.z); 
    107                 //printf("Inc U (%.4f, %.4f, %.4f) \n", Inc[1].x, Inc[1].y, Inc[1].z); 
    108         printf("Inc U (%.4f, %.4f, %.4f) \n", lumel_x_axis.x, lumel_x_axis.y, lumel_x_axis.z); 
    109         printf("Inc V (%.4f, %.4f, %.4f) ", lumel_y_axis.x, lumel_y_axis.y, lumel_y_axis.z); 
    110          
    111         if (bound) bound->Print(); 
    112         if (bspnodebound) bspnodebound->Print(); 
    113          
    114          
    115         /* 
    116         printf("\nIndex de triangles del cluster: %d -->", trianglelistid.GetSize()); 
    117         for (register int i = 0; i < trianglelistid.GetSize(); i++) 
    118         { 
    119                 printf(" %d", trianglelistid.Get(i)); 
    120         } 
    121         */ 
    122          
    123         printf("Printant els vertexs: "); 
    124          
    125         //for (int i = 0; i < 4; i++) 
    126         //      printf("\nVector3s %d del cluster: (%.4f, %.4f, %.4f)", i, vertexs[i].x, vertexs[i].y, vertexs[i].z); 
    127         // Gametools -- Isma 17/08/2005 
    128         //for (int i = 0; i < vertexs_vector.size(); i++) 
    129         //      printf("\nVector3s %d del cluster: (%.4f, %.4f, %.4f)", i, vertexs_vector[i].x, vertexs_vector[i].y, vertexs_vector[i].z); 
    130  
    131         //printf("\nVector3s del cluster: "); 
    132         //for (int i = 0; i < 4; i++) 
    133         //{ 
    134         //              printf("\nVector3s %d: (%.4f, %.4f, %.4f)", i, vertexs_triangle_text[i].x, vertexs_triangle_text[i].y, vertexs_triangle_text[i].z); 
    135         //}      
    136          
    137         /* 
    138         printf("\nCoordenades de texture dels vertes: %d -->", vertexs_vector.size()); 
    139          
    140         for (int i = 0 ; i < vertexs_vector.size(); i++) 
    141         { 
    142                 Vector3 vec= vertexs_triangle_text[i]; 
    143                  
    144                 printf("  (%.4f, %.4f)", vec.x, vec.y); 
    145         }        
    146         */       
     115        Ogre::LogManager::getSingleton().logMessage("\nOrigin (" + Ogre::StringConverter::toString(lumel_origin) + ")"); 
     116        Ogre::LogManager::getSingleton().logMessage("Inc U (" + Ogre::StringConverter::toString(lumel_x_axis) + ")"); 
     117        Ogre::LogManager::getSingleton().logMessage("Inc V (" + Ogre::StringConverter::toString(lumel_y_axis.z) + ")"); 
     118         
     119        bound.Print(); 
     120 
     121        bspnodebound.Print(); 
     122         
     123        Ogre::LogManager::getSingleton().logMessage("Printant els vertexs: "); 
    147124} 
    148125 
     
    152129        Ogre::Vector3 *normal = plane.GetNormal(); 
    153130         
    154         if (Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->y) && Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->z))       return (0);              
    155         if (Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->x) && Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->z))       return (1); 
    156         else                                                                            return (2); 
    157 } 
    158  
    159 // Gametools -- Isma 17/08/2005 
    160 //bool CreatePatches(bool dinamic = false); 
    161 // Gametools -- Isma 17/08/2005 
    162 //Listid *GetPatchList() { return &patchlistid;} 
    163 //Listid *GetTriangleList(){ return &trianglelistid; } 
    164 // Gametools -- Isma 17/08/2005 
    165 //int GetIdPatch (unsigned int i) 
    166 //{ 
    167 //      if (i > patchlistid.GetSize()) return -1; 
    168 //       
    169 //      return patchlistid.Get(i); 
    170 //} 
    171 // Gametools -- Isma 17/08/2005 
    172 //int GetIdTriangle  (unsigned int i) 
    173 //{ 
    174 //      if (i > trianglelistid.GetSize()) return -1; 
    175 //       
    176 //      return trianglelistid.Get(i); 
    177 //} 
    178 void Cluster::Finish() { 
    179         printf("\nCluster::Finish()"); 
     131        if (Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->y) && Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->z)) 
     132        { 
     133                return (0);              
     134        } 
     135        if (Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->x) && Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->z)) 
     136        { 
     137                return (1); 
     138        } 
     139        else 
     140        { 
     141                return (2); 
     142        } 
     143} 
     144 
     145void Cluster::Finish()  
     146{ 
     147        Ogre::LogManager::getSingleton().logMessage("\nCluster::Finish()"); 
    180148        Plane3 *plane = GetPlane(); 
    181149        Ogre::Vector3 normal = *plane->GetNormal(); 
     
    192160        bool type = true; 
    193161 
    194         printf("\n\tCreant cluster 2d"); 
     162        Ogre::LogManager::getSingleton().logMessage("\tCreant cluster 2d"); 
    195163        axisproj = cluster2d.Create2d (this, 0, true);   
    196         printf("\n\t Imprimint el que hi al del cluster"); 
     164        Ogre::LogManager::getSingleton().logMessage("\t Imprimint el que hi al del cluster"); 
    197165                 
    198         //this->Print(); 
    199         //printf("\n\t Imprimint el que hi ha del cluster2d"); 
    200         //cluster2d.Print(); 
    201                  
    202         //Vector3 *v = GetVector3s(); 
    203         //vertexs2d = cluster2d.GetVector3s(); 
    204166        std::vector<Ogre::Vector2> vector2; 
    205167        vector2 =*cluster2d.GetVector3sVector(); 
    206168         
    207                  
    208         // Gametools -- Isma 17/08/2005 
    209         //if (ObscuranceRayTracing::Config::Debug)  
    210         //{ 
    211         //      this->Print(); 
    212         //      //poly2d->Print(); 
    213         //      cluster2d.Print(); 
    214         //} 
    215                  
    216          
    217         bound = new BBox; 
    218169        for (unsigned int i = 0; i < vector2.size(); i++) 
    219170        {                
    220                 bound->AddBoundingVector3 (vector2[i].x, vector2[i].y, 0);               
    221         } 
    222          
    223         min = bound->GetMinimum();       
    224         max = bound->GetMaximum(); 
    225         //if (ObscuranceRayTracing::Config::Debug)  
    226         { 
    227                 printf("\nCaixa Englobant del cluster 2d\n"); 
    228                 bound->Print(); 
    229         } 
    230         //----- 
    231  
    232         // Gametools -- Isma 17/08/2005 
    233         //if (ObscuranceRayTracing::Config::Debug)  
    234         //      printf("\nAxisproject: %d\n", axisproj); 
    235          
    236         // Gametools -- Isma 17/08/2005 
    237         //vertexs_triangle_text = new Vector3[num_vertexs]; 
    238          
    239          
     171                bound.AddBoundingVector3 (vector2[i].x, vector2[i].y, 0);                
     172        } 
     173         
     174        min = bound.GetMinimum();        
     175        max = bound.GetMaximum(); 
     176         
     177        Ogre::LogManager::getSingleton().logMessage("Caixa Englobant del cluster 2d"); 
     178        bound.Print(); 
     179 
    240180        Ogre::Vector3 aux (-9999,-9999,-9999); 
    241         //reconstruim a 3d el polygon englobant del polygon original a partir del pla 
    242          
    243         printf("\nAxisproj: %d", axisproj); 
    244         // Gametools -- Isma 17/08/2005 
    245         /* 
    246         switch(axisproj) 
    247         { 
    248                 case 0:  
    249  
    250                         { 
    251  
    252                                 vertexs_triangle_text[0].z = min.x; 
    253                                 vertexs_triangle_text[0].y = min.y; 
    254                                 vertexs_triangle_text[0].x = - (normal.y * min.y + normal.z * min.x + distance) / normal.x; 
    255                                  
    256                                 vertexs_triangle_text[1].z = max.x; 
    257                                 vertexs_triangle_text[1].y = min.y; 
    258                                 vertexs_triangle_text[1].x = - (normal.y * min.y + normal.z * max.x + distance) / normal.x; 
    259                                  
    260                                 vertexs_triangle_text[2].z = min.x; 
    261                                 vertexs_triangle_text[2].y = max.y; 
    262                                 vertexs_triangle_text[2].x = - (normal.y * max.y + normal.z * min.x + distance) / normal.x; 
    263  
    264                                 vertexs_triangle_text[3].z = max.x; 
    265                                 vertexs_triangle_text[3].y = max.y; 
    266                                 vertexs_triangle_text[3].x = - (normal.y * max.y + normal.z * max.x + distance) / normal.x; 
    267                          
    268                         } 
    269                         break; 
    270                 case 1: 
    271                         { 
    272                                  
    273                                  
    274                                 vertexs_triangle_text[0].x = min.x; 
    275                                 vertexs_triangle_text[0].z = min.y; 
    276                                 vertexs_triangle_text[0].y = - (normal.x * min.x + normal.z * min.y + distance) / normal.y; 
    277                                  
    278                                 vertexs_triangle_text[1].x = max.x; 
    279                                 vertexs_triangle_text[1].z = min.y; 
    280                                 vertexs_triangle_text[1].y = - (normal.x * max.x + normal.z * min.y + distance) / normal.y; 
    281                                                  
    282                                 vertexs_triangle_text[3].x = max.x; 
    283                                 vertexs_triangle_text[3].z = max.y; 
    284                                 vertexs_triangle_text[3].y = - (normal.x * max.x + normal.z * max.y + distance) / normal.y; 
    285  
    286                                 vertexs_triangle_text[2].x = min.x; 
    287                                 vertexs_triangle_text[2].z = max.y; 
    288                                 vertexs_triangle_text[2].y = - (normal.x * min.x + normal.z * max.y + distance) / normal.y; 
    289                                  
    290  
    291                                  
    292                         } 
    293                         break; 
    294                 case 2: 
    295  
    296                         {                                
    297                                  
    298                                 vertexs_triangle_text[0].x = min.x; 
    299                                 vertexs_triangle_text[0].y = min.y; 
    300                                 vertexs_triangle_text[0].z = - (normal.x * min.x + normal.y * min.y + distance) / normal.z; 
    301                                  
    302                                 vertexs_triangle_text[1].x = max.x; 
    303                                 vertexs_triangle_text[1].y = min.y; 
    304                                 vertexs_triangle_text[1].z = - (normal.x * max.x + normal.y * min.y + distance) / normal.z; 
    305                                  
    306                                 vertexs_triangle_text[3].x = max.x; 
    307                                 vertexs_triangle_text[3].y = max.y; 
    308                                 vertexs_triangle_text[3].z = - (normal.x * max.x + normal.y * max.y + distance) / normal.z; 
    309                                  
    310                                 vertexs_triangle_text[2].x = min.x; 
    311                                 vertexs_triangle_text[2].y = max.y; 
    312                                 vertexs_triangle_text[2].z =  -(normal.x * min.x + normal.y * max.y + distance) / normal.z; 
    313                         } 
    314                         break;   
    315         } 
    316         */ 
    317          
    318         //triangle2d_text = new Cluster2d; 
    319         //triangle2d_text->Create2d (this, 1, true); 
    320          
    321         Ogre::Vector3 v01_, v10_; 
    322          
    323         printf("\nvertexs del cluster \n"); 
    324  
    325         // Gametools -- Isma 17/08/2005 
    326         //for (int i = 0; i< 4; i++) 
    327         //      printf("%d - (%.4f, %.4f, %.4f)\n", i, vertexs_triangle_text[i].x, vertexs_triangle_text[i].y, vertexs_triangle_text[i].z); 
    328                  
    329         // Gametools -- Isma 17/08/2005  
    330         //v01_ = vertexs_triangle_text[1] - vertexs_triangle_text[0]; 
    331         //v10_ = vertexs_triangle_text[2] - vertexs_triangle_text[0]; 
    332          
    333         // Gametools -- Isma 17/08/2005 
    334         //lumel_origin = vertexs_triangle_text[0]; 
    335         //lumel_x_axis = Vector3 (v01_.x / ObscuranceRayTracing::Config::MapHeight , v01_.y / ObscuranceRayTracing::Config::MapHeight, v01_.z / ObscuranceRayTracing::Config::MapHeight); 
    336         //lumel_y_axis = Vector3 (v10_.x / ObscuranceRayTracing::Config::MapWidth, v10_.y / ObscuranceRayTracing::Config::MapWidth, v10_.z / ObscuranceRayTracing::Config::MapWidth); 
    337          
    338         // Gametools -- Isma 17/08/2005 
    339         //if (ObscuranceRayTracing::Config::Debug)  
    340         //{ 
    341         //      printf("Increment cada cop: (%.4f, %.4f, %.4f)\n", lumel_origin.x, lumel_origin.y, lumel_origin.z);                      
    342         //      printf("Increment cada cop:  (%.4f, %.4f, %.4f)\n", lumel_x_axis.x, lumel_x_axis.y, lumel_x_axis.z);     
    343         //      printf("Increment cada cop:  (%.4f, %.4f, %.4f)\n", lumel_y_axis.x, lumel_y_axis.y, lumel_y_axis.z);     
    344         //} 
    345         /* 
    346  
    347         Vector3 finalx, finaly, final; 
    348           
    349         finalx.x = lumel_origin.x + lumel_x_axis.x * ObscuranceRayTracing::Config::MapWidth; 
    350         finalx.y = lumel_origin.y + lumel_x_axis.y * ObscuranceRayTracing::Config::MapWidth; 
    351         finalx.z = lumel_origin.z + lumel_x_axis.z * ObscuranceRayTracing::Config::MapWidth; 
    352           
    353         finaly.x = lumel_origin.x + lumel_y_axis.x * ObscuranceRayTracing::Config::MapHeight; 
    354         finaly.y = lumel_origin.y + lumel_y_axis.y * ObscuranceRayTracing::Config::MapHeight; 
    355         finaly.z = lumel_origin.z + lumel_y_axis.z * ObscuranceRayTracing::Config::MapHeight; 
    356                  
    357         final.x = lumel_origin.x + lumel_x_axis.x * ObscuranceRayTracing::Config::MapWidth + lumel_y_axis.x * ObscuranceRayTracing::Config::MapHeight; 
    358         final.y = lumel_origin.y + lumel_x_axis.y * ObscuranceRayTracing::Config::MapWidth + lumel_y_axis.y * ObscuranceRayTracing::Config::MapHeight; 
    359         final.z = lumel_origin.z + lumel_x_axis.z * ObscuranceRayTracing::Config::MapWidth + lumel_y_axis.z * ObscuranceRayTracing::Config::MapHeight; 
    360          
    361         vertexs = new Vector3s[4]; 
    362         vertexs[0] = lumel_origin; 
    363         vertexs[1] = finalx; 
    364         vertexs[2] = finaly; 
    365         vertexs[3] = final; 
    366         */       
    367         /* 
    368         switch (axisproj) 
    369         { 
    370                 case 0: 
    371                         order = ORDER_6; break; 
    372                 case 1: 
    373                         order = ORDER_2; break; 
    374                 case 2: 
    375                         order = ORDER_0; break; 
    376         } 
    377         //order = 1; 
    378         if (ObscuranceRayTracing::Config::Debug) printf("\nOrder del triangle: %d", order); 
    379         */ 
     181 
     182        Ogre::LogManager::getSingleton().logMessage("Axisproj:" + Ogre::StringConverter::toString(axisproj)); 
    380183} 
    381184 
    382185//* Return the increment in U (lumel increment in x). For patchs calculation  
    383 Ogre::Vector3 Cluster::GetIncU() { 
    384   
     186Ogre::Vector3 Cluster::GetIncU()  
     187{  
    385188        return lumel_x_axis; 
    386189} 
    387190 
    388191//* Return the increment in V (lumel increment in x). For patchs calculation  
    389 Ogre::Vector3 Cluster::GetIncV() { 
    390   
     192Ogre::Vector3 Cluster::GetIncV()  
     193{ 
    391194        return lumel_y_axis; 
    392  
    393 } 
    394  
    395 //Vector3 GetOrigin() const { if (Inc) return Inc[0]; } 
    396  
    397 //* Return the origin. For patchs calculation  
    398 Ogre::Vector3 Cluster::GetOrigin() { 
    399   
     195} 
     196 
     197Ogre::Vector3 Cluster::GetOrigin()  
     198{ 
    400199        return lumel_origin; 
    401          
    402 } 
    403  
    404 // 
    405 //      void CreateVector3s() 
    406 //      {  
    407 //               
    408 //              //Vector3s = new Vector3[4]; 
    409 //              //Vector3s_triangle_text = new Vector3[4]; 
    410 //      } 
    411 //       
    412 bool Cluster::PointIn(Ogre::Vector3 & point) { 
    413          
    414         register unsigned int i = 0; 
    415         //Polygon2d poly2d; 
    416         Ogre::Vector2 point2d; 
    417         Ogre::Vector2 * vertexs2d; 
    418         Ogre::Vector3 v1, vp; 
    419          
    420         //printf("\ndins pointin cluster"); 
    421          
    422         // Gametools -- Isma 17/08/2005 
    423         //if (ObscuranceRayTracing::Config::Debug) printf("\nPointin\n"); 
    424          
    425         //int axis = poly2d.CreatePoly2d (this); 
    426          
    427         //poly2d.Print(); 
    428         //poly2d->Print(); 
    429          
    430         // GametoolsError -- Isma 17/08/2005 
    431         //point2d = point2d.ProjectVector33d (point, axisproj); 
    432         //if (bound->intersects ( &Vector3 (point2d.x, point2d.y, 0))) return true; 
    433          
    434         return false; 
    435         //point2d.Print(); 
    436          
    437         //if (poly2d_text) return poly2d_text->PointIn(point2d); 
    438         /*               
    439         poly2d_text->Print(); 
    440          
    441          
    442          
    443         //vertexs2d = poly2d.GetVector3s(); 
    444         //vertexs2d = poly2d->GetVector3s(); 
    445         poly2d_text->GetVector3s(); 
    446          
    447         //checks if clockwise orientation 
    448         /** 
    449         v1 = vertexs[i+1] - vertexs[i];          
    450         vp.x = point2d.x - vertexs[i].x; 
    451         vp.y = point2d.y - vertexs[i].y; 
    452          
    453         if ((v1.x * vp.y - vp.x * v1.y) < 0) 
    454         **/ 
    455         /* 
    456         for (; i < 3; i++) 
    457         { 
    458                 v1.x = vertexs2d[i+1].x - vertexs2d[i].x;                
    459                 v1.y = vertexs2d[i+1].y - vertexs2d[i].y;                
    460                  
    461                 vp.x = point2d.x - vertexs2d[i].x; 
    462                 vp.y = point2d.y - vertexs2d[i].y; 
    463                 v1.Print(); 
    464                 vp.Print(); 
    465                 printf("\nValor del determinant: %f", (v1.x * vp.y - vp.x * v1.y)); 
    466                 if ((v1.x * vp.y - vp.x * v1.y) > 0) return false; 
    467                  
    468         } 
    469         printf("\nEl punt està dins\n"); 
    470          
    471         return true;*/ 
    472200} 
    473201 
    474202unsigned int Cluster::ID_CLUSTER = 0; 
    475203 
    476 // Gametools -- Isma 17/08/2005 
    477 //Listid patchlistid; 
    478 //Listid trianglelistid; 
    479 int Cluster::CalcPatch(Ogre::Vector3 & point) { 
    480         return 0; 
    481 } 
    482  
    483 Cluster::~Cluster() { 
    484 } 
    485  
    486  
    487 } 
     204} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGCluster2d.cpp

    r699 r721  
    11 
    2 #include "IMGCluster2d.h" 
    3 #include "IMGCluster.h" 
     2#include <IMGCluster2d.h> 
     3#include <IMGCluster.h> 
    44 
    5 namespace IMG { 
     5namespace IMG  
     6{ 
    67 
    7 //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal. 
     8Cluster2d::Cluster2d()  
     9{ 
     10    Vector3s = NULL; 
     11    cluster =NULL; 
     12    normal = NULL; 
     13} 
     14 
     15Ogre::Vector2 * Cluster2d::GetVector3s() 
     16{  
     17        return Vector3s;  
     18} 
     19 
     20std::vector<Ogre::Vector2> * Cluster2d::GetVector3sVector()  
     21{  
     22        return &Vector3s2_vector;  
     23}  
     24 
     25Ogre::Vector3 * Cluster2d::GetNormal()  
     26{  
     27        return normal;  
     28} 
     29 
     30//* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant ERROR_MSG. 
    831//                       
    932//        
    10 int Cluster2d::Create2d(Cluster * cluster, int type, int type_vertexs) { 
    11         if (!cluster) return false; 
     33int Cluster2d::Create2d(Cluster * cluster, int type, int type_vertexs)  
     34{ 
     35        if (!cluster) 
     36        { 
     37                return false; 
     38        } 
    1239         
    1340        int axis = cluster->AxisProjected(); 
    14         Ogre::Vector3 *vertexs3d; 
    15         std::vector<Ogre::Vector3> vertexs3d_; 
    16         int num_vertexs = 4; 
    17          
    18         //printf("\nDins Create cluster2d axisproj: %d ", axis); 
    19          
    20          
    21          
    22         switch(type) 
    23         { 
    24                 //case 0:       vertexs3d = poly->GetVector3s(); break; 
    25                 case 0: vertexs3d_ = *cluster->GetVector3sVector(); break;               
    26                 //case 1: vertexs3d = poly->GetVector3sTex(); break; 
    27         } 
    28         /* 
    29         if (type_vertexs) num_vertexs = 3; 
    30         else num_vertexs = 4; 
    31         */ 
     41 
    3242        this->cluster = cluster; 
    33          
    34         //Vector2 * vertexs2d = new Vector2[4]; 
    35         // GametoolsError -- Isma 17/08/2005 
    36         //vertexs = new Vector2[4]; 
    37         //vertexs = new Vector2[vertexs3d_.size()]; 
    38          
    39         //normal = new Vector2; 
    40         normal = new Ogre::Vector3; 
    41         Ogre::Vector3 *normal3d = cluster->GetPlane()->GetNormal(); 
    42         Ogre::Box bound; 
    43          
    44          
    45         switch(axis) 
    46         { 
    47                 case (0): 
    48                         for (int i = 0; i < vertexs3d_.size(); i++) 
    49                         {        
    50                                 // GametoolsError -- Isma 17/08/2005 
    51                                 //vertexs[i].x = vertexs3d_[i].z; 
    52                                 //vertexs[i].y = vertexs3d_[i].y; 
    53                                 //vertexs2_vector.push_back(vertexs[i]); 
    5443 
    55                                 //printf("Assignat 0: (%.4f, %.4f)- (%.4f, %.4f)\n", vertexs3d_[i].z, vertexs3d_[i].y, vertexs[i].x, vertexs[i].y); 
    56                                 //bound.AddBoundingVector3 (vertexs[i].x, vertexs[i].y, 0);              
    57          
    58                         } 
    59                         break;                                   
    60                  
    61                   case (1): 
    62  
    63                          
    64                         for (int i = 0; i < vertexs3d_.size(); i++) 
    65                         { 
    66                                 // GametoolsError -- Isma 17/08/2005 
    67                                 //vertexs[i].x = vertexs3d_[i].x; 
    68                                 //vertexs[i].y = vertexs3d_[i].z; 
    69                                 //vertexs2_vector.push_back(vertexs[i]); 
    70                                 //printf("Assignat 1: (%.4f, %.4f)- (%.4f, %.4f)\n", vertexs3d_[i].x, vertexs3d_[i].z, vertexs[i].x, vertexs[i].y); 
    71                                 //bound.AddBoundingVector3 (vertexs[i].x, vertexs[i].y, 0);      
    72                         } 
    73                          
    74                         break; 
    75  
    76                 case(2): 
    77                         for (int i = 0; i < vertexs3d_.size(); i++) 
    78                         { 
    79                                 // GametoolsError -- Isma 17/08/2005 
    80                                 //vertexs[i].x = vertexs3d_[i].x; 
    81                                 //vertexs[i].y = vertexs3d_[i].y; 
    82                                 //vertexs2_vector.push_back(vertexs[i]); 
    83                                 //printf("Assignat 2: (%.4f, %.4f)- (%.4f, %.4f)\n", vertexs3d_[i].x, vertexs3d_[i].y, vertexs[i].x, vertexs[i].y); 
    84                                 //bound.AddBoundingVector3 (vertexs[i].x, vertexs[i].y, 0);      
    85                         } 
    86                  
    87                 break; 
    88         } 
    89  
    90          
    91         id = cluster->GetId(); 
    92         //printf("\n\nen 2d: "); 
    93         //Print(); 
    94         //printf("\n-----------------"); 
    9544        return axis; 
    9645} 
    9746 
    98 void Cluster2d::Print() { 
     47void Cluster2d::Print()  
     48{ 
    9949        printf("\nPrintant cluster2d: %d", id); 
    100         // GametoolsError -- Isma 17/08/2005 
    101         //if (!vertexs) return; 
    102          
    103         //printf("\nVector3 1 (%.4f, %.4f)  ", vertexs[0].x, vertexs[0].y); 
    104         //printf("\nVector3 2 (%.4f, %.4f)  ", vertexs[1].x, vertexs[1].y); 
    105         //printf("\nVector3 3 (%.4f, %.4f)  ", vertexs[2].x, vertexs[2].y);      
    106         //printf("\nVector3 3 (%.4f, %.4f)  ", vertexs[3].x, vertexs[3].y);      
    10750} 
    10851 
    109 Cluster2d::~Cluster2d() { 
     52Cluster2d::~Cluster2d()  
     53{ 
    11054} 
    11155 
    112  
    11356} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGClusterList.cpp

    r709 r721  
    11 
    2 #include "IMGClusterList.h" 
     2#include <IMGClusterList.h> 
    33 
    44namespace IMG { 
    5  
    6 // Gametools -- Isma 17/08/2005 
    7 //int Cluster::CalculaPatch (Vector3 &point) 
    8 //{ 
    9 //      //printf("\nCalculaPatch on està el vertex: (%.4f, %.4f, %.4f)", point.x, point.y, point.z);    
    10 //       
    11 //      //this->Print(); 
    12 //       
    13 //      int idpatch = this->CalcPatch (point); 
    14 //      if (ObscuranceRayTracing::Config::Debug) printf("\nEl idpatch calculat és: %d", idpatch); 
    15 //      int id = GetIdPatch(idpatch); 
    16 //      if (ObscuranceRayTracing::Config::Debug) printf("\nEl patch real és el : %d", id); 
    17 //      return id; 
    18 //} 
    19 // Gametools -- Isma 17/08/2005 
    20 // 
    21 //int Cluster::CalcPatch (Vector3 &point) 
    22 //{ 
    23 //      //printf("\nDins Calcular Patch, valor de la caixa: "); 
    24 //      //bound->Print(); 
    25 //      int x, y; 
    26 //      //Polygon2d poly2d; 
    27 //      //int axisproj;  
    28 //      Vector2 point2d; 
    29 //      //Box box; 
    30 //      Vector3 min, max; 
    31 //      //Vector2 *vertexs; 
    32 //      //int order; 
    33 //       
    34 //       
    35 //      //vertexs = poly2d_text->GetVector3s(); 
    36 //      //vertexs = triangle2d_text->GetVector3s(); 
    37 //       
    38 //      //printf("\nCalc Patch "); 
    39 //       
    40 //       
    41 //      //for (register unsigned int i = 0; i < 4; i++) 
    42 //      //{ 
    43 //      //      box.AddBoundingVector3 (vertexs[i].x, vertexs[i].y, 0);          
    44 //      //}      
    45 //       
    46 //       
    47 //       
    48 //      min = bound->GetMinimum();       
    49 //      max = bound->GetMaximum(); 
    50 //      //box.Print(); 
    51 //       
    52 //      point2d = point2d.ProjectVector33d (point, axisproj); 
    53 //      //printf("\nPoint2d: (%.4f, %.4f)", point2d.x, point2d.y); 
    54 //       
    55 //       
    56 //      switch (axisproj) 
    57 //      { 
    58 //               
    59 //              case 1: // 2 3 
    60 //                      // 0 1 
    61 //                               
    62 //                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (max.x - min.x)); 
    63 //                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (max.y - min.y)); 
    64 //                      return x + y * ObscuranceRayTracing::Config::MapWidth; 
    65 //              case 2: // 0 1 
    66 //                      // 2 3 
    67 // 
    68 //                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (max.x - min.x)); 
    69 //                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (min.y - max.y)); 
    70 //                      //printf("\nValor x: %d", x); 
    71 //                      //printf("\nValor y: %d", y); 
    72 //                       
    73 //                      if (x < 0) x = -x;      //arreglo temporal si no no va bé 
    74 //                      if (y < 0) y = -y; 
    75 //                      return x + y * ObscuranceRayTracing::Config::MapWidth; 
    76 //               
    77 //              case 0: // 3 2 
    78 //                      // 1 0 
    79 // 
    80 //                       
    81 //                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (min.x - max.x)); 
    82 //                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (max.y - min.y)); 
    83 //                       
    84 //                      //printf("\nValor x: %d", x); 
    85 //                      //printf("\nValor y: %d", y); 
    86 //                      if (x < 0) x = -x; 
    87 //                      if (y < 0) y = -y; 
    88 //                      return x + y * ObscuranceRayTracing::Config::MapWidth;           
    89 //      } 
    90 //       
    91 //      return -1; 
    92 //} 
    93 // 
    94 // Gametools -- Isma 17/08/2005 
    95 // 
    96 //bool Cluster::CreatePatches( bool dinamic) 
    97 //{ 
    98 //      if (ObscuranceRayTracing::Config::Debug)  
    99 //      { 
    100 //              printf("\n\nCreant Patches en cluster (%d), isdinamic %d\n\n", dinamic, GetId()); 
    101 //              printf("\nEl polygon es: "); 
    102 //              Print(); 
    103 //              //printf("\n-----------\n "); 
    104 //      } 
    105 //       
    106 //      //if (!Inc) return false; 
    107 //      //if (!vertexs) return false; 
    108 //                               
    109 //      int acum = 0; 
    110 //      register unsigned int i = 0, j = 0; 
    111 //      //Vector3 orig = Inc[0], valorx = Inc[1], valory = Inc[2]; 
    112 //       
    113 //       
    114 //      Vector3 orig, valorx, valory; 
    115 //       
    116 //      orig = lumel_origin; 
    117 //      valorx = lumel_x_axis; 
    118 //      valory = lumel_y_axis; 
    119 //       
    120 //      //if (ObscuranceRayTracing::Config::Debug) 
    121 //      { 
    122 //              printf("\nValor de origen: (%.4f, %.4f, %.4f)", lumel_origin.x, lumel_origin.y,lumel_origin.z); 
    123 //              printf("\nValor de Ax: (%.4f, %.4f, %.4f)", lumel_x_axis.x, lumel_x_axis.y, lumel_x_axis.z); 
    124 //              printf("\nValor de Ay: (%.4f, %.4f, %.4f)", lumel_y_axis.x, lumel_y_axis.y, lumel_y_axis.z); 
    125 //      } 
    126 //       
    127 //      Vector3 p0, p1, p2, p3; 
    128 //       
    129 //       
    130 //      patchlistid.GetList()->reserve ( ObscuranceRayTracing::Config::MapHeight * ObscuranceRayTracing::Config::MapWidth); 
    131 //      int cont = 0; 
    132 //      for (; j <  ObscuranceRayTracing::Config::MapHeight; j++) 
    133 //      {                
    134 //              i = 0; 
    135 //              for (i = 0; i < ObscuranceRayTracing::Config::MapWidth; i++) 
    136 //              {                        
    137 //                      Patch * patch = new Patch;                                               
    138 //                      patch->SetCoord (i, j); 
    139 //                      //patch->SetCoord (j, i); 
    140 //                      patch->SetIdLumel(i + j + acum); 
    141 //                      patch->SetCluster (this); 
    142 //                       
    143 //                      if (dinamic) patch->dinamic = dinamic; 
    144 //                       
    145 //                       
    146 //                      Patch::seqid++;                  
    147 //                                               
    148 //                      //if (ObscuranceRayTracing::Config::Debug) patch->Print(2); 
    149 //                       
    150 //                      patchlistid.Insert(patch->GetId());     //add the id (index) to polygon's patchlistid 
    151 //                       
    152 //                      //if (dinamic) ObscuranceRayTracing::patchlistdinamic.Insert(patch); 
    153 //                      //else ObscuranceRayTracing::patchlist.Insert(patch); 
    154 //                       
    155 //                      ObscuranceRayTracing::patchlist_triangle.Insert(patch); 
    156 //                      //ObscuranceRayTracing::patchlist_cluster.Insert(patch); 
    157 //                      //patch->Print(2); 
    158 //                       
    159 //                      delete patch; 
    160 //                      cont++; 
    161 //              } 
    162 //                       
    163 //              acum = acum + ObscuranceRayTracing::Config::MapWidth - 1;       //el id del patch segÃŒent acum += lightmap_del_polygon->GetWidth() - 1 
    164 //      } 
    165 //       
    166 //      //if (ObscuranceRayTracing::Config::Debug)  
    167 //              printf("\n\nLlista de indexs de patchs del polygon: %d" , patchlistid.GetSize()); 
    168 //      return true; 
    169 //} 
    170 // 
    171  
    172 bool ClusterList::Insert(Cluster * p) { 
    173         if (!p) return false; 
    174         //printf("\nInserting polygon"); 
    175         //p->Print();    
    176         //list.push_back(p); 
    177         //printf("\nInsert polygon: INsert\n"); 
    178         list.push_back(*p); 
    179         //printf("\nInsert polygon: INsert fora\n"); 
    180         return true; 
    181 } 
    182  
    183 void ClusterList::Print() { 
    184         printf("\n\n\nNombre de  cluster a la llista: %d --> ", list.size()); 
    185         for (register int i = 0; i < list.size(); i ++) 
    186         { 
    187                 //printf( "%d", GetPolygon(i)->GetId()); 
    188                 Get(i)->Print(); 
    189         } 
    190          
    191 } 
    1925 
    1936ClusterList::~ClusterList()  
     
    1969} 
    19710 
     11bool ClusterList::Insert(Cluster * p)  
     12{ 
     13        if (!p) 
     14        { 
     15                return false; 
     16        } 
     17 
     18        list.push_back(*p); 
     19         
     20        return true; 
     21} 
     22 
     23void ClusterList::Print()  
     24{ 
     25        Ogre::LogManager::getSingleton().logMessage("nNombre de  cluster a la llista: " + Ogre::StringConverter::toString(list.size())); 
     26        for (register int i = 0; i < list.size(); i ++) 
     27        { 
     28                Get(i)->Print(); 
     29        }        
     30} 
     31 
     32ClusterList::ClusterList()  
     33{ 
     34    list.reserve(100); 
     35} 
     36 
     37std::vector<Cluster> * ClusterList::GetList()  
     38{ 
     39        return &list; 
     40} 
     41 
     42unsigned int ClusterList::GetSize() const 
     43{  
     44        return list.size();  
     45} 
     46 
     47Cluster * ClusterList::Get(unsigned int i)  
     48{ 
     49    if (i <= list.size()) 
     50        { 
     51                return &list[i]; 
     52        } 
     53     
     54    return NULL; 
     55} 
    19856 
    19957} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGNodeBsp.cpp

    r699 r721  
    11 
    2 #include "IMGNodeBsp.h" 
     2#include <IMGNodeBsp.h> 
    33 
    4 namespace IMG { 
     4namespace IMG  
     5{ 
    56 
    6 NodeBsp::NodeBsp(){ 
    7         child[0] = NULL; 
    8         child[1] = NULL; 
    9         //bound.StartBoundingBox(); 
    10         bound = NULL; 
    11         //id= NodeBsp::ID++; 
     7NodeBsp::NodeBsp(): references(0) // initialize references to 0  
     8{ 
    129        id = -1; 
    1310        fit = false; 
    1411} 
    1512 
    16 Box2d * NodeBsp::GetBound() { 
    17   
    18         return bound;    
     13NodeBsp::~NodeBsp()  
     14{ 
    1915} 
    2016 
    21 void NodeBsp::Print() { 
    22         printf("\nNode : %d, fit: %d", id, fit); 
    23         if (bound) bound->Print(); 
    24         //if (plane) plane->Print(); 
     17void NodeBsp::SetBound(Box2d * box)  
     18{  
     19        bound = (*box);  
    2520} 
    2621 
    27 //void SetPlane (Plane3 *pla) { plane = pla; } 
    28 //Plane3 * GetPlane () { return plane; } 
    29 NodeBsp * NodeBsp::Insert(int w, int h) { 
    30         //printf("\nInsert del node: :%d (%d, %d)\n", id, w,  h); 
     22NodeBspPtr NodeBsp::GetChild(int i)  
     23{  
     24        return child[i];  
     25} 
     26 
     27void NodeBsp::SetId(int id_)  
     28{  
     29        id = id_;  
     30} 
     31 
     32unsigned int NodeBsp::GetId() const 
     33{  
     34        return id;  
     35} 
     36 
     37void NodeBsp::SetChild(NodeBspPtr node, int i)  
     38{  
     39        child[i] = node;  
     40} 
     41 
     42NodeBspPtr NodeBsp::Get(NodeBspPtr node, int i)  
     43{ 
     44    if (!node) 
     45        { 
     46                return NULL; 
     47        } 
     48 
     49    if (node->GetId() == i ) 
     50        { 
     51                return node; 
     52        } 
     53     
     54    NodeBspPtr nod;  
     55    if (nod = node->GetChild(0)->Get(node->GetChild(0), i))  
     56        { 
     57                return nod; 
     58        } 
     59     
     60    return node->GetChild(0)->Get(node->GetChild(1), i); 
     61} 
     62 
     63 
     64Box2d * NodeBsp::GetBound()  
     65{  
     66        return &bound;    
     67} 
     68 
     69void NodeBsp::Print()  
     70{ 
     71        Ogre::LogManager::getSingleton().logMessage("Node : " + Ogre::StringConverter::toString(id) + ", fit: " + Ogre::StringConverter::toString(fit)); 
     72 
     73        bound.Print(); 
     74} 
     75 
     76NodeBspPtr NodeBsp::Insert(int w, int h)  
     77{ 
     78        //Ogre::LogManager::getSingleton().logMessage("\nInsert del node: :" + Ogre::StringConverter::toString(id) + " (" + Ogre::StringConverter::toString(w) + ", " + Ogre::StringConverter::toString(h)); 
    3179         
    32         if (this->fit == true) return NULL; 
     80        if (this->fit == true) 
     81        { 
     82                return NULL; 
     83        } 
    3384         
    3485        if (this->child[0] != NULL && this->child[1] != NULL) 
    3586        { 
    36                 NodeBsp * new_node = child[0]->Insert (w, h); 
     87                NodeBspPtr new_node = child[0]->Insert(w, h); 
    3788                 
    3889                if (new_node) return new_node; 
     
    4192        } 
    4293         
    43         if (!bound->In (w,h)) {//printf("\nNo hi quep!!!\n");  
    44                                 return NULL; } 
     94        if (!bound.In (w,h))  
     95        { 
     96                return NULL;  
     97        } 
    4598         
    46         if (bound->FitPerfect(w,h)){ //printf("\nFit Perfectly: \n");  
    47                                 fit = true;  return this; } 
     99        if (bound.FitPerfect(w,h)) 
     100        { 
     101                fit = true;  return this;  
     102        } 
    48103         
    49         child[0] = new NodeBsp; 
    50         child[1] = new NodeBsp; 
     104        child[0] = NodeBspPtr(new NodeBsp); 
     105        child[1] = NodeBspPtr(new NodeBsp); 
    51106         
    52107        int dw, dh; 
     
    54109        float width, height; 
    55110         
    56         bound->Print(); 
    57         min = bound->GetMinimum(); 
    58         max = bound->GetMaximum(); 
     111        bound.Print(); 
     112        min = bound.GetMinimum(); 
     113        max = bound.GetMaximum(); 
    59114         
    60115        width = max.x - min.x; 
    61116        height = max.y - min.y; 
    62117         
    63         //printf("\nwidth: %.4f\n", width); 
    64         //printf("\nheigth: %.4f\n", height); 
    65          
    66118        dw = (int) width - w; 
    67119        dh = (int) height - h; 
    68120         
    69         //printf("\n Valor dw: %d\n", dw); 
    70         //printf("\n Valor dh: %d\n", dh); 
    71          
    72         child[0]->bound = new Box2d; 
    73         child[1]->bound = new Box2d; 
    74          
    75121        if (dw > dh) 
    76122        {        
    77                 /* 
    78                 child[0]->bound->SetBoundBox(   min.x                   , max.y,  
    79                                                 min.x + width - 1       , min.y);                
    80                 child[1]->bound->SetBoundBox(   min.x + width           , max.y,  
    81                                                 max.x                   , min.y);                                
    82                 */ 
    83                 child[0]->bound->SetBoundBox(   min.x                   , min.y,  
    84                                                 min.x + w               , max.y);                
    85                                                 //min.x + w - 1         , max.y);                
    86                 //child[1]->bound->SetBoundBox( min.x + w + 1           , min.y,  
    87                 child[1]->bound->SetBoundBox(   min.x + w               , min.y,  
    88                                                 max.x                   , max.y);                                                                                
     123                child[0]->bound.SetBoundBox(min.x, min.y, min.x + w, max.y);             
     124                child[1]->bound.SetBoundBox(min.x + w, min.y, max.x, max.y);                                                                             
    89125        } 
    90126        else 
    91127        {                
    92                 //child[0]->bound->SetBoundBox( min.x                   , max.y,  
    93                 //                              max.x                   , max.y + height - 1); 
    94                 child[0]->bound->SetBoundBox(   min.x                   , max.y - h , 
    95                 //child[0]->bound->SetBoundBox( min.x                   , max.y - h - 1 , 
    96                                                 max.x                   , max.y 
    97                                                 ); 
    98                                                  
    99                 //child[1]->bound->SetBoundBox( min.x                   , max.y + height,  
    100                 //                              max.x                   , min.y); 
    101                 child[1]->bound->SetBoundBox(   min.x                   , min.y, 
    102                                                 //max.x                 , max.y - h -1 
    103                                                 max.x                   , max.y - h  
    104                                                 ); 
     128                child[0]->bound.SetBoundBox(min.x, max.y - h, max.x, max.y); 
     129                child[1]->bound.SetBoundBox(min.x, min.y, max.x, max.y - h); 
    105130        } 
    106131         
    107         //printf("\nImprimint child[0]: \n"); 
    108         //child[0]->Print(); 
    109         //printf("\nImprimint child[1]: \n"); 
    110         //child[1]->Print(); 
    111          
    112         return child[0]->Insert (w, h); 
     132        return child[0]->Insert(w, h); 
    113133} 
    114134 
    115135unsigned int NodeBsp::ID = 0; 
    116136 
    117 NodeBsp::~NodeBsp() { 
    118137} 
    119  
    120  
    121 } 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGPlane3.cpp

    r699 r721  
    11 
    2 #include "IMGPlane3.h" 
     2#include <IMGPlane3.h> 
    33 
    44namespace IMG { 
    55 
    6 Plane3::~Plane3() { 
     6Plane3::Plane3() 
     7{ 
    78} 
    89 
     10Plane3::~Plane3()  
     11{ 
     12} 
     13 
     14Plane3 & Plane3::operator =(const Plane3 & p)  
     15{ 
     16    normal.x = p.normal.x; 
     17    normal.y = p.normal.y; 
     18    normal.z = p.normal.z; 
     19    d = p.d;             
     20    return *this; 
     21} 
     22 
     23Ogre::Vector3 * Plane3::GetNormal()  
     24{ 
     25        Ogre::Vector3 *v = new Ogre::Vector3; 
     26    v->x = normal.x; 
     27    v->y = normal.y; 
     28    v->z = normal.z; 
     29    return v; 
     30} 
     31 
     32void Plane3::SetNormal(float x, float y, float z)  
     33{ 
     34    normal.x = x; 
     35    normal.y = y; 
     36    normal.z = z;                
     37} 
     38 
     39void Plane3::SetDistance(float dist)  
     40{ 
     41    d = dist; 
     42} 
     43 
     44float Plane3::GetDistance() const  
     45{  
     46        return d; 
     47} 
     48 
     49void Plane3::Print()  
     50{ 
     51        Ogre::LogManager::getSingleton().logMessage("Printant pla: (" + Ogre::StringConverter::toString(normal) + Ogre::StringConverter::toString(d) + ")"); 
     52} 
    953 
    1054} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardKMeansClusterData.cpp

    r699 r721  
    1010} 
    1111 
    12  
    13 } 
     12void BillboardKMeansClusterData::readBillboardClusterData(TiXmlNode *parentNode) 
     13{ 
     14 
     15} 
     16 
     17void BillboardKMeansClusterData::writeBillboardClusterData(TiXmlNode *parentNode) 
     18{ 
     19        BBC::EntityClusterPtr entityCluster = getEntityCluster(); 
     20        Ogre::Vector3 normal = getNormal(); 
     21        normal.normalise(); 
     22 
     23        float d = 0; 
     24        for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
     25        { 
     26                LeafKMeansClusterData *leafKMeansClusterData = (LeafKMeansClusterData*)entityCluster->getEntityClusterData(iLeaf).get(); 
     27                Leaf *leaf = (Leaf*)leafKMeansClusterData->getEntity().get(); 
     28                d = d + leaf->getPosition().dotProduct(normal); 
     29        }        
     30        d = - d / entityCluster->getNumEntitiesClusterData(); 
     31         
     32        TiXmlNode *billboardNode; 
     33        TiXmlNode *coord4dNode; 
     34        TiXmlNode *quadTopRightCornerNode; 
     35        TiXmlNode *quadTopLeftCornerNode; 
     36        TiXmlNode *quadBottomRightCornerNode; 
     37        TiXmlNode *quadBottomLeftCornerNode; 
     38        TiXmlNode *axisXNode; 
     39        TiXmlNode *axisYNode; 
     40        TiXmlNode *axisZNode; 
     41        TiXmlNode *leavesNode; 
     42        TiXmlNode *leafNode; 
     43        billboardNode = parentNode->ToElement()->InsertEndChild(TiXmlElement("billboard"))->ToElement(); 
     44 
     45        coord4dNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("coord4d"))->ToElement(); 
     46        Ogre::String sNX = Ogre::StringConverter::toString(normal.x); 
     47        coord4dNode->ToElement()->SetAttribute("nx",sNX.c_str()); 
     48        Ogre::String sNY = Ogre::StringConverter::toString(normal.y); 
     49        coord4dNode->ToElement()->SetAttribute("ny",sNY.c_str()); 
     50        Ogre::String sNZ = Ogre::StringConverter::toString(normal.z); 
     51        coord4dNode->ToElement()->SetAttribute("nz",sNZ.c_str()); 
     52        Ogre::String sD = Ogre::StringConverter::toString(d); 
     53        coord4dNode->ToElement()->SetAttribute("d",sD.c_str()); 
     54         
     55        quadTopLeftCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("topLeft"))->ToElement(); 
     56        Ogre::String sTLX = Ogre::StringConverter::toString(getQuadTopLeftCorner().x); 
     57        quadTopLeftCornerNode->ToElement()->SetAttribute("x",sTLX.c_str()); 
     58        Ogre::String sTLY = Ogre::StringConverter::toString(getQuadTopLeftCorner().y); 
     59        quadTopLeftCornerNode->ToElement()->SetAttribute("y",sTLY.c_str()); 
     60        Ogre::String sTLZ = Ogre::StringConverter::toString(getQuadTopLeftCorner().z); 
     61        quadTopLeftCornerNode->ToElement()->SetAttribute("z",sTLZ.c_str());      
     62 
     63        quadTopRightCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("topRight"))->ToElement(); 
     64        Ogre::String sTRX = Ogre::StringConverter::toString(getQuadTopRightCorner().x); 
     65        quadTopRightCornerNode->ToElement()->SetAttribute("x",sTRX.c_str()); 
     66        Ogre::String sTRY = Ogre::StringConverter::toString(getQuadTopRightCorner().y); 
     67        quadTopRightCornerNode->ToElement()->SetAttribute("y",sTRY.c_str()); 
     68        Ogre::String sTRZ = Ogre::StringConverter::toString(getQuadTopRightCorner().z); 
     69        quadTopRightCornerNode->ToElement()->SetAttribute("z",sTRZ.c_str());     
     70 
     71        quadBottomRightCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("bottomRight"))->ToElement(); 
     72        Ogre::String sBRX = Ogre::StringConverter::toString(getQuadBottomRightCorner().x); 
     73        quadBottomRightCornerNode->ToElement()->SetAttribute("x",sBRX.c_str()); 
     74        Ogre::String sBRY = Ogre::StringConverter::toString(getQuadBottomRightCorner().y); 
     75        quadBottomRightCornerNode->ToElement()->SetAttribute("y",sBRY.c_str()); 
     76        Ogre::String sBRZ = Ogre::StringConverter::toString(getQuadBottomRightCorner().z); 
     77        quadBottomRightCornerNode->ToElement()->SetAttribute("z",sBRZ.c_str());  
     78 
     79        quadBottomLeftCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("bottomLeft"))->ToElement(); 
     80        Ogre::String sBLX = Ogre::StringConverter::toString(getQuadBottomLeftCorner().x); 
     81        quadBottomLeftCornerNode->ToElement()->SetAttribute("x",sBLX.c_str()); 
     82        Ogre::String sBLY = Ogre::StringConverter::toString(getQuadBottomLeftCorner().y); 
     83        quadBottomLeftCornerNode->ToElement()->SetAttribute("y",sBLY.c_str()); 
     84        Ogre::String sBLZ = Ogre::StringConverter::toString(getQuadBottomLeftCorner().z); 
     85        quadBottomLeftCornerNode->ToElement()->SetAttribute("z",sBLZ.c_str());   
     86 
     87        axisYNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisX"))->ToElement(); 
     88        Ogre::String sAXX = Ogre::StringConverter::toString(getAxisX().x); 
     89        axisYNode->ToElement()->SetAttribute("x",sAXX.c_str()); 
     90        Ogre::String sAXY = Ogre::StringConverter::toString(getAxisX().y); 
     91        axisYNode->ToElement()->SetAttribute("y",sAXY.c_str()); 
     92        Ogre::String sAXZ = Ogre::StringConverter::toString(getAxisX().z); 
     93        axisYNode->ToElement()->SetAttribute("z",sAXZ.c_str());  
     94 
     95        axisYNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisY"))->ToElement(); 
     96        Ogre::String sAYX = Ogre::StringConverter::toString(getAxisY().x); 
     97        axisYNode->ToElement()->SetAttribute("x",sAYX.c_str()); 
     98        Ogre::String sAYY = Ogre::StringConverter::toString(getAxisY().y); 
     99        axisYNode->ToElement()->SetAttribute("y",sAYY.c_str()); 
     100        Ogre::String sAYZ = Ogre::StringConverter::toString(getAxisY().z); 
     101        axisYNode->ToElement()->SetAttribute("z",sAYZ.c_str());  
     102 
     103        axisZNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisZ"))->ToElement(); 
     104        Ogre::String sAZX = Ogre::StringConverter::toString(getAxisZ().x); 
     105        axisZNode->ToElement()->SetAttribute("x",sAZX.c_str()); 
     106        Ogre::String sAZY = Ogre::StringConverter::toString(getAxisZ().y); 
     107        axisZNode->ToElement()->SetAttribute("y",sAZY.c_str()); 
     108        Ogre::String sAZZ = Ogre::StringConverter::toString(getAxisZ().z); 
     109        axisZNode->ToElement()->SetAttribute("z",sAZZ.c_str());  
     110 
     111        leavesNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("leaves"))->ToElement(); 
     112        Ogre::String sLeaves = Ogre::StringConverter::toString(entityCluster->getNumEntitiesClusterData()); 
     113        leavesNode->ToElement()->SetAttribute("count",sLeaves.c_str()); 
     114         
     115        for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
     116        { 
     117                LeafKMeansClusterData *leafKMeansClusterData = (LeafKMeansClusterData*)entityCluster->getEntityClusterData(iLeaf).get(); 
     118                Leaf *leaf = (Leaf*)leafKMeansClusterData->getEntity().get(); 
     119                leafNode = leavesNode->ToElement()->InsertEndChild(TiXmlElement("leaf"))->ToElement(); 
     120                Ogre::String sLeaf = Ogre::StringConverter::toString(leaf->getEntityHandle()); 
     121                leafNode->ToElement()->SetAttribute("id",sLeaf.c_str()); 
     122        } 
     123} 
     124 
     125void BillboardKMeansClusterData::generateBillboardBoundingQuad()  
     126{ 
     127         
     128        Ogre::Vector3 normal = getNormal(); 
     129        Ogre::Vector3 planePosition; 
     130        float d = getD(); 
     131 
     132        normal.normalise(); 
     133 
     134        if ((abs(normal[0] > abs(normal[1])) && (abs(normal[0] > abs(normal[2]))))) 
     135        { 
     136                planePosition[0] = -d / normal[0]; 
     137                planePosition[1] = 0; 
     138                planePosition[2] = 0; 
     139        } 
     140        else if ((abs(normal[1] > abs(normal[0])) && (abs(normal[1] > abs(normal[2]))))) 
     141        { 
     142                planePosition[0] = 0; 
     143                planePosition[1] = -d / normal[1]; 
     144                planePosition[2] = 0; 
     145        } 
     146        else 
     147        { 
     148                planePosition[0] = 0; 
     149                planePosition[1] = 0; 
     150                planePosition[2] = -d / normal[2]; 
     151        } 
     152         
     153        mAxisX = normal.perpendicular(); 
     154        mAxisX.normalise(); 
     155        mAxisY = normal.crossProduct(mAxisX);    
     156        mAxisY.normalise(); 
     157        mAxisZ = normal; 
     158 
     159        Ogre::Matrix4 coordPlane; 
     160        Ogre::Matrix4 constCoord; 
     161        Ogre::Matrix4 invMCoordPlane; 
     162 
     163        coordPlane[0][0] = mAxisX.x; 
     164        coordPlane[0][1] = mAxisX.y; 
     165        coordPlane[0][2] = mAxisX.z; 
     166        coordPlane[0][3] = 0.0f; 
     167        coordPlane[1][0] = mAxisY.x; 
     168        coordPlane[1][1] = mAxisY.y; 
     169        coordPlane[1][2] = mAxisY.z; 
     170        coordPlane[1][3] = 0.0f; 
     171        coordPlane[2][0] = mAxisZ.x; 
     172        coordPlane[2][1] = mAxisZ.y; 
     173        coordPlane[2][2] = mAxisZ.z; 
     174        coordPlane[2][3] = 0.0f; 
     175        coordPlane[3][0] = planePosition.x; 
     176        coordPlane[3][1] = planePosition.y; 
     177        coordPlane[3][2] = planePosition.z; 
     178        coordPlane[3][3] = 1.0f; 
     179 
     180        invMCoordPlane = coordPlane.inverse(); 
     181 
     182        constCoord[0][0] = 1.0f; 
     183        constCoord[0][1] = 0.0f; 
     184        constCoord[0][2] = 0.0f; 
     185        constCoord[0][3] = 0.0f; 
     186        constCoord[1][0] = 0.0f; 
     187        constCoord[1][1] = 1.0f; 
     188        constCoord[1][2] = 0.0f; 
     189        constCoord[1][3] = 0.0f; 
     190        constCoord[2][0] = 0.0f; 
     191        constCoord[2][1] = 0.0f; 
     192        constCoord[2][2] = 0.0f; 
     193        constCoord[2][3] = 0.0f; 
     194        constCoord[3][0] = 0.0f; 
     195        constCoord[3][1] = 0.0f; 
     196        constCoord[3][2] = 0.0f; 
     197        constCoord[3][3] = 1.0f; 
     198 
     199        float xMax = -FLT_MAX; 
     200        float xMin = FLT_MAX; 
     201        float yMax = -FLT_MAX; 
     202        float yMin = FLT_MAX; 
     203 
     204        Ogre::Vector3 vXmax; 
     205        Ogre::Vector3 vXmin; 
     206        Ogre::Vector3 vYmax; 
     207        Ogre::Vector3 vYmin; 
     208 
     209        BBC::EntityClusterPtr entityCluster = getEntityCluster(); 
     210        BBC::EntityPtr entity = entityCluster->getEntity(); 
     211 
     212        for (unsigned int iVertex = 0; iVertex < entity->getSubEntity(0)->getNumVertices(); iVertex++) 
     213        {                                
     214                Ogre::Vector3 position = entity->getSubEntity(0)->getPosition(iVertex); 
     215                Ogre::Vector4 projPointP1d4 =  Ogre::Vector4(position.x,position.y,position.z,1.0f) * invMCoordPlane * constCoord * coordPlane; 
     216         
     217                // The point projected in the plane 
     218                Ogre::Vector3 projPointP1(projPointP1d4.x,projPointP1d4.y,projPointP1d4.z); 
     219 
     220                float v1 = normal.dotProduct(planePosition); 
     221                float v2 = normal.dotProduct(position); 
     222                float t = v1 - v2; 
     223                projPointP1 = position + (normal * t); 
     224 
     225                float x1 = mAxisX.dotProduct(projPointP1 - planePosition); 
     226                float y1 = mAxisY.dotProduct(projPointP1 - planePosition); 
     227                float z1 = mAxisZ.dotProduct(projPointP1 - planePosition);               
     228                 
     229                if (x1 > xMax) 
     230                { 
     231                        xMax = x1; 
     232                        vXmax = projPointP1; 
     233                } 
     234                if (x1 < xMin) 
     235                { 
     236                        xMin = x1; 
     237                        vXmin = projPointP1; 
     238                } 
     239                if (y1 > yMax) 
     240                { 
     241                        yMax = y1; 
     242                        vYmax = projPointP1; 
     243                } 
     244                if (y1 < yMin) 
     245                { 
     246                        yMin = y1; 
     247                        vYmin = projPointP1; 
     248                }                
     249        } 
     250 
     251        Ogre::Vector3 aP; 
     252        Ogre::Vector3 bP; 
     253        Ogre::Vector3 pP; 
     254        Ogre::Vector3 abV; 
     255        Ogre::Vector3 apV; 
     256        Ogre::Vector3 dProdV; 
     257        float aLength; 
     258        float abLength; 
     259        float dist; 
     260        Ogre::Vector3 intersectP; 
     261 
     262        aP = vYmin; 
     263        bP = vYmin + mAxisX; 
     264        pP = vXmin; 
     265        abV = bP - aP; 
     266        apV = pP - aP; 
     267        dProdV = abV.crossProduct(apV); 
     268        aLength = dProdV.length(); 
     269        abLength = abV.length(); 
     270        dist = aLength / abLength; 
     271        mBillboardCorners[QUAD_TOP_LEFT] = pP + (mAxisY * (-dist)); 
     272 
     273        aP = vYmax; 
     274        bP = vYmax + mAxisX; 
     275        pP = vXmax; 
     276        abV = bP - aP; 
     277        apV = pP - aP; 
     278        dProdV = abV.crossProduct(apV); 
     279        aLength = dProdV.length(); 
     280        abLength = abV.length(); 
     281        dist = aLength / abLength; 
     282        mBillboardCorners[QUAD_BOTTOM_RIGHT] = pP + (mAxisY * dist); 
     283 
     284        aP = vXmax; 
     285        bP = vXmax + mAxisY; 
     286        pP = vYmin; 
     287        abV = bP - aP; 
     288        apV = pP - aP; 
     289        dProdV = abV.crossProduct(apV); 
     290        aLength = dProdV.length(); 
     291        abLength = abV.length(); 
     292        dist = aLength / abLength; 
     293        mBillboardCorners[QUAD_BOTTOM_LEFT] = pP + (mAxisX * dist); 
     294 
     295        Ogre::Vector3 vDirWidth = mBillboardCorners[QUAD_BOTTOM_LEFT] - mBillboardCorners[QUAD_BOTTOM_RIGHT]; 
     296        float distWidth = vDirWidth.length(); 
     297        mBillboardCorners[QUAD_TOP_RIGHT] = mBillboardCorners[QUAD_TOP_LEFT] + (mAxisY * distWidth); 
     298} 
     299 
     300} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardKdTreeClusterData.cpp

    r699 r721  
    1010} 
    1111 
    12 void BillboardKdTreeClusterData::readBillboardClusterData(TiXmlNode *parentNode) 
    13 { 
    1412 
    1513} 
    16  
    17 void BillboardKdTreeClusterData::writeBillboardClusterData(TiXmlNode *parentNode) 
    18 { 
    19         BBC::EntityCluster *entityCluster = getEntityCluster(); 
    20         Ogre::Vector3 normal = getNormal(); 
    21         normal.normalise(); 
    22  
    23         float d = 0; 
    24         for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
    25         { 
    26                 LeafKdTreeClusterData *leafKdTreeClusterData = (LeafKdTreeClusterData*)entityCluster->getEntityClusterData(iLeaf); 
    27                 Leaf *leaf = (Leaf*)leafKdTreeClusterData->getEntity(); 
    28                 d = d + leaf->getPosition().dotProduct(normal); 
    29         }        
    30         d = - d / entityCluster->getNumEntitiesClusterData(); 
    31          
    32         TiXmlNode *billboardNode; 
    33         TiXmlNode *coord4dNode; 
    34         TiXmlNode *quadTopRightCornerNode; 
    35         TiXmlNode *quadTopLeftCornerNode; 
    36         TiXmlNode *quadBottomRightCornerNode; 
    37         TiXmlNode *quadBottomLeftCornerNode; 
    38         TiXmlNode *axisXNode; 
    39         TiXmlNode *axisYNode; 
    40         TiXmlNode *axisZNode; 
    41         TiXmlNode *leavesNode; 
    42         TiXmlNode *leafNode; 
    43         billboardNode = parentNode->ToElement()->InsertEndChild(TiXmlElement("billboard"))->ToElement(); 
    44  
    45         coord4dNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("coord4d"))->ToElement(); 
    46         Ogre::String sNX = Ogre::StringConverter::toString(normal.x); 
    47         coord4dNode->ToElement()->SetAttribute("nx",sNX.c_str()); 
    48         Ogre::String sNY = Ogre::StringConverter::toString(normal.y); 
    49         coord4dNode->ToElement()->SetAttribute("ny",sNY.c_str()); 
    50         Ogre::String sNZ = Ogre::StringConverter::toString(normal.z); 
    51         coord4dNode->ToElement()->SetAttribute("nz",sNZ.c_str()); 
    52         Ogre::String sD = Ogre::StringConverter::toString(d); 
    53         coord4dNode->ToElement()->SetAttribute("d",sD.c_str()); 
    54          
    55         quadTopLeftCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("topLeft"))->ToElement(); 
    56         Ogre::String sTLX = Ogre::StringConverter::toString(getQuadTopLeftCorner().x); 
    57         quadTopLeftCornerNode->ToElement()->SetAttribute("x",sTLX.c_str()); 
    58         Ogre::String sTLY = Ogre::StringConverter::toString(getQuadTopLeftCorner().y); 
    59         quadTopLeftCornerNode->ToElement()->SetAttribute("y",sTLY.c_str()); 
    60         Ogre::String sTLZ = Ogre::StringConverter::toString(getQuadTopLeftCorner().z); 
    61         quadTopLeftCornerNode->ToElement()->SetAttribute("z",sTLZ.c_str());      
    62  
    63         quadTopRightCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("topRight"))->ToElement(); 
    64         Ogre::String sTRX = Ogre::StringConverter::toString(getQuadTopRightCorner().x); 
    65         quadTopRightCornerNode->ToElement()->SetAttribute("x",sTRX.c_str()); 
    66         Ogre::String sTRY = Ogre::StringConverter::toString(getQuadTopRightCorner().y); 
    67         quadTopRightCornerNode->ToElement()->SetAttribute("y",sTRY.c_str()); 
    68         Ogre::String sTRZ = Ogre::StringConverter::toString(getQuadTopRightCorner().z); 
    69         quadTopRightCornerNode->ToElement()->SetAttribute("z",sTRZ.c_str());     
    70  
    71         quadBottomRightCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("bottomRight"))->ToElement(); 
    72         Ogre::String sBRX = Ogre::StringConverter::toString(getQuadBottomRightCorner().x); 
    73         quadBottomRightCornerNode->ToElement()->SetAttribute("x",sBRX.c_str()); 
    74         Ogre::String sBRY = Ogre::StringConverter::toString(getQuadBottomRightCorner().y); 
    75         quadBottomRightCornerNode->ToElement()->SetAttribute("y",sBRY.c_str()); 
    76         Ogre::String sBRZ = Ogre::StringConverter::toString(getQuadBottomRightCorner().z); 
    77         quadBottomRightCornerNode->ToElement()->SetAttribute("z",sBRZ.c_str());  
    78  
    79         quadBottomLeftCornerNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("bottomLeft"))->ToElement(); 
    80         Ogre::String sBLX = Ogre::StringConverter::toString(getQuadBottomLeftCorner().x); 
    81         quadBottomLeftCornerNode->ToElement()->SetAttribute("x",sBLX.c_str()); 
    82         Ogre::String sBLY = Ogre::StringConverter::toString(getQuadBottomLeftCorner().y); 
    83         quadBottomLeftCornerNode->ToElement()->SetAttribute("y",sBLY.c_str()); 
    84         Ogre::String sBLZ = Ogre::StringConverter::toString(getQuadBottomLeftCorner().z); 
    85         quadBottomLeftCornerNode->ToElement()->SetAttribute("z",sBLZ.c_str());   
    86  
    87         axisYNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisX"))->ToElement(); 
    88         Ogre::String sAXX = Ogre::StringConverter::toString(getAxisX().x); 
    89         axisYNode->ToElement()->SetAttribute("x",sAXX.c_str()); 
    90         Ogre::String sAXY = Ogre::StringConverter::toString(getAxisX().y); 
    91         axisYNode->ToElement()->SetAttribute("y",sAXY.c_str()); 
    92         Ogre::String sAXZ = Ogre::StringConverter::toString(getAxisX().z); 
    93         axisYNode->ToElement()->SetAttribute("z",sAXZ.c_str());  
    94  
    95         axisYNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisY"))->ToElement(); 
    96         Ogre::String sAYX = Ogre::StringConverter::toString(getAxisY().x); 
    97         axisYNode->ToElement()->SetAttribute("x",sAYX.c_str()); 
    98         Ogre::String sAYY = Ogre::StringConverter::toString(getAxisY().y); 
    99         axisYNode->ToElement()->SetAttribute("y",sAYY.c_str()); 
    100         Ogre::String sAYZ = Ogre::StringConverter::toString(getAxisY().z); 
    101         axisYNode->ToElement()->SetAttribute("z",sAYZ.c_str());  
    102  
    103         axisZNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("axisZ"))->ToElement(); 
    104         Ogre::String sAZX = Ogre::StringConverter::toString(getAxisZ().x); 
    105         axisZNode->ToElement()->SetAttribute("x",sAZX.c_str()); 
    106         Ogre::String sAZY = Ogre::StringConverter::toString(getAxisZ().y); 
    107         axisZNode->ToElement()->SetAttribute("y",sAZY.c_str()); 
    108         Ogre::String sAZZ = Ogre::StringConverter::toString(getAxisZ().z); 
    109         axisZNode->ToElement()->SetAttribute("z",sAZZ.c_str());  
    110  
    111         leavesNode = billboardNode->ToElement()->InsertEndChild(TiXmlElement("leaves"))->ToElement(); 
    112         Ogre::String sLeaves = Ogre::StringConverter::toString(entityCluster->getNumEntitiesClusterData()); 
    113         leavesNode->ToElement()->SetAttribute("count",sLeaves.c_str()); 
    114          
    115         for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
    116         { 
    117                 LeafKdTreeClusterData *leafKdTreeClusterData = (LeafKdTreeClusterData*)entityCluster->getEntityClusterData(iLeaf); 
    118                 Leaf *leaf = (Leaf*)leafKdTreeClusterData->getEntity(); 
    119                 leafNode = leavesNode->ToElement()->InsertEndChild(TiXmlElement("leaf"))->ToElement(); 
    120                 Ogre::String sLeaf = Ogre::StringConverter::toString(leaf->getEntityHandle()); 
    121                 leafNode->ToElement()->SetAttribute("id",sLeaf.c_str()); 
    122         } 
    123 } 
    124  
    125 void BillboardKdTreeClusterData::generateBillboardBoundingQuad()  
    126 { 
    127          
    128         Ogre::Vector3 normal = getNormal(); 
    129         Ogre::Vector3 planePosition; 
    130         float d = getD(); 
    131  
    132         normal.normalise(); 
    133  
    134         if ((abs(normal[0] > abs(normal[1])) && (abs(normal[0] > abs(normal[2]))))) 
    135         { 
    136                 planePosition[0] = -d / normal[0]; 
    137                 planePosition[1] = 0; 
    138                 planePosition[2] = 0; 
    139         } 
    140         else if ((abs(normal[1] > abs(normal[0])) && (abs(normal[1] > abs(normal[2]))))) 
    141         { 
    142                 planePosition[0] = 0; 
    143                 planePosition[1] = -d / normal[1]; 
    144                 planePosition[2] = 0; 
    145         } 
    146         else 
    147         { 
    148                 planePosition[0] = 0; 
    149                 planePosition[1] = 0; 
    150                 planePosition[2] = -d / normal[2]; 
    151         } 
    152          
    153         mAxisX = normal.perpendicular(); 
    154         mAxisX.normalise(); 
    155         mAxisY = normal.crossProduct(mAxisX);    
    156         mAxisY.normalise(); 
    157         mAxisZ = normal; 
    158  
    159         Ogre::Matrix4 coordPlane; 
    160         Ogre::Matrix4 constCoord; 
    161         Ogre::Matrix4 invMCoordPlane; 
    162  
    163         coordPlane[0][0] = mAxisX.x; 
    164         coordPlane[0][1] = mAxisX.y; 
    165         coordPlane[0][2] = mAxisX.z; 
    166         coordPlane[0][3] = 0.0f; 
    167         coordPlane[1][0] = mAxisY.x; 
    168         coordPlane[1][1] = mAxisY.y; 
    169         coordPlane[1][2] = mAxisY.z; 
    170         coordPlane[1][3] = 0.0f; 
    171         coordPlane[2][0] = mAxisZ.x; 
    172         coordPlane[2][1] = mAxisZ.y; 
    173         coordPlane[2][2] = mAxisZ.z; 
    174         coordPlane[2][3] = 0.0f; 
    175         coordPlane[3][0] = planePosition.x; 
    176         coordPlane[3][1] = planePosition.y; 
    177         coordPlane[3][2] = planePosition.z; 
    178         coordPlane[3][3] = 1.0f; 
    179  
    180         invMCoordPlane = coordPlane.inverse(); 
    181  
    182         constCoord[0][0] = 1.0f; 
    183         constCoord[0][1] = 0.0f; 
    184         constCoord[0][2] = 0.0f; 
    185         constCoord[0][3] = 0.0f; 
    186         constCoord[1][0] = 0.0f; 
    187         constCoord[1][1] = 1.0f; 
    188         constCoord[1][2] = 0.0f; 
    189         constCoord[1][3] = 0.0f; 
    190         constCoord[2][0] = 0.0f; 
    191         constCoord[2][1] = 0.0f; 
    192         constCoord[2][2] = 0.0f; 
    193         constCoord[2][3] = 0.0f; 
    194         constCoord[3][0] = 0.0f; 
    195         constCoord[3][1] = 0.0f; 
    196         constCoord[3][2] = 0.0f; 
    197         constCoord[3][3] = 1.0f; 
    198  
    199         float xMax = -FLT_MAX; 
    200         float xMin = FLT_MAX; 
    201         float yMax = -FLT_MAX; 
    202         float yMin = FLT_MAX; 
    203  
    204         Ogre::Vector3 vXmax; 
    205         Ogre::Vector3 vXmin; 
    206         Ogre::Vector3 vYmax; 
    207         Ogre::Vector3 vYmin; 
    208  
    209         BBC::EntityCluster *entityCluster = getEntityCluster(); 
    210         BBC::Entity *entity = entityCluster->getEntity(); 
    211  
    212         for (unsigned int iVertex = 0; iVertex < entity->getSubEntity(0)->getNumVertices(); iVertex++) 
    213         {                                
    214                 Ogre::Vector3 position = entity->getSubEntity(0)->getPosition(iVertex); 
    215                 Ogre::Vector4 projPointP1d4 =  Ogre::Vector4(position.x,position.y,position.z,1.0f) * invMCoordPlane * constCoord * coordPlane; 
    216          
    217                 // The point projected in the plane 
    218                 Ogre::Vector3 projPointP1(projPointP1d4.x,projPointP1d4.y,projPointP1d4.z); 
    219  
    220                 float v1 = normal.dotProduct(planePosition); 
    221                 float v2 = normal.dotProduct(position); 
    222                 float t = v1 - v2; 
    223                 projPointP1 = position + (normal * t); 
    224  
    225                 float x1 = mAxisX.dotProduct(projPointP1 - planePosition); 
    226                 float y1 = mAxisY.dotProduct(projPointP1 - planePosition); 
    227                 float z1 = mAxisZ.dotProduct(projPointP1 - planePosition);               
    228                  
    229                 if (x1 > xMax) 
    230                 { 
    231                         xMax = x1; 
    232                         vXmax = projPointP1; 
    233                 } 
    234                 if (x1 < xMin) 
    235                 { 
    236                         xMin = x1; 
    237                         vXmin = projPointP1; 
    238                 } 
    239                 if (y1 > yMax) 
    240                 { 
    241                         yMax = y1; 
    242                         vYmax = projPointP1; 
    243                 } 
    244                 if (y1 < yMin) 
    245                 { 
    246                         yMin = y1; 
    247                         vYmin = projPointP1; 
    248                 }                
    249         } 
    250  
    251         Ogre::Vector3 aP; 
    252         Ogre::Vector3 bP; 
    253         Ogre::Vector3 pP; 
    254         Ogre::Vector3 abV; 
    255         Ogre::Vector3 apV; 
    256         Ogre::Vector3 dProdV; 
    257         float aLength; 
    258         float abLength; 
    259         float dist; 
    260         Ogre::Vector3 intersectP; 
    261  
    262         aP = vYmin; 
    263         bP = vYmin + mAxisX; 
    264         pP = vXmin; 
    265         abV = bP - aP; 
    266         apV = pP - aP; 
    267         dProdV = abV.crossProduct(apV); 
    268         aLength = dProdV.length(); 
    269         abLength = abV.length(); 
    270         dist = aLength / abLength; 
    271         mBillboardCorners[QUAD_TOP_LEFT] = pP + (mAxisY * (-dist)); 
    272  
    273         aP = vYmax; 
    274         bP = vYmax + mAxisX; 
    275         pP = vXmax; 
    276         abV = bP - aP; 
    277         apV = pP - aP; 
    278         dProdV = abV.crossProduct(apV); 
    279         aLength = dProdV.length(); 
    280         abLength = abV.length(); 
    281         dist = aLength / abLength; 
    282         mBillboardCorners[QUAD_BOTTOM_RIGHT] = pP + (mAxisY * dist); 
    283  
    284         aP = vXmax; 
    285         bP = vXmax + mAxisY; 
    286         pP = vYmin; 
    287         abV = bP - aP; 
    288         apV = pP - aP; 
    289         dProdV = abV.crossProduct(apV); 
    290         aLength = dProdV.length(); 
    291         abLength = abV.length(); 
    292         dist = aLength / abLength; 
    293         mBillboardCorners[QUAD_BOTTOM_LEFT] = pP + (mAxisX * dist); 
    294  
    295         Ogre::Vector3 vDirWidth = mBillboardCorners[QUAD_BOTTOM_LEFT] - mBillboardCorners[QUAD_BOTTOM_RIGHT]; 
    296         float distWidth = vDirWidth.length(); 
    297         mBillboardCorners[QUAD_TOP_RIGHT] = mBillboardCorners[QUAD_TOP_LEFT] + (mAxisY * distWidth); 
    298 } 
    299  
    300 } 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKMeansClusterGenerator.cpp

    r699 r721  
    1  
    2 #include "LBBCKMeansClusterGenerator.h" 
     1#include <LBBCKMeansClusterGenerator.h> 
    32 
    43namespace LBBC { 
    54 
     5void KMeansClusterGenerator::setAlpha(float value) 
     6{ 
     7        mAlpha = value; 
     8} 
     9 
     10float KMeansClusterGenerator::getAlpha() 
     11{ 
     12        return mAlpha; 
     13} 
     14 
     15void KMeansClusterGenerator::setNumIterations(unsigned int value) 
     16{ 
     17        mNumIterations = value; 
     18} 
     19 
     20unsigned int KMeansClusterGenerator::getNumIterations() 
     21{ 
     22        return mNumIterations; 
     23} 
     24 
     25unsigned int KMeansClusterGenerator::findBestBillboard(Leaf *leaf) 
     26{ 
     27        float minError = FLT_MAX; 
     28        unsigned int iMinErrorBillboard = 0; 
     29         
     30        Ogre::Vector3 normalLeaf = leaf->getLeafNormal(); 
     31        Ogre::Vector3 positionLeaf = leaf->getPosition();                
     32         
     33        for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
     34        { 
     35                BBC::BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); 
     36                BillboardKMeansClusterData *billboardClusterData = (BillboardKMeansClusterData*)billboard->getBillboardClusterData().get(); 
     37                Ogre::Vector3 normalBillboard = billboardClusterData->getNormal();                       
     38 
     39                float d = (normalBillboard.dotProduct(positionLeaf) +  billboardClusterData->getD()); 
     40                float cosine = normalBillboard.dotProduct(normalLeaf); 
     41                float error = (d*d) + ( 1 - cosine * cosine ) * mAlpha; 
     42 
     43                if (error < minError) 
     44                { 
     45                        minError = error; 
     46                        iMinErrorBillboard = billboard->getBillboardHandle(); 
     47                }                                
     48        } 
     49        return iMinErrorBillboard; 
     50} 
     51 
     52void KMeansClusterGenerator::assignLeafBillboard(Leaf *leaf, BBC::BillboardPtr billboard) 
     53{ 
     54        BillboardKMeansClusterData *billboardClusterData = (BillboardKMeansClusterData*)billboard->getBillboardClusterData().get();                      
     55        BBC::EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 
     56 
     57        BBC::EntityClusterDataPtr entityClusterData = BBC::EntityClusterDataPtr( (BBC::EntityClusterData*) new LeafKMeansClusterData() ); 
     58        entityClusterData->setEntity(leaf); 
     59        entityCluster->addEntityClusterData(entityClusterData); 
     60} 
     61 
     62void KMeansClusterGenerator::splitLeafDistribution() 
     63{ 
     64        for (unsigned int iLeaf = 0; iLeaf < mEntityDistribution->getNumEntities(); iLeaf++) 
     65        { 
     66                Leaf *leaf = (Leaf*)mEntityDistribution->getEntity(iLeaf).get(); 
     67                unsigned int iMinErrorBillboard = findBestBillboard(leaf); 
     68 
     69                BBC::BillboardPtr billboardMinError = mBillboardCloud->getBillboard(iMinErrorBillboard); 
     70                assignLeafBillboard(leaf,billboardMinError); 
     71        } 
     72} 
     73 
     74void KMeansClusterGenerator::recomputeBillboard(BBC::BillboardPtr billboard) 
     75{ 
     76        Ogre::Matrix3 nmii = Ogre::Matrix3::ZERO; 
     77        Ogre::Matrix3 nmiiSum = Ogre::Matrix3::ZERO; 
     78        Ogre::Matrix3 miiSum = Ogre::Matrix3::ZERO; 
     79        Ogre::Matrix3 mii = Ogre::Matrix3::ZERO;         
     80        Ogre::Matrix3 mijSum = Ogre::Matrix3::ZERO; 
     81        Ogre::Matrix3 mij = Ogre::Matrix3::ZERO;  
     82        Ogre::Vector3 lastY = Ogre::Vector3::ZERO; 
     83        Ogre::Vector3 piSum = Ogre::Vector3::ZERO; 
     84        Ogre::Vector3 normSum = Ogre::Vector3::ZERO; 
     85 
     86        BillboardKMeansClusterData *billboardClusterData = (BillboardKMeansClusterData*)billboard->getBillboardClusterData().get();                      
     87        BBC::EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 
     88 
     89        for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
     90        { 
     91                Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 
     92                Ogre::Vector3 pi = leaf->getPosition();  
     93                Ogre::Vector3 norm2 = leaf->getLeafNormal();     
     94                piSum = piSum + pi * (1.0 / (float)entityCluster->getNumEntitiesClusterData()); 
     95                         
     96                mii[0][0] = pi.x * pi.x; 
     97                mii[0][1] = pi.x * pi.y; 
     98                mii[0][2] = pi.x * pi.z; 
     99                mii[1][0] = pi.y * pi.x; 
     100                mii[1][1] = pi.y * pi.y; 
     101                mii[1][2] = pi.y * pi.z; 
     102                mii[2][0] = pi.z * pi.x; 
     103                mii[2][1] = pi.z * pi.y; 
     104                mii[2][2] = pi.z * pi.z;         
     105                nmii[0][0] = norm2.x * norm2.x; 
     106                nmii[0][1] = norm2.x * norm2.y; 
     107                nmii[0][2] = norm2.x * norm2.z; 
     108                nmii[1][0] = norm2.y * norm2.x; 
     109                nmii[1][1] = norm2.y * norm2.y; 
     110                nmii[1][2] = norm2.y * norm2.z; 
     111                nmii[2][0] = norm2.z * norm2.x; 
     112                nmii[2][1] = norm2.z * norm2.y; 
     113                nmii[2][2] = norm2.z * norm2.z;  
     114                 
     115                nmiiSum = nmiiSum + ( nmii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 
     116 
     117                miiSum = miiSum + ( mii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 
     118 
     119                // Generate the initial value for the iterative method as the average... 
     120                Ogre::Vector3 norm = leaf->getLeafNormal(); 
     121                lastY = lastY + norm; 
     122 
     123                // Generate the sum normal of all the leaves associated to the plane... 
     124                normSum = normSum + norm; 
     125        } 
     126         
     127        mijSum[0][0] = piSum.x * piSum.x; 
     128        mijSum[0][1] = piSum.x * piSum.y; 
     129        mijSum[0][2] = piSum.x * piSum.z; 
     130        mijSum[1][0] = piSum.y * piSum.x; 
     131        mijSum[1][1] = piSum.y * piSum.y; 
     132        mijSum[1][2] = piSum.y * piSum.z; 
     133        mijSum[2][0] = piSum.z * piSum.x; 
     134        mijSum[2][1] = piSum.z * piSum.y; 
     135        mijSum[2][2] = piSum.z * piSum.z;        
     136 
     137        Ogre::Matrix3 mA = miiSum - mijSum; 
     138        mA = mA - (mAlpha * nmiiSum); 
     139        mA = mA.Inverse(); 
     140 
     141        lastY.normalise(); 
     142        normSum.normalise(); 
     143 
     144        // Apply the iterative approach 
     145        Ogre::Vector3 currY; 
     146        currY = mA * lastY; 
     147        currY.normalise(); 
     148 
     149        for(unsigned int icount = 0; icount < 100; icount++) 
     150        { 
     151                lastY = currY; 
     152                currY = mA * lastY; 
     153                currY.normalise(); 
     154        } 
     155 
     156        // Generate the d parameter... 
     157        float sumD = 0; 
     158        for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
     159        { 
     160                Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 
     161                Ogre::Vector3 pi = leaf->getPosition();  
     162                sumD = sumD + pi.dotProduct(currY); 
     163        } 
     164 
     165        sumD = - sumD / (float)entityCluster->getNumEntitiesClusterData(); 
     166 
     167        billboardClusterData->setNormal(currY); 
     168        billboardClusterData->setD(sumD); 
     169} 
     170 
     171void KMeansClusterGenerator::recomputeBillboardCloud() 
     172{ 
     173        for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
     174        { 
     175                BBC::BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); 
     176                recomputeBillboard(billboard); 
     177        } 
     178} 
     179 
     180void KMeansClusterGenerator::iterativeRecomputeBillboardCloud() 
     181{ 
     182        for (unsigned int iIteration = 0; iIteration < mNumIterations; iIteration++) 
     183        { 
     184                recomputeBillboardCloud(); 
     185        } 
     186} 
     187 
    6188void KMeansClusterGenerator::generate()  
    7189{ 
    8  
     190        // Generate the initial random billboards and cluster the leaves with them 
     191        // 1. Create the billboards and assign an initial random orientation 
     192        initializeBillboardCloud(); 
     193        // 2. Split the leaf distribution, each leaf in the it's best candidate billboard 
     194        splitLeafDistribution(); 
     195        // 3. The billboard is recomputed in order to minimize the total error  
     196        // for the leaves of this cluster with respect to this plane. 
     197        iterativeRecomputeBillboardCloud(); 
     198        // 4. Generate each entity cluster packed entity and compute the bounding quad for each entity cluster 
     199        generateBillboardCloudBounds(); 
     200} 
     201 
     202BBC::BillboardPtr KMeansClusterGenerator::createBillboard() 
     203{ 
     204        BBC::BillboardPtr billboard = BBC::BillboardPtr( new BBC::Billboard() ); 
     205        mBillboardCloud->addBillboard(billboard); 
     206        return billboard; 
     207} 
     208 
     209void KMeansClusterGenerator::initializeBillboardClusterData(BBC::BillboardPtr billboard) 
     210{ 
     211        BBC::BillboardClusterDataPtr billboardClusterData = BBC::BillboardClusterDataPtr( new BillboardKMeansClusterData() ); 
     212        billboard->setBillboardClusterData(billboardClusterData); 
     213        BBC::EntityClusterPtr entityCluster = BBC::EntityClusterPtr( new BBC::EntityCluster() ); 
     214        billboard->getBillboardClusterData()->setEntityCluster(entityCluster); 
     215} 
     216 
     217void KMeansClusterGenerator::generateBillboardCloudBounds() 
     218{ 
     219        for (unsigned int iBillboard = 0; iBillboard < this->getMaxNumBillboards(); iBillboard++) 
     220        { 
     221                BBC::BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard);                 
     222                BBC::EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     223 
     224                if (entityCluster->getNumEntitiesClusterData() > 0) 
     225                {                                        
     226                        entityCluster->generateEntityCluster(); 
     227                        billboard->getBillboardClusterData()->generateBillboardBoundingQuad(); 
     228                } 
     229        } 
     230} 
     231 
     232void KMeansClusterGenerator::initializeRandomBillboard(BBC::BillboardPtr billboard) 
     233{ 
     234        float dMin = ((LeafDistribution*)mEntityDistribution)->getMinD(); 
     235        float dMax = ((LeafDistribution*)mEntityDistribution)->getMaxD(); 
     236 
     237        float d = Ogre::Math::RangeRandom(dMin,dMax); 
     238 
     239        //Ogre::Vector3 normalMin = ((LeafDistribution*)mEntityDistribution)->getMinNormal(); 
     240        //Ogre::Vector3 normalMax = ((LeafDistribution*)mEntityDistribution)->getMaxNormal(); 
     241        Ogre::Vector3 normal; 
     242        normal.x = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.x,normalMax.x); 
     243        normal.y = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.y,normalMax.y); 
     244        normal.z = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.z,normalMax.z); 
     245         
     246        BillboardKMeansClusterData *mBillboardClusterData = (BillboardKMeansClusterData *)billboard->getBillboardClusterData().get(); 
     247        mBillboardClusterData->setNormal(normal); 
     248        mBillboardClusterData->setD(d); 
     249} 
     250 
     251void KMeansClusterGenerator::initializeBillboardCloud() 
     252{ 
     253        for (unsigned int iBillboard = 0; iBillboard < this->getMaxNumBillboards(); iBillboard++) 
     254        { 
     255                BBC::BillboardPtr billboard = createBillboard(); 
     256                initializeBillboardClusterData(billboard); 
     257                initializeRandomBillboard(billboard); 
     258        } 
    9259} 
    10260 
    11261void KMeansClusterGenerator::init()  
    12262{ 
    13  
    14 } 
    15  
    16 KMeansClusterGenerator::KMeansClusterGenerator() { 
    17 } 
    18  
    19 KMeansClusterGenerator::~KMeansClusterGenerator() { 
    20 } 
    21  
    22  
    23 } 
     263} 
     264 
     265KMeansClusterGenerator::KMeansClusterGenerator()  
     266{ 
     267} 
     268 
     269KMeansClusterGenerator::~KMeansClusterGenerator()  
     270{ 
     271 
     272} 
     273 
     274 
     275} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKMeansClusterSerializer.cpp

    r699 r721  
    1010} 
    1111 
    12 void KMeansClusterSerializer::writeBillboardCloud(TiXmlDocument *document) { 
     12void KMeansClusterSerializer::writeBillboardCloud(TiXmlDocument *document) 
     13{ 
     14        TiXmlNode *billboardCloudNode = document->InsertEndChild(TiXmlElement("billboardCloud"))->ToElement(); 
     15 
     16        unsigned int numSerializedBillboards = 0; 
     17        unsigned int numSerializedEntities = 0; 
     18        for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
     19        { 
     20                BBC::BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); 
     21                BBC::EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
     22 
     23                // If the Billboard has Entities... 
     24                if (entityCluster->getNumEntitiesClusterData() > 0) 
     25                { 
     26                        BillboardKMeansClusterData *billboardKMeansClusterData = (BillboardKMeansClusterData*)billboard->getBillboardClusterData().get(); 
     27                        billboardKMeansClusterData->writeBillboardClusterData(billboardCloudNode);       
     28                        numSerializedBillboards++; 
     29                        numSerializedEntities = numSerializedEntities + entityCluster->getNumEntitiesClusterData(); 
     30                } 
     31        } 
     32        billboardCloudNode->ToElement()->SetAttribute("count",Ogre::StringConverter::toString(numSerializedBillboards)); 
     33         
     34        Ogre::LogManager::getSingleton().logMessage("Num.Serialized Billboards:" + Ogre::StringConverter::toString(numSerializedBillboards) + " with " + Ogre::StringConverter::toString(numSerializedEntities) + " Entities"); 
    1335} 
    1436 
    15  
    1637} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKdTreeClusterGenerator.cpp

    r699 r721  
    1 #include <LBBCKdTreeClusterGenerator.h> 
     1 
     2#include "LBBCKdTreeClusterGenerator.h" 
    23 
    34namespace LBBC { 
    45 
    5 void KdTreeClusterGenerator::setAlpha(float value) 
    6 { 
    7         mAlpha = value; 
    8 } 
    9  
    10 float KdTreeClusterGenerator::getAlpha() 
    11 { 
    12         return mAlpha; 
    13 } 
    14  
    15 void KdTreeClusterGenerator::setNumIterations(unsigned int value) 
    16 { 
    17         mNumIterations = value; 
    18 } 
    19  
    20 unsigned int KdTreeClusterGenerator::getNumIterations() 
    21 { 
    22         return mNumIterations; 
    23 } 
    24  
    25 unsigned int KdTreeClusterGenerator::findBestBillboard(Leaf *leaf) 
    26 { 
    27         float minError = FLT_MAX; 
    28         unsigned int iMinErrorBillboard = 0; 
    29          
    30         Ogre::Vector3 normalLeaf = leaf->getLeafNormal(); 
    31         Ogre::Vector3 positionLeaf = leaf->getPosition();                
    32          
    33         for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
    34         { 
    35                 BBC::Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 
    36                 BillboardKdTreeClusterData *billboardClusterData = (BillboardKdTreeClusterData*)billboard->getBillboardClusterData(); 
    37                 Ogre::Vector3 normalBillboard = billboardClusterData->getNormal();                       
    38  
    39                 float d = (normalBillboard.dotProduct(positionLeaf) +  billboardClusterData->getD()); 
    40                 float cosine = normalBillboard.dotProduct(normalLeaf); 
    41                 float error = (d*d) + ( 1 - cosine * cosine ) * mAlpha; 
    42  
    43                 if (error < minError) 
    44                 { 
    45                         minError = error; 
    46                         iMinErrorBillboard = billboard->getBillboardHandle(); 
    47                 }                                
    48         } 
    49         return iMinErrorBillboard; 
    50 } 
    51  
    52 void KdTreeClusterGenerator::assignLeafBillboard(Leaf *leaf, BBC::Billboard *billboard) 
    53 { 
    54         BillboardKdTreeClusterData *billboardClusterData = (BillboardKdTreeClusterData*)billboard->getBillboardClusterData();                    
    55         BBC::EntityCluster *entityCluster = billboardClusterData->getEntityCluster(); 
    56  
    57         BBC::EntityClusterData *entityClusterData = new LeafKdTreeClusterData(); 
    58         entityClusterData->setEntity(leaf); 
    59         entityCluster->addEntityClusterData(entityClusterData); 
    60 } 
    61  
    62 void KdTreeClusterGenerator::splitLeafDistribution() 
    63 { 
    64         for (unsigned int iLeaf = 0; iLeaf < mEntityDistribution->getNumEntities(); iLeaf++) 
    65         { 
    66                 Leaf *leaf = (Leaf*)mEntityDistribution->getEntity(iLeaf); 
    67                 unsigned int iMinErrorBillboard = findBestBillboard(leaf); 
    68  
    69                 BBC::Billboard *billboardMinError = mBillboardCloud->getBillboard(iMinErrorBillboard); 
    70                 assignLeafBillboard(leaf,billboardMinError); 
    71         } 
    72 } 
    73  
    74 void KdTreeClusterGenerator::recomputeBillboard(BBC::Billboard *billboard) 
    75 { 
    76         Ogre::Matrix3 nmii = Ogre::Matrix3::ZERO; 
    77         Ogre::Matrix3 nmiiSum = Ogre::Matrix3::ZERO; 
    78         Ogre::Matrix3 miiSum = Ogre::Matrix3::ZERO; 
    79         Ogre::Matrix3 mii = Ogre::Matrix3::ZERO;         
    80         Ogre::Matrix3 mijSum = Ogre::Matrix3::ZERO; 
    81         Ogre::Matrix3 mij = Ogre::Matrix3::ZERO;  
    82         Ogre::Vector3 lastY = Ogre::Vector3::ZERO; 
    83         Ogre::Vector3 piSum = Ogre::Vector3::ZERO; 
    84         Ogre::Vector3 normSum = Ogre::Vector3::ZERO; 
    85  
    86         BillboardKdTreeClusterData *billboardClusterData = (BillboardKdTreeClusterData*)billboard->getBillboardClusterData();                    
    87         BBC::EntityCluster *entityCluster = billboardClusterData->getEntityCluster(); 
    88  
    89         for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
    90         { 
    91                 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity(); 
    92                 Ogre::Vector3 pi = leaf->getPosition();  
    93                 Ogre::Vector3 norm2 = leaf->getLeafNormal();     
    94                 piSum = piSum + pi * (1.0 / (float)entityCluster->getNumEntitiesClusterData()); 
    95                          
    96                 mii[0][0] = pi.x * pi.x; 
    97                 mii[0][1] = pi.x * pi.y; 
    98                 mii[0][2] = pi.x * pi.z; 
    99                 mii[1][0] = pi.y * pi.x; 
    100                 mii[1][1] = pi.y * pi.y; 
    101                 mii[1][2] = pi.y * pi.z; 
    102                 mii[2][0] = pi.z * pi.x; 
    103                 mii[2][1] = pi.z * pi.y; 
    104                 mii[2][2] = pi.z * pi.z;         
    105                 nmii[0][0] = norm2.x * norm2.x; 
    106                 nmii[0][1] = norm2.x * norm2.y; 
    107                 nmii[0][2] = norm2.x * norm2.z; 
    108                 nmii[1][0] = norm2.y * norm2.x; 
    109                 nmii[1][1] = norm2.y * norm2.y; 
    110                 nmii[1][2] = norm2.y * norm2.z; 
    111                 nmii[2][0] = norm2.z * norm2.x; 
    112                 nmii[2][1] = norm2.z * norm2.y; 
    113                 nmii[2][2] = norm2.z * norm2.z;  
    114                  
    115                 nmiiSum = nmiiSum + ( nmii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 
    116  
    117                 miiSum = miiSum + ( mii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 
    118  
    119                 // Generate the initial value for the iterative method as the average... 
    120                 Ogre::Vector3 norm = leaf->getLeafNormal(); 
    121                 lastY = lastY + norm; 
    122  
    123                 // Generate the sum normal of all the leaves associated to the plane... 
    124                 normSum = normSum + norm; 
    125         } 
    126          
    127         mijSum[0][0] = piSum.x * piSum.x; 
    128         mijSum[0][1] = piSum.x * piSum.y; 
    129         mijSum[0][2] = piSum.x * piSum.z; 
    130         mijSum[1][0] = piSum.y * piSum.x; 
    131         mijSum[1][1] = piSum.y * piSum.y; 
    132         mijSum[1][2] = piSum.y * piSum.z; 
    133         mijSum[2][0] = piSum.z * piSum.x; 
    134         mijSum[2][1] = piSum.z * piSum.y; 
    135         mijSum[2][2] = piSum.z * piSum.z;        
    136  
    137         Ogre::Matrix3 mA = miiSum - mijSum; 
    138         mA = mA - (mAlpha * nmiiSum); 
    139         mA = mA.Inverse(); 
    140  
    141         lastY.normalise(); 
    142         normSum.normalise(); 
    143  
    144         // Apply the iterative approach 
    145         Ogre::Vector3 currY; 
    146         currY = mA * lastY; 
    147         currY.normalise(); 
    148  
    149         for(unsigned int icount = 0; icount < 100; icount++) 
    150         { 
    151                 lastY = currY; 
    152                 currY = mA * lastY; 
    153                 currY.normalise(); 
    154         } 
    155  
    156         // Generate the d parameter... 
    157         float sumD = 0; 
    158         for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
    159         { 
    160                 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity(); 
    161                 Ogre::Vector3 pi = leaf->getPosition();  
    162                 sumD = sumD + pi.dotProduct(currY); 
    163         } 
    164  
    165         sumD = - sumD / (float)entityCluster->getNumEntitiesClusterData(); 
    166  
    167         billboardClusterData->setNormal(currY); 
    168         billboardClusterData->setD(sumD); 
    169 } 
    170  
    171 void KdTreeClusterGenerator::recomputeBillboardCloud() 
    172 { 
    173         for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
    174         { 
    175                 BBC::Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 
    176                 recomputeBillboard(billboard); 
    177         } 
    178 } 
    179  
    180 void KdTreeClusterGenerator::iterativeRecomputeBillboardCloud() 
    181 { 
    182         for (unsigned int iIteration = 0; iIteration < mNumIterations; iIteration++) 
    183         { 
    184                 recomputeBillboardCloud(); 
    185         } 
    186 } 
    187  
    1886void KdTreeClusterGenerator::generate()  
    1897{ 
    190         // Generate the initial random billboards and cluster the leaves with them 
    191         // 1. Create the billboards and assign an initial random orientation 
    192         initializeBillboardCloud(); 
    193         // 2. Split the leaf distribution, each leaf in the it's best candidate billboard 
    194         splitLeafDistribution(); 
    195         // 3. The billboard is recomputed in order to minimize the total error  
    196         // for the leaves of this cluster with respect to this plane. 
    197         iterativeRecomputeBillboardCloud(); 
    198         // 4. Generate each entity cluster packed entity and compute the bounding quad for each entity cluster 
    199         generateBillboardCloudBounds(); 
    200 } 
    2018 
    202 BBC::Billboard* KdTreeClusterGenerator::createBillboard() 
    203 { 
    204         BBC::Billboard *billboard = new BBC::Billboard(); 
    205         mBillboardCloud->addBillboard(billboard); 
    206         return billboard; 
    207 } 
    208  
    209 void KdTreeClusterGenerator::initializeBillboardClusterData(BBC::Billboard *billboard) 
    210 { 
    211         BBC::BillboardClusterData *billboardClusterData = new BillboardKdTreeClusterData(); 
    212         billboard->setBillboardClusterData(billboardClusterData); 
    213         BBC::EntityCluster *entityCluster = new BBC::EntityCluster(); 
    214         billboard->getBillboardClusterData()->setEntityCluster(entityCluster); 
    215 } 
    216  
    217 void KdTreeClusterGenerator::generateBillboardCloudBounds() 
    218 { 
    219         for (unsigned int iBillboard = 0; iBillboard < this->getMaxNumBillboards(); iBillboard++) 
    220         { 
    221                 BBC::Billboard *billboard = mBillboardCloud->getBillboard(iBillboard);           
    222                 BBC::EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    223  
    224                 if (entityCluster->getNumEntitiesClusterData() > 0) 
    225                 {                                        
    226                         entityCluster->generateEntityCluster(); 
    227                         billboard->getBillboardClusterData()->generateBillboardBoundingQuad(); 
    228                 } 
    229         } 
    230 } 
    231  
    232 void KdTreeClusterGenerator::initializeRandomBillboard(BBC::Billboard *billboard) 
    233 { 
    234         float dMin = ((LeafDistribution*)mEntityDistribution)->getMinD(); 
    235         float dMax = ((LeafDistribution*)mEntityDistribution)->getMaxD(); 
    236  
    237         float d = Ogre::Math::RangeRandom(dMin,dMax); 
    238  
    239         //Ogre::Vector3 normalMin = ((LeafDistribution*)mEntityDistribution)->getMinNormal(); 
    240         //Ogre::Vector3 normalMax = ((LeafDistribution*)mEntityDistribution)->getMaxNormal(); 
    241         Ogre::Vector3 normal; 
    242         normal.x = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.x,normalMax.x); 
    243         normal.y = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.y,normalMax.y); 
    244         normal.z = Ogre::Math::RangeRandom(-1,1); // Ogre::Math::RangeRandom(normalMin.z,normalMax.z); 
    245          
    246         BillboardKdTreeClusterData *mBillboardClusterData = (BillboardKdTreeClusterData *)billboard->getBillboardClusterData(); 
    247         mBillboardClusterData->setNormal(normal); 
    248         mBillboardClusterData->setD(d); 
    249 } 
    250  
    251 void KdTreeClusterGenerator::initializeBillboardCloud() 
    252 { 
    253         for (unsigned int iBillboard = 0; iBillboard < this->getMaxNumBillboards(); iBillboard++) 
    254         { 
    255                 BBC::Billboard *billboard = createBillboard(); 
    256                 initializeBillboardClusterData(billboard); 
    257                 initializeRandomBillboard(billboard); 
    258         } 
    2599} 
    26010 
    26111void KdTreeClusterGenerator::init()  
    26212{ 
     13 
    26314} 
    26415 
    265 KdTreeClusterGenerator::KdTreeClusterGenerator()  
    266 { 
     16KdTreeClusterGenerator::KdTreeClusterGenerator() { 
    26717} 
    26818 
    269 KdTreeClusterGenerator::~KdTreeClusterGenerator()  
    270 { 
    271         for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
    272         { 
    273                 BBC::Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 
    274                 BillboardKdTreeClusterData *billboardKdTreeClusterData = (BillboardKdTreeClusterData*)billboard->getBillboardClusterData(); 
    275                 BBC::EntityCluster *entityCluster = billboardKdTreeClusterData->getEntityCluster(); 
    276  
    277                 for (unsigned int iEntityClusterData = 0; iEntityClusterData < entityCluster->getNumEntitiesClusterData(); iEntityClusterData++) 
    278                 { 
    279                         LeafKdTreeClusterData *entityClusterData = (LeafKdTreeClusterData*) entityCluster->getEntityClusterData(iEntityClusterData); 
    280                         delete entityClusterData; 
    281                 } 
    282  
    283                 delete entityCluster; 
    284                 delete billboardKdTreeClusterData; 
    285         } 
     19KdTreeClusterGenerator::~KdTreeClusterGenerator() { 
    28620} 
    28721 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKdTreeClusterSerializer.cpp

    r699 r721  
    1010} 
    1111 
    12 void KdTreeClusterSerializer::writeBillboardCloud(TiXmlDocument *document) 
    13 { 
    14         TiXmlNode *billboardCloudNode = document->InsertEndChild(TiXmlElement("billboardCloud"))->ToElement(); 
    15  
    16         unsigned int numSerializedBillboards = 0; 
    17         unsigned int numSerializedEntities = 0; 
    18         for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 
    19         { 
    20                 BBC::Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 
    21                 BBC::EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 
    22  
    23                 // If the Billboard has Entities... 
    24                 if (entityCluster->getNumEntitiesClusterData() > 0) 
    25                 { 
    26                         BillboardKdTreeClusterData *billboardKdTreeClusterData = (BillboardKdTreeClusterData*)billboard->getBillboardClusterData(); 
    27                         billboardKdTreeClusterData->writeBillboardClusterData(billboardCloudNode);       
    28                         numSerializedBillboards++; 
    29                         numSerializedEntities = numSerializedEntities + entityCluster->getNumEntitiesClusterData(); 
    30                 } 
    31         } 
    32         billboardCloudNode->ToElement()->SetAttribute("count",Ogre::StringConverter::toString(numSerializedBillboards)); 
    33          
    34         Ogre::LogManager::getSingleton().logMessage("Num.Serialized Billboards:" + Ogre::StringConverter::toString(numSerializedBillboards) + " with " + Ogre::StringConverter::toString(numSerializedEntities) + " Entities"); 
     12void KdTreeClusterSerializer::writeBillboardCloud(TiXmlDocument *document) { 
    3513} 
    3614 
     15 
    3716} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeaf.cpp

    r699 r721  
    33 
    44namespace LBBC { 
     5 
     6Leaf::Leaf()  
     7{ 
     8} 
     9 
     10Leaf::~Leaf()  
     11{ 
     12 
     13} 
    514 
    615void Leaf::setPlaneD(float value) { 
     
    221230} 
    222231 
    223 Leaf::Leaf() { 
    224 } 
    225  
    226 Leaf::~Leaf() { 
    227 } 
    228  
    229 } 
     232} 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistribution.cpp

    r699 r721  
    99LeafDistribution::~LeafDistribution()  
    1010{ 
    11         for (unsigned int iLeaf = 0; iLeaf < getNumEntities(); iLeaf++) 
    12         { 
    13                 Leaf *leaf = (Leaf*)getEntity(iLeaf); 
    14                 delete leaf; 
    15         } 
     11 
    1612} 
    1713 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionGenerator.cpp

    r709 r721  
    88LeafDistributionGenerator::LeafDistributionGenerator()  
    99{ 
    10         mEntity = new BBC::Entity(); 
     10        mEntity = BBC::EntityPtr(new BBC::Entity()); 
    1111} 
    1212 
    1313LeafDistributionGenerator::~LeafDistributionGenerator()  
    1414{ 
    15         delete mEntity; 
    1615} 
    1716 
     
    122121                                        while ((j < mEntityDistribution->getNumEntities()) && (!leaveFound)) 
    123122                                        {                                                
    124                                                 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(j); 
     123                                                Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(j).get(); 
    125124                                                if (leaf->hasFace(iF01)) 
    126125                                                { 
     
    186185        for (unsigned int ileaf = 0; ileaf < mEntityDistribution->getNumEntities(); ileaf++) 
    187186        { 
    188                 Leaf *leaf = (Leaf*) mEntityDistribution->getEntity(ileaf); 
     187                Leaf *leaf = (Leaf*) mEntityDistribution->getEntity(ileaf).get(); 
    189188                leaf->setPosition(leaf->getSubEntity(0)->getUniqueVertex(0).position); 
    190189        generateAverageLeafNormal(leaf); 
     
    223222        for (unsigned int iD = 0; iD < mEntityDistribution->getNumEntities(); iD++) 
    224223        {                
    225                 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(iD);                 
     224                Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(iD).get();           
    226225                if (leaf->getLeafD() < dMin) 
    227226                { 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionSerializer.cpp

    r699 r721  
    77                                                   : BBC::EntityDistributionSerializer() 
    88{ 
    9         mEntity = new BBC::Entity(); 
     9 
    1010} 
    1111 
    1212LeafDistributionSerializer::~LeafDistributionSerializer()  
    1313{ 
    14         delete mEntity; 
     14 
    1515} 
    1616 
     
    9494        for (unsigned int k=0; k < mLeafDistribution->getNumEntities(); k++) 
    9595        { 
    96                 Leaf *leaf = (Leaf *)mLeafDistribution->getEntity(k); 
     96                Leaf *leaf = (Leaf *)mLeafDistribution->getEntity(k).get(); 
    9797 
    9898                TiXmlNode *leafNode = leavesNode->ToElement()->InsertEndChild(TiXmlElement(Ogre::String("leaf").c_str()))->ToElement(); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeaves.cpp

    r699 r721  
    1313Leaves::~Leaves()  
    1414{ 
    15         delete mBillboardCloud; 
    16         delete mLeafDistribution; 
     15        if (mBillboardCloud) 
     16        { 
     17                delete mBillboardCloud; 
     18        } 
     19 
     20        if (mLeafDistribution) 
     21        { 
     22                delete mLeafDistribution; 
     23        } 
    1724} 
    1825 
    19 Ogre::Mesh* Leaves::getMesh() { 
    20         return mMesh; 
     26BBC::EntityPtr Leaves::getEntity()  
     27{ 
     28        return mEntity; 
    2129} 
    2230 
    23 void Leaves::setMesh(Ogre::Mesh * value) { 
    24         mMesh = value; 
     31void Leaves::setEntity(BBC::EntityPtr value)  
     32{ 
     33        mEntity = value; 
    2534} 
    2635 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp

    r709 r721  
    77        : BBC::Manager()  
    88{ 
    9         //mCf.load("lbbc.cfg");  
    10          
    11         mBillboardCloudSerializer = new KdTreeClusterSerializer(); 
     9        mBillboardCloudSerializer = new KMeansClusterSerializer(); 
    1210        mLeafDistributionSerializer = new LeafDistributionSerializer(); 
    1311        mLeafDistributionGenerator = new LeafDistributionGenerator(); 
    14         mBillboardCloudGenerator = new KdTreeClusterGenerator(); 
     12        mBillboardCloudGenerator = new KMeansClusterGenerator(); 
    1513        mBillboardCloudUVMapper = new BBC::BillboardCloudUVMapper(); 
    1614        mOgreMeshSerializer = new BBC::OgreMeshSerializer(); 
     
    1917Manager::~Manager()  
    2018{ 
    21         // How to manage the destruction of BBC::Manager? 
    22         delete mBillboardCloudSerializer; 
    23         delete mLeafDistributionSerializer; 
    24         delete mLeafDistributionGenerator; 
    25         delete mBillboardCloudGenerator; 
    26         delete mBillboardCloudUVMapper; 
    27         delete mOgreMeshSerializer; 
    28         delete mLeaves; 
     19        if (mOgreMeshSerializer) 
     20        { 
     21                delete mOgreMeshSerializer; 
     22        } 
     23        if (mSampleConfigFile) 
     24        { 
     25                delete mSampleConfigFile; 
     26        } 
     27        if (mLeafDistributionSerializer) 
     28        { 
     29                delete mLeafDistributionSerializer; 
     30        } 
     31        if (mLeafDistributionGenerator) 
     32        { 
     33                delete mLeafDistributionGenerator; 
     34        } 
     35        if (mBillboardCloudGenerator) 
     36        { 
     37                delete mBillboardCloudGenerator; 
     38        } 
     39        if (mBillboardCloudUVMapper) 
     40        { 
     41                delete mBillboardCloudUVMapper; 
     42        } 
     43        if (mBillboardCloudSerializer) 
     44        { 
     45                delete mBillboardCloudSerializer; 
     46        } 
     47        if (mLeaves) 
     48        { 
     49                delete mLeaves; 
     50        } 
     51 
    2952} 
    3053 
    3154SampleConfigFile* Manager::getSampleConfigFile() 
    3255{ 
    33         return &mSampleCf; 
    34 } 
    35 void Manager::runSample(Ogre::String sampleConfigFile) 
    36 { 
    37         Ogre::LogManager::getSingleton().logMessage("Sample Config Filename:" + sampleConfigFile); 
    38  
    39         mSampleCf.load(sampleConfigFile); 
     56        return mSampleConfigFile; 
     57} 
     58 
     59void Manager::setSampleConfigFile(SampleConfigFile *sampleConfigFile) 
     60{ 
     61        mSampleConfigFile = sampleConfigFile; 
     62} 
     63 
     64void Manager::loadSampleConfigFile(Ogre::String sampleConfigFile) 
     65{ 
     66        mSampleConfigFile = new SampleConfigFile(); 
     67        mSampleConfigFile->load(sampleConfigFile); 
     68} 
     69 
     70void Manager::runSampleConfigFile() 
     71{ 
    4072        mLeaves = new Leaves(); 
    41  
    42         Ogre::Mesh* leavesMesh = BBC::Manager::getSingleton().loadMesh( 
    43                                                                 mSampleCf.getEntitiesMeshPrefixFilename() + ".mesh");    
    4473         
    45         mLeaves->setMesh(leavesMesh); 
    46  
    47         if (mSampleCf.getEntityDistributionGeneration()) 
     74        BBC::EntityPtr entityLeaves(new BBC::Entity); 
     75        BBC::MeshPtr meshLeaves(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + ".mesh")) ); 
     76        entityLeaves->setMesh(meshLeaves);       
     77        mLeaves->setEntity(entityLeaves); 
     78        mLeaves->getEntity()->setMesh(meshLeaves); 
     79 
     80        if (mSampleConfigFile->getEntityDistributionGeneration()) 
    4881        { 
    4982                generateEntityDistribution(); 
     
    5487        } 
    5588         
    56         if (mSampleCf.getEntityClustersGeneration()) 
     89        if (mSampleConfigFile->getEntityClustersGeneration()) 
    5790        { 
    5891                generateEntityClusters(); 
    5992        } 
    60         if (mSampleCf.getBillboardCloudGeneration()) 
     93 
     94        if (mSampleConfigFile->getBillboardCloudGeneration()) 
    6195        { 
    6296                generateBillboardCloud(); 
     
    67101{ 
    68102        mLeafDistributionGenerator->setDistribution(mLeaves->getDistribution()); 
    69         mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getMesh());    
     103        mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getEntity()->getMesh());       
    70104        mLeafDistributionGenerator->generate(); 
    71105} 
     
    73107void Manager::saveEntityDistributionSplitted() 
    74108{ 
    75         BBC::Entity *entity; 
    76         entity = new BBC::Entity(); 
    77  
    78         if (mSampleCf.getEntityDistributionSplitted() || mSampleCf.getEntityDistributionMerged()) 
     109        BBC::EntityPtr entity; 
     110        entity = BBC::EntityPtr(new BBC::Entity()); 
     111 
     112        if (mSampleConfigFile->getEntityDistributionSplitted() || mSampleConfigFile->getEntityDistributionMerged()) 
    79113        { 
    80114                BBC::EntityDistribution *entityDistribution;             
    81115                unsigned int numSerializedEntities = 0; 
    82  
    83116                 
    84117                entityDistribution = mLeaves->getDistribution(); 
    85118                for (unsigned int iEntity = 0; iEntity < entityDistribution->getNumEntities(); iEntity++) 
    86119                {                                
    87                                 BBC::SubEntity *subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 
     120                                BBC::SubEntityPtr subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 
    88121 
    89122                                if (iEntity == 0) 
    90123                                { 
    91                                         // Delete the default constructed subentity... 
     124                                        // delete the default constructed subentity... 
    92125                                        entity->removeSubEntity(0); 
    93126 
     
    100133                                } 
    101134 
    102                                 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleCf.getEntityDistributionMergedMaterialPrefixName()); 
     135                                entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 
    103136                                numSerializedEntities++;                         
    104137                }                
     
    106139                entity->setSubEntitiesDistinctVertexColours(); 
    107140                 
    108                 if (mSampleCf.getEntityDistributionSplitted()) 
     141                if (mSampleConfigFile->getEntityDistributionSplitted()) 
    109142                { 
    110143                        mOgreMeshSerializer->setEntity(entity); 
    111                         mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 
    112                                 mSampleCf.getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 
     144                        mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 
     145                                mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 
    113146                         
    114                         mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityDistributionFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh"); 
    115                         //mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh" + ".xml"); 
    116                 } 
    117         } 
    118  
    119         if (mSampleCf.getEntityDistributionMerged()) 
     147                        OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh"); 
     148                        //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh().get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh" + ".xml");                       
     149                } 
     150        } 
     151 
     152        if (mSampleConfigFile->getEntityDistributionMerged()) 
    120153        { 
    121154                entity->mergeSubEntities(); 
    122                 entity->getSubEntity(0)->setMaterialName(mSampleCf.getEntityDistributionMergedMaterialPrefixName()); 
     155                entity->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 
    123156         
    124157                mOgreMeshSerializer->setEntity(entity); 
    125                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 
    126                         mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 
    127                  
    128                 mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityDistributionFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Merged.mesh"); 
    129                 //mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Merged.mesh" + ".xml"); 
    130                  
    131                 delete entity; 
     158                mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 
     159                        mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 
     160                 
     161                OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh"); 
     162                //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh" + ".xml");               
     163 
     164                //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh"); 
    132165        } 
    133166} 
     
    136169{ 
    137170        TiXmlDocument *document = mLeafDistributionSerializer->create( 
    138                                                                         mSampleCf.getEntityDistributionFolder() + 
    139                                                                         mSampleCf.getEntityDistributionXMLPrefixFilename() + ".xml"); 
     171                                                                        mSampleConfigFile->getEntityDistributionFolder() + 
     172                                                                        mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 
    140173        mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 
    141174        mLeafDistributionSerializer->writeLeafDistribution(document);    
     
    146179{ 
    147180        TiXmlDocument *document = mLeafDistributionSerializer->load( 
    148                                                                         mSampleCf.getEntityDistributionFolder() + 
    149                                                                         mSampleCf.getEntityDistributionXMLPrefixFilename() + ".xml"); 
     181                                                                        mSampleConfigFile->getEntityDistributionFolder() + 
     182                                                                        mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 
    150183        mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 
    151         mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getMesh()); 
     184        mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 
    152185        mLeafDistributionSerializer->readLeafDistribution(document); 
    153186 
    154         BBC::Entity *entity; 
     187        BBC::EntityPtr entity; 
    155188        BBC::EntityDistribution *entityDistribution; 
    156189 
    157         Ogre::Mesh* leavesSplittedMesh = BBC::Manager::getSingleton().loadMesh(mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh");             
    158         entity = new BBC::Entity(); 
    159         entity->setMesh(leavesSplittedMesh); 
     190        BBC::MeshPtr pMeshLeavesSplitted(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh"))); 
     191        entity = BBC::EntityPtr(new BBC::Entity()); 
     192        entity->setMesh(pMeshLeavesSplitted); 
    160193 
    161194        entity->loadMesh(false); 
     
    164197        for (unsigned int iSubEntity = 0; iSubEntity < entity->getNumSubEntities(); iSubEntity++) 
    165198        {        
    166                 BBC::Entity *entitySample; 
    167                 BBC::SubEntity *subEntity; 
    168                 BBC::SubEntity *subEntitySample; 
     199                BBC::EntityPtr entitySample; 
     200                BBC::SubEntityPtr subEntity; 
     201                BBC::SubEntityPtr subEntitySample; 
    169202                         
    170203                subEntity = entity->getSubEntity(iSubEntity); 
     
    180213void Manager::generateEntityDistribution() 
    181214{ 
    182         if (mSampleCf.getEntityDistributionGeneration()) 
     215        if (mSampleConfigFile->getEntityDistributionGeneration()) 
    183216        { 
    184217                createEntityDistribution(); 
     
    192225        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    193226        { 
    194                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    195                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     227                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     228                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    196229        } 
    197230        mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    198231    
    199232        Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 
    200         mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 
    201                                 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh",false, false); 
    202         mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 
    203         mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh.xml"); 
     233        mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 
     234                                mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh",false, false); 
     235        OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 
     236        OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh.xml"); 
     237 
     238        //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 
    204239} 
    205240 
     
    209244        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    210245        { 
    211                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    212                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     246                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     247                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    213248        } 
    214249 
    215250        mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    216         mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 
    217                                 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false); 
    218         mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh"); 
    219         mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh.xml"); 
     251 
     252        Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 
     253 
     254        mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 
     255                                mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false); 
     256 
     257        OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh"); 
     258 
     259        OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh.xml"); 
    220260} 
    221261 
    222262void Manager::saveBillboardCloudMerged() 
    223263{        
    224         //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     264        //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    225265        //mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    226         //mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 
    227         //                      mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleCf.getBillboardCloudMergedBillboards(), false); 
    228         //mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(),  
    229         //                      mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 
    230         //mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 
     266        //mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 
     267        //                      mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleConfigFile->getBillboardCloudMergedBillboards(), false); 
     268        //OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(),  
     269        //                      mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 
     270        //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 
    231271         
    232272 
    233273        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    234274        { 
    235                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    236                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     275                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     276                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    237277        } 
    238278        mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    239279    
    240280        Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 
    241         mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 
    242                                 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh",false, false); 
    243         mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 
    244         mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 
     281        mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 
     282                                mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh",false, false); 
     283        OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh");     
     284        OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 
     285         
     286        //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 
    245287} 
    246288 
     
    249291        //saveBillboardCloud() 
    250292        TiXmlDocument *document2 = mBillboardCloudSerializer->create( 
    251                                                                         mSampleCf.getBillboardCloudFolder() +  
    252                                                                         mSampleCf.getBillboardCloudXMLPrefixFilename() + ".xml"); 
     293                                                                        mSampleConfigFile->getBillboardCloudFolder() +  
     294                                                                        mSampleConfigFile->getBillboardCloudXMLPrefixFilename() + ".xml"); 
    253295        mBillboardCloudSerializer->setBillboardCloud(mLeaves->getBillboardCloud()); 
    254296        mBillboardCloudSerializer->writeBillboardCloud(document2);       
     
    258300void Manager::saveEntityClusters() 
    259301{ 
    260         BBC::BillboardClusterData *billboardClusterData; 
    261         BBC::EntityCluster *entityCluster; 
     302        BBC::BillboardClusterDataPtr billboardClusterData; 
     303        BBC::EntityClusterPtr entityCluster; 
    262304        unsigned int numSerializedBillboards = 0;        
    263305 
    264         if (mSampleCf.getEntityClustersSplittedClusters()) 
     306        if (mSampleConfigFile->getEntityClustersSplittedClusters()) 
    265307        { 
    266308 
     
    272314                        if (entityCluster->getNumEntitiesClusterData() > 0) 
    273315                        {                                        
    274                                 BBC::Entity *entityClusterized = entityCluster->getEntity(); 
    275                                 entityClusterized->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename()); 
     316                                BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 
     317                                entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 
    276318                                mOgreMeshSerializer->setEntity(entityClusterized); 
    277                                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityDistributionFolder() + 
    278                                         mSampleCf.getEntityClustersMeshPrefixFilename() + 
    279                                         Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleCf.getEntityClustersSplittedClusters()), false); 
    280                                 mMeshSerializer->exportMesh(entityClusterized->getMesh(), 
    281                                         mSampleCf.getEntityClustersFolder() + 
    282                                         mSampleCf.getEntityClustersMeshPrefixFilename() + 
     319                                mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() + 
     320                                        mSampleConfigFile->getEntityClustersMeshPrefixFilename() + 
     321                                        Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleConfigFile->getEntityClustersSplittedClusters()), false); 
     322                                OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entityClusterized->getMesh()->get(), 
     323                                        mSampleConfigFile->getEntityClustersFolder() + 
     324                                        mSampleConfigFile->getEntityClustersMeshPrefixFilename() + 
    283325                                        Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh"); 
    284                                 //mXMLMeshSerializer->exportMesh(entityClusterized->getMesh(), entityClusterized->getMesh()->getName() + ".xml"); 
     326                                //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityClusterized->getMesh(), entityClusterized->getMesh()->getName() + ".xml"); 
     327 
     328                                //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh"); 
    285329 
    286330                                numSerializedBillboards++; 
     
    290334        numSerializedBillboards = 0; 
    291335 
    292 if (mSampleCf.getEntityClustersMergedClusters()) 
    293         { 
    294                 BBC::Entity *entity; 
    295                 entity = new BBC::Entity(); 
     336        if (mSampleConfigFile->getEntityClustersMergedClusters()) 
     337        { 
     338                BBC::EntityPtr entity; 
     339                entity = BBC::EntityPtr(new BBC::Entity()); 
    296340 
    297341                for (unsigned int iBillboard = 0; iBillboard < mLeaves->getBillboardCloud()->getNumBillboards(); iBillboard++) 
     
    302346                        if (entityCluster->getNumEntitiesClusterData() > 0) 
    303347                        {                        
    304                                 BBC::Entity *entityClusterized = entityCluster->getEntity(); 
    305                                 entityClusterized->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename()); 
    306                                 BBC::SubEntity *subEntity = entityClusterized->getSubEntity(0); 
     348                                BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 
     349                                entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 
     350                                BBC::SubEntityPtr subEntity = entityClusterized->getSubEntity(0); 
    307351 
    308352                                if (numSerializedBillboards == 0) 
    309353                                { 
    310                                         // Delete the default constructed subentity... 
     354                                        // delete the default constructed subentity... 
    311355                                        entity->removeSubEntity(0); 
    312356 
     
    326370 
    327371                mOgreMeshSerializer->setEntity(entity); 
    328                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 
    329                         mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 
    330                  
    331                 mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 
    332                 //mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh" + ".xml"); 
    333  
    334                 delete entity; 
    335         } 
    336  
    337  
    338  
     372                mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 
     373                        mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 
     374                 
     375                OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 
     376                //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh" + ".xml"); 
     377 
     378                //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 
     379 
     380                Ogre::LogManager::getSingleton().logMessage("Before deleting:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh");      
     381        } 
    339382} 
    340383 
     
    343386        mBillboardCloudGenerator->setDistribution(mLeaves->getDistribution()); 
    344387        mBillboardCloudGenerator->setBillboardCloud(mLeaves->getBillboardCloud()); 
    345         mBillboardCloudGenerator->setMaxNumBillboards(mSampleCf.getEntityClustersMaxClusters()); 
    346         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleCf.getEntityClustersAlpha()); 
    347         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleCf.getEntityClustersNumIterations()); 
    348         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->generate(); 
     388        mBillboardCloudGenerator->setMaxNumBillboards(mSampleConfigFile->getEntityClustersMaxClusters()); 
     389        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleConfigFile->getEntityClustersAlpha()); 
     390        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleConfigFile->getEntityClustersNumIterations()); 
     391        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->generate(); 
    349392} 
    350393 
    351394void Manager::saveSingleEntity() 
    352395{ 
    353         if (mSampleCf.getEntitySampleMeshGeneration()) 
    354         { 
    355                 BBC::Entity *entityLeaf = mLeaves->getDistribution()->getEntity(2); 
    356                 entityLeaf->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename()); 
     396        if (mSampleConfigFile->getEntitySampleMeshGeneration()) 
     397        { 
     398                BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2); 
     399                entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 
    357400                mOgreMeshSerializer->setEntity(entityLeaf); 
    358                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityDistributionFolder() + 
    359                         mSampleCf.getEntitySampleMeshPrefixFilename(), mSampleCf.getEntityClustersMergedClusters(), false); 
    360                 //mXMLMeshSerializer->exportMesh(entityLeaf->getMesh(), entityLeaf->getMesh()->getName() + ".xml"); 
     401                mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() + 
     402                        mSampleConfigFile->getEntitySampleMeshPrefixFilename(), mSampleConfigFile->getEntityClustersMergedClusters(), false); 
     403                //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh(), entityLeaf->getMesh()->getName() + ".xml"); 
     404 
    361405        } 
    362406} 
     
    364408void Manager::generateEntityClusters() 
    365409{ 
    366         Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleCf.getEntityClustersMeshPrefixFilename()); 
     410        Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename()); 
    367411        createEntityClusters(); 
    368412        saveEntityClusters(); 
     
    372416void Manager::generateBillboardCloud() 
    373417{ 
    374         if (mSampleCf.getBillboardCloudMergedBillboards()) 
    375         { 
    376                 //mLeaves->getBillboardCloud()->generateBillboardCloud(mSampleCf.getBillboardCloudMergedBillboards()); 
    377                 //mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 
    378  
    379                 //if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    380                 //{ 
    381                 //      mBillboardCloudUVMapper->clear(); 
    382                 //      mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    383                 //      mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    384                 //      mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    385                 //      mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    386                 //      mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    387                 //      mBillboardCloudUVMapper->initialize(); 
    388                 //      mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1);  
    389                 //} 
    390  
    391                 //mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 
    392                 //saveBillboardCloudMerged(); 
    393  
     418        if (mSampleConfigFile->getBillboardCloudMergedBillboards()) 
     419        { 
    394420                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
     421 
    395422                mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 
    396                  
    397                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    398                 { 
    399                         mBillboardCloudUVMapper->clear(); 
     423 
     424                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     425                { 
     426                        mBillboardCloudUVMapper->shutdown(); 
    400427                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    401                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    402                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    403                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    404                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     428                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     429                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     430                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     431                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    405432                        mBillboardCloudUVMapper->initialize(); 
    406                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1);  
     433 
     434                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1);  
    407435                } 
    408436 
     
    410438 
    411439                saveBillboardCloudMerged(); 
    412         } 
    413  
    414         if (mSampleCf.getBillboardCloudGroupedBillboards()) 
     440 
     441        } 
     442 
     443        if (mSampleConfigFile->getBillboardCloudGroupedBillboards()) 
    415444        {                                
    416445                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
    417                 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleCf.getBillboardCloudGroups()); 
    418                  
    419                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    420                 { 
    421                         mBillboardCloudUVMapper->clear(); 
     446                mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups()); 
     447                 
     448                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     449                { 
     450                        mBillboardCloudUVMapper->shutdown(); 
    422451                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    423                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    424                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    425                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    426                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     452                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     453                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     454                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     455                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    427456                        mBillboardCloudUVMapper->initialize(); 
    428                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), mSampleCf.getBillboardCloudGroups());  
     457                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups());  
    429458                } 
    430459 
     
    434463        } 
    435464 
    436         if (mSampleCf.getBillboardCloudSplittedBillboards()) 
     465        if (mSampleConfigFile->getBillboardCloudSplittedBillboards()) 
    437466        {                
    438                 mLeaves->getBillboardCloud()->generateBillboardCloud(!mSampleCf.getBillboardCloudSplittedBillboards()); 
    439                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    440                 { 
    441                         mBillboardCloudUVMapper->clear(); 
     467                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
     468                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     469                { 
     470                        mBillboardCloudUVMapper->shutdown(); 
    442471                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    443                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    444                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    445                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    446                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     472                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     473                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     474                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     475                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    447476                        mBillboardCloudUVMapper->initialize(); 
    448                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleCf.getBillboardCloudSplittedBillboards(),false);  
     477                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false);  
    449478                } 
    450479                saveBillboardCloudSplitted(); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCSampleConfigFile.cpp

    r709 r721  
    33namespace LBBC { 
    44 
    5 SampleConfigFile::SampleConfigFile() 
     5SampleConfigFile::SampleConfigFile(): Ogre::ConfigFile() 
    66{ 
    77} 
     
    4848Ogre::String SampleConfigFile::getEntitiesFolder() 
    4949{ 
    50         return getSetting("Entites Folder"); 
     50        return getSetting("Entities Folder"); 
    5151} 
    5252 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/main.cpp

    r709 r721  
    1 #include <LBBC.h> 
    2 #include <LBBCPrerequisites.h> 
    31 
    4 struct CommandLineOptions 
    5 { 
    6         Ogre::String cfg; 
    7 }; 
    8  
    9 int findCommandLineOpts(int numargs, char** argv, Ogre::UnaryOptionList& unaryOptList,  
    10                                                 Ogre::BinaryOptionList& binOptList) 
    11 { 
    12     int startIndex = 1; 
    13     for (int i = 1; i < numargs; ++i) 
    14     { 
    15                 Ogre::String tmp(argv[i]); 
    16                 if (Ogre::StringUtil::startsWith(tmp, "-")) 
    17         { 
    18                         Ogre::UnaryOptionList::iterator ui = unaryOptList.find(argv[i]); 
    19             if(ui != unaryOptList.end()) 
    20             { 
    21                 ui->second = true; 
    22                 ++startIndex; 
    23                 continue; 
    24             } 
    25                         Ogre::BinaryOptionList::iterator bi = binOptList.find(argv[i]); 
    26             if(bi != binOptList.end()) 
    27             { 
    28                 bi->second = argv[i+1]; 
    29                 startIndex += 2; 
    30                 ++i; 
    31                 continue; 
    32             } 
    33  
    34             // Invalid option 
    35                         std::cout<<"Invalid option "<<tmp<<std::endl; 
    36  
    37         } 
    38     } 
    39     return startIndex; 
    40 } 
    41  
    42 CommandLineOptions parseArgs(int numArgs, char **args) 
    43 { 
    44     CommandLineOptions opts; 
    45  
    46         Ogre::UnaryOptionList unOpt; 
    47         Ogre::BinaryOptionList binOpt; 
    48  
    49     binOpt["-cfg"] = ""; 
    50      
    51         int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt); 
    52         Ogre::UnaryOptionList::iterator ui; 
    53         Ogre::BinaryOptionList::iterator bi; 
    54          
    55     bi = binOpt.find("-cfg"); 
    56     if (!bi->second.empty()) 
    57     { 
    58                 opts.cfg = bi->second;   
    59     }    
    60  
    61     return opts; 
    62 } 
    63  
    64 void help() 
    65 { 
    66         std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl; 
    67 } 
     2#include <IBRBillboardCloudTreeApplication.h> 
    683 
    694int main(int numargs, char** args) 
    705{        
    71         /* 
    72         if (numargs < 2) 
    73     { 
    74         help(); 
    75         return -1; 
    76     } 
    77     */ 
    78  
    79         CommandLineOptions opts = parseArgs(numargs, args); 
    80  
    81         LBBC::Manager* manager = new LBBC::Manager(); 
    82         LBBC::Manager::getSingleton().initialize();      
    83  
    84         manager->runSample(Ogre::String(opts.cfg));      
    85  
    86         LBBC::Manager::getSingleton().shutdown(); 
    87         delete manager;  
     6        IBRBillboardCloudTreeApplication *app = new IBRBillboardCloudTreeApplication(); 
     7        app->parseArgs(numargs, args); 
     8        app->initialize(); 
     9        delete app; 
    8810 
    8911        return 0; 
Note: See TracChangeset for help on using the changeset viewer.