Irrlicht 3D Engine
 
Loading...
Searching...
No Matches
SSkinMeshBuffer.h
Go to the documentation of this file.
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__
6#define __I_SKIN_MESH_BUFFER_H_INCLUDED__
7
8#include "IMeshBuffer.h"
9#include "S3DVertex.h"
10
11
12namespace irr
13{
14namespace scene
15{
16
17
20{
31
33 virtual const video::SMaterial& getMaterial() const
34 {
35 return Material;
36 }
37
40 {
41 return Material;
42 }
43
46 {
47 switch (VertexType)
48 {
50 return (video::S3DVertex*)&Vertices_2TCoords[index];
52 return (video::S3DVertex*)&Vertices_Tangents[index];
53 default:
54 return &Vertices_Standard[index];
55 }
56 }
57
59 virtual const void* getVertices() const
60 {
61 switch (VertexType)
62 {
64 return Vertices_2TCoords.const_pointer();
66 return Vertices_Tangents.const_pointer();
67 default:
68 return Vertices_Standard.const_pointer();
69 }
70 }
71
73 virtual void* getVertices()
74 {
75 switch (VertexType)
76 {
78 return Vertices_2TCoords.pointer();
80 return Vertices_Tangents.pointer();
81 default:
82 return Vertices_Standard.pointer();
83 }
84 }
85
87 virtual u32 getVertexCount() const
88 {
89 switch (VertexType)
90 {
92 return Vertices_2TCoords.size();
94 return Vertices_Tangents.size();
95 default:
96 return Vertices_Standard.size();
97 }
98 }
99
101
103 {
104 return video::EIT_16BIT;
105 }
106
108 virtual const u16* getIndices() const
109 {
110 return Indices.const_pointer();
111 }
112
114 virtual u16* getIndices()
115 {
116 return Indices.pointer();
117 }
118
120 virtual u32 getIndexCount() const
121 {
122 return Indices.size();
123 }
124
126 virtual const core::aabbox3d<f32>& getBoundingBox() const
127 {
128 return BoundingBox;
129 }
130
132 virtual void setBoundingBox( const core::aabbox3df& box)
133 {
134 BoundingBox = box;
135 }
136
139 {
141 return;
142
144
145 switch (VertexType)
146 {
148 {
149 if (Vertices_Standard.empty())
150 BoundingBox.reset(0,0,0);
151 else
152 {
154 for (u32 i=1; i<Vertices_Standard.size(); ++i)
156 }
157 break;
158 }
160 {
161 if (Vertices_2TCoords.empty())
162 BoundingBox.reset(0,0,0);
163 else
164 {
166 for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
168 }
169 break;
170 }
172 {
173 if (Vertices_Tangents.empty())
174 BoundingBox.reset(0,0,0);
175 else
176 {
178 for (u32 i=1; i<Vertices_Tangents.size(); ++i)
180 }
181 break;
182 }
183 }
184 }
185
188 {
189 return VertexType;
190 }
191
193 virtual void convertTo2TCoords()
194 {
196 {
197 for(u32 n=0;n<Vertices_Standard.size();++n)
198 {
200 Vertex.Color=Vertices_Standard[n].Color;
201 Vertex.Pos=Vertices_Standard[n].Pos;
202 Vertex.Normal=Vertices_Standard[n].Normal;
203 Vertex.TCoords=Vertices_Standard[n].TCoords;
204 Vertices_2TCoords.push_back(Vertex);
205 }
206 Vertices_Standard.clear();
208 }
209 }
210
212 virtual void convertToTangents()
213 {
215 {
216 for(u32 n=0;n<Vertices_Standard.size();++n)
217 {
219 Vertex.Color=Vertices_Standard[n].Color;
220 Vertex.Pos=Vertices_Standard[n].Pos;
221 Vertex.Normal=Vertices_Standard[n].Normal;
222 Vertex.TCoords=Vertices_Standard[n].TCoords;
223 Vertices_Tangents.push_back(Vertex);
224 }
225 Vertices_Standard.clear();
227 }
229 {
230 for(u32 n=0;n<Vertices_2TCoords.size();++n)
231 {
233 Vertex.Color=Vertices_2TCoords[n].Color;
234 Vertex.Pos=Vertices_2TCoords[n].Pos;
235 Vertex.Normal=Vertices_2TCoords[n].Normal;
236 Vertex.TCoords=Vertices_2TCoords[n].TCoords;
237 Vertices_Tangents.push_back(Vertex);
238 }
239 Vertices_2TCoords.clear();
241 }
242 }
243
245 virtual const core::vector3df& getPosition(u32 i) const
246 {
247 switch (VertexType)
248 {
250 return Vertices_2TCoords[i].Pos;
252 return Vertices_Tangents[i].Pos;
253 default:
254 return Vertices_Standard[i].Pos;
255 }
256 }
257
260 {
261 switch (VertexType)
262 {
264 return Vertices_2TCoords[i].Pos;
266 return Vertices_Tangents[i].Pos;
267 default:
268 return Vertices_Standard[i].Pos;
269 }
270 }
271
273 virtual const core::vector3df& getNormal(u32 i) const
274 {
275 switch (VertexType)
276 {
278 return Vertices_2TCoords[i].Normal;
280 return Vertices_Tangents[i].Normal;
281 default:
282 return Vertices_Standard[i].Normal;
283 }
284 }
285
288 {
289 switch (VertexType)
290 {
292 return Vertices_2TCoords[i].Normal;
294 return Vertices_Tangents[i].Normal;
295 default:
296 return Vertices_Standard[i].Normal;
297 }
298 }
299
301 virtual const core::vector2df& getTCoords(u32 i) const
302 {
303 switch (VertexType)
304 {
306 return Vertices_2TCoords[i].TCoords;
308 return Vertices_Tangents[i].TCoords;
309 default:
310 return Vertices_Standard[i].TCoords;
311 }
312 }
313
316 {
317 switch (VertexType)
318 {
320 return Vertices_2TCoords[i].TCoords;
322 return Vertices_Tangents[i].TCoords;
323 default:
324 return Vertices_Standard[i].TCoords;
325 }
326 }
327
329 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
330
332 virtual void append(const IMeshBuffer* const other) {}
333
339
345
348 {
349 if (Buffer==EBT_VERTEX)
350 MappingHint_Vertex=NewMappingHint;
351 else if (Buffer==EBT_INDEX)
352 MappingHint_Index=NewMappingHint;
353 else if (Buffer==EBT_VERTEX_AND_INDEX)
354 {
355 MappingHint_Vertex=NewMappingHint;
356 MappingHint_Index=NewMappingHint;
357 }
358 }
359
362 {
363 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
365 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
367 }
368
369 virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
370
371 virtual u32 getChangedID_Index() const {return ChangedID_Index;}
372
375
380
383
384 //ISkinnedMesh::SJoint *AttachedJoint;
386
389
391
392 // hardware mapping hint
395
397};
398
399
400} // end namespace scene
401} // end namespace irr
402
403#endif
404
void setDebugName(const c8 *newName)
Sets the debug name of the object.
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.h:46
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.h:74
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.h:50
T * pointer()
Gets a pointer to the array.
Definition irrArray.h:352
u32 size() const
Get number of occupied elements of the array.
Definition irrArray.h:368
const T * const_pointer() const
Gets a const pointer to the array.
Definition irrArray.h:360
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:40
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
@ EBT_INDEX
Change the index mapping.
@ EBT_VERTEX
Change the vertex mapping.
@ EHM_NEVER
Don't store on the hardware.
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.h:25
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.h:29
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.h:40
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
virtual u32 getVertexCount() const
Get vertex count.
virtual video::E_INDEX_TYPE getIndexType() const
Get type of index data which is stored in this meshbuffer.
core::aabbox3d< f32 > BoundingBox
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
get the current hardware mapping hint for vertex buffers
core::array< video::S3DVertex > Vertices_Standard
virtual u16 * getIndices()
Get pointer to index array.
core::array< video::S3DVertex2TCoords > Vertices_2TCoords
virtual const core::vector2df & getTCoords(u32 i) const
returns texture coords of vertex i
E_HARDWARE_MAPPING MappingHint_Index
virtual void convertTo2TCoords()
Convert to 2tcoords vertex type.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
get the current hardware mapping hint for index buffers
video::E_VERTEX_TYPE VertexType
virtual void append(const IMeshBuffer *const other)
append the meshbuffer to the current buffer
virtual u32 getChangedID_Index() const
Get the currently used ID for identification of changes.
virtual const void * getVertices() const
Get pointer to vertex array.
virtual const core::vector3df & getPosition(u32 i) const
returns position of vertex i
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
virtual core::vector2df & getTCoords(u32 i)
returns texture coords of vertex i
virtual video::E_VERTEX_TYPE getVertexType() const
Get vertex type.
virtual void * getVertices()
Get pointer to vertex array.
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
virtual void convertToTangents()
Convert to tangents vertex type.
core::array< video::S3DVertexTangents > Vertices_Tangents
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
E_HARDWARE_MAPPING MappingHint_Vertex
virtual void setBoundingBox(const core::aabbox3df &box)
Set bounding box.
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
set the hardware mapping hint, for driver
virtual core::vector3df & getPosition(u32 i)
returns position of vertex i
virtual video::S3DVertex * getVertex(u32 index)
Get standard vertex at given index.
virtual video::SMaterial & getMaterial()
Get Material of this buffer.
virtual const video::SMaterial & getMaterial() const
Get Material of this buffer.
virtual u32 getIndexCount() const
Get index count.
virtual const core::vector3df & getNormal(u32 i) const
returns normal of vertex i
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)
append the vertices and indices to the current buffer
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
flags the mesh as changed, reloads hardware buffers
void boundingBoxNeedsRecalculated(void)
Call this after changing the positions of any vertex.
virtual const u16 * getIndices() const
Get pointer to index array.
virtual void recalculateBoundingBox()
Recalculate bounding box.
Vertex with two texture coordinates.
Definition S3DVertex.h:110
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.h:66
core::vector3df Normal
Normal vector.
Definition S3DVertex.h:60
SColor Color
Color.
Definition S3DVertex.h:63
core::vector3df Pos
Position.
Definition S3DVertex.h:57
Vertex with a tangent and binormal vector.
Definition S3DVertex.h:188