#ifndef _BBCENTITY_H #define _BBCENTITY_H #include #include #include namespace BBC { // Forward declarations class Entity; namespace boost { void intrusive_ptr_add_ref(Entity * p); void intrusive_ptr_release(Entity * p); }; class _BBCExport Entity { private: long references; friend void boost::intrusive_ptr_add_ref(Entity * p); friend void boost::intrusive_ptr_release(Entity * p); protected: typedef std::vector SubEntityList; unsigned int mEntityHandle; unsigned int mBillboardHandle; SubEntityList mSubEntityList; MeshPtr mMesh; public: Entity(); virtual ~Entity(); void createSubEntity(); void addSubEntity(SubEntityPtr value); SubEntityPtr getSubEntity(unsigned int index); void removeSubEntity(unsigned int index); virtual MeshPtr getMesh(); virtual void setMesh(MeshPtr value); void loadMesh(bool mergeSubMeshes); void getMeshPositions(Ogre::Vector3 position, Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes); void getMeshNormals(Ogre::Quaternion orient, Ogre::Vector3 scale, bool mergeSubMeshes); void getMeshVertexColours(bool mergeSubMeshes); void getMeshTexCoords(bool mergeSubMeshes); void getMeshFacesVerticesID(bool mergeSubMeshes); void setSubEntitiesDistinctVertexColours(); unsigned int getEntityHandle(); void setEntityHandle(unsigned int value); void sincronizeNumSubEntities(); unsigned int getNumSubEntities(); void mergeSubEntities(); }; // class specific addref/release implementation // the two function overloads must be in the boost namespace on most compilers: namespace boost { inline void intrusive_ptr_add_ref(Entity * p) { // increment reference count of object *p ++(p->references); } inline void intrusive_ptr_release(Entity * p) { // decrement reference count, and delete object when reference count reaches 0 if (--(p->references) == 0) delete p; } } // namespace boost typedef ::boost::intrusive_ptr EntityPtr; } #endif