arsa  2.7
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 
35  {
36  return Material;
37  }
38 
41  {
42  return Material;
43  }
44 
47  {
48  switch (VertexType)
49  {
54  default:
55  return &Vertices_Standard[index];
56  }
57  }
58 
60  virtual const void* getVertices() const _IRR_OVERRIDE_
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() _IRR_OVERRIDE_
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 
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 
110  {
111  return Indices.const_pointer();
112  }
113 
116  {
117  return Indices.pointer();
118  }
119 
122  {
123  return Indices.size();
124  }
125 
128  {
129  return BoundingBox;
130  }
131 
134  {
135  BoundingBox = box;
136  }
137 
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 
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 
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 
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 _IRR_OVERRIDE_
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 
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) _IRR_OVERRIDE_ {}
331 
333  virtual void append(const IMeshBuffer* const other) _IRR_OVERRIDE_ {}
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  {
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 
383 
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 append(const IMeshBuffer *const other) _IRR_OVERRIDE_
append the meshbuffer to the current buffer
virtual u32 getChangedID_Vertex() const _IRR_OVERRIDE_
Get the currently used ID for identification of changes.
Change the vertex mapping.
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
core::array< video::S3DVertex2TCoords > Vertices_2TCoords
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_
get the current hardware mapping hint for index buffers
GLdouble n
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
E_HARDWARE_MAPPING MappingHint_Index
virtual video::S3DVertex * getVertex(u32 index)
Get standard vertex at given index.
video::E_VERTEX_TYPE VertexType
virtual u32 getIndexCount() const _IRR_OVERRIDE_
Get index count.
core::vector3df Pos
Position.
Definition: S3DVertex.h:59
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: SDL_opengl.h:1571
virtual core::vector3df & getNormal(u32 i) _IRR_OVERRIDE_
returns normal of vertex i
void convertTo2TCoords()
Convert to 2tcoords vertex type.
const T * const_pointer() const
Gets a const pointer to the array.
Definition: irrArray.h:356
virtual const core::vector3df & getPosition(u32 i) const _IRR_OVERRIDE_
returns position of vertex i
E_HARDWARE_MAPPING MappingHint_Vertex
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_
get the current hardware mapping hint for vertex buffers
void convertToTangents()
Convert to tangents vertex type.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
virtual const void * getVertices() const _IRR_OVERRIDE_
Get pointer to vertex array.
Don't store on the hardware.
virtual const core::vector2df & getTCoords(u32 i) const _IRR_OVERRIDE_
returns texture coords of vertex i
virtual video::SMaterial & getMaterial() _IRR_OVERRIDE_
Get Material of this buffer.
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 E_PRIMITIVE_TYPE getPrimitiveType() const _IRR_OVERRIDE_
Get the kind of primitive geometry which is used by the meshbuffer.
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) _IRR_OVERRIDE_
append the vertices and indices to the current buffer
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
virtual video::E_VERTEX_TYPE getVertexType() const _IRR_OVERRIDE_
Get vertex type.
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
set the hardware mapping hint, for driver
Vertex with two texture coordinates.
Definition: S3DVertex.h:112
core::array< video::S3DVertex > Vertices_Standard
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 const core::vector3df & getNormal(u32 i) const _IRR_OVERRIDE_
returns normal of vertex i
virtual u32 getChangedID_Index() const _IRR_OVERRIDE_
Get the currently used ID for identification of changes.
virtual u16 * getIndices() _IRR_OVERRIDE_
Get pointer to index array.
virtual void * getVertices() _IRR_OVERRIDE_
Get pointer to vertex array.
core::aabbox3d< f32 > BoundingBox
virtual const core::aabbox3d< f32 > & getBoundingBox() const _IRR_OVERRIDE_
Get bounding box.
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 video::E_INDEX_TYPE getIndexType() const _IRR_OVERRIDE_
Get type of index data which is stored in this meshbuffer.
standard vertex used by the Irrlicht engine.
Definition: S3DVertex.h:44
GLuint index
core::array< video::S3DVertexTangents > Vertices_Tangents
core::array< u16 > Indices
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
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
virtual const u16 * getIndices() const _IRR_OVERRIDE_
Get pointer to index array.
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
#define _IRR_OVERRIDE_
Defines an override macro, to protect virtual functions from typos and other mismatches.
Definition: irrTypes.h:216
virtual void recalculateBoundingBox() _IRR_OVERRIDE_
Recalculate bounding box.
virtual void setBoundingBox(const core::aabbox3df &box) _IRR_OVERRIDE_
Set bounding box.
void setDebugName(const c8 *newName)
Sets the debug name of the object.
virtual const video::SMaterial & getMaterial() const _IRR_OVERRIDE_
Get Material of this buffer.
virtual core::vector3df & getPosition(u32 i) _IRR_OVERRIDE_
returns position of vertex i
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
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
core::vector2d< f32 > TCoords
Texture coordinates.
Definition: S3DVertex.h:68
#define const
Definition: zconf.h:217
core::vector3df Normal
Normal vector.
Definition: S3DVertex.h:62
virtual core::vector2df & getTCoords(u32 i) _IRR_OVERRIDE_
returns texture coords of vertex i
Vertex with a tangent and binormal vector.
Definition: S3DVertex.h:192
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304
T * pointer()
Gets a pointer to the array.
Definition: irrArray.h:348
virtual u32 getVertexCount() const _IRR_OVERRIDE_
Get vertex count.
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) _IRR_OVERRIDE_
Describe what kind of primitive geometry is used by the meshbuffer.