Changeset 721 for GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE
- Timestamp:
- 03/31/06 17:29:32 (18 years ago)
- 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 6 6 namespace BBC { 7 7 8 class _BBCExport Billboard { 8 // Forward declarations 9 class Billboard; 10 11 namespace boost 12 { 13 void intrusive_ptr_add_ref(Billboard * p); 14 void intrusive_ptr_release(Billboard * p); 15 }; 16 17 18 class _BBCExport Billboard 19 { 20 private: 21 long references; 22 friend void boost::intrusive_ptr_add_ref(Billboard * p); 23 friend void boost::intrusive_ptr_release(Billboard * p); 24 9 25 public: 10 26 Billboard(); 11 27 12 ~Billboard();28 virtual ~Billboard(); 13 29 14 30 … … 25 41 protected: 26 42 27 BillboardClusterData *mBillboardClusterData;43 BillboardClusterDataPtr mBillboardClusterData; 28 44 29 45 public: 30 46 31 void setBillboardClusterData(BillboardClusterData *value);47 void setBillboardClusterData(BillboardClusterDataPtr value); 32 48 33 BillboardClusterData *getBillboardClusterData();49 BillboardClusterDataPtr getBillboardClusterData(); 34 50 35 51 }; 36 52 53 // class specific addref/release implementation 54 // the two function overloads must be in the boost namespace on most compilers: 55 namespace 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 73 typedef ::boost::intrusive_ptr<Billboard> BillboardPtr; 74 37 75 } 38 76 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h
r709 r721 13 13 BillboardCloud(); 14 14 15 ~BillboardCloud();15 virtual ~BillboardCloud(); 16 16 17 17 18 18 protected: 19 std::vector<Billboard *> mBillboardList;19 std::vector<BillboardPtr> mBillboardList; 20 20 21 std::vector<BillboardGroup *> mBillboardGroupList;21 std::vector<BillboardGroupPtr> mBillboardGroupList; 22 22 23 23 public: 24 std::vector<Billboard *>* getBillboardList();24 std::vector<BillboardPtr>* getBillboardList(); 25 25 26 void setBillboardList(std::vector<Billboard *> &value);26 void setBillboardList(std::vector<BillboardPtr> &value); 27 27 28 void addBillboard(Billboard *value);28 void addBillboard(BillboardPtr value); 29 29 30 30 void removeBillboard(unsigned int value); 31 31 32 Billboard *getBillboard(unsigned int value);32 BillboardPtr getBillboard(unsigned int value); 33 33 34 34 unsigned int BillboardCloud::getNumBillboards(); … … 42 42 unsigned int getNumBillboardGroups(); 43 43 44 BillboardGroup *getBillboardGroup(unsigned int iBillboardGroup);44 BillboardGroupPtr getBillboardGroup(unsigned int iBillboardGroup); 45 45 46 void addBillboardGroup(BillboardGroup *value);46 void addBillboardGroup(BillboardGroupPtr value); 47 47 48 48 void removeBillboardGroup(unsigned int value); 49 49 50 50 protected: 51 Entity *mEntity;51 EntityPtr mEntity; 52 52 53 53 54 54 public: 55 Entity *getEntity();55 EntityPtr getEntity(); 56 56 57 void setEntity(Entity *value);57 void setEntity(EntityPtr value); 58 58 59 59 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h
r700 r721 11 11 class _BBCExport BillboardCloudGenerator { 12 12 public: 13 14 BillboardCloudGenerator(); 15 16 virtual ~BillboardCloudGenerator(); 17 13 18 void generate(); 14 19 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudSerializer.h
r700 r721 17 17 BillboardCloudSerializer(); 18 18 19 ~BillboardCloudSerializer();19 virtual ~BillboardCloudSerializer(); 20 20 21 21 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h
r709 r721 66 66 void removeClusterList(unsigned int iClusterList); 67 67 68 void clear();68 void shutdown(); 69 69 70 70 unsigned int getNumClusterLists(); … … 74 74 BillboardCloudUVMapper(); 75 75 76 ~BillboardCloudUVMapper();76 virtual ~BillboardCloudUVMapper(); 77 77 78 78 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h
r700 r721 6 6 namespace BBC { 7 7 8 class _BBCExport BillboardClusterData { 8 // Fordward declaration... 9 class BillboardClusterData; 10 11 namespace boost 12 { 13 void intrusive_ptr_add_ref(BillboardClusterData * p); 14 void intrusive_ptr_release(BillboardClusterData * p); 15 }; 16 17 class _BBCExport BillboardClusterData 18 { 19 private: 20 long references; 21 friend void boost::intrusive_ptr_add_ref(BillboardClusterData * p); 22 friend void boost::intrusive_ptr_release(BillboardClusterData * p); 23 9 24 public: 10 25 BillboardClusterData(); 11 26 12 ~BillboardClusterData();27 virtual ~BillboardClusterData(); 13 28 14 29 void setNormal(Ogre::Vector3 value); … … 20 35 float getD(); 21 36 22 EntityCluster *getEntityCluster();37 EntityClusterPtr getEntityCluster(); 23 38 24 void setEntityCluster(EntityCluster *value);39 void setEntityCluster(EntityClusterPtr value); 25 40 26 41 virtual void readBillboardClusterData(TiXmlNode *parentNode); … … 47 62 48 63 protected: 49 EntityCluster *mEntityCluster;64 EntityClusterPtr mEntityCluster; 50 65 51 66 Ogre::Vector3 mAxisX; … … 70 85 }; 71 86 87 // class specific addref/release implementation 88 // the two function overloads must be in the boost namespace on most compilers: 89 namespace 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 107 typedef ::boost::intrusive_ptr<BillboardClusterData> BillboardClusterDataPtr; 108 72 109 } 73 110 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h
r709 r721 6 6 namespace BBC { 7 7 8 class BillboardGroup { 8 typedef 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 18 class BillboardGroup; 19 20 21 namespace boost 22 { 23 void intrusive_ptr_add_ref(BillboardGroup * p); 24 void intrusive_ptr_release(BillboardGroup * p); 25 }; 26 27 class BillboardGroup 28 { 29 private: 30 long references; 31 friend void boost::intrusive_ptr_add_ref(BillboardGroup * p); 32 friend void boost::intrusive_ptr_release(BillboardGroup * p); 33 9 34 protected: 10 35 std::vector<unsigned int> mBillboardHandleList; 11 36 12 37 public: 38 39 BillboardGroup(); 40 41 virtual ~BillboardGroup(); 42 13 43 unsigned int getBillboardHandle(unsigned int iBillboard); 14 44 … … 19 49 }; 20 50 51 // class specific addref/release implementation 52 // the two function overloads must be in the boost namespace on most compilers: 53 namespace 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 71 typedef ::boost::intrusive_ptr<BillboardGroup> BillboardGroupPtr; 72 21 73 } 22 74 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntity.h
r700 r721 4 4 #include <BBCPrerequisites.h> 5 5 #include <BBCSubEntity.h> 6 #include <BBCMesh.h> 6 7 7 8 namespace BBC { 8 9 10 // Forward declarations 11 class Entity; 12 13 14 namespace boost 15 { 16 void intrusive_ptr_add_ref(Entity * p); 17 void intrusive_ptr_release(Entity * p); 18 }; 19 9 20 class _BBCExport Entity 10 21 { 22 private: 23 long references; 24 friend void boost::intrusive_ptr_add_ref(Entity * p); 25 friend void boost::intrusive_ptr_release(Entity * p); 26 11 27 protected: 12 28 13 typedef std::vector<SubEntity *> SubEntityList;29 typedef std::vector<SubEntityPtr> SubEntityList; 14 30 15 31 unsigned int mEntityHandle; … … 19 35 SubEntityList mSubEntityList; 20 36 21 Ogre::Mesh *mMesh;37 MeshPtr mMesh; 22 38 23 39 public: … … 25 41 Entity(); 26 42 27 ~Entity();43 virtual ~Entity(); 28 44 29 45 void createSubEntity(); 30 46 31 void addSubEntity(SubEntity *value);47 void addSubEntity(SubEntityPtr value); 32 48 33 SubEntity *getSubEntity(unsigned int index);49 SubEntityPtr getSubEntity(unsigned int index); 34 50 35 51 void removeSubEntity(unsigned int index); 36 52 37 virtual Ogre::Mesh*getMesh();53 virtual MeshPtr getMesh(); 38 54 39 virtual void setMesh( Ogre::Mesh *value);55 virtual void setMesh(MeshPtr value); 40 56 41 57 void loadMesh(bool mergeSubMeshes); … … 65 81 }; 66 82 83 // class specific addref/release implementation 84 // the two function overloads must be in the boost namespace on most compilers: 85 namespace 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 103 typedef ::boost::intrusive_ptr<Entity> EntityPtr; 104 67 105 } 68 106 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityCluster.h
r700 r721 11 11 namespace BBC { 12 12 13 class _BBCExport EntityCluster { 13 // Forward declarations 14 class EntityCluster; 15 16 17 namespace boost 18 { 19 void intrusive_ptr_add_ref(EntityCluster * p); 20 void intrusive_ptr_release(EntityCluster * p); 21 }; 22 23 class _BBCExport EntityCluster 24 { 25 private: 26 long references; 27 friend void boost::intrusive_ptr_add_ref(EntityCluster * p); 28 friend void boost::intrusive_ptr_release(EntityCluster * p); 29 14 30 public: 15 31 EntityCluster(); 16 32 17 ~EntityCluster();33 virtual ~EntityCluster(); 18 34 19 EntityClusterData* getEntityClusterData(unsigned int value);35 void removeEntityClusterData(unsigned int value); 20 36 21 void addEntityClusterData(EntityClusterData *value); 37 EntityClusterDataPtr getEntityClusterData(unsigned int value); 38 39 void addEntityClusterData(EntityClusterDataPtr value); 22 40 23 41 void removeEntitClusterData(unsigned int value); 24 42 25 EntityDistribution *getEntityDistribution();43 EntityDistributionPtr getEntityDistribution(); 26 44 27 void setEntityDistribution(EntityDistribution *value);45 void setEntityDistribution(EntityDistributionPtr value); 28 46 29 47 protected: 30 48 31 EntityDistribution *mEntityDistribution;49 EntityDistributionPtr mEntityDistribution; 32 50 33 std::vector<EntityClusterData *> mEntityClusterDataList;51 std::vector<EntityClusterDataPtr> mEntityClusterDataList; 34 52 35 53 std::vector<unsigned int> mBillboarHandle; 36 54 37 Entity *mEntity;55 EntityPtr mEntity; 38 56 39 57 unsigned int mBillboardHandle; … … 41 59 public: 42 60 43 Entity *getEntity();61 EntityPtr getEntity(); 44 62 45 void setEntity(Entity *value);63 void setEntity(EntityPtr value); 46 64 47 65 unsigned int getNumEntitiesClusterData(); … … 55 73 }; 56 74 75 // class specific addref/release implementation 76 // the two function overloads must be in the boost namespace on most compilers: 77 namespace 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 95 typedef ::boost::intrusive_ptr<EntityCluster> EntityClusterPtr; 96 97 57 98 } 58 99 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityClusterData.h
r700 r721 6 6 namespace BBC { 7 7 8 class _BBCExport EntityClusterData { 8 // Fordward declaration... 9 class EntityClusterData; 10 11 namespace boost 12 { 13 void intrusive_ptr_add_ref(EntityClusterData * p); 14 void intrusive_ptr_release(EntityClusterData * p); 15 }; 16 17 class _BBCExport EntityClusterData 18 { 19 private: 20 long references; 21 friend void boost::intrusive_ptr_add_ref(EntityClusterData * p); 22 friend void boost::intrusive_ptr_release(EntityClusterData * p); 23 9 24 public: 10 25 EntityClusterData(); 11 26 12 ~EntityClusterData();27 virtual ~EntityClusterData(); 13 28 14 void setEntity(Entity *value);29 void setEntity(EntityPtr value); 15 30 16 Entity *getEntity();31 EntityPtr getEntity(); 17 32 18 33 protected: 19 Entity *mEntity;34 EntityPtr mEntity; 20 35 21 36 }; 22 37 38 // class specific addref/release implementation 39 // the two function overloads must be in the boost namespace on most compilers: 40 namespace 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 58 typedef ::boost::intrusive_ptr<EntityClusterData> EntityClusterDataPtr; 59 23 60 } 24 61 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistribution.h
r700 r721 6 6 namespace BBC { 7 7 8 class _BBCExport EntityDistribution { 8 // Forward declarations 9 class EntityDistribution; 10 11 12 namespace boost 13 { 14 void intrusive_ptr_add_ref(EntityDistribution * p); 15 void intrusive_ptr_release(EntityDistribution * p); 16 }; 17 18 class _BBCExport EntityDistribution 19 { 20 private: 21 long references; 22 friend void boost::intrusive_ptr_add_ref(EntityDistribution * p); 23 friend void boost::intrusive_ptr_release(EntityDistribution * p); 24 9 25 protected: 10 std::vector<Entity *> mEntityList;26 std::vector<EntityPtr> mEntityList; 11 27 12 28 public: 13 Entity* getEntity(unsigned int value);29 EntityDistribution(); 14 30 15 void addEntity(Entity *value); 31 virtual ~EntityDistribution(); 32 33 EntityPtr getEntity(unsigned int value); 34 35 void addEntity(EntityPtr value); 16 36 17 37 void removeEntity(unsigned int value); … … 20 40 }; 21 41 42 43 // class specific addref/release implementation 44 // the two function overloads must be in the boost namespace on most compilers: 45 namespace 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 63 typedef ::boost::intrusive_ptr<EntityDistribution> EntityDistributionPtr; 64 22 65 } 23 66 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionGenerator.h
r700 r721 13 13 EntityDistribution *mEntityDistribution; 14 14 15 Entity *mEntity;15 EntityPtr mEntity; 16 16 17 17 public: … … 20 20 void init(); 21 21 22 Entity *getEntity();22 EntityPtr getEntity(); 23 23 24 void setEntity(Entity *value);24 void setEntity(EntityPtr value); 25 25 26 26 void setDistribution(EntityDistribution *value); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCEntityDistributionSerializer.h
r700 r721 10 10 class _BBCExport EntityDistributionSerializer: public BBC::XmlSerializer { 11 11 protected: 12 Entity *mEntity;12 EntityPtr mEntity; 13 13 14 14 public: 15 Entity *getEntity();15 EntityPtr getEntity(); 16 16 17 void setEntity(Entity *value);17 void setEntity(EntityPtr value); 18 18 19 19 void generate(); … … 23 23 EntityDistributionSerializer(); 24 24 25 ~EntityDistributionSerializer();25 virtual ~EntityDistributionSerializer(); 26 26 27 27 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h
r700 r721 4 4 #include <BBCPrerequisites.h> 5 5 #include <BBCSingleton.h> 6 7 //#include <ExampleFrameListener.h>8 6 9 7 namespace BBC { … … 19 17 static Manager* getSingletonPtr(void); 20 18 21 void initRenderWindow(); 22 23 Ogre::Mesh* loadMesh(Ogre::String name); 19 Ogre::Mesh* loadMesh(Ogre::String folderName, Ogre::String fileName); 24 20 25 21 Ogre::Mesh* loadXMLMesh(Ogre::String name); 26 27 void loadResources();28 22 29 23 void saveMesh(Ogre::String name); … … 40 34 41 35 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 53 37 }; 54 38 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCOgreMeshSerializer.h
r700 r721 4 4 #include <BBCPrerequisites.h> 5 5 #include <BBCEntity.h> 6 #include <BBCMesh.h> 6 7 7 8 namespace BBC { … … 14 15 virtual ~OgreMeshSerializer(); 15 16 16 void setEntity(Entity *entity);17 void setEntity(EntityPtr entity); 17 18 18 Entity *getEntity();19 EntityPtr getEntity(); 19 20 20 21 void exportMesh(const Ogre::String& fileName, bool mergeSubMeshes, bool tangents); … … 22 23 protected: 23 24 24 Entity *mEntity;25 EntityPtr mEntity; 25 26 26 void buildMesh( Ogre::Mesh*pMesh, bool mergeSubmeshes);27 void buildMesh(MeshPtr pMesh, bool mergeSubmeshes); 27 28 28 void generateEntityAABB( Ogre::Mesh*pMesh);29 void generateEntityAABB(MeshPtr pMesh); 29 30 30 void exportSubMeshes( Ogre::Mesh*pMesh);31 void exportSubMeshes(MeshPtr pMesh); 31 32 32 void exportSubMesh( Ogre::Mesh* pMesh, SubEntity *subEntity);33 void exportSubMesh(MeshPtr pMesh, SubEntityPtr subEntity); 33 34 34 template <typename T> void writeIndexes(T* buf, SubEntity *subEntity);35 template <typename T> void writeIndexes(T* buf, SubEntityPtr subEntity); 35 36 36 37 void createVertexBuffer(Ogre::VertexData* vd, unsigned short bufIdx, UniqueVertexList *uniqueVertexList); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCPrerequisites.h
r700 r721 23 23 #include <OgreVertexBoneAssignment.h> 24 24 #include <OgreAxisAlignedBox.h> 25 26 25 #include <OgreKeyEvent.h> 27 26 #include <OgreEventListeners.h> … … 31 30 #include <OgrePixelFormat.h> 32 31 #include <OgreGpuProgram.h> 32 #include <OgreSharedPtr.h> 33 34 #include <OBA.h> 35 36 #include <boost/smart_ptr.hpp> 33 37 34 38 //#include <ospace/stl/hashset.h> … … 36 40 37 41 #define _BBCExport __declspec( dllexport ) 42 38 43 #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__ 3 3 4 4 namespace BBC { -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h
r700 r721 5 5 6 6 namespace BBC { 7 7 8 8 class _BBCExport UniqueVertex 9 9 { … … 24 24 typedef std::vector<UniqueVertex> UniqueVertexList; 25 25 26 class _BBCExport SubEntity { 27 public: 26 // Fordward declaration 27 class SubEntity; 28 29 namespace boost 30 { 31 void intrusive_ptr_add_ref(SubEntity * p); 32 void intrusive_ptr_release(SubEntity * p); 33 }; 34 35 class _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: 28 45 29 46 typedef std::vector<unsigned short int> TextureCoordSetsDimensions; 47 30 48 typedef std::vector<Ogre::Vector3> Indices; 31 32 protected:33 49 34 50 UniqueVertexList mUniqueVertexList; … … 56 72 SubEntity(); 57 73 58 ~SubEntity();74 virtual ~SubEntity(); 59 75 60 76 void enableTangents(bool value); … … 129 145 130 146 void generateAABBox(); 147 148 const char *GetClassName(void) const; 149 131 150 }; 151 152 // class specific addref/release implementation 153 // the two function overloads must be in the boost namespace on most compilers: 154 namespace 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 172 typedef ::boost::intrusive_ptr<SubEntity> SubEntityPtr; 132 173 133 174 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCXmlSerializer.h
r700 r721 11 11 XmlSerializer(); 12 12 13 ~XmlSerializer();13 virtual ~XmlSerializer(); 14 14 15 15 protected: 16 16 Ogre::String mFilename; 17 17 18 TiXmlDocument *mFile; 19 18 20 bool mLoaded; 19 21 -
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 9 3 10 4 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBBox.h
r700 r721 27 27 class BBox: public Ogre::AxisAlignedBox { 28 28 public: 29 inline BBox() { BBox::StartBoundingBox(); }29 BBox(); 30 30 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(); 39 32 40 inline Ogre::Vector3 GetMinimum() { return mMinimum; } 33 void StartBoundingBox(); 41 34 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(); 56 36 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(); 74 38 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); 78 40 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(); 114 42 115 inline bool intersects(Ogre::Vector3 * v) { 116 return Ogre::AxisAlignedBox::intersects(*v); 117 }; 43 Ogre::Vector3 GetCorner(int corner) const; 118 44 119 ~BBox();45 bool intersects(Ogre::Vector3 v); 120 46 121 47 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBox2d.h
r700 r721 2 2 #define _IMGBOX2D_H 3 3 4 #include "IMGBBox.h"4 #include <IMGBBox.h> 5 5 6 6 namespace IMG { 7 7 8 8 //* 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 }; 9 class Box2d 10 { 11 public: 12 Box2d(); 18 13 19 // GametoolsError -- Isma 17/08/2005 20 inline Box2d & operator =(const Box2d & p) { 21 mMinimum = p.mMinimum; 22 mMaximum = p.mMaximum; 23 }; 14 ~Box2d(); 24 15 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 } 28 23 29 inline Ogre::Vector2 GetMaximum() { 30 return mMaximum; 31 }; 24 Ogre::Vector2 GetMinimum(); 32 25 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(); 39 27 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); 44 29 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); 48 31 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(); 69 33 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; 76 35 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); 83 37 84 ~Box2d();38 bool FitPerfect(int w, int h); 85 39 86 pr ivate:40 protected: 87 41 Ogre::Vector2 mMinimum, mMaximum; 88 42 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGBsp.h
r700 r721 9 9 class Bsp { 10 10 public: 11 inline Bsp() : root(NULL), countleaf(0), counttotal(0){};11 Bsp(); 12 12 13 inline void SetRoot(NodeBsp * node) { 14 root = node; 15 counttotal++; 16 }; 13 virtual ~Bsp(); 17 14 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); 22 16 23 inline void PrintLeaf() { 24 PrintLeaf(root); 25 }; 17 void Print(); 26 18 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(); 45 20 46 inline NodeBsp * Get(int i) { 47 return root->Get (root, i); 48 }; 21 NodeBspPtr Insert(int w, int h, int idcluster); 49 22 23 NodeBspPtr Get(int i); 50 24 51 pr ivate:52 NodeBsp *root;25 protected: 26 NodeBspPtr root; 53 27 54 28 int countleaf; … … 56 30 int counttotal; 57 31 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); 64 33 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); 79 35 80 36 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster.h
r700 r721 2 2 #define _IMGCLUSTER_H 3 3 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> 8 9 9 namespace IMG { class Cluster2d; } 10 namespace IMG 11 { 10 12 11 namespace IMG { 12 13 class Cluster { 13 class Cluster 14 { 14 15 public: 15 16 Cluster(); … … 19 20 Cluster(const Cluster & p); 20 21 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); 27 23 28 inline Ogre::Vector3* GetNormal() { return &normal; };24 Ogre::Vector3* GetNormal(); 29 25 30 inline BBox* GetBound() { return bound; };26 BBox* GetBound(); 31 27 32 inline Box2d* GetBspNodeBound() { return bspnodebound; };28 Box2d* GetBspNodeBound(); 33 29 34 inline void SetBspNodeBound(Box2d* box) { 35 bspnodebound = box; 36 }; 30 void SetBspNodeBound(Box2d* box); 37 31 38 32 void Print(); … … 41 35 int AxisProjected(); 42 36 43 in line int GetId() const { return id; };37 int GetId() const; 44 38 45 inline void SetId(int id_) { id = id;};39 void SetId(int id_); 46 40 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(); 51 42 52 inline Ogre::Vector3* GetVector3sTex() const { return Vector3s_triangle_text;};43 Ogre::Vector3* GetVector3sTex() const; 53 44 54 // Gametools -- Isma 17/08/200555 //bool CreatePatches(bool dinamic = false);56 // Gametools -- Isma 17/08/200557 //Listid *GetPatchList() { return &patchlistid;}58 //Listid *GetTriangleList(){ return &trianglelistid; }59 // Gametools -- Isma 17/08/200560 //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/200567 //int GetIdTriangle (unsigned int i)68 //{69 // if (i > trianglelistid.GetSize()) return -1;70 //71 // return trianglelistid.Get(i);72 //}73 45 void Finish(); 74 46 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); 81 48 82 inline Plane3 * GetPlane() { return &plane; };49 Plane3 * GetPlane(); 83 50 84 51 //* Return the increment in U (lumel increment in x). For patchs calculation … … 91 58 Ogre::Vector3 GetOrigin(); 92 59 93 //94 // void CreateVector3s()95 // {96 //97 // //Vector3s = new Vector3[4];98 // //Vector3s_triangle_text = new Vector3[4];99 // }100 //101 60 bool PointIn(Ogre::Vector3 & point); 102 61 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; 106 67 107 68 private: 108 BBox *bound;69 BBox bound; 109 70 110 Box2d *bspnodebound;71 Box2d bspnodebound; 111 72 112 73 static unsigned int ID_CLUSTER; … … 117 78 118 79 std::vector<Ogre::Vector3> Vector3s_vector; 80 119 81 Ogre::Vector3 *Vector3s; 82 120 83 Ogre::Vector3 *Vector3s_triangle_text; 121 84 … … 130 93 Plane3 plane; 131 94 132 // Gametools -- Isma 17/08/2005133 //Listid patchlistid;134 //Listid trianglelistid;135 int CalcPatch(Ogre::Vector3 & point);136 137 138 95 public: 139 ~Cluster();96 virtual ~Cluster(); 140 97 141 98 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGCluster2d.h
r700 r721 2 2 #define _IMGCLUSTER2D_H 3 3 4 #include "IMGCluster.h"4 #include <IMGPrerequisites.h> 5 5 6 6 namespace IMG { 7 7 8 class Cluster; 9 8 10 class Cluster2d { 9 11 public: 10 inline Cluster2d() { 11 Vector3s = NULL; 12 cluster =NULL; 13 normal = NULL; 14 }; 12 Cluster2d(); 13 14 virtual ~Cluster2d(); 15 15 16 16 //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal. … … 21 21 void Print(); 22 22 23 inline Ogre::Vector2 * GetVector3s() { return Vector3s; }23 Ogre::Vector2 * GetVector3s(); 24 24 25 inline std::vector<Ogre::Vector2> * GetVector3sVector() { return &Vector3s2_vector; }25 std::vector<Ogre::Vector2> * GetVector3sVector(); 26 26 27 inline Ogre::Vector3 * GetNormal() { return normal; }27 Ogre::Vector3 * GetNormal(); 28 28 29 protected: 29 30 30 private:31 31 unsigned int id; 32 32 … … 34 34 35 35 Ogre::Vector2 *Vector3s; 36 36 37 std::vector<Ogre::Vector2> Vector3s2_vector; 37 38 38 39 Ogre::Vector3 *normal; 39 40 public:41 ~Cluster2d();42 40 43 41 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h
r709 r721 7 7 namespace IMG { 8 8 9 //* 10 // ClusterList 11 //* 12 class ClusterList { 9 class ClusterList 10 { 13 11 public: 14 inline ClusterList() { 15 list.reserve(100); 16 }; 12 ClusterList(); 17 13 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(); 20 17 21 18 //return the pointer to the list of voxels 22 inline unsigned int GetSize() const { return list.size(); }19 unsigned int GetSize() const; 23 20 24 21 //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); 30 23 31 24 bool Insert(Cluster * p); … … 34 27 35 28 36 private: 29 protected: 30 37 31 std::vector<Cluster> list; 38 39 public:40 ~ClusterList();41 32 42 33 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h
r700 r721 7 7 namespace IMG { 8 8 9 class NodeBsp { 9 // Fordward declaration... 10 class NodeBsp; 11 12 typedef ::boost::intrusive_ptr<NodeBsp> NodeBspPtr; 13 14 namespace boost 15 { 16 void intrusive_ptr_add_ref(NodeBsp * p); 17 void intrusive_ptr_release(NodeBsp * p); 18 }; 19 20 class NodeBsp 21 { 10 22 public: 11 23 NodeBsp(); 12 24 13 Box2d * GetBound();25 virtual ~NodeBsp(); 14 26 15 inline void SetBound(Box2d * box) { bound = box; };27 Box2d* GetBound(); 16 28 17 inline NodeBsp * GetChild(int i) { return child[i]; };29 void SetBound(Box2d *box); 18 30 19 inline void SetId(int id_) { id = id_; };31 NodeBspPtr GetChild(int i); 20 32 21 inline unsigned int GetId() const { return id; };33 void SetId(int id_); 22 34 23 inline void SetChild(NodeBsp * node, int i) { child[i] = node; }; 35 unsigned int GetId() const; 36 37 void SetChild(NodeBspPtr node, int i); 24 38 25 39 void Print(); 26 40 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); 30 42 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); 41 44 45 protected: 42 46 43 private:44 47 bool fit; 45 48 46 Box2d *bound;49 Box2d bound; 47 50 48 NodeBsp *child[2];51 NodeBspPtr child[2]; 49 52 50 53 static unsigned int ID; … … 52 55 int id; 53 56 57 private: 58 59 long references; 54 60 55 public: 56 ~NodeBsp(); 61 friend void boost::intrusive_ptr_add_ref(NodeBsp * p); 57 62 63 friend void boost::intrusive_ptr_release(NodeBsp * p); 58 64 }; 65 66 // class specific addref/release implementation 67 // the two function overloads must be in the boost namespace on most compilers: 68 namespace 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 59 85 60 86 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPlane3.h
r700 r721 2 2 #define _IMGPLANE3_H 3 3 4 #include "IMGPrerequisites.h"4 #include <IMGPrerequisites.h> 5 5 6 6 namespace IMG { … … 9 9 public: 10 10 //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(); 20 12 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(); 28 14 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); 34 16 35 inline void SetDistance(float dist) { 36 d = dist; 37 }; 17 Ogre::Vector3 * GetNormal(); 38 18 39 inline float GetDistance() const { return d;};19 void SetNormal(float x, float y, float z); 40 20 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); 44 22 45 ~Plane3(); 23 float GetDistance() const; 24 25 void Print(); 46 26 47 27 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGPrerequisites.h
r700 r721 9 9 #include <OgreAxisAlignedBox.h> 10 10 11 #include <boost/smart_ptr.hpp> 12 11 13 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h
r700 r721 7 7 #include <LBBCLeafKdTreeClusterData.h> 8 8 #include <LBBCSampleConfigFile.h> 9 #include <LBBCBillboardViewMode.h> 10 #include <LBBCClusterViewMode.h> 9 11 10 12 #endif -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKMeansClusterData.h
r700 r721 1 #ifndef _LBBCBILLBOARDKM EANSCLUSTERDATA_H2 #define _LBBCBILLBOARDKM EANSCLUSTERDATA_H1 #ifndef _LBBCBILLBOARDKMeansCLUSTERDATA_H 2 #define _LBBCBILLBOARDKMeansCLUSTERDATA_H 3 3 4 4 #include <BBC.h> 5 #include <LBBCLeafKMeansClusterData.h> 6 #include <LBBCLeaf.h> 5 7 6 8 namespace LBBC { … … 10 12 BillboardKMeansClusterData(); 11 13 12 ~BillboardKMeansClusterData(); 14 virtual ~BillboardKMeansClusterData(); 15 16 virtual void readBillboardClusterData(TiXmlNode *parentNode); 17 18 virtual void writeBillboardClusterData(TiXmlNode *parentNode); 19 20 virtual void generateBillboardBoundingQuad(); 13 21 14 22 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardKdTreeClusterData.h
r700 r721 1 #ifndef _LBBCBILLBOARDK DTREECLUSTERDATA_H2 #define _LBBCBILLBOARDK DTREECLUSTERDATA_H1 #ifndef _LBBCBILLBOARDKdTreeCLUSTERDATA_H 2 #define _LBBCBILLBOARDKdTreeCLUSTERDATA_H 3 3 4 4 #include <BBC.h> 5 #include <LBBCLeafKdTreeClusterData.h>6 #include <LBBCLeaf.h>7 5 8 6 namespace LBBC { … … 12 10 BillboardKdTreeClusterData(); 13 11 14 ~BillboardKdTreeClusterData(); 15 16 virtual void readBillboardClusterData(TiXmlNode *parentNode); 17 18 virtual void writeBillboardClusterData(TiXmlNode *parentNode); 19 20 virtual void generateBillboardBoundingQuad(); 12 virtual ~BillboardKdTreeClusterData(); 21 13 22 14 }; -
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 4 3 5 4 #include <BBC.h> 5 #include <LBBCLeafKMeansClusterData.h> 6 #include <LBBCBillboardKMeansClusterData.h> 7 #include <LBBCLeaf.h> 8 #include <LBBCLeafDistribution.h> 6 9 7 10 namespace LBBC { 8 11 9 class _BBCExport KMeansClusterGenerator : public BBC::BillboardCloudGenerator { 12 class _BBCExport KMeansClusterGenerator: public BBC::BillboardCloudGenerator 13 { 10 14 public: 11 15 void generate(); … … 13 17 void init(); 14 18 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 15 49 KMeansClusterGenerator(); 16 50 17 ~KMeansClusterGenerator();51 virtual ~KMeansClusterGenerator(); 18 52 19 53 protected: 20 54 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; 35 56 36 void setLeftChild(Cell *lChild) 37 { 38 left = lChild; 39 } 57 float mEpsilonYN; 40 58 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; 77 60 }; 78 61 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKMeansClusterSerializer.h
r700 r721 1 #ifndef _LBBCKM EANSCLUSTERSERIALIZER_H2 #define _LBBCKM EANSCLUSTERSERIALIZER_H1 #ifndef _LBBCKMeansCLUSTERSERIALIZER_H 2 #define _LBBCKMeansCLUSTERSERIALIZER_H 3 3 4 4 #include <BBC.h> 5 #include <LBBCBillboardKMeansClusterData.h> 6 7 #include <string> 5 8 6 9 namespace LBBC { … … 10 13 KMeansClusterSerializer(); 11 14 12 ~KMeansClusterSerializer();15 virtual ~KMeansClusterSerializer(); 13 16 14 17 virtual void writeBillboardCloud(TiXmlDocument *document); 15 18 16 19 }; -
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 3 4 4 5 #include <BBC.h> 5 #include <LBBCLeafKdTreeClusterData.h>6 #include <LBBCBillboardKdTreeClusterData.h>7 #include <LBBCLeaf.h>8 #include <LBBCLeafDistribution.h>9 6 10 7 namespace LBBC { … … 16 13 void init(); 17 14 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 48 15 KdTreeClusterGenerator(); 49 16 50 ~KdTreeClusterGenerator();17 virtual ~KdTreeClusterGenerator(); 51 18 52 19 protected: 53 20 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 } 55 35 56 float mEpsilonYN; 36 void setLeftChild(Cell *lChild) 37 { 38 left = lChild; 39 } 57 40 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 59 77 }; 60 78 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCKdTreeClusterSerializer.h
r700 r721 1 #ifndef _LBBCK DTREECLUSTERSERIALIZER_H2 #define _LBBCK DTREECLUSTERSERIALIZER_H1 #ifndef _LBBCKdTreeCLUSTERSERIALIZER_H 2 #define _LBBCKdTreeCLUSTERSERIALIZER_H 3 3 4 4 #include <BBC.h> 5 #include <LBBCBillboardKdTreeClusterData.h>6 7 #include <string>8 5 9 6 namespace LBBC { … … 13 10 KdTreeClusterSerializer(); 14 11 15 ~KdTreeClusterSerializer();12 virtual ~KdTreeClusterSerializer(); 16 13 17 virtualvoid writeBillboardCloud(TiXmlDocument *document);14 void writeBillboardCloud(TiXmlDocument *document); 18 15 19 16 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaf.h
r700 r721 81 81 Leaf(); 82 82 83 ~Leaf();83 virtual ~Leaf(); 84 84 85 85 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistribution.h
r700 r721 19 19 LeafDistribution(); 20 20 21 ~LeafDistribution();21 virtual ~LeafDistribution(); 22 22 23 23 void setMinD(float value); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h
r700 r721 14 14 LeafDistributionGenerator(); 15 15 16 ~LeafDistributionGenerator();16 virtual ~LeafDistributionGenerator(); 17 17 18 18 void generateAverageLeafNormal(Leaf *leaf); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionSerializer.h
r700 r721 13 13 LeafDistributionSerializer(); 14 14 15 ~LeafDistributionSerializer();15 virtual ~LeafDistributionSerializer(); 16 16 17 17 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKMeansClusterData.h
r700 r721 1 #ifndef _LBBCLEAFKM EANSCLUSTERDATA_H2 #define _LBBCLEAFKM EANSCLUSTERDATA_H1 #ifndef _LBBCLEAFKMeansCLUSTERDATA_H 2 #define _LBBCLEAFKMeansCLUSTERDATA_H 3 3 4 4 #include <BBCEntityClusterData.h> … … 10 10 LeafKMeansClusterData(); 11 11 12 ~LeafKMeansClusterData(); 12 virtual ~LeafKMeansClusterData(); 13 14 protected: 13 15 14 16 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafKdTreeClusterData.h
r700 r721 1 #ifndef _LBBCLEAFK DTREECLUSTERDATA_H2 #define _LBBCLEAFK DTREECLUSTERDATA_H1 #ifndef _LBBCLEAFKdTreeCLUSTERDATA_H 2 #define _LBBCLEAFKdTreeCLUSTERDATA_H 3 3 4 4 #include <BBCEntityClusterData.h> … … 10 10 LeafKdTreeClusterData(); 11 11 12 ~LeafKdTreeClusterData(); 13 14 protected: 12 virtual ~LeafKdTreeClusterData(); 15 13 16 14 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeaves.h
r700 r721 11 11 Leaves(); 12 12 13 ~Leaves();13 virtual ~Leaves(); 14 14 15 15 protected: 16 16 bool mMeshLoaded; 17 17 18 Ogre::Mesh *mMesh;18 BBC::EntityPtr mEntity; 19 19 20 20 BBC::BillboardCloud *mBillboardCloud; 21 21 22 22 public: 23 Ogre::Mesh* getMesh();23 BBC::EntityPtr getEntity(); 24 24 25 void set Mesh(Ogre::Mesh *value);25 void setEntity(BBC::EntityPtr value); 26 26 27 27 void load(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
r709 r721 2 2 #define _LBBCMANAGER_H 3 3 4 #include <BBC.h>5 4 #include <LBBCPrerequisites.h> 6 5 #include <LBBCLeaves.h> … … 22 21 ~Manager(); 23 22 24 void runSample(Ogre::String sampleConfigFile); 23 void runSampleConfigFile(); 24 25 void loadSampleConfigFile(Ogre::String sampleConfigFile); 25 26 26 27 SampleConfigFile* getSampleConfigFile(); 28 29 void setSampleConfigFile(SampleConfigFile *sampleConfigFile); 27 30 28 31 void generateEntityDistribution(); … … 72 75 BBC::OgreMeshSerializer *mOgreMeshSerializer; 73 76 74 SampleConfigFile mSampleCf;77 SampleConfigFile *mSampleConfigFile; 75 78 76 Ogre::ConfigFile mCf; 79 Ogre::ConfigFile *mConfigFile; 80 77 81 }; 78 82 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
r709 r721 10 10 SampleConfigFile(); 11 11 12 ~SampleConfigFile();12 virtual ~SampleConfigFile(); 13 13 14 14 bool getEntityDistributionMerged(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGenerator.vcproj
r698 r721 20 20 <Tool 21 21 Name="VCCLCompilerTool" 22 AdditionalOptions="/D "TIXML_USE_STL" "22 AdditionalOptions="/D "TIXML_USE_STL" /D "OBA_LIB_BUILD"" 23 23 Optimization="0" 24 AdditionalIncludeDirectories=""$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Samples/Common/include";"$(OGRE_PATH)/Tools/XMLConverter/include";../include/IMG;../include/BBC;../include/LBBC "24 AdditionalIncludeDirectories=""$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Samples/Common/include";"$(OGRE_PATH)/Tools/XMLConverter/include";../include/IMG;../include/BBC;../include/LBBC;../include/OBA;D:\design_04_11_2005\svn\NonGTP\Boost" 25 25 PreprocessorDefinitions="WIN32;_DEBUG;_USRDLL;_MT" 26 26 MinimalRebuild="TRUE" … … 53 53 Name="VCMIDLTool"/> 54 54 <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"/> 59 56 <Tool 60 57 Name="VCPreBuildEventTool"/> … … 82 79 <Tool 83 80 Name="VCCLCompilerTool" 84 AdditionalOptions="/D "TIXML_USE_STL" "85 AdditionalIncludeDirectories=""$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include";"$(OGRE_PATH)/Samples/Common/include";../include/IMG;../include/BBC;../include/LBBC "81 AdditionalOptions="/D "TIXML_USE_STL" /D "TIXML_USE_STL" /D "OBA_LIB_BUILD"" 82 AdditionalIncludeDirectories=""$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include";"$(OGRE_PATH)/Samples/Common/include";../include/IMG;../include/BBC;../include/LBBC;../include/OBA;D:\design_04_11_2005\svn\NonGTP\Boost" 86 83 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 87 84 RuntimeLibrary="2" … … 108 105 Name="VCMIDLTool"/> 109 106 <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"/> 114 108 <Tool 115 109 Name="VCPreBuildEventTool"/> … … 138 132 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 139 133 <File 140 RelativePath="..\src\BBCBillboard.cpp">141 </File>142 <File143 RelativePath="..\src\BBCBillboardCloud.cpp">144 </File>145 <File146 RelativePath="..\src\BBCBillboardCloudGenerator.cpp">147 </File>148 <File149 RelativePath="..\src\BBCBillboardCloudSerializer.cpp">150 </File>151 <File152 RelativePath="..\src\BBCBillboardCloudTextureGenerator.cpp">153 </File>154 <File155 RelativePath="..\src\BBCBillboardCloudUVMapper.cpp">156 </File>157 <File158 RelativePath="..\src\BBCBillboardClusterData.cpp">159 </File>160 <File161 RelativePath="..\src\BBCBillboardGroup.cpp">162 </File>163 <File164 RelativePath="..\src\BBCEntity.cpp">165 </File>166 <File167 RelativePath="..\src\BBCEntityCluster.cpp">168 </File>169 <File170 RelativePath="..\src\BBCEntityClusterData.cpp">171 </File>172 <File173 RelativePath="..\src\BBCEntityDistribution.cpp">174 </File>175 <File176 RelativePath="..\src\BBCEntityDistributionGenerator.cpp">177 </File>178 <File179 RelativePath="..\src\BBCEntityDistributionSerializer.cpp">180 </File>181 <File182 RelativePath="..\src\BBCManager.cpp">183 </File>184 <File185 RelativePath="..\src\BBCOgreMeshSerializer.cpp">186 </File>187 <File188 RelativePath="..\src\BBCSubEntity.cpp">189 </File>190 <File191 RelativePath="..\src\BBCTimer.cpp">192 </File>193 <File194 RelativePath="..\src\BBCXmlSerializer.cpp">195 </File>196 <File197 RelativePath="..\src\IMGBBox.cpp">198 </File>199 <File200 RelativePath="..\src\IMGBox2d.cpp">201 </File>202 <File203 RelativePath="..\src\IMGBsp.cpp">204 </File>205 <File206 RelativePath="..\src\IMGCluster.cpp">207 </File>208 <File209 RelativePath="..\src\IMGCluster2d.cpp">210 </File>211 <File212 RelativePath="..\src\IMGClusterList.cpp">213 </File>214 <File215 RelativePath="..\src\IMGNodeBsp.cpp">216 </File>217 <File218 RelativePath="..\src\IMGPlane3.cpp">219 </File>220 <File221 RelativePath="..\src\IMGVoxel.cpp">222 </File>223 <File224 RelativePath="..\src\IMGVoxelList.cpp">225 </File>226 <File227 RelativePath="..\src\LBBCBillboardKdTreeClusterData.cpp">228 </File>229 <File230 RelativePath="..\src\LBBCBillboardKMeansClusterData.cpp">231 </File>232 <File233 RelativePath="..\src\LBBCKdTreeClusterGenerator.cpp">234 </File>235 <File236 RelativePath="..\src\LBBCKdTreeClusterSerializer.cpp">237 </File>238 <File239 RelativePath="..\src\LBBCKMeansClusterGenerator.cpp">240 </File>241 <File242 RelativePath="..\src\LBBCKMeansClusterSerializer.cpp">243 </File>244 <File245 RelativePath="..\src\LBBCLeaf.cpp">246 </File>247 <File248 RelativePath="..\src\LBBCLeafDistribution.cpp">249 </File>250 <File251 RelativePath="..\src\LBBCLeafDistributionGenerator.cpp">252 </File>253 <File254 RelativePath="..\src\LBBCLeafDistributionSerializer.cpp">255 </File>256 <File257 RelativePath="..\src\LBBCLeafKdTreeClusterData.cpp">258 </File>259 <File260 RelativePath="..\src\LBBCLeafKMeansClusterData.cpp">261 </File>262 <File263 RelativePath="..\src\LBBCLeaves.cpp">264 </File>265 <File266 RelativePath="..\src\LBBCManager.cpp">267 </File>268 <File269 RelativePath="..\src\LBBCSampleConfigFile.cpp">270 </File>271 <File272 134 RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\src\OgreXMLMeshSerializer.cpp"> 273 135 </File> … … 284 146 RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\src\tinyxmlparser.cpp"> 285 147 </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> 286 307 </Filter> 287 308 <Filter … … 290 311 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 291 312 <File 292 RelativePath="..\include\Bbc\BBC.h">293 </File>294 <File295 RelativePath="..\include\Bbc\BBCBillboard.h">296 </File>297 <File298 RelativePath="..\include\Bbc\BBCBillboardCloud.h">299 </File>300 <File301 RelativePath="..\include\Bbc\BBCBillboardCloudGenerator.h">302 </File>303 <File304 RelativePath="..\include\Bbc\BBCBillboardCloudSerializer.h">305 </File>306 <File307 RelativePath="..\include\Bbc\BBCBillboardCloudTextureGenerator.h">308 </File>309 <File310 RelativePath="..\include\Bbc\BBCBillboardCloudUVMapper.h">311 </File>312 <File313 RelativePath="..\include\Bbc\BBCBillboardClusterData.h">314 </File>315 <File316 RelativePath="..\include\Bbc\BBCBillboardGroup.h">317 </File>318 <File319 RelativePath="..\include\Bbc\BBCEntity.h">320 </File>321 <File322 RelativePath="..\include\Bbc\BBCEntityCluster.h">323 </File>324 <File325 RelativePath="..\include\Bbc\BBCEntityClusterData.h">326 </File>327 <File328 RelativePath="..\include\Bbc\BBCEntityDistribution.h">329 </File>330 <File331 RelativePath="..\include\Bbc\BBCEntityDistributionGenerator.h">332 </File>333 <File334 RelativePath="..\include\Bbc\BBCEntityDistributionSerializer.h">335 </File>336 <File337 RelativePath="..\include\Bbc\BBCManager.h">338 </File>339 <File340 RelativePath="..\include\Bbc\BBCOgreMeshSerializer.h">341 </File>342 <File343 RelativePath="..\include\Bbc\BBCPrerequisites.h">344 </File>345 <File346 RelativePath="..\include\Bbc\BBCSingleton.h">347 </File>348 <File349 RelativePath="..\include\Bbc\BBCSubEntity.h">350 </File>351 <File352 RelativePath="..\include\Bbc\BBCTimer.h">353 </File>354 <File355 RelativePath="..\include\Bbc\BBCUtil.h">356 </File>357 <File358 RelativePath="..\include\Bbc\BBCXmlSerializer.h">359 </File>360 <File361 RelativePath="..\include\Img\IMG.h">362 </File>363 <File364 RelativePath="..\include\Img\IMGBBox.h">365 </File>366 <File367 RelativePath="..\include\Img\IMGBox2d.h">368 </File>369 <File370 RelativePath="..\include\Img\IMGBsp.h">371 </File>372 <File373 RelativePath="..\include\Img\IMGCluster.h">374 </File>375 <File376 RelativePath="..\include\Img\IMGCluster2d.h">377 </File>378 <File379 RelativePath="..\include\Img\IMGClusterList.h">380 </File>381 <File382 RelativePath="..\include\Img\IMGNodeBsp.h">383 </File>384 <File385 RelativePath="..\include\Img\IMGPlane3.h">386 </File>387 <File388 RelativePath="..\include\Img\IMGPrerequisites.h">389 </File>390 <File391 RelativePath="..\include\Img\IMGVoxel.h">392 </File>393 <File394 RelativePath="..\include\Img\IMGVoxelList.h">395 </File>396 <File397 RelativePath="..\include\Lbbc\LBBC.h">398 </File>399 <File400 RelativePath="..\include\Lbbc\LBBCBillboardKdTreeClusterData.h">401 </File>402 <File403 RelativePath="..\include\Lbbc\LBBCBillboardKMeansClusterData.h">404 </File>405 <File406 RelativePath="..\include\Lbbc\LBBCKdTreeClusterGenerator.h">407 </File>408 <File409 RelativePath="..\include\Lbbc\LBBCKdTreeClusterSerializer.h">410 </File>411 <File412 RelativePath="..\include\Lbbc\LBBCKMeansClusterGenerator.h">413 </File>414 <File415 RelativePath="..\include\Lbbc\LBBCKMeansClusterSerializer.h">416 </File>417 <File418 RelativePath="..\include\Lbbc\LBBCLeaf.h">419 </File>420 <File421 RelativePath="..\include\Lbbc\LBBCLeafDistribution.h">422 </File>423 <File424 RelativePath="..\include\Lbbc\LBBCLeafDistributionGenerator.h">425 </File>426 <File427 RelativePath="..\include\Lbbc\LBBCLeafDistributionSerializer.h">428 </File>429 <File430 RelativePath="..\include\Lbbc\LBBCLeafKdTreeClusterData.h">431 </File>432 <File433 RelativePath="..\include\Lbbc\LBBCLeafKMeansClusterData.h">434 </File>435 <File436 RelativePath="..\include\Lbbc\LBBCLeaves.h">437 </File>438 <File439 RelativePath="..\include\Lbbc\LBBCManager.h">440 </File>441 <File442 RelativePath="..\include\Lbbc\LBBCPrerequisites.h">443 </File>444 <File445 RelativePath="..\include\Lbbc\LBBCSampleConfigFile.h">446 </File>447 <File448 313 RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\include\OgreXMLMeshSerializer.h"> 449 314 </File> … … 457 322 RelativePath="..\..\..\..\..\..\..\Ogre\trunk\ogrenew\Tools\XMLConverter\include\tinyxml.h"> 458 323 </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> 459 520 </Filter> 460 521 <Filter -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGeneratorCommandLine.vcproj
r709 r721 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="../include;../include/BBC;../include/IMG;../include/ LBBC;"$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include""22 AdditionalIncludeDirectories="../include;../include/BBC;../include/IMG;../include/OBA;../include/LBBC;"$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include";D:\design_04_11_2005\svn\NonGTP\Boost" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" 24 24 MinimalRebuild="TRUE" … … 33 33 <Tool 34 34 Name="VCLinkerTool" 35 AdditionalDependencies=" odbc32.lib kernel32.lib odbccp32.libIBRBillboardCloudTreeGenerator_d.lib OgreMain_d.lib"35 AdditionalDependencies="IBRBillboardCloudTreeGenerator_d.lib OgreMain_d.lib" 36 36 OutputFile="$(OutDir)/IBRBillboardCloudTreeGeneratorCmd_d.exe" 37 37 LinkIncremental="2" … … 70 70 <Tool 71 71 Name="VCCLCompilerTool" 72 AdditionalIncludeDirectories="../include;../include/ BBC;../include/IMG;../include/LBBC;"$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include""72 AdditionalIncludeDirectories="../include;../include/OBA;../include/BBC;../include/IMG;../include/LBBC;"$(OGRE_PATH)/OgreMain/include";"$(OGRE_PATH)/Tools/XMLConverter/include";D:\design_04_11_2005\svn\NonGTP\Boost" 73 73 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 74 74 RuntimeLibrary="0" … … 81 81 <Tool 82 82 Name="VCLinkerTool" 83 AdditionalDependencies=" odbc32.lib kernel32.lib odbccp32.libIBRBillboardCloudTreeGenerator.lib OgreMain.lib"83 AdditionalDependencies="IBRBillboardCloudTreeGenerator.lib OgreMain.lib" 84 84 OutputFile="$(OutDir)/IBRBillboardCloudTreeGeneratorCmd.exe" 85 85 LinkIncremental="1" … … 120 120 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 121 121 <File 122 RelativePath="..\src\IBRBillboardCloudTreeApplication.cpp"> 123 </File> 124 <File 125 RelativePath="..\src\IBRBillboardCloudTreeFrameListener.cpp"> 126 </File> 127 <File 122 128 RelativePath="..\src\main.cpp"> 123 129 </File> … … 127 133 Filter="h;hpp;hxx;hm;inl;inc;xsd" 128 134 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> 129 165 </Filter> 130 166 <Filter -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboard.cpp
r699 r721 4 4 namespace BBC { 5 5 6 Billboard::Billboard() { 6 Billboard::Billboard(): references(0) // initialize references to 0 7 { 8 7 9 } 8 10 9 Billboard::~Billboard() { 11 Billboard::~Billboard() 12 { 13 10 14 } 11 15 … … 20 24 } 21 25 22 void Billboard::setBillboardClusterData(BillboardClusterData *value)26 void Billboard::setBillboardClusterData(BillboardClusterDataPtr value) 23 27 { 24 28 mBillboardClusterData = value; 25 29 } 26 30 27 BillboardClusterData *Billboard::getBillboardClusterData()31 BillboardClusterDataPtr Billboard::getBillboardClusterData() 28 32 { 29 33 return mBillboardClusterData; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloud.cpp
r709 r721 6 6 BillboardCloud::BillboardCloud() 7 7 { 8 mEntity = new Entity(); 8 //mEntity = new Entity(); 9 mEntity = 0; 9 10 } 10 11 11 12 BillboardCloud::~BillboardCloud() 12 13 { 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 17 std::vector<BillboardPtr>* BillboardCloud::getBillboardList() 29 18 { 30 19 return &mBillboardList; 31 20 } 32 21 33 void BillboardCloud::setBillboardList(std::vector<Billboard *> &value)22 void BillboardCloud::setBillboardList(std::vector<BillboardPtr> &value) 34 23 { 35 24 mBillboardList = value; … … 41 30 } 42 31 43 void BillboardCloud::addBillboard(Billboard *value)32 void BillboardCloud::addBillboard(BillboardPtr value) 44 33 { 45 34 value->setBillboardHandle((unsigned int)(mBillboardList.size())); … … 49 38 void BillboardCloud::removeBillboard(unsigned int value) 50 39 { 51 Billboard *billboard = mBillboardList[value];40 BillboardPtr billboard = mBillboardList[value]; 52 41 mBillboardList.erase(mBillboardList.begin() + value); 53 delete billboard; 54 } 55 56 Billboard* BillboardCloud::getBillboard(unsigned int value) 42 } 43 44 BillboardPtr BillboardCloud::getBillboard(unsigned int value) 57 45 { 58 46 return mBillboardList[value]; 59 47 } 60 48 61 Entity *BillboardCloud::getEntity()49 EntityPtr BillboardCloud::getEntity() 62 50 { 63 51 return mEntity; 64 52 } 65 53 66 void BillboardCloud::setEntity(Entity *value)54 void BillboardCloud::setEntity(EntityPtr value) 67 55 { 68 56 mEntity = value; … … 71 59 void BillboardCloud::generateBillboardCloud(bool mergeBillboards) 72 60 { 73 if (mEntity != NULL) 74 { 75 delete mEntity; 76 mEntity = new Entity(); 77 } 61 mEntity = EntityPtr(new Entity()); 78 62 79 63 unsigned int numGeneratedBillboardClouds = 0; 80 64 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 81 65 { 82 Billboard *billboard = this->getBillboard(iBillboard);83 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster();66 BillboardPtr billboard = this->getBillboard(iBillboard); 67 EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 84 68 85 69 if (entityCluster->getNumEntitiesClusterData() > 0) 86 70 { 87 SubEntity *subEntity;71 SubEntityPtr subEntity; 88 72 if (mergeBillboards) 89 73 { … … 157 141 while (getNumBillboardGroups() > 0) 158 142 { 159 BillboardGroup *billboardGroup = getBillboardGroup(getNumBillboardGroups()-1);143 BillboardGroupPtr billboardGroup = getBillboardGroup(getNumBillboardGroups()-1); 160 144 removeBillboardGroup(getNumBillboardGroups()-1); 161 145 } … … 166 150 for (iBillboardGroup = 0; iBillboardGroup < numberGroups; iBillboardGroup++) 167 151 { 168 BillboardGroup *billboardGroup = new BillboardGroup();152 BillboardGroupPtr billboardGroup = BillboardGroupPtr( new BillboardGroup() ); 169 153 addBillboardGroup(billboardGroup); 170 154 } 171 155 172 156 Ogre::LogManager::getSingleton().logMessage("New.Num.Billboard Groups:" + Ogre::StringConverter::toString(getNumBillboardGroups())); 173 std::cin.get();174 std::cin.get();175 157 176 158 unsigned int numGeneratedBillboardClouds = 0; 177 159 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 178 160 { 179 Billboard *billboard = this->getBillboard(iBillboard);180 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster();161 BillboardPtr billboard = this->getBillboard(iBillboard); 162 EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 181 163 182 164 if (entityCluster->getNumEntitiesClusterData() > 0) … … 197 179 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 198 180 { 199 Billboard *billboard = this->getBillboard(iBillboard);200 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster();181 BillboardPtr billboard = this->getBillboard(iBillboard); 182 EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 201 183 202 184 if (entityCluster->getNumEntitiesClusterData() > 0) … … 229 211 void BillboardCloud::generateBillboardCloudGroups() 230 212 { 231 SubEntity *subEntityGroup;232 SubEntity *subEntity;233 Entity *entity = new Entity();213 SubEntityPtr subEntityGroup; 214 SubEntityPtr subEntity; 215 EntityPtr entity = EntityPtr(new Entity()); 234 216 unsigned int numGeneratedBillboardClouds = 0; 235 217 … … 244 226 subEntityGroup = entity->getSubEntity(iBillboardGroup); 245 227 246 BillboardGroup *billboardGroup = this->getBillboardGroup(iBillboardGroup);228 BillboardGroupPtr billboardGroup = this->getBillboardGroup(iBillboardGroup); 247 229 248 230 Ogre::LogManager::getSingleton().logMessage("BBCG-Num.Billboards:" + Ogre::StringConverter::toString(billboardGroup->getNumBillboards())); 249 std::cin.get();250 std::cin.get();251 231 252 232 for (unsigned int iBillboard = 0; iBillboard < billboardGroup->getNumBillboards(); iBillboard++) 253 233 { 254 234 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(); 257 237 258 238 if (entityCluster->getNumEntitiesClusterData() > 0) … … 318 298 } 319 299 320 delete mEntity;321 300 mEntity = entity; 322 301 entity->setSubEntitiesDistinctVertexColours(); … … 328 307 } 329 308 330 BillboardGroup *BillboardCloud::getBillboardGroup(unsigned int iBillboardGroup)309 BillboardGroupPtr BillboardCloud::getBillboardGroup(unsigned int iBillboardGroup) 331 310 { 332 311 return mBillboardGroupList[iBillboardGroup]; 333 312 } 334 313 335 void BillboardCloud::addBillboardGroup(BillboardGroup *value)314 void BillboardCloud::addBillboardGroup(BillboardGroupPtr value) 336 315 { 337 316 mBillboardGroupList.push_back(value); … … 340 319 void BillboardCloud::removeBillboardGroup(unsigned int value) 341 320 { 342 BillboardGroup *billboardGroup = mBillboardGroupList[value];321 BillboardGroupPtr billboardGroup = mBillboardGroupList[value]; 343 322 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 4 4 5 5 namespace BBC { 6 7 BillboardCloudGenerator::BillboardCloudGenerator() 8 { 9 } 10 11 BillboardCloudGenerator::~BillboardCloudGenerator() 12 { 13 } 6 14 7 15 void BillboardCloudGenerator::setBillboardCloud(BillboardCloud *value) -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudUVMapper.cpp
r709 r721 14 14 BillboardCloudUVMapper::~BillboardCloudUVMapper() 15 15 { 16 clear();16 shutdown(); 17 17 } 18 18 … … 21 21 } 22 22 23 void BillboardCloudUVMapper::clear() 24 { 25 Ogre::LogManager::getSingleton().logMessage("Init.BSP:" + Ogre::StringConverter::toString(getNumBsp())); 26 23 void BillboardCloudUVMapper::shutdown() 24 { 27 25 while (getNumBsp() > 0) 28 26 { … … 30 28 } 31 29 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 } 43 34 } 44 35 … … 82 73 void BillboardCloudUVMapper::removeClusterList(unsigned int iClusterList) 83 74 { 84 //mClusterLists.erase(mClusterLists.begin() + iClusterList); 75 IMG::ClusterList *clusterList = mClusterLists[iClusterList]; 76 mClusterLists.erase(mClusterLists.begin() + iClusterList); 77 delete clusterList; 85 78 } 86 79 … … 142 135 "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 143 136 144 SubEntity *subEntity;137 SubEntityPtr subEntity; 145 138 146 139 Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; … … 160 153 { 161 154 Ogre::LogManager::getSingleton().logMessage("DontMerge"); 162 subEntity = subEntity =mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup);155 subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup); 163 156 164 157 // Face A … … 285 278 void BillboardCloudUVMapper::addTextureInBsp(unsigned int iBillboardGroup, unsigned int iBillboard) 286 279 { 287 IMG::NodeBsp *nodeDest;280 IMG::NodeBspPtr nodeDest; 288 281 IMG::Cluster cluster; 289 282 Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); … … 304 297 for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 305 298 { 306 Billboard *billboard = mBillboardCloud->getBillboard(iBillboard);307 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster();299 BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); 300 EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 308 301 309 302 if (entityCluster->getNumEntitiesClusterData() > 0) … … 313 306 if (!enabledTextureCoordSet) 314 307 { 315 SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(0);308 SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(0); 316 309 subEntity->addTextureCoordSet(2); 317 310 subEntity->enableVertexColours(true); … … 323 316 if (groupedBillboards) 324 317 { 325 SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds);318 SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 326 319 subEntity->addTextureCoordSet(2); 327 320 subEntity->enableVertexColours(true); … … 355 348 unsigned int iBillboardGroup; 356 349 for (iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) 357 { 358 359 IMG::NodeBsp *node = new IMG::NodeBsp; 350 { 360 351 IMG::Bsp *bsp = new IMG::Bsp(); 361 IMG::Box2d *box = new IMG::Box2d;362 352 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); 366 356 bsp->SetRoot(node); 357 367 358 addBsp(bsp); 368 359 addClusterList(clusterList); … … 375 366 Ogre::LogManager::getSingleton().logMessage("id:" + Ogre::StringConverter::toString(mBillboardCloud->getBillboard(iBillboard)->getBillboardHandle())); 376 367 377 BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData() ;368 BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData().get(); 378 369 379 370 if (billboardClusterData != NULL) 380 371 { 381 372 Ogre::LogManager::getSingleton().logMessage("billboardData"); 382 EntityCluster *entityCluster = billboardClusterData->getEntityCluster();373 EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 383 374 if (entityCluster->getNumEntitiesClusterData() > 0) 384 375 { -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardClusterData.cpp
r699 r721 4 4 namespace BBC { 5 5 6 BillboardClusterData::BillboardClusterData() { 6 BillboardClusterData::BillboardClusterData(): references(0) // initialize references to 0 7 { 7 8 } 8 9 9 BillboardClusterData::~BillboardClusterData() { 10 BillboardClusterData::~BillboardClusterData() 11 { 10 12 } 11 13 … … 45 47 } 46 48 47 void BillboardClusterData::setEntityCluster(EntityCluster *value)49 void BillboardClusterData::setEntityCluster(EntityClusterPtr value) 48 50 { 49 51 mEntityCluster = value; 50 52 } 51 53 52 EntityCluster *BillboardClusterData::getEntityCluster()54 EntityClusterPtr BillboardClusterData::getEntityCluster() 53 55 { 54 56 return mEntityCluster; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardGroup.cpp
r709 r721 3 3 4 4 namespace BBC { 5 6 BillboardGroup::BillboardGroup(): references(0) // initialize references to 0 7 { 8 } 9 10 BillboardGroup::~BillboardGroup() 11 { 12 } 5 13 6 14 unsigned int BillboardGroup::getBillboardHandle(unsigned int iBillboard) -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntity.cpp
r699 r721 4 4 namespace BBC { 5 5 6 Entity::Entity() 6 Entity::Entity(): references(0) // initialize references to 0 7 7 { 8 8 createSubEntity(); … … 11 11 Entity::~Entity() 12 12 { 13 for (unsigned int iSubEntity = 0; iSubEntity < getNumSubEntities(); iSubEntity++) 14 { 15 SubEntity *subEntity = getSubEntity(iSubEntity); 16 delete subEntity; 17 } 13 18 14 } 19 15 20 16 void Entity::createSubEntity() 21 17 { 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 22 void Entity::addSubEntity(SubEntityPtr value) 27 23 { 28 24 mSubEntityList.push_back(value); 29 25 } 30 26 31 SubEntity *Entity::getSubEntity(unsigned int index)27 SubEntityPtr Entity::getSubEntity(unsigned int index) 32 28 { 33 29 return mSubEntityList[index]; … … 36 32 void Entity::removeSubEntity(unsigned int index) 37 33 { 38 SubEntity *subEntity = mSubEntityList[index];39 34 mSubEntityList.erase(mSubEntityList.begin()+index); 40 delete subEntity;41 35 } 42 36 … … 57 51 } 58 52 59 Ogre::Mesh*Entity::getMesh()53 MeshPtr Entity::getMesh() 60 54 { 61 55 return mMesh; 62 56 } 63 57 64 void Entity::setMesh( Ogre::Mesh *value)58 void Entity::setMesh(MeshPtr value) 65 59 { 66 60 mMesh = value; … … 93 87 void Entity::sincronizeNumSubEntities() 94 88 { 95 if (this->getNumSubEntities() < mMesh->get NumSubMeshes())96 { 97 while (this->getNumSubEntities() < mMesh->get NumSubMeshes())89 if (this->getNumSubEntities() < mMesh->get()->getNumSubMeshes()) 90 { 91 while (this->getNumSubEntities() < mMesh->get()->getNumSubMeshes()) 98 92 { 99 93 this->createSubEntity(); … … 101 95 } 102 96 103 if (this->getNumSubEntities() > mMesh->get NumSubMeshes())104 { 105 while (this->getNumSubEntities() > mMesh->get NumSubMeshes())97 if (this->getNumSubEntities() > mMesh->get()->getNumSubMeshes()) 98 { 99 while (this->getNumSubEntities() > mMesh->get()->getNumSubMeshes()) 106 100 { 107 101 this->removeSubEntity(this->getNumSubEntities()-1); … … 117 111 size_t next_offset = 0; 118 112 119 unsigned int numSubMeshes = mMesh->get NumSubMeshes();113 unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 120 114 sincronizeNumSubEntities(); 121 115 122 116 added_shared = false; 123 for (unsigned short i = 0; i < mMesh->get NumSubMeshes(); i++)124 { 125 Ogre::SubMesh* subMesh = mMesh->get SubMesh(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; 127 121 128 122 if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) … … 173 167 size_t next_offset = 0; 174 168 175 unsigned int numSubMeshes = mMesh->get NumSubMeshes();169 unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 176 170 sincronizeNumSubEntities(); 177 171 178 172 added_shared = false; 179 for (unsigned short i = 0; i < mMesh->get NumSubMeshes(); i++)180 { 181 Ogre::SubMesh* subMesh = mMesh->get SubMesh(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; 183 177 184 178 if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) … … 223 217 size_t next_offset = 0; 224 218 225 unsigned int numSubMeshes = mMesh->get NumSubMeshes();219 unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 226 220 sincronizeNumSubEntities(); 227 221 228 222 added_shared = false; 229 for (unsigned short i = 0; i < mMesh->get NumSubMeshes(); i++)230 { 231 Ogre::SubMesh* subMesh = mMesh->get SubMesh(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; 233 227 234 228 if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) … … 290 284 size_t next_offset = 0; 291 285 292 unsigned int numSubMeshes = mMesh->get NumSubMeshes();286 unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 293 287 sincronizeNumSubEntities(); 294 288 295 289 added_shared = false; 296 for (unsigned short i = 0; i < mMesh->get NumSubMeshes(); i++)297 { 298 Ogre::SubMesh* subMesh = mMesh->get SubMesh(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; 300 294 301 295 if ((!subMesh->useSharedVertices) || (subMesh->useSharedVertices && !added_shared)) … … 411 405 size_t index_offset = 0; 412 406 413 unsigned int numSubMeshes = mMesh->get NumSubMeshes();407 unsigned int numSubMeshes = mMesh->get()->getNumSubMeshes(); 414 408 sincronizeNumSubEntities(); 415 409 … … 417 411 418 412 // Run through the submeshes again, adding the data into the arrays 419 for ( unsigned short i = 0; i < mMesh->get NumSubMeshes(); ++i)420 { 421 Ogre::SubMesh* submesh = mMesh->get SubMesh(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; 424 418 425 419 if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared)) … … 497 491 unsigned int Entity::getNumSubEntities() 498 492 { 499 return static_cast<unsigned int>(mSubEntityList.size());493 return mSubEntityList.size(); 500 494 } 501 495 … … 530 524 for (unsigned int iSubEntity = 1; iSubEntity < mSubEntityList.size(); iSubEntity) 531 525 { 532 SubEntityList::iterator subEntityListIterator = mSubEntityList.begin()+iSubEntity;533 // Gametools -- 02/03/2006534 // BUG: If I delete the subentity other entities that reference it will lose it's data...535 //SubEntity *subEntity = (*subEntityListIterator);536 526 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 5 5 namespace BBC { 6 6 7 EntityCluster::EntityCluster() 7 EntityCluster::EntityCluster(): references(0) // initialize references to 0 8 8 { 9 9 } … … 11 11 EntityCluster::~EntityCluster() 12 12 { 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(); 20 14 } 21 15 22 EntityClusterData *EntityCluster::getEntityClusterData(unsigned int value)16 EntityClusterDataPtr EntityCluster::getEntityClusterData(unsigned int value) 23 17 { 24 18 return mEntityClusterDataList[value]; 25 19 } 20 21 void EntityCluster::removeEntityClusterData(unsigned int value) 22 { 23 mEntityClusterDataList.erase(mEntityClusterDataList.begin() + value); 24 } 25 26 26 27 27 unsigned int EntityCluster::getNumEntitiesClusterData() … … 30 30 } 31 31 32 void EntityCluster::addEntityClusterData(EntityClusterData *value)32 void EntityCluster::addEntityClusterData(EntityClusterDataPtr value) 33 33 { 34 34 mEntityClusterDataList.push_back(value); … … 40 40 } 41 41 42 Entity *EntityCluster::getEntity()42 EntityPtr EntityCluster::getEntity() 43 43 { 44 44 return mEntity; 45 45 } 46 46 47 void EntityCluster::setEntity(Entity *value) {47 void EntityCluster::setEntity(EntityPtr value) { 48 48 mEntity = value; 49 49 } … … 57 57 } 58 58 59 void EntityCluster::setEntityDistribution(EntityDistribution *value)59 void EntityCluster::setEntityDistribution(EntityDistributionPtr value) 60 60 { 61 61 mEntityDistribution = value; 62 62 } 63 63 64 EntityDistribution *EntityCluster::getEntityDistribution()64 EntityDistributionPtr EntityCluster::getEntityDistribution() 65 65 { 66 66 return mEntityDistribution; … … 69 69 void EntityCluster::generateEntityCluster() 70 70 { 71 mEntity = new BBC::Entity();71 mEntity = BBC::EntityPtr(new BBC::Entity()); 72 72 73 73 mEntity->getSubEntity(0)->addTextureCoordSet(2); … … 84 84 for (unsigned int iEntityClusterData = 0; iEntityClusterData < getNumEntitiesClusterData(); iEntityClusterData++) 85 85 { 86 Entity *entity = getEntityClusterData(iEntityClusterData)->getEntity();86 EntityPtr entity = getEntityClusterData(iEntityClusterData)->getEntity(); 87 87 88 88 for (unsigned int iFace = 0; iFace < entity->getSubEntity(0)->getNumFaces(); iFace++) -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityClusterData.cpp
r699 r721 4 4 namespace BBC { 5 5 6 EntityClusterData::EntityClusterData() { 6 EntityClusterData::EntityClusterData(): references(0) // initialize references to 0 7 { 7 8 } 8 9 9 EntityClusterData::~EntityClusterData() { 10 EntityClusterData::~EntityClusterData() 11 { 12 10 13 } 11 14 12 void EntityClusterData::setEntity(Entity *value)15 void EntityClusterData::setEntity(EntityPtr value) 13 16 { 14 17 mEntity = value; 15 18 } 16 19 17 Entity *EntityClusterData::getEntity()20 EntityPtr EntityClusterData::getEntity() 18 21 { 19 22 return mEntity; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistribution.cpp
r699 r721 4 4 namespace BBC { 5 5 6 Entity* EntityDistribution::getEntity(unsigned unsigned int value) 6 EntityDistribution::EntityDistribution(): references(0) // initialize references to 0 7 { 8 } 9 10 EntityDistribution::~EntityDistribution() 11 { 12 mEntityList.clear(); 13 } 14 15 EntityPtr EntityDistribution::getEntity(unsigned unsigned int value) 7 16 { 8 17 return mEntityList[value]; 9 18 } 10 19 11 void EntityDistribution::addEntity(Entity *value)20 void EntityDistribution::addEntity(EntityPtr value) 12 21 { 13 22 mEntityList.push_back(value); … … 21 30 unsigned int EntityDistribution::getNumEntities(void) 22 31 { 23 return static_cast<unsigned int>(mEntityList.size());32 return mEntityList.size(); 24 33 } 25 34 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistributionGenerator.cpp
r699 r721 10 10 } 11 11 12 Entity *EntityDistributionGenerator::getEntity() {12 EntityPtr EntityDistributionGenerator::getEntity() { 13 13 return mEntity; 14 14 } 15 15 16 void EntityDistributionGenerator::setEntity(Entity *value) {16 void EntityDistributionGenerator::setEntity(EntityPtr value) { 17 17 mEntity = value; 18 18 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCEntityDistributionSerializer.cpp
r699 r721 4 4 namespace BBC { 5 5 6 Entity* EntityDistributionSerializer::getEntity() { 6 EntityPtr EntityDistributionSerializer::getEntity() 7 { 7 8 return mEntity; 8 9 } 9 10 10 void EntityDistributionSerializer::setEntity(Entity * value) { 11 void EntityDistributionSerializer::setEntity(EntityPtr value) 12 { 11 13 mEntity = value; 12 14 } … … 18 20 } 19 21 20 EntityDistributionSerializer::EntityDistributionSerializer() { 22 EntityDistributionSerializer::EntityDistributionSerializer() 23 { 24 mEntity = BBC::EntityPtr(new BBC::Entity()); 21 25 } 22 26 23 EntityDistributionSerializer::~EntityDistributionSerializer() { 27 EntityDistributionSerializer::~EntityDistributionSerializer() 28 { 24 29 } 25 30 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCManager.cpp
r699 r721 17 17 18 18 Manager::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 { 97 20 } 98 21 … … 103 26 void Manager::shutdown() 104 27 { 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 123 28 } 124 29 … … 127 32 } 128 33 129 Ogre::Mesh* Manager::loadMesh(Ogre::String name)34 Ogre::Mesh* Manager::loadMesh(Ogre::String folderName, Ogre::String fileName) 130 35 { 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(); 133 47 } 134 48 … … 149 63 } 150 64 151 mXMLMeshSerializer->importMesh(name, colourElementType, newMesh.getPointer()); 65 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->importMesh(name, colourElementType, newMesh.getPointer()); 66 152 67 return newMesh.getPointer(); 153 68 } … … 156 71 { 157 72 Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(name); 158 mMeshSerializer->exportMesh(meshPtr.getPointer(),name);73 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(meshPtr.getPointer(),name); 159 74 } 160 75 … … 162 77 { 163 78 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"); 175 80 } 176 81 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCOgreMeshSerializer.cpp
r699 r721 25 25 } 26 26 27 void OgreMeshSerializer::setEntity(Entity *entity)27 void OgreMeshSerializer::setEntity(EntityPtr entity) 28 28 { 29 29 mEntity = entity; 30 30 } 31 31 32 Entity *OgreMeshSerializer::getEntity()32 EntityPtr OgreMeshSerializer::getEntity() 33 33 { 34 34 return mEntity; … … 50 50 // Derive the scene root 51 51 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); 57 60 58 61 // write the data into a mesh 59 buildMesh(pMesh .getPointer(), mergeSubMeshes);62 buildMesh(pMesh, mergeSubMeshes); 60 63 61 64 if(tangents) … … 63 66 Ogre::LogManager::getSingleton().logMessage("Calculating tangents"); 64 67 unsigned short src, dest; 65 if (pMesh-> suggestTangentVectorBuildParams(src, dest))68 if (pMesh->get()->suggestTangentVectorBuildParams(src, dest)) 66 69 { 67 pMesh-> buildTangentVectors(src, dest);70 pMesh->get()->buildTangentVectors(src, dest); 68 71 } 69 72 else … … 76 79 } 77 80 78 void OgreMeshSerializer::buildMesh( Ogre::Mesh*pMesh, bool mergeSubmeshes)81 void OgreMeshSerializer::buildMesh(MeshPtr pMesh, bool mergeSubmeshes) 79 82 { 80 83 if (!mergeSubmeshes) … … 99 102 } 100 103 101 void OgreMeshSerializer::generateEntityAABB( Ogre::Mesh*pMesh)104 void OgreMeshSerializer::generateEntityAABB(MeshPtr pMesh) 102 105 { 103 106 // Bounds calculation … … 132 135 Ogre::AxisAlignedBox box; 133 136 box.setExtents(min, max); 134 box.merge(pMesh->get Bounds());135 pMesh-> _setBounds(box);136 pMesh-> _setBoundingSphereRadius(137 box.merge(pMesh->get()->getBounds()); 138 pMesh->get()->_setBounds(box); 139 pMesh->get()->_setBoundingSphereRadius( 137 140 std::max( 138 pMesh->get BoundingSphereRadius(),141 pMesh->get()->getBoundingSphereRadius(), 139 142 Ogre::Math::Sqrt(squaredRadius))); 140 143 141 Ogre::LogManager::getSingleton().logMessage("Bounds:" + Ogre::StringConverter::toString(pMesh->get BoundingSphereRadius()) + " -- 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) 145 148 { 146 149 for (unsigned int iSubEntity = 0; iSubEntity < mEntity->getNumSubEntities(); iSubEntity++) … … 150 153 } 151 154 152 void OgreMeshSerializer::exportSubMesh( Ogre::Mesh* pMesh, SubEntity *subEntity)155 void OgreMeshSerializer::exportSubMesh(MeshPtr pMesh, SubEntityPtr subEntity) 153 156 { 154 157 Ogre::SubMesh* sm = 0; 155 158 if (subEntity->getName() == "") 156 159 { 157 sm = pMesh-> createSubMesh();160 sm = pMesh->get()->createSubMesh(); 158 161 } 159 162 else 160 163 { 161 sm = pMesh-> createSubMesh(subEntity->getName());164 sm = pMesh->get()->createSubMesh(subEntity->getName()); 162 165 } 163 166 // Set material … … 231 234 232 235 template <typename T> 233 void OgreMeshSerializer::writeIndexes(T* buf, SubEntity *subEntity)236 void OgreMeshSerializer::writeIndexes(T* buf, SubEntityPtr subEntity) 234 237 { 235 238 for (unsigned int i = 0; i < subEntity->getNumFaces(); i++) -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCSubEntity.cpp
r709 r721 4 4 namespace BBC { 5 5 6 SubEntity::SubEntity() 6 SubEntity::SubEntity(): references(0) // initialize references to 0 7 7 { 8 8 mHasTangents = false; … … 14 14 SubEntity::~SubEntity() 15 15 { 16 mUniqueVertexList.clear(); 17 mIndices.clear(); 18 mTextureCoordSetsDimensions.clear(); 19 16 20 } 17 21 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCXmlSerializer.cpp
r699 r721 11 11 if (mLoaded) 12 12 { 13 delete mFile; 13 if (mFile) 14 { 15 delete mFile; 16 } 14 17 mLoaded = false; 15 18 } … … 26 29 else 27 30 { 28 delete mFile; 31 if (mFile) 32 { 33 delete mFile; 34 } 29 35 mFile = new TiXmlDocument(filename.c_str()); 30 36 } … … 51 57 else 52 58 { 53 delete mFile; 59 if (mFile) 60 { 61 delete mFile; 62 } 54 63 mFile = new TiXmlDocument(filename.c_str()); 55 64 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBBox.cpp
r699 r721 1 1 2 #include "IMGBBox.h"2 #include <IMGBBox.h> 3 3 4 4 namespace IMG { 5 5 6 BBox::~BBox() { 6 BBox::BBox() 7 { 8 BBox::StartBoundingBox(); 7 9 } 8 10 11 BBox::~BBox() 12 { 13 } 14 15 void 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 25 Ogre::Vector3 BBox::GetMinimum() 26 { 27 return mMinimum; 28 } 29 30 Ogre::Vector3 BBox::GetMaximum() 31 { 32 return mMaximum; 33 } 34 35 void 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 68 void BBox::Print() 69 { 70 Ogre::LogManager::getSingleton().logMessage("\nValor de la Caixa: (" + Ogre::StringConverter::toString(mMinimum) + ") - (" + + ") " + Ogre::StringConverter::toString(mMaximum)); 71 } 72 73 Ogre::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 91 bool BBox::intersects(Ogre::Vector3 v) 92 { 93 return Ogre::AxisAlignedBox::intersects(v); 94 } 9 95 10 96 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBox2d.cpp
r699 r721 1 1 2 #include "IMGBox2d.h"2 #include <IMGBox2d.h> 3 3 4 namespace IMG { 4 namespace IMG 5 { 5 6 6 Box2d::~Box2d() { 7 Box2d::Box2d() 8 { 9 mMinimum.x = BOUNDINGBOX_MAXVALUE; 10 mMinimum.y = BOUNDINGBOX_MAXVALUE; 11 12 mMaximum.x = -BOUNDINGBOX_MAXVALUE; 13 mMaximum.y = -BOUNDINGBOX_MAXVALUE; 7 14 } 8 15 16 Box2d::~Box2d() 17 { 18 } 19 20 Ogre::Vector2 Box2d::GetMinimum() 21 { 22 return mMinimum; 23 } 24 25 Ogre::Vector2 Box2d::GetMaximum() 26 { 27 return mMaximum; 28 } 29 30 void 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 38 void 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 61 void 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 66 Ogre::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 81 bool 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 91 bool 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 } 9 100 10 101 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBsp.cpp
r709 r721 1 1 2 #include "IMGBsp.h"2 #include <IMGBsp.h> 3 3 4 namespace IMG { 4 namespace IMG 5 { 6 7 Bsp::Bsp() : root(NULL), countleaf(0), counttotal(0) 8 { 9 } 5 10 6 11 Bsp::~Bsp() 7 12 { 8 delete root; 13 9 14 } 10 15 16 void Bsp::SetRoot(NodeBspPtr node) 17 { 18 root = node; 19 counttotal++; 20 } 21 22 void 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 28 void Bsp::PrintLeaf() 29 { 30 PrintLeaf(root); 31 } 32 33 NodeBspPtr 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 50 NodeBspPtr Bsp::Get(int i) 51 { 52 return root->Get(root, i); 53 } 54 55 void Bsp::Print(NodeBspPtr node) 56 { 57 node->Print(); 58 Print(node->GetChild(0)); 59 Print(node->GetChild(1)); 60 } 61 62 void 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 } 11 72 12 73 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGCluster.cpp
r699 r721 1 1 2 #include "IMGCluster.h"3 #include "IMGCluster2d.h"2 #include <IMGCluster.h> 3 #include <IMGCluster2d.h> 4 4 5 5 namespace IMG { … … 7 7 Cluster::Cluster(){ 8 8 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 11 Cluster::~Cluster() 12 { 13 } 14 15 void Cluster::SetNormal(Ogre::Vector3* n) 16 { 17 normal = *n; 18 } 19 20 Ogre::Vector3* Cluster::GetNormal() 21 { 22 return &normal; 23 } 24 25 BBox* Cluster::GetBound() 26 { 27 return &bound; 28 } 29 30 Box2d* Cluster::GetBspNodeBound() 31 { 32 return &bspnodebound; 33 } 34 35 void Cluster::SetBspNodeBound(Box2d* box) 36 { 37 bspnodebound = (*box); 38 } 39 40 int Cluster::GetId() const 41 { 42 return id; 43 } 44 45 void Cluster::SetId(int id_) 46 { 47 id = id; 48 } 49 50 std::vector<Ogre::Vector3>* Cluster::GetVector3sVector() 51 { 52 return &Vector3s_vector; 53 } 54 55 Ogre::Vector3* Cluster::GetVector3sTex() const 56 { 57 return Vector3s_triangle_text; 58 } 59 60 void 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 67 Plane3 * Cluster::GetPlane() 68 { 69 return &plane; 70 } 71 72 Cluster & Cluster::operator =(const Cluster & p) 73 { 20 74 uv = p.uv; 21 75 id = p.id; 22 76 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 25 78 lumel_origin = p.lumel_origin; 26 79 lumel_x_axis = p.lumel_x_axis; 27 80 lumel_y_axis = p.lumel_y_axis; 28 29 //patchlistid = p.patchlistid; 30 //plane = p.plane; 31 81 32 82 axisproj = p.axisproj; 33 83 order = p.order; … … 39 89 } 40 90 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()); 91 Cluster::Cluster(const Cluster & p) 92 { 49 93 uv = p.uv; 50 94 id = p.id; … … 55 99 lumel_x_axis = p.lumel_x_axis; 56 100 lumel_y_axis = p.lumel_y_axis; 57 58 //patchlistid = p.patchlistid;59 //plane = p.plane;60 101 61 102 axisproj = p.axisproj; … … 65 106 normal = p.normal; 66 107 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 110 void 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 105 114 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: "); 147 124 } 148 125 … … 152 129 Ogre::Vector3 *normal = plane.GetNormal(); 153 130 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 145 void Cluster::Finish() 146 { 147 Ogre::LogManager::getSingleton().logMessage("\nCluster::Finish()"); 180 148 Plane3 *plane = GetPlane(); 181 149 Ogre::Vector3 normal = *plane->GetNormal(); … … 192 160 bool type = true; 193 161 194 printf("\n\tCreant cluster 2d");162 Ogre::LogManager::getSingleton().logMessage("\tCreant cluster 2d"); 195 163 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"); 197 165 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();204 166 std::vector<Ogre::Vector2> vector2; 205 167 vector2 =*cluster2d.GetVector3sVector(); 206 168 207 208 // Gametools -- Isma 17/08/2005209 //if (ObscuranceRayTracing::Config::Debug)210 //{211 // this->Print();212 // //poly2d->Print();213 // cluster2d.Print();214 //}215 216 217 bound = new BBox;218 169 for (unsigned int i = 0; i < vector2.size(); i++) 219 170 { 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 240 180 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)); 380 183 } 381 184 382 185 //* Return the increment in U (lumel increment in x). For patchs calculation 383 Ogre::Vector3 Cluster::GetIncU() {384 186 Ogre::Vector3 Cluster::GetIncU() 187 { 385 188 return lumel_x_axis; 386 189 } 387 190 388 191 //* Return the increment in V (lumel increment in x). For patchs calculation 389 Ogre::Vector3 Cluster::GetIncV() {390 192 Ogre::Vector3 Cluster::GetIncV() 193 { 391 194 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 197 Ogre::Vector3 Cluster::GetOrigin() 198 { 400 199 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/2005423 //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/2005431 //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 orientation448 /**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;*/472 200 } 473 201 474 202 unsigned int Cluster::ID_CLUSTER = 0; 475 203 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 1 1 2 #include "IMGCluster2d.h"3 #include "IMGCluster.h"2 #include <IMGCluster2d.h> 3 #include <IMGCluster.h> 4 4 5 namespace IMG { 5 namespace IMG 6 { 6 7 7 //* Create a 2d polygon from a polygon 3d. The projecte polygon is belong the dominant normal. 8 Cluster2d::Cluster2d() 9 { 10 Vector3s = NULL; 11 cluster =NULL; 12 normal = NULL; 13 } 14 15 Ogre::Vector2 * Cluster2d::GetVector3s() 16 { 17 return Vector3s; 18 } 19 20 std::vector<Ogre::Vector2> * Cluster2d::GetVector3sVector() 21 { 22 return &Vector3s2_vector; 23 } 24 25 Ogre::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. 8 31 // 9 32 // 10 int Cluster2d::Create2d(Cluster * cluster, int type, int type_vertexs) { 11 if (!cluster) return false; 33 int Cluster2d::Create2d(Cluster * cluster, int type, int type_vertexs) 34 { 35 if (!cluster) 36 { 37 return false; 38 } 12 39 13 40 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 32 42 this->cluster = cluster; 33 34 //Vector2 * vertexs2d = new Vector2[4];35 // GametoolsError -- Isma 17/08/200536 //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/200551 //vertexs[i].x = vertexs3d_[i].z;52 //vertexs[i].y = vertexs3d_[i].y;53 //vertexs2_vector.push_back(vertexs[i]);54 43 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/200567 //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/200580 //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-----------------");95 44 return axis; 96 45 } 97 46 98 void Cluster2d::Print() { 47 void Cluster2d::Print() 48 { 99 49 printf("\nPrintant cluster2d: %d", id); 100 // GametoolsError -- Isma 17/08/2005101 //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);107 50 } 108 51 109 Cluster2d::~Cluster2d() { 52 Cluster2d::~Cluster2d() 53 { 110 54 } 111 55 112 113 56 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGClusterList.cpp
r709 r721 1 1 2 #include "IMGClusterList.h"2 #include <IMGClusterList.h> 3 3 4 4 namespace IMG { 5 6 // Gametools -- Isma 17/08/20057 //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/200520 //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 360 // // 0 161 //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 166 // // 2 367 //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 278 // // 1 079 //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/200595 //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 patchlistid151 //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() - 1164 // }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 }192 5 193 6 ClusterList::~ClusterList() … … 196 9 } 197 10 11 bool 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 23 void 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 32 ClusterList::ClusterList() 33 { 34 list.reserve(100); 35 } 36 37 std::vector<Cluster> * ClusterList::GetList() 38 { 39 return &list; 40 } 41 42 unsigned int ClusterList::GetSize() const 43 { 44 return list.size(); 45 } 46 47 Cluster * ClusterList::Get(unsigned int i) 48 { 49 if (i <= list.size()) 50 { 51 return &list[i]; 52 } 53 54 return NULL; 55 } 198 56 199 57 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGNodeBsp.cpp
r699 r721 1 1 2 #include "IMGNodeBsp.h"2 #include <IMGNodeBsp.h> 3 3 4 namespace IMG { 4 namespace IMG 5 { 5 6 6 NodeBsp::NodeBsp(){ 7 child[0] = NULL; 8 child[1] = NULL; 9 //bound.StartBoundingBox(); 10 bound = NULL; 11 //id= NodeBsp::ID++; 7 NodeBsp::NodeBsp(): references(0) // initialize references to 0 8 { 12 9 id = -1; 13 10 fit = false; 14 11 } 15 12 16 Box2d * NodeBsp::GetBound() { 17 18 return bound; 13 NodeBsp::~NodeBsp() 14 { 19 15 } 20 16 21 void NodeBsp::Print() { 22 printf("\nNode : %d, fit: %d", id, fit); 23 if (bound) bound->Print(); 24 //if (plane) plane->Print(); 17 void NodeBsp::SetBound(Box2d * box) 18 { 19 bound = (*box); 25 20 } 26 21 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); 22 NodeBspPtr NodeBsp::GetChild(int i) 23 { 24 return child[i]; 25 } 26 27 void NodeBsp::SetId(int id_) 28 { 29 id = id_; 30 } 31 32 unsigned int NodeBsp::GetId() const 33 { 34 return id; 35 } 36 37 void NodeBsp::SetChild(NodeBspPtr node, int i) 38 { 39 child[i] = node; 40 } 41 42 NodeBspPtr 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 64 Box2d * NodeBsp::GetBound() 65 { 66 return &bound; 67 } 68 69 void NodeBsp::Print() 70 { 71 Ogre::LogManager::getSingleton().logMessage("Node : " + Ogre::StringConverter::toString(id) + ", fit: " + Ogre::StringConverter::toString(fit)); 72 73 bound.Print(); 74 } 75 76 NodeBspPtr 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)); 31 79 32 if (this->fit == true) return NULL; 80 if (this->fit == true) 81 { 82 return NULL; 83 } 33 84 34 85 if (this->child[0] != NULL && this->child[1] != NULL) 35 86 { 36 NodeBsp * new_node = child[0]->Insert(w, h);87 NodeBspPtr new_node = child[0]->Insert(w, h); 37 88 38 89 if (new_node) return new_node; … … 41 92 } 42 93 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 } 45 98 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 } 48 103 49 child[0] = new NodeBsp;50 child[1] = new NodeBsp;104 child[0] = NodeBspPtr(new NodeBsp); 105 child[1] = NodeBspPtr(new NodeBsp); 51 106 52 107 int dw, dh; … … 54 109 float width, height; 55 110 56 bound ->Print();57 min = bound ->GetMinimum();58 max = bound ->GetMaximum();111 bound.Print(); 112 min = bound.GetMinimum(); 113 max = bound.GetMaximum(); 59 114 60 115 width = max.x - min.x; 61 116 height = max.y - min.y; 62 117 63 //printf("\nwidth: %.4f\n", width);64 //printf("\nheigth: %.4f\n", height);65 66 118 dw = (int) width - w; 67 119 dh = (int) height - h; 68 120 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 75 121 if (dw > dh) 76 122 { 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); 89 125 } 90 126 else 91 127 { 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); 105 130 } 106 131 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); 113 133 } 114 134 115 135 unsigned int NodeBsp::ID = 0; 116 136 117 NodeBsp::~NodeBsp() {118 137 } 119 120 121 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGPlane3.cpp
r699 r721 1 1 2 #include "IMGPlane3.h"2 #include <IMGPlane3.h> 3 3 4 4 namespace IMG { 5 5 6 Plane3::~Plane3() { 6 Plane3::Plane3() 7 { 7 8 } 8 9 10 Plane3::~Plane3() 11 { 12 } 13 14 Plane3 & 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 23 Ogre::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 32 void Plane3::SetNormal(float x, float y, float z) 33 { 34 normal.x = x; 35 normal.y = y; 36 normal.z = z; 37 } 38 39 void Plane3::SetDistance(float dist) 40 { 41 d = dist; 42 } 43 44 float Plane3::GetDistance() const 45 { 46 return d; 47 } 48 49 void Plane3::Print() 50 { 51 Ogre::LogManager::getSingleton().logMessage("Printant pla: (" + Ogre::StringConverter::toString(normal) + Ogre::StringConverter::toString(d) + ")"); 52 } 9 53 10 54 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardKMeansClusterData.cpp
r699 r721 10 10 } 11 11 12 13 } 12 void BillboardKMeansClusterData::readBillboardClusterData(TiXmlNode *parentNode) 13 { 14 15 } 16 17 void 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 125 void 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 10 10 } 11 11 12 void BillboardKdTreeClusterData::readBillboardClusterData(TiXmlNode *parentNode)13 {14 12 15 13 } 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 else147 {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 plane218 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> 3 2 4 3 namespace LBBC { 5 4 5 void KMeansClusterGenerator::setAlpha(float value) 6 { 7 mAlpha = value; 8 } 9 10 float KMeansClusterGenerator::getAlpha() 11 { 12 return mAlpha; 13 } 14 15 void KMeansClusterGenerator::setNumIterations(unsigned int value) 16 { 17 mNumIterations = value; 18 } 19 20 unsigned int KMeansClusterGenerator::getNumIterations() 21 { 22 return mNumIterations; 23 } 24 25 unsigned 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 52 void 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 62 void 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 74 void 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 171 void 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 180 void KMeansClusterGenerator::iterativeRecomputeBillboardCloud() 181 { 182 for (unsigned int iIteration = 0; iIteration < mNumIterations; iIteration++) 183 { 184 recomputeBillboardCloud(); 185 } 186 } 187 6 188 void KMeansClusterGenerator::generate() 7 189 { 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 202 BBC::BillboardPtr KMeansClusterGenerator::createBillboard() 203 { 204 BBC::BillboardPtr billboard = BBC::BillboardPtr( new BBC::Billboard() ); 205 mBillboardCloud->addBillboard(billboard); 206 return billboard; 207 } 208 209 void 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 217 void 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 232 void 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 251 void 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 } 9 259 } 10 260 11 261 void KMeansClusterGenerator::init() 12 262 { 13 14 } 15 16 KMeansClusterGenerator::KMeansClusterGenerator() { 17 } 18 19 KMeansClusterGenerator::~KMeansClusterGenerator() { 20 } 21 22 23 } 263 } 264 265 KMeansClusterGenerator::KMeansClusterGenerator() 266 { 267 } 268 269 KMeansClusterGenerator::~KMeansClusterGenerator() 270 { 271 272 } 273 274 275 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKMeansClusterSerializer.cpp
r699 r721 10 10 } 11 11 12 void KMeansClusterSerializer::writeBillboardCloud(TiXmlDocument *document) { 12 void 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"); 13 35 } 14 36 15 16 37 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKdTreeClusterGenerator.cpp
r699 r721 1 #include <LBBCKdTreeClusterGenerator.h> 1 2 #include "LBBCKdTreeClusterGenerator.h" 2 3 3 4 namespace LBBC { 4 5 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 approach145 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 188 6 void KdTreeClusterGenerator::generate() 189 7 { 190 // Generate the initial random billboards and cluster the leaves with them191 // 1. Create the billboards and assign an initial random orientation192 initializeBillboardCloud();193 // 2. Split the leaf distribution, each leaf in the it's best candidate billboard194 splitLeafDistribution();195 // 3. The billboard is recomputed in order to minimize the total error196 // 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 cluster199 generateBillboardCloudBounds();200 }201 8 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 }259 9 } 260 10 261 11 void KdTreeClusterGenerator::init() 262 12 { 13 263 14 } 264 15 265 KdTreeClusterGenerator::KdTreeClusterGenerator() 266 { 16 KdTreeClusterGenerator::KdTreeClusterGenerator() { 267 17 } 268 18 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 } 19 KdTreeClusterGenerator::~KdTreeClusterGenerator() { 286 20 } 287 21 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKdTreeClusterSerializer.cpp
r699 r721 10 10 } 11 11 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"); 12 void KdTreeClusterSerializer::writeBillboardCloud(TiXmlDocument *document) { 35 13 } 36 14 15 37 16 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeaf.cpp
r699 r721 3 3 4 4 namespace LBBC { 5 6 Leaf::Leaf() 7 { 8 } 9 10 Leaf::~Leaf() 11 { 12 13 } 5 14 6 15 void Leaf::setPlaneD(float value) { … … 221 230 } 222 231 223 Leaf::Leaf() { 224 } 225 226 Leaf::~Leaf() { 227 } 228 229 } 232 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistribution.cpp
r699 r721 9 9 LeafDistribution::~LeafDistribution() 10 10 { 11 for (unsigned int iLeaf = 0; iLeaf < getNumEntities(); iLeaf++) 12 { 13 Leaf *leaf = (Leaf*)getEntity(iLeaf); 14 delete leaf; 15 } 11 16 12 } 17 13 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionGenerator.cpp
r709 r721 8 8 LeafDistributionGenerator::LeafDistributionGenerator() 9 9 { 10 mEntity = new BBC::Entity();10 mEntity = BBC::EntityPtr(new BBC::Entity()); 11 11 } 12 12 13 13 LeafDistributionGenerator::~LeafDistributionGenerator() 14 14 { 15 delete mEntity;16 15 } 17 16 … … 122 121 while ((j < mEntityDistribution->getNumEntities()) && (!leaveFound)) 123 122 { 124 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(j) ;123 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(j).get(); 125 124 if (leaf->hasFace(iF01)) 126 125 { … … 186 185 for (unsigned int ileaf = 0; ileaf < mEntityDistribution->getNumEntities(); ileaf++) 187 186 { 188 Leaf *leaf = (Leaf*) mEntityDistribution->getEntity(ileaf) ;187 Leaf *leaf = (Leaf*) mEntityDistribution->getEntity(ileaf).get(); 189 188 leaf->setPosition(leaf->getSubEntity(0)->getUniqueVertex(0).position); 190 189 generateAverageLeafNormal(leaf); … … 223 222 for (unsigned int iD = 0; iD < mEntityDistribution->getNumEntities(); iD++) 224 223 { 225 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(iD) ;224 Leaf *leaf = (Leaf *)mEntityDistribution->getEntity(iD).get(); 226 225 if (leaf->getLeafD() < dMin) 227 226 { -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionSerializer.cpp
r699 r721 7 7 : BBC::EntityDistributionSerializer() 8 8 { 9 mEntity = new BBC::Entity(); 9 10 10 } 11 11 12 12 LeafDistributionSerializer::~LeafDistributionSerializer() 13 13 { 14 delete mEntity; 14 15 15 } 16 16 … … 94 94 for (unsigned int k=0; k < mLeafDistribution->getNumEntities(); k++) 95 95 { 96 Leaf *leaf = (Leaf *)mLeafDistribution->getEntity(k) ;96 Leaf *leaf = (Leaf *)mLeafDistribution->getEntity(k).get(); 97 97 98 98 TiXmlNode *leafNode = leavesNode->ToElement()->InsertEndChild(TiXmlElement(Ogre::String("leaf").c_str()))->ToElement(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeaves.cpp
r699 r721 13 13 Leaves::~Leaves() 14 14 { 15 delete mBillboardCloud; 16 delete mLeafDistribution; 15 if (mBillboardCloud) 16 { 17 delete mBillboardCloud; 18 } 19 20 if (mLeafDistribution) 21 { 22 delete mLeafDistribution; 23 } 17 24 } 18 25 19 Ogre::Mesh* Leaves::getMesh() { 20 return mMesh; 26 BBC::EntityPtr Leaves::getEntity() 27 { 28 return mEntity; 21 29 } 22 30 23 void Leaves::setMesh(Ogre::Mesh * value) { 24 mMesh = value; 31 void Leaves::setEntity(BBC::EntityPtr value) 32 { 33 mEntity = value; 25 34 } 26 35 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp
r709 r721 7 7 : BBC::Manager() 8 8 { 9 //mCf.load("lbbc.cfg"); 10 11 mBillboardCloudSerializer = new KdTreeClusterSerializer(); 9 mBillboardCloudSerializer = new KMeansClusterSerializer(); 12 10 mLeafDistributionSerializer = new LeafDistributionSerializer(); 13 11 mLeafDistributionGenerator = new LeafDistributionGenerator(); 14 mBillboardCloudGenerator = new K dTreeClusterGenerator();12 mBillboardCloudGenerator = new KMeansClusterGenerator(); 15 13 mBillboardCloudUVMapper = new BBC::BillboardCloudUVMapper(); 16 14 mOgreMeshSerializer = new BBC::OgreMeshSerializer(); … … 19 17 Manager::~Manager() 20 18 { 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 29 52 } 30 53 31 54 SampleConfigFile* Manager::getSampleConfigFile() 32 55 { 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 59 void Manager::setSampleConfigFile(SampleConfigFile *sampleConfigFile) 60 { 61 mSampleConfigFile = sampleConfigFile; 62 } 63 64 void Manager::loadSampleConfigFile(Ogre::String sampleConfigFile) 65 { 66 mSampleConfigFile = new SampleConfigFile(); 67 mSampleConfigFile->load(sampleConfigFile); 68 } 69 70 void Manager::runSampleConfigFile() 71 { 40 72 mLeaves = new Leaves(); 41 42 Ogre::Mesh* leavesMesh = BBC::Manager::getSingleton().loadMesh(43 mSampleCf.getEntitiesMeshPrefixFilename() + ".mesh");44 73 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()) 48 81 { 49 82 generateEntityDistribution(); … … 54 87 } 55 88 56 if (mSampleC f.getEntityClustersGeneration())89 if (mSampleConfigFile->getEntityClustersGeneration()) 57 90 { 58 91 generateEntityClusters(); 59 92 } 60 if (mSampleCf.getBillboardCloudGeneration()) 93 94 if (mSampleConfigFile->getBillboardCloudGeneration()) 61 95 { 62 96 generateBillboardCloud(); … … 67 101 { 68 102 mLeafDistributionGenerator->setDistribution(mLeaves->getDistribution()); 69 mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->get Mesh());103 mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 70 104 mLeafDistributionGenerator->generate(); 71 105 } … … 73 107 void Manager::saveEntityDistributionSplitted() 74 108 { 75 BBC::Entity *entity;76 entity = new BBC::Entity();77 78 if (mSampleC f.getEntityDistributionSplitted() || mSampleCf.getEntityDistributionMerged())109 BBC::EntityPtr entity; 110 entity = BBC::EntityPtr(new BBC::Entity()); 111 112 if (mSampleConfigFile->getEntityDistributionSplitted() || mSampleConfigFile->getEntityDistributionMerged()) 79 113 { 80 114 BBC::EntityDistribution *entityDistribution; 81 115 unsigned int numSerializedEntities = 0; 82 83 116 84 117 entityDistribution = mLeaves->getDistribution(); 85 118 for (unsigned int iEntity = 0; iEntity < entityDistribution->getNumEntities(); iEntity++) 86 119 { 87 BBC::SubEntity *subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0);120 BBC::SubEntityPtr subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 88 121 89 122 if (iEntity == 0) 90 123 { 91 // Delete the default constructed subentity...124 // delete the default constructed subentity... 92 125 entity->removeSubEntity(0); 93 126 … … 100 133 } 101 134 102 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleC f.getEntityDistributionMergedMaterialPrefixName());135 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 103 136 numSerializedEntities++; 104 137 } … … 106 139 entity->setSubEntitiesDistinctVertexColours(); 107 140 108 if (mSampleC f.getEntityDistributionSplitted())141 if (mSampleConfigFile->getEntityDistributionSplitted()) 109 142 { 110 143 mOgreMeshSerializer->setEntity(entity); 111 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityClustersFolder() +112 mSampleC f.getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false);144 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 145 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 113 146 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 (mSampleC f.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()) 120 153 { 121 154 entity->mergeSubEntities(); 122 entity->getSubEntity(0)->setMaterialName(mSampleC f.getEntityDistributionMergedMaterialPrefixName());155 entity->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 123 156 124 157 mOgreMeshSerializer->setEntity(entity); 125 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityClustersFolder() +126 mSampleC f.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"); 132 165 } 133 166 } … … 136 169 { 137 170 TiXmlDocument *document = mLeafDistributionSerializer->create( 138 mSampleC f.getEntityDistributionFolder() +139 mSampleC f.getEntityDistributionXMLPrefixFilename() + ".xml");171 mSampleConfigFile->getEntityDistributionFolder() + 172 mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 140 173 mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 141 174 mLeafDistributionSerializer->writeLeafDistribution(document); … … 146 179 { 147 180 TiXmlDocument *document = mLeafDistributionSerializer->load( 148 mSampleC f.getEntityDistributionFolder() +149 mSampleC f.getEntityDistributionXMLPrefixFilename() + ".xml");181 mSampleConfigFile->getEntityDistributionFolder() + 182 mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 150 183 mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 151 mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->get Mesh());184 mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 152 185 mLeafDistributionSerializer->readLeafDistribution(document); 153 186 154 BBC::Entity *entity;187 BBC::EntityPtr entity; 155 188 BBC::EntityDistribution *entityDistribution; 156 189 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); 160 193 161 194 entity->loadMesh(false); … … 164 197 for (unsigned int iSubEntity = 0; iSubEntity < entity->getNumSubEntities(); iSubEntity++) 165 198 { 166 BBC::Entity *entitySample;167 BBC::SubEntity *subEntity;168 BBC::SubEntity *subEntitySample;199 BBC::EntityPtr entitySample; 200 BBC::SubEntityPtr subEntity; 201 BBC::SubEntityPtr subEntitySample; 169 202 170 203 subEntity = entity->getSubEntity(iSubEntity); … … 180 213 void Manager::generateEntityDistribution() 181 214 { 182 if (mSampleC f.getEntityDistributionGeneration())215 if (mSampleConfigFile->getEntityDistributionGeneration()) 183 216 { 184 217 createEntityDistribution(); … … 192 225 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 193 226 { 194 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);195 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());227 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 228 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 196 229 } 197 230 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 198 231 199 232 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"); 204 239 } 205 240 … … 209 244 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 210 245 { 211 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);212 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());246 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 247 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 213 248 } 214 249 215 250 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"); 220 260 } 221 261 222 262 void Manager::saveBillboardCloudMerged() 223 263 { 224 //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());264 //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 225 265 //mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 226 //mOgreMeshSerializer->exportMesh(mSampleC f.getBillboardCloudFolder() +227 // mSampleC f.getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleCf.getBillboardCloudMergedBillboards(), false);228 // mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(),229 // mSampleC f.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"); 231 271 232 272 233 273 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 234 274 { 235 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);236 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());275 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 276 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 237 277 } 238 278 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 239 279 240 280 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"); 245 287 } 246 288 … … 249 291 //saveBillboardCloud() 250 292 TiXmlDocument *document2 = mBillboardCloudSerializer->create( 251 mSampleC f.getBillboardCloudFolder() +252 mSampleC f.getBillboardCloudXMLPrefixFilename() + ".xml");293 mSampleConfigFile->getBillboardCloudFolder() + 294 mSampleConfigFile->getBillboardCloudXMLPrefixFilename() + ".xml"); 253 295 mBillboardCloudSerializer->setBillboardCloud(mLeaves->getBillboardCloud()); 254 296 mBillboardCloudSerializer->writeBillboardCloud(document2); … … 258 300 void Manager::saveEntityClusters() 259 301 { 260 BBC::BillboardClusterData *billboardClusterData;261 BBC::EntityCluster *entityCluster;302 BBC::BillboardClusterDataPtr billboardClusterData; 303 BBC::EntityClusterPtr entityCluster; 262 304 unsigned int numSerializedBillboards = 0; 263 305 264 if (mSampleC f.getEntityClustersSplittedClusters())306 if (mSampleConfigFile->getEntityClustersSplittedClusters()) 265 307 { 266 308 … … 272 314 if (entityCluster->getNumEntitiesClusterData() > 0) 273 315 { 274 BBC::Entity *entityClusterized = entityCluster->getEntity();275 entityClusterized->getSubEntity(0)->setMaterialName(mSampleC f.getEntityClustersMaterialPrefixFilename());316 BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 317 entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 276 318 mOgreMeshSerializer->setEntity(entityClusterized); 277 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityDistributionFolder() +278 mSampleC f.getEntityClustersMeshPrefixFilename() +279 Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleC f.getEntityClustersSplittedClusters()), false);280 mMeshSerializer->exportMesh(entityClusterized->getMesh(),281 mSampleC f.getEntityClustersFolder() +282 mSampleC f.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() + 283 325 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"); 285 329 286 330 numSerializedBillboards++; … … 290 334 numSerializedBillboards = 0; 291 335 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()); 296 340 297 341 for (unsigned int iBillboard = 0; iBillboard < mLeaves->getBillboardCloud()->getNumBillboards(); iBillboard++) … … 302 346 if (entityCluster->getNumEntitiesClusterData() > 0) 303 347 { 304 BBC::Entity *entityClusterized = entityCluster->getEntity();305 entityClusterized->getSubEntity(0)->setMaterialName(mSampleC f.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); 307 351 308 352 if (numSerializedBillboards == 0) 309 353 { 310 // Delete the default constructed subentity...354 // delete the default constructed subentity... 311 355 entity->removeSubEntity(0); 312 356 … … 326 370 327 371 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 } 339 382 } 340 383 … … 343 386 mBillboardCloudGenerator->setDistribution(mLeaves->getDistribution()); 344 387 mBillboardCloudGenerator->setBillboardCloud(mLeaves->getBillboardCloud()); 345 mBillboardCloudGenerator->setMaxNumBillboards(mSampleC f.getEntityClustersMaxClusters());346 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleCf.getEntityClustersAlpha());347 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleCf.getEntityClustersNumIterations());348 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->generate();388 mBillboardCloudGenerator->setMaxNumBillboards(mSampleConfigFile->getEntityClustersMaxClusters()); 389 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleConfigFile->getEntityClustersAlpha()); 390 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleConfigFile->getEntityClustersNumIterations()); 391 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->generate(); 349 392 } 350 393 351 394 void Manager::saveSingleEntity() 352 395 { 353 if (mSampleC f.getEntitySampleMeshGeneration())354 { 355 BBC::Entity *entityLeaf = mLeaves->getDistribution()->getEntity(2);356 entityLeaf->getSubEntity(0)->setMaterialName(mSampleC f.getEntityClustersMaterialPrefixFilename());396 if (mSampleConfigFile->getEntitySampleMeshGeneration()) 397 { 398 BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2); 399 entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 357 400 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 361 405 } 362 406 } … … 364 408 void Manager::generateEntityClusters() 365 409 { 366 Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleC f.getEntityClustersMeshPrefixFilename());410 Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename()); 367 411 createEntityClusters(); 368 412 saveEntityClusters(); … … 372 416 void Manager::generateBillboardCloud() 373 417 { 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 { 394 420 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 421 395 422 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 396 397 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())398 { 399 mBillboardCloudUVMapper-> clear();423 424 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 425 { 426 mBillboardCloudUVMapper->shutdown(); 400 427 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 401 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());402 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());403 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());404 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());428 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 429 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 430 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 431 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 405 432 mBillboardCloudUVMapper->initialize(); 406 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1); 433 434 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1); 407 435 } 408 436 … … 410 438 411 439 saveBillboardCloudMerged(); 412 } 413 414 if (mSampleCf.getBillboardCloudGroupedBillboards()) 440 441 } 442 443 if (mSampleConfigFile->getBillboardCloudGroupedBillboards()) 415 444 { 416 445 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 417 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleC f.getBillboardCloudGroups());418 419 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())420 { 421 mBillboardCloudUVMapper-> clear();446 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups()); 447 448 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 449 { 450 mBillboardCloudUVMapper->shutdown(); 422 451 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 423 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());424 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());425 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());426 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());452 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 453 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 454 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 455 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 427 456 mBillboardCloudUVMapper->initialize(); 428 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleC f.getBillboardCloudGroupedBillboards(), mSampleCf.getBillboardCloudGroups());457 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups()); 429 458 } 430 459 … … 434 463 } 435 464 436 if (mSampleC f.getBillboardCloudSplittedBillboards())465 if (mSampleConfigFile->getBillboardCloudSplittedBillboards()) 437 466 { 438 mLeaves->getBillboardCloud()->generateBillboardCloud( !mSampleCf.getBillboardCloudSplittedBillboards());439 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())440 { 441 mBillboardCloudUVMapper-> clear();467 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 468 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 469 { 470 mBillboardCloudUVMapper->shutdown(); 442 471 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 443 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());444 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());445 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());446 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());472 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 473 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 474 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 475 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 447 476 mBillboardCloudUVMapper->initialize(); 448 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleC f.getBillboardCloudSplittedBillboards(),false);477 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false); 449 478 } 450 479 saveBillboardCloudSplitted(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCSampleConfigFile.cpp
r709 r721 3 3 namespace LBBC { 4 4 5 SampleConfigFile::SampleConfigFile() 5 SampleConfigFile::SampleConfigFile(): Ogre::ConfigFile() 6 6 { 7 7 } … … 48 48 Ogre::String SampleConfigFile::getEntitiesFolder() 49 49 { 50 return getSetting("Entit es Folder");50 return getSetting("Entities Folder"); 51 51 } 52 52 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/main.cpp
r709 r721 1 #include <LBBC.h>2 #include <LBBCPrerequisites.h>3 1 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> 68 3 69 4 int main(int numargs, char** args) 70 5 { 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; 88 10 89 11 return 0;
Note: See TracChangeset
for help on using the changeset viewer.