Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials
SSkinMeshBuffer.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2010 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 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Fri Mar 21 2014 04:40:17 by Doxygen (1.8.1.2)