Irrlicht 3D Engine
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 
12 namespace irr
13 {
14 namespace scene
15 {
16 
17 
20 {
26  {
27  #ifdef _DEBUG
28  setDebugName("SSkinMeshBuffer");
29  #endif
30  }
31 
33  virtual const video::SMaterial& getMaterial() const
34  {
35  return Material;
36  }
37 
40  {
41  return Material;
42  }
43 
45  virtual video::S3DVertex *getVertex(u32 index)
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  {
67  default:
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 
138  virtual void recalculateBoundingBox()
139  {
141  return;
142 
144 
145  switch (VertexType)
146  {
147  case video::EVT_STANDARD:
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  }
159  case video::EVT_2TCOORDS:
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  }
171  case video::EVT_TANGENTS:
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;
205  }
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;
224  }
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;
238  }
241  }
242  }
243 
245  virtual const core::vector3df& getPosition(u32 i) const
246  {
247  switch (VertexType)
248  {
249  case video::EVT_2TCOORDS:
250  return Vertices_2TCoords[i].Pos;
251  case video::EVT_TANGENTS:
252  return Vertices_Tangents[i].Pos;
253  default:
254  return Vertices_Standard[i].Pos;
255  }
256  }
257 
260  {
261  switch (VertexType)
262  {
263  case video::EVT_2TCOORDS:
264  return Vertices_2TCoords[i].Pos;
265  case video::EVT_TANGENTS:
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  {
277  case video::EVT_2TCOORDS:
278  return Vertices_2TCoords[i].Normal;
279  case video::EVT_TANGENTS:
280  return Vertices_Tangents[i].Normal;
281  default:
282  return Vertices_Standard[i].Normal;
283  }
284  }
285 
288  {
289  switch (VertexType)
290  {
291  case video::EVT_2TCOORDS:
292  return Vertices_2TCoords[i].Normal;
293  case video::EVT_TANGENTS:
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  {
305  case video::EVT_2TCOORDS:
306  return Vertices_2TCoords[i].TCoords;
307  case video::EVT_TANGENTS:
308  return Vertices_Tangents[i].TCoords;
309  default:
310  return Vertices_Standard[i].TCoords;
311  }
312  }
313 
316  {
317  switch (VertexType)
318  {
319  case video::EVT_2TCOORDS:
320  return Vertices_2TCoords[i].TCoords;
321  case video::EVT_TANGENTS:
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 
336  {
337  return MappingHint_Vertex;
338  }
339 
342  {
343  return MappingHint_Index;
344  }
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)
366  ++ChangedID_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 
Change the vertex mapping.
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
virtual video::SMaterial & getMaterial()
Get Material of this buffer.
virtual u32 getIndexCount() const
Get index count.
core::array< video::S3DVertex2TCoords > Vertices_2TCoords
virtual const core::vector2df & getTCoords(u32 i) const
returns texture coords of vertex i
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
set the hardware mapping hint, for driver
virtual const u16 * getIndices() const
Get pointer to index array.
virtual const void * getVertices() const
Get pointer to vertex array.
E_HARDWARE_MAPPING MappingHint_Index
virtual video::S3DVertex * getVertex(u32 index)
Get standard vertex at given index.
video::E_VERTEX_TYPE VertexType
virtual void setBoundingBox(const core::aabbox3df &box)
Set bounding box.
core::vector3df Pos
Position.
Definition: S3DVertex.h:57
virtual const core::vector3df & getNormal(u32 i) const
returns normal of vertex i
virtual core::vector2df & getTCoords(u32 i)
returns texture coords of vertex i
const T * const_pointer() const
Gets a const pointer to the array.
Definition: irrArray.h:360
E_HARDWARE_MAPPING MappingHint_Vertex
virtual const core::vector3df & getPosition(u32 i) const
returns position of vertex i
virtual u32 getChangedID_Index() const
Get the currently used ID for identification of changes.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
Don&#39;t store on the hardware.
void boundingBoxNeedsRecalculated(void)
Call this after changing the positions of any vertex.
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition: S3DVertex.h:25
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition: aabbox3d.h:50
void push_back(const T &element)
Adds an element at back of array.
Definition: irrArray.h:112
virtual video::E_VERTEX_TYPE getVertexType() const
Get vertex type.
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
bool empty() const
Check if array is empty.
Definition: irrArray.h:385
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:40
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime...
Vertex with two texture coordinates.
Definition: S3DVertex.h:108
virtual void convertToTangents()
Convert to tangents vertex type.
core::array< video::S3DVertex > Vertices_Standard
virtual void convertTo2TCoords()
Convert to 2tcoords vertex type.
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition: S3DVertex.h:29
virtual u32 getVertexCount() const
Get vertex count.
core::aabbox3d< f32 > BoundingBox
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:58
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition: S3DVertex.h:21
Change both vertex and index mapping to the same value.
u32 size() const
Get number of occupied elements of the array.
Definition: irrArray.h:368
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
standard vertex used by the Irrlicht engine.
Definition: S3DVertex.h:42
virtual core::vector3df & getPosition(u32 i)
returns position of vertex i
core::array< video::S3DVertexTangents > Vertices_Tangents
core::array< u16 > Indices
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
flags the mesh as changed, reloads hardware buffers
SColor Color
Color.
Definition: S3DVertex.h:63
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition: matrix4.h:45
Change the index mapping.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition: aabbox3d.h:74
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 u16 * getIndices()
Get pointer to index array.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
get the current hardware mapping hint for index buffers
virtual void append(const IMeshBuffer *const other)
append the meshbuffer to the current buffer
void setDebugName(const c8 *newName)
Sets the debug name of the object.
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition: S3DVertex.h:18
virtual const video::SMaterial & getMaterial() const
Get Material of this buffer.
core::vector2d< f32 > TCoords
Texture coordinates.
Definition: S3DVertex.h:66
void clear()
Clears the array and deletes all allocated memory.
Definition: irrArray.h:203
core::vector3df Normal
Normal vector.
Definition: S3DVertex.h:60
Vertex with a tangent and binormal vector.
Definition: S3DVertex.h:185
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:226
virtual void * getVertices()
Get pointer to vertex array.
T * pointer()
Gets a pointer to the array.
Definition: irrArray.h:352
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
get the current hardware mapping hint for vertex buffers
virtual video::E_INDEX_TYPE getIndexType() const
Get type of index data which is stored in this meshbuffer.
virtual void recalculateBoundingBox()
Recalculate bounding box.