[700] | 1 | #ifndef _BBCENTITY_H |
---|
| 2 | #define _BBCENTITY_H |
---|
| 3 | |
---|
| 4 | #include <BBCPrerequisites.h> |
---|
| 5 | #include <BBCSubEntity.h> |
---|
[721] | 6 | #include <BBCMesh.h> |
---|
[700] | 7 | |
---|
| 8 | namespace BBC { |
---|
| 9 | |
---|
[721] | 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 | |
---|
[700] | 20 | class _BBCExport Entity |
---|
| 21 | { |
---|
[721] | 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 | |
---|
[700] | 27 | protected: |
---|
| 28 | |
---|
[721] | 29 | typedef std::vector<SubEntityPtr> SubEntityList; |
---|
[700] | 30 | |
---|
| 31 | unsigned int mEntityHandle; |
---|
| 32 | |
---|
| 33 | unsigned int mBillboardHandle; |
---|
| 34 | |
---|
| 35 | SubEntityList mSubEntityList; |
---|
| 36 | |
---|
[721] | 37 | MeshPtr mMesh; |
---|
[700] | 38 | |
---|
| 39 | public: |
---|
| 40 | |
---|
| 41 | Entity(); |
---|
| 42 | |
---|
[721] | 43 | virtual ~Entity(); |
---|
[700] | 44 | |
---|
| 45 | void createSubEntity(); |
---|
| 46 | |
---|
[721] | 47 | void addSubEntity(SubEntityPtr value); |
---|
[700] | 48 | |
---|
[721] | 49 | SubEntityPtr getSubEntity(unsigned int index); |
---|
[700] | 50 | |
---|
| 51 | void removeSubEntity(unsigned int index); |
---|
| 52 | |
---|
[721] | 53 | virtual MeshPtr getMesh(); |
---|
[700] | 54 | |
---|
[721] | 55 | virtual void setMesh(MeshPtr value); |
---|
[700] | 56 | |
---|
| 57 | void loadMesh(bool mergeSubMeshes); |
---|
| 58 | |
---|
| 59 | void getMeshPositions(Ogre::Vector3 position, Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes); |
---|
| 60 | |
---|
| 61 | void getMeshNormals(Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes); |
---|
| 62 | |
---|
| 63 | void getMeshVertexColours(bool mergeSubMeshes); |
---|
| 64 | |
---|
| 65 | void getMeshTexCoords(bool mergeSubMeshes); |
---|
| 66 | |
---|
| 67 | void getMeshFacesVerticesID(bool mergeSubMeshes); |
---|
| 68 | |
---|
| 69 | void setSubEntitiesDistinctVertexColours(); |
---|
| 70 | |
---|
| 71 | unsigned int getEntityHandle(); |
---|
| 72 | |
---|
| 73 | void setEntityHandle(unsigned int value); |
---|
| 74 | |
---|
| 75 | void sincronizeNumSubEntities(); |
---|
| 76 | |
---|
| 77 | unsigned int getNumSubEntities(); |
---|
| 78 | |
---|
| 79 | void mergeSubEntities(); |
---|
| 80 | |
---|
| 81 | }; |
---|
| 82 | |
---|
[721] | 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 | |
---|
[700] | 105 | } |
---|
| 106 | #endif |
---|