[700] | 1 | #ifndef _BBCSUBENTITY_H |
---|
| 2 | #define _BBCSUBENTITY_H |
---|
| 3 | |
---|
| 4 | #include <BBCPrerequisites.h> |
---|
| 5 | |
---|
| 6 | namespace BBC { |
---|
[721] | 7 | |
---|
[700] | 8 | class _BBCExport UniqueVertex
|
---|
| 9 | {
|
---|
| 10 | public:
|
---|
| 11 | Ogre::Vector3 position;
|
---|
| 12 | Ogre::Vector3 normal;
|
---|
| 13 | Ogre::Vector3 uv[OGRE_MAX_TEXTURE_COORD_SETS];
|
---|
| 14 | Ogre::RGBA colour;
|
---|
| 15 | // The index of the next component with the same base details
|
---|
| 16 | // but with some variation
|
---|
| 17 | size_t nextIndex;
|
---|
| 18 |
|
---|
| 19 | UniqueVertex();
|
---|
| 20 | bool operator==(const UniqueVertex& rhs) const;
|
---|
| 21 |
|
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | typedef std::vector<UniqueVertex> UniqueVertexList; |
---|
| 25 | |
---|
[721] | 26 | // Fordward declaration |
---|
| 27 | class SubEntity; |
---|
[700] | 28 | |
---|
[721] | 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: |
---|
| 45 | |
---|
[700] | 46 | typedef std::vector<unsigned short int> TextureCoordSetsDimensions;
|
---|
[721] | 47 |
|
---|
[700] | 48 | typedef std::vector<Ogre::Vector3> Indices;
|
---|
| 49 | |
---|
| 50 | UniqueVertexList mUniqueVertexList; |
---|
| 51 | |
---|
| 52 | TextureCoordSetsDimensions mTextureCoordSetsDimensions; |
---|
| 53 | |
---|
| 54 | Indices mIndices; |
---|
| 55 | |
---|
| 56 | bool mHasTangents; |
---|
| 57 | |
---|
| 58 | bool mHasVertexColours; |
---|
| 59 | |
---|
| 60 | bool mHasNormals; |
---|
| 61 | |
---|
| 62 | bool mHasTextureCoords; |
---|
| 63 | |
---|
| 64 | Ogre::String mName; |
---|
| 65 | |
---|
| 66 | Ogre::String mMaterialName; |
---|
| 67 | |
---|
| 68 | Ogre::AxisAlignedBox mAABBox; |
---|
| 69 | |
---|
| 70 | public: |
---|
| 71 | |
---|
| 72 | SubEntity(); |
---|
| 73 | |
---|
[721] | 74 | virtual ~SubEntity(); |
---|
[700] | 75 | |
---|
| 76 | void enableTangents(bool value); |
---|
| 77 | |
---|
| 78 | bool hasTangents(); |
---|
| 79 | |
---|
| 80 | void enableNormals(bool value); |
---|
| 81 | |
---|
| 82 | bool hasNormals(); |
---|
| 83 | |
---|
| 84 | void enableTextureCoords(bool value); |
---|
| 85 | |
---|
| 86 | bool hasVertexColours(); |
---|
| 87 | |
---|
| 88 | void enableVertexColours(bool value); |
---|
| 89 | |
---|
| 90 | void setVertexColour(unsigned int index, Ogre::RGBA value); |
---|
| 91 | |
---|
| 92 | Ogre::RGBA getVertexColour(unsigned int index); |
---|
| 93 | |
---|
| 94 | unsigned int getNumTexCoordSets(); |
---|
| 95 | |
---|
| 96 | unsigned int getTexCoordDimensions(unsigned int value); |
---|
| 97 | |
---|
| 98 | void addTextureCoordSet(unsigned int numTexCoords); |
---|
| 99 | |
---|
| 100 | unsigned int getNumTexCoords(); |
---|
| 101 | |
---|
| 102 | unsigned int getNumVertices(); |
---|
| 103 | |
---|
| 104 | void setPosition(unsigned int index, Ogre::Vector3 value);
|
---|
| 105 |
|
---|
| 106 | Ogre::Vector3 getPosition(unsigned int index);
|
---|
| 107 |
|
---|
| 108 | void setNormal(unsigned int index, Ogre::Vector3 value);
|
---|
| 109 |
|
---|
| 110 | Ogre::Vector3 getNormal(unsigned int index);
|
---|
| 111 |
|
---|
| 112 | void setTexCoord(unsigned int index, unsigned int set, Ogre::Vector3 value);
|
---|
| 113 |
|
---|
| 114 | Ogre::Vector3 getTexCoord(unsigned int index, unsigned int set, unsigned int value); |
---|
| 115 | |
---|
| 116 | void addFaceVerticesIDs(Ogre::Vector3 value); |
---|
| 117 | |
---|
| 118 | void removeFaceVerticesIDs(unsigned int value); |
---|
| 119 | |
---|
| 120 | Ogre::Vector3 getFaceVerticesIDs(unsigned int value); |
---|
| 121 | |
---|
| 122 | unsigned int getNumFaces(); |
---|
| 123 | |
---|
| 124 | Ogre::String getName(); |
---|
| 125 | |
---|
| 126 | void setName(Ogre::String value); |
---|
| 127 | |
---|
| 128 | Ogre::String getMaterialName(); |
---|
| 129 | |
---|
| 130 | void setMaterialName(Ogre::String value); |
---|
| 131 | |
---|
| 132 | //void createUniqueVertices(); |
---|
| 133 | |
---|
| 134 | UniqueVertexList* getUniqueVertices(); |
---|
| 135 | |
---|
| 136 | void addUniqueVertex(UniqueVertex uniqueVertex); |
---|
| 137 | |
---|
| 138 | void removeUniqueVertex(unsigned int index); |
---|
| 139 | |
---|
| 140 | UniqueVertex getUniqueVertex(unsigned int index); |
---|
| 141 | |
---|
| 142 | const Ogre::AxisAlignedBox &getAABBox(); |
---|
| 143 | |
---|
| 144 | void setAABBox(Ogre::AxisAlignedBox box); |
---|
| 145 | |
---|
| 146 | void generateAABBox(); |
---|
[721] | 147 | |
---|
| 148 | const char *GetClassName(void) const;
|
---|
| 149 | |
---|
[700] | 150 | }; |
---|
| 151 | |
---|
[721] | 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; |
---|
| 173 | |
---|
[700] | 174 | } |
---|
| 175 | #endif |
---|