1 | #ifndef _BBCSUBENTITY_H |
---|
2 | #define _BBCSUBENTITY_H |
---|
3 | |
---|
4 | #include <BBCPrerequisites.h> |
---|
5 | |
---|
6 | namespace BBC { |
---|
7 | |
---|
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 | |
---|
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: |
---|
45 | |
---|
46 | typedef std::vector<unsigned short int> TextureCoordSetsDimensions;
|
---|
47 |
|
---|
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 mHasVertexColors; |
---|
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 | |
---|
74 | virtual ~SubEntity(); |
---|
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 hasVertexColors(); |
---|
87 | |
---|
88 | void enableVertexColors(bool value); |
---|
89 | |
---|
90 | void setVertexColor(unsigned int index, Ogre::RGBA value); |
---|
91 | |
---|
92 | Ogre::RGBA getVertexColor(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 | void removeTextureCoordSet(); |
---|
101 | |
---|
102 | unsigned int getNumTexCoords(); |
---|
103 | |
---|
104 | unsigned int getNumVertices(); |
---|
105 | |
---|
106 | void setPosition(unsigned int index, Ogre::Vector3 value);
|
---|
107 |
|
---|
108 | Ogre::Vector3 getPosition(unsigned int index);
|
---|
109 |
|
---|
110 | void setNormal(unsigned int index, Ogre::Vector3 value);
|
---|
111 |
|
---|
112 | Ogre::Vector3 getNormal(unsigned int index);
|
---|
113 |
|
---|
114 | void setTexCoord(unsigned int index, unsigned int set, Ogre::Vector3 value);
|
---|
115 |
|
---|
116 | Ogre::Vector3 getTexCoord(unsigned int index, unsigned int set); |
---|
117 | |
---|
118 | void addFaceVerticesIDs(Ogre::Vector3 value); |
---|
119 | |
---|
120 | void removeFaceVerticesIDs(unsigned int value); |
---|
121 | |
---|
122 | Ogre::Vector3 getFaceVerticesIDs(unsigned int value); |
---|
123 | |
---|
124 | unsigned int getNumFaces(); |
---|
125 | |
---|
126 | Ogre::String getName(); |
---|
127 | |
---|
128 | void setName(Ogre::String value); |
---|
129 | |
---|
130 | Ogre::String getMaterialName(); |
---|
131 | |
---|
132 | void setMaterialName(Ogre::String value); |
---|
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(); |
---|
147 | |
---|
148 | const char *GetClassName(void) const;
|
---|
149 | |
---|
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; |
---|
173 | |
---|
174 | } |
---|
175 | #endif |
---|