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 {
27  {
28  #ifdef _DEBUG
29  setDebugName("SSkinMeshBuffer");
30  #endif
31  }
32 
34  virtual const video::SMaterial& getMaterial() const
35  {
36  return Material;
37  }
38 
41  {
42  return Material;
43  }
44 
46  virtual video::S3DVertex *getVertex(u32 index)
47  {
48  switch (VertexType)
49  {
51  return (video::S3DVertex*)&Vertices_2TCoords[index];
53  return (video::S3DVertex*)&Vertices_Tangents[index];
54  default:
55  return &Vertices_Standard[index];
56  }
57  }
58 
60  virtual const void* getVertices() const
61  {
62  switch (VertexType)
63  {
65  return Vertices_2TCoords.const_pointer();
67  return Vertices_Tangents.const_pointer();
68  default:
69  return Vertices_Standard.const_pointer();
70  }
71  }
72 
74  virtual void* getVertices()
75  {
76  switch (VertexType)
77  {
79  return Vertices_2TCoords.pointer();
81  return Vertices_Tangents.pointer();
82  default:
83  return Vertices_Standard.pointer();
84  }
85  }
86 
88  virtual u32 getVertexCount() const
89  {
90  switch (VertexType)
91  {
93  return Vertices_2TCoords.size();
95  return Vertices_Tangents.size();
96  default:
97  return Vertices_Standard.size();
98  }
99  }
100 
102 
104  {
105  return video::EIT_16BIT;
106  }
107 
109  virtual const u16* getIndices() const
110  {
111  return Indices.const_pointer();
112  }
113 
115  virtual u16* getIndices()
116  {
117  return Indices.pointer();
118  }
119 
121  virtual u32 getIndexCount() const
122  {
123  return Indices.size();
124  }
125 
127  virtual const core::aabbox3d<f32>& getBoundingBox() const
128  {
129  return BoundingBox;
130  }
131 
133  virtual void setBoundingBox( const core::aabbox3df& box)
134  {
135  BoundingBox = box;
136  }
137 
139  virtual void recalculateBoundingBox()
140  {
142  return;
143 
145 
146  switch (VertexType)
147  {
148  case video::EVT_STANDARD:
149  {
150  if (Vertices_Standard.empty())
151  BoundingBox.reset(0,0,0);
152  else
153  {
155  for (u32 i=1; i<Vertices_Standard.size(); ++i)
157  }
158  break;
159  }
160  case video::EVT_2TCOORDS:
161  {
162  if (Vertices_2TCoords.empty())
163  BoundingBox.reset(0,0,0);
164  else
165  {
167  for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
169  }
170  break;
171  }
172  case video::EVT_TANGENTS:
173  {
174  if (Vertices_Tangents.empty())
175  BoundingBox.reset(0,0,0);
176  else
177  {
179  for (u32 i=1; i<Vertices_Tangents.size(); ++i)
181  }
182  break;
183  }
184  }
185  }
186 
189  {
190  return VertexType;
191  }
192 
194  virtual void convertTo2TCoords()
195  {
197  {
198  for(u32 n=0;n<Vertices_Standard.size();++n)
199  {
201  Vertex.Color=Vertices_Standard[n].Color;
202  Vertex.Pos=Vertices_Standard[n].Pos;
203  Vertex.Normal=Vertices_Standard[n].Normal;
204  Vertex.TCoords=Vertices_Standard[n].TCoords;
205  Vertices_2TCoords.push_back(Vertex);
206  }
207  Vertices_Standard.clear();
209  }
210  }
211 
213  virtual void convertToTangents()
214  {
216  {
217  for(u32 n=0;n<Vertices_Standard.size();++n)
218  {
220  Vertex.Color=Vertices_Standard[n].Color;
221  Vertex.Pos=Vertices_Standard[n].Pos;
222  Vertex.Normal=Vertices_Standard[n].Normal;
223  Vertex.TCoords=Vertices_Standard[n].TCoords;
224  Vertices_Tangents.push_back(Vertex);
225  }
226  Vertices_Standard.clear();
228  }
230  {
231  for(u32 n=0;n<Vertices_2TCoords.size();++n)
232  {
234  Vertex.Color=Vertices_2TCoords[n].Color;
235  Vertex.Pos=Vertices_2TCoords[n].Pos;
236  Vertex.Normal=Vertices_2TCoords[n].Normal;
237  Vertex.TCoords=Vertices_2TCoords[n].TCoords;
238  Vertices_Tangents.push_back(Vertex);
239  }
240  Vertices_2TCoords.clear();
242  }
243  }
244 
246  virtual const core::vector3df& getPosition(u32 i) const
247  {
248  switch (VertexType)
249  {
250  case video::EVT_2TCOORDS:
251  return Vertices_2TCoords[i].Pos;
252  case video::EVT_TANGENTS:
253  return Vertices_Tangents[i].Pos;
254  default:
255  return Vertices_Standard[i].Pos;
256  }
257  }
258 
261  {
262  switch (VertexType)
263  {
264  case video::EVT_2TCOORDS:
265  return Vertices_2TCoords[i].Pos;
266  case video::EVT_TANGENTS:
267  return Vertices_Tangents[i].Pos;
268  default:
269  return Vertices_Standard[i].Pos;
270  }
271  }
272 
274  virtual const core::vector3df& getNormal(u32 i) const
275  {
276  switch (VertexType)
277  {
278  case video::EVT_2TCOORDS:
279  return Vertices_2TCoords[i].Normal;
280  case video::EVT_TANGENTS:
281  return Vertices_Tangents[i].Normal;
282  default:
283  return Vertices_Standard[i].Normal;
284  }
285  }
286 
289  {
290  switch (VertexType)
291  {
292  case video::EVT_2TCOORDS:
293  return Vertices_2TCoords[i].Normal;
294  case video::EVT_TANGENTS:
295  return Vertices_Tangents[i].Normal;
296  default:
297  return Vertices_Standard[i].Normal;
298  }
299  }
300 
302  virtual const core::vector2df& getTCoords(u32 i) const
303  {
304  switch (VertexType)
305  {
306  case video::EVT_2TCOORDS:
307  return Vertices_2TCoords[i].TCoords;
308  case video::EVT_TANGENTS:
309  return Vertices_Tangents[i].TCoords;
310  default:
311  return Vertices_Standard[i].TCoords;
312  }
313  }
314 
317  {
318  switch (VertexType)
319  {
320  case video::EVT_2TCOORDS:
321  return Vertices_2TCoords[i].TCoords;
322  case video::EVT_TANGENTS:
323  return Vertices_Tangents[i].TCoords;
324  default:
325  return Vertices_Standard[i].TCoords;
326  }
327  }
328 
330  virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
331 
333  virtual void append(const IMeshBuffer* const other) {}
334 
337  {
338  return MappingHint_Vertex;
339  }
340 
343  {
344  return MappingHint_Index;
345  }
346 
349  {
350  if (Buffer==EBT_VERTEX)
351  MappingHint_Vertex=NewMappingHint;
352  else if (Buffer==EBT_INDEX)
353  MappingHint_Index=NewMappingHint;
354  else if (Buffer==EBT_VERTEX_AND_INDEX)
355  {
356  MappingHint_Vertex=NewMappingHint;
357  MappingHint_Index=NewMappingHint;
358  }
359  }
360 
363  {
364  PrimitiveType = type;
365  }
366 
369  {
370  return PrimitiveType;
371  }
372 
375  {
376  if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
378  if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
379  ++ChangedID_Index;
380  }
381 
382  virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
383 
384  virtual u32 getChangedID_Index() const {return ChangedID_Index;}
385 
388 
393 
396 
397  //ISkinnedMesh::SJoint *AttachedJoint;
399 
402 
404 
407 
408  // hardware mapping hint
411 
413 };
414 
415 
416 } // end namespace scene
417 } // end namespace irr
418 
419 #endif
420 
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
Describe what kind of primitive geometry is used by the meshbuffer.
Change the vertex mapping.
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
Get the kind of primitive geometry which is used by the meshbuffer.
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.
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
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:59
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:356
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'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
virtual video::E_VERTEX_TYPE getVertexType() const
Get vertex type.
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
Vertex with two texture coordinates.
Definition: S3DVertex.h:111
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:31
virtual u32 getVertexCount() const
Get vertex count.
core::aabbox3d< f32 > BoundingBox
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition: S3DVertex.h:21
Explicitly set all vertices for each triangle.
Change both vertex and index mapping to the same value.
u32 size() const
Get number of occupied elements of the array.
Definition: irrArray.h:364
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
standard vertex used by the Irrlicht engine.
Definition: S3DVertex.h:44
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:65
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
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
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_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
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:68
core::vector3df Normal
Normal vector.
Definition: S3DVertex.h:62
Vertex with a tangent and binormal vector.
Definition: S3DVertex.h:191
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:286
virtual void * getVertices()
Get pointer to vertex array.
T * pointer()
Gets a pointer to the array.
Definition: irrArray.h:348
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.