#ifndef _BBCSUBENTITY_H #define _BBCSUBENTITY_H #include namespace BBC { class _BBCExport UniqueVertex { public: Ogre::Vector3 position; Ogre::Vector3 normal; Ogre::Vector3 uv[OGRE_MAX_TEXTURE_COORD_SETS]; Ogre::RGBA colour; // The index of the next component with the same base details // but with some variation size_t nextIndex; UniqueVertex(); bool operator==(const UniqueVertex& rhs) const; }; typedef std::vector UniqueVertexList; // Fordward declaration class SubEntity; namespace boost { void intrusive_ptr_add_ref(SubEntity * p); void intrusive_ptr_release(SubEntity * p); }; class _BBCExport SubEntity { private: long references; friend void boost::intrusive_ptr_add_ref(SubEntity * p); friend void boost::intrusive_ptr_release(SubEntity * p); protected: typedef std::vector TextureCoordSetsDimensions; typedef std::vector Indices; UniqueVertexList mUniqueVertexList; TextureCoordSetsDimensions mTextureCoordSetsDimensions; Indices mIndices; bool mHasTangents; bool mHasVertexColours; bool mHasNormals; bool mHasTextureCoords; Ogre::String mName; Ogre::String mMaterialName; Ogre::AxisAlignedBox mAABBox; public: SubEntity(); virtual ~SubEntity(); void enableTangents(bool value); bool hasTangents(); void enableNormals(bool value); bool hasNormals(); void enableTextureCoords(bool value); bool hasVertexColours(); void enableVertexColours(bool value); void setVertexColour(unsigned int index, Ogre::RGBA value); Ogre::RGBA getVertexColour(unsigned int index); unsigned int getNumTexCoordSets(); unsigned int getTexCoordDimensions(unsigned int value); void addTextureCoordSet(unsigned int numTexCoords); unsigned int getNumTexCoords(); unsigned int getNumVertices(); void setPosition(unsigned int index, Ogre::Vector3 value); Ogre::Vector3 getPosition(unsigned int index); void setNormal(unsigned int index, Ogre::Vector3 value); Ogre::Vector3 getNormal(unsigned int index); void setTexCoord(unsigned int index, unsigned int set, Ogre::Vector3 value); Ogre::Vector3 getTexCoord(unsigned int index, unsigned int set, unsigned int value); void addFaceVerticesIDs(Ogre::Vector3 value); void removeFaceVerticesIDs(unsigned int value); Ogre::Vector3 getFaceVerticesIDs(unsigned int value); unsigned int getNumFaces(); Ogre::String getName(); void setName(Ogre::String value); Ogre::String getMaterialName(); void setMaterialName(Ogre::String value); //void createUniqueVertices(); UniqueVertexList* getUniqueVertices(); void addUniqueVertex(UniqueVertex uniqueVertex); void removeUniqueVertex(unsigned int index); UniqueVertex getUniqueVertex(unsigned int index); const Ogre::AxisAlignedBox &getAABBox(); void setAABBox(Ogre::AxisAlignedBox box); void generateAABBox(); const char *GetClassName(void) const; }; // 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(SubEntity * p) { // increment reference count of object *p ++(p->references); } inline void intrusive_ptr_release(SubEntity * p) { // decrement reference count, and delete object when reference count reaches 0 if (--(p->references) == 0) delete p; } } // namespace boost typedef ::boost::intrusive_ptr SubEntityPtr; } #endif