diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/include/CMeshBuffer.h | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/include/CMeshBuffer.h')
-rw-r--r-- | libraries/irrlicht-1.8/include/CMeshBuffer.h | 602 |
1 files changed, 301 insertions, 301 deletions
diff --git a/libraries/irrlicht-1.8/include/CMeshBuffer.h b/libraries/irrlicht-1.8/include/CMeshBuffer.h index 7512a38..24a95e2 100644 --- a/libraries/irrlicht-1.8/include/CMeshBuffer.h +++ b/libraries/irrlicht-1.8/include/CMeshBuffer.h | |||
@@ -1,301 +1,301 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __T_MESH_BUFFER_H_INCLUDED__ | 5 | #ifndef __T_MESH_BUFFER_H_INCLUDED__ |
6 | #define __T_MESH_BUFFER_H_INCLUDED__ | 6 | #define __T_MESH_BUFFER_H_INCLUDED__ |
7 | 7 | ||
8 | #include "irrArray.h" | 8 | #include "irrArray.h" |
9 | #include "IMeshBuffer.h" | 9 | #include "IMeshBuffer.h" |
10 | 10 | ||
11 | namespace irr | 11 | namespace irr |
12 | { | 12 | { |
13 | namespace scene | 13 | namespace scene |
14 | { | 14 | { |
15 | //! Template implementation of the IMeshBuffer interface | 15 | //! Template implementation of the IMeshBuffer interface |
16 | template <class T> | 16 | template <class T> |
17 | class CMeshBuffer : public IMeshBuffer | 17 | class CMeshBuffer : public IMeshBuffer |
18 | { | 18 | { |
19 | public: | 19 | public: |
20 | //! Default constructor for empty meshbuffer | 20 | //! Default constructor for empty meshbuffer |
21 | CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER) | 21 | CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER) |
22 | { | 22 | { |
23 | #ifdef _DEBUG | 23 | #ifdef _DEBUG |
24 | setDebugName("SMeshBuffer"); | 24 | setDebugName("SMeshBuffer"); |
25 | #endif | 25 | #endif |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | //! Get material of this meshbuffer | 29 | //! Get material of this meshbuffer |
30 | /** \return Material of this buffer */ | 30 | /** \return Material of this buffer */ |
31 | virtual const video::SMaterial& getMaterial() const | 31 | virtual const video::SMaterial& getMaterial() const |
32 | { | 32 | { |
33 | return Material; | 33 | return Material; |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | //! Get material of this meshbuffer | 37 | //! Get material of this meshbuffer |
38 | /** \return Material of this buffer */ | 38 | /** \return Material of this buffer */ |
39 | virtual video::SMaterial& getMaterial() | 39 | virtual video::SMaterial& getMaterial() |
40 | { | 40 | { |
41 | return Material; | 41 | return Material; |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | //! Get pointer to vertices | 45 | //! Get pointer to vertices |
46 | /** \return Pointer to vertices. */ | 46 | /** \return Pointer to vertices. */ |
47 | virtual const void* getVertices() const | 47 | virtual const void* getVertices() const |
48 | { | 48 | { |
49 | return Vertices.const_pointer(); | 49 | return Vertices.const_pointer(); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | //! Get pointer to vertices | 53 | //! Get pointer to vertices |
54 | /** \return Pointer to vertices. */ | 54 | /** \return Pointer to vertices. */ |
55 | virtual void* getVertices() | 55 | virtual void* getVertices() |
56 | { | 56 | { |
57 | return Vertices.pointer(); | 57 | return Vertices.pointer(); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | //! Get number of vertices | 61 | //! Get number of vertices |
62 | /** \return Number of vertices. */ | 62 | /** \return Number of vertices. */ |
63 | virtual u32 getVertexCount() const | 63 | virtual u32 getVertexCount() const |
64 | { | 64 | { |
65 | return Vertices.size(); | 65 | return Vertices.size(); |
66 | } | 66 | } |
67 | 67 | ||
68 | //! Get type of index data which is stored in this meshbuffer. | 68 | //! Get type of index data which is stored in this meshbuffer. |
69 | /** \return Index type of this buffer. */ | 69 | /** \return Index type of this buffer. */ |
70 | virtual video::E_INDEX_TYPE getIndexType() const | 70 | virtual video::E_INDEX_TYPE getIndexType() const |
71 | { | 71 | { |
72 | return video::EIT_16BIT; | 72 | return video::EIT_16BIT; |
73 | } | 73 | } |
74 | 74 | ||
75 | //! Get pointer to indices | 75 | //! Get pointer to indices |
76 | /** \return Pointer to indices. */ | 76 | /** \return Pointer to indices. */ |
77 | virtual const u16* getIndices() const | 77 | virtual const u16* getIndices() const |
78 | { | 78 | { |
79 | return Indices.const_pointer(); | 79 | return Indices.const_pointer(); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | //! Get pointer to indices | 83 | //! Get pointer to indices |
84 | /** \return Pointer to indices. */ | 84 | /** \return Pointer to indices. */ |
85 | virtual u16* getIndices() | 85 | virtual u16* getIndices() |
86 | { | 86 | { |
87 | return Indices.pointer(); | 87 | return Indices.pointer(); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | //! Get number of indices | 91 | //! Get number of indices |
92 | /** \return Number of indices. */ | 92 | /** \return Number of indices. */ |
93 | virtual u32 getIndexCount() const | 93 | virtual u32 getIndexCount() const |
94 | { | 94 | { |
95 | return Indices.size(); | 95 | return Indices.size(); |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | //! Get the axis aligned bounding box | 99 | //! Get the axis aligned bounding box |
100 | /** \return Axis aligned bounding box of this buffer. */ | 100 | /** \return Axis aligned bounding box of this buffer. */ |
101 | virtual const core::aabbox3d<f32>& getBoundingBox() const | 101 | virtual const core::aabbox3d<f32>& getBoundingBox() const |
102 | { | 102 | { |
103 | return BoundingBox; | 103 | return BoundingBox; |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | //! Set the axis aligned bounding box | 107 | //! Set the axis aligned bounding box |
108 | /** \param box New axis aligned bounding box for this buffer. */ | 108 | /** \param box New axis aligned bounding box for this buffer. */ |
109 | //! set user axis aligned bounding box | 109 | //! set user axis aligned bounding box |
110 | virtual void setBoundingBox(const core::aabbox3df& box) | 110 | virtual void setBoundingBox(const core::aabbox3df& box) |
111 | { | 111 | { |
112 | BoundingBox = box; | 112 | BoundingBox = box; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | //! Recalculate the bounding box. | 116 | //! Recalculate the bounding box. |
117 | /** should be called if the mesh changed. */ | 117 | /** should be called if the mesh changed. */ |
118 | virtual void recalculateBoundingBox() | 118 | virtual void recalculateBoundingBox() |
119 | { | 119 | { |
120 | if (Vertices.empty()) | 120 | if (Vertices.empty()) |
121 | BoundingBox.reset(0,0,0); | 121 | BoundingBox.reset(0,0,0); |
122 | else | 122 | else |
123 | { | 123 | { |
124 | BoundingBox.reset(Vertices[0].Pos); | 124 | BoundingBox.reset(Vertices[0].Pos); |
125 | for (u32 i=1; i<Vertices.size(); ++i) | 125 | for (u32 i=1; i<Vertices.size(); ++i) |
126 | BoundingBox.addInternalPoint(Vertices[i].Pos); | 126 | BoundingBox.addInternalPoint(Vertices[i].Pos); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | //! Get type of vertex data stored in this buffer. | 131 | //! Get type of vertex data stored in this buffer. |
132 | /** \return Type of vertex data. */ | 132 | /** \return Type of vertex data. */ |
133 | virtual video::E_VERTEX_TYPE getVertexType() const | 133 | virtual video::E_VERTEX_TYPE getVertexType() const |
134 | { | 134 | { |
135 | return T().getType(); | 135 | return T().getType(); |
136 | } | 136 | } |
137 | 137 | ||
138 | //! returns position of vertex i | 138 | //! returns position of vertex i |
139 | virtual const core::vector3df& getPosition(u32 i) const | 139 | virtual const core::vector3df& getPosition(u32 i) const |
140 | { | 140 | { |
141 | return Vertices[i].Pos; | 141 | return Vertices[i].Pos; |
142 | } | 142 | } |
143 | 143 | ||
144 | //! returns position of vertex i | 144 | //! returns position of vertex i |
145 | virtual core::vector3df& getPosition(u32 i) | 145 | virtual core::vector3df& getPosition(u32 i) |
146 | { | 146 | { |
147 | return Vertices[i].Pos; | 147 | return Vertices[i].Pos; |
148 | } | 148 | } |
149 | 149 | ||
150 | //! returns normal of vertex i | 150 | //! returns normal of vertex i |
151 | virtual const core::vector3df& getNormal(u32 i) const | 151 | virtual const core::vector3df& getNormal(u32 i) const |
152 | { | 152 | { |
153 | return Vertices[i].Normal; | 153 | return Vertices[i].Normal; |
154 | } | 154 | } |
155 | 155 | ||
156 | //! returns normal of vertex i | 156 | //! returns normal of vertex i |
157 | virtual core::vector3df& getNormal(u32 i) | 157 | virtual core::vector3df& getNormal(u32 i) |
158 | { | 158 | { |
159 | return Vertices[i].Normal; | 159 | return Vertices[i].Normal; |
160 | } | 160 | } |
161 | 161 | ||
162 | //! returns texture coord of vertex i | 162 | //! returns texture coord of vertex i |
163 | virtual const core::vector2df& getTCoords(u32 i) const | 163 | virtual const core::vector2df& getTCoords(u32 i) const |
164 | { | 164 | { |
165 | return Vertices[i].TCoords; | 165 | return Vertices[i].TCoords; |
166 | } | 166 | } |
167 | 167 | ||
168 | //! returns texture coord of vertex i | 168 | //! returns texture coord of vertex i |
169 | virtual core::vector2df& getTCoords(u32 i) | 169 | virtual core::vector2df& getTCoords(u32 i) |
170 | { | 170 | { |
171 | return Vertices[i].TCoords; | 171 | return Vertices[i].TCoords; |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | //! Append the vertices and indices to the current buffer | 175 | //! Append the vertices and indices to the current buffer |
176 | /** Only works for compatible types, i.e. either the same type | 176 | /** Only works for compatible types, i.e. either the same type |
177 | or the main buffer is of standard type. Otherwise, behavior is | 177 | or the main buffer is of standard type. Otherwise, behavior is |
178 | undefined. | 178 | undefined. |
179 | */ | 179 | */ |
180 | virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) | 180 | virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) |
181 | { | 181 | { |
182 | if (vertices == getVertices()) | 182 | if (vertices == getVertices()) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | const u32 vertexCount = getVertexCount(); | 185 | const u32 vertexCount = getVertexCount(); |
186 | u32 i; | 186 | u32 i; |
187 | 187 | ||
188 | Vertices.reallocate(vertexCount+numVertices); | 188 | Vertices.reallocate(vertexCount+numVertices); |
189 | for (i=0; i<numVertices; ++i) | 189 | for (i=0; i<numVertices; ++i) |
190 | { | 190 | { |
191 | Vertices.push_back(reinterpret_cast<const T*>(vertices)[i]); | 191 | Vertices.push_back(reinterpret_cast<const T*>(vertices)[i]); |
192 | BoundingBox.addInternalPoint(reinterpret_cast<const T*>(vertices)[i].Pos); | 192 | BoundingBox.addInternalPoint(reinterpret_cast<const T*>(vertices)[i].Pos); |
193 | } | 193 | } |
194 | 194 | ||
195 | Indices.reallocate(getIndexCount()+numIndices); | 195 | Indices.reallocate(getIndexCount()+numIndices); |
196 | for (i=0; i<numIndices; ++i) | 196 | for (i=0; i<numIndices; ++i) |
197 | { | 197 | { |
198 | Indices.push_back(indices[i]+vertexCount); | 198 | Indices.push_back(indices[i]+vertexCount); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | //! Append the meshbuffer to the current buffer | 203 | //! Append the meshbuffer to the current buffer |
204 | /** Only works for compatible types, i.e. either the same type | 204 | /** Only works for compatible types, i.e. either the same type |
205 | or the main buffer is of standard type. Otherwise, behavior is | 205 | or the main buffer is of standard type. Otherwise, behavior is |
206 | undefined. | 206 | undefined. |
207 | \param other Meshbuffer to be appended to this one. | 207 | \param other Meshbuffer to be appended to this one. |
208 | */ | 208 | */ |
209 | virtual void append(const IMeshBuffer* const other) | 209 | virtual void append(const IMeshBuffer* const other) |
210 | { | 210 | { |
211 | /* | 211 | /* |
212 | if (this==other) | 212 | if (this==other) |
213 | return; | 213 | return; |
214 | 214 | ||
215 | const u32 vertexCount = getVertexCount(); | 215 | const u32 vertexCount = getVertexCount(); |
216 | u32 i; | 216 | u32 i; |
217 | 217 | ||
218 | Vertices.reallocate(vertexCount+other->getVertexCount()); | 218 | Vertices.reallocate(vertexCount+other->getVertexCount()); |
219 | for (i=0; i<other->getVertexCount(); ++i) | 219 | for (i=0; i<other->getVertexCount(); ++i) |
220 | { | 220 | { |
221 | Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]); | 221 | Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]); |
222 | } | 222 | } |
223 | 223 | ||
224 | Indices.reallocate(getIndexCount()+other->getIndexCount()); | 224 | Indices.reallocate(getIndexCount()+other->getIndexCount()); |
225 | for (i=0; i<other->getIndexCount(); ++i) | 225 | for (i=0; i<other->getIndexCount(); ++i) |
226 | { | 226 | { |
227 | Indices.push_back(other->getIndices()[i]+vertexCount); | 227 | Indices.push_back(other->getIndices()[i]+vertexCount); |
228 | } | 228 | } |
229 | BoundingBox.addInternalBox(other->getBoundingBox()); | 229 | BoundingBox.addInternalBox(other->getBoundingBox()); |
230 | */ | 230 | */ |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | //! get the current hardware mapping hint | 234 | //! get the current hardware mapping hint |
235 | virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const | 235 | virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const |
236 | { | 236 | { |
237 | return MappingHint_Vertex; | 237 | return MappingHint_Vertex; |
238 | } | 238 | } |
239 | 239 | ||
240 | //! get the current hardware mapping hint | 240 | //! get the current hardware mapping hint |
241 | virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const | 241 | virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const |
242 | { | 242 | { |
243 | return MappingHint_Index; | 243 | return MappingHint_Index; |
244 | } | 244 | } |
245 | 245 | ||
246 | //! set the hardware mapping hint, for driver | 246 | //! set the hardware mapping hint, for driver |
247 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) | 247 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) |
248 | { | 248 | { |
249 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) | 249 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) |
250 | MappingHint_Vertex=NewMappingHint; | 250 | MappingHint_Vertex=NewMappingHint; |
251 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) | 251 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) |
252 | MappingHint_Index=NewMappingHint; | 252 | MappingHint_Index=NewMappingHint; |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | //! flags the mesh as changed, reloads hardware buffers | 256 | //! flags the mesh as changed, reloads hardware buffers |
257 | virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) | 257 | virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) |
258 | { | 258 | { |
259 | if (Buffer==EBT_VERTEX_AND_INDEX ||Buffer==EBT_VERTEX) | 259 | if (Buffer==EBT_VERTEX_AND_INDEX ||Buffer==EBT_VERTEX) |
260 | ++ChangedID_Vertex; | 260 | ++ChangedID_Vertex; |
261 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) | 261 | if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) |
262 | ++ChangedID_Index; | 262 | ++ChangedID_Index; |
263 | } | 263 | } |
264 | 264 | ||
265 | //! Get the currently used ID for identification of changes. | 265 | //! Get the currently used ID for identification of changes. |
266 | /** This shouldn't be used for anything outside the VideoDriver. */ | 266 | /** This shouldn't be used for anything outside the VideoDriver. */ |
267 | virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;} | 267 | virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;} |
268 | 268 | ||
269 | //! Get the currently used ID for identification of changes. | 269 | //! Get the currently used ID for identification of changes. |
270 | /** This shouldn't be used for anything outside the VideoDriver. */ | 270 | /** This shouldn't be used for anything outside the VideoDriver. */ |
271 | virtual u32 getChangedID_Index() const {return ChangedID_Index;} | 271 | virtual u32 getChangedID_Index() const {return ChangedID_Index;} |
272 | 272 | ||
273 | u32 ChangedID_Vertex; | 273 | u32 ChangedID_Vertex; |
274 | u32 ChangedID_Index; | 274 | u32 ChangedID_Index; |
275 | 275 | ||
276 | //! hardware mapping hint | 276 | //! hardware mapping hint |
277 | E_HARDWARE_MAPPING MappingHint_Vertex; | 277 | E_HARDWARE_MAPPING MappingHint_Vertex; |
278 | E_HARDWARE_MAPPING MappingHint_Index; | 278 | E_HARDWARE_MAPPING MappingHint_Index; |
279 | 279 | ||
280 | //! Material for this meshbuffer. | 280 | //! Material for this meshbuffer. |
281 | video::SMaterial Material; | 281 | video::SMaterial Material; |
282 | //! Vertices of this buffer | 282 | //! Vertices of this buffer |
283 | core::array<T> Vertices; | 283 | core::array<T> Vertices; |
284 | //! Indices into the vertices of this buffer. | 284 | //! Indices into the vertices of this buffer. |
285 | core::array<u16> Indices; | 285 | core::array<u16> Indices; |
286 | //! Bounding box of this meshbuffer. | 286 | //! Bounding box of this meshbuffer. |
287 | core::aabbox3d<f32> BoundingBox; | 287 | core::aabbox3d<f32> BoundingBox; |
288 | }; | 288 | }; |
289 | 289 | ||
290 | //! Standard meshbuffer | 290 | //! Standard meshbuffer |
291 | typedef CMeshBuffer<video::S3DVertex> SMeshBuffer; | 291 | typedef CMeshBuffer<video::S3DVertex> SMeshBuffer; |
292 | //! Meshbuffer with two texture coords per vertex, e.g. for lightmaps | 292 | //! Meshbuffer with two texture coords per vertex, e.g. for lightmaps |
293 | typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap; | 293 | typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap; |
294 | //! Meshbuffer with vertices having tangents stored, e.g. for normal mapping | 294 | //! Meshbuffer with vertices having tangents stored, e.g. for normal mapping |
295 | typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents; | 295 | typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents; |
296 | } // end namespace scene | 296 | } // end namespace scene |
297 | } // end namespace irr | 297 | } // end namespace irr |
298 | 298 | ||
299 | #endif | 299 | #endif |
300 | 300 | ||
301 | 301 | ||