Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials
IAnimatedMeshMD3.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2010 Nikolaus Gebhardt / Thomas Alten
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_ANIMATED_MESH_MD3_H_INCLUDED__
6 #define __I_ANIMATED_MESH_MD3_H_INCLUDED__
7 
8 #include "IAnimatedMesh.h"
9 #include "IQ3Shader.h"
10 #include "quaternion.h"
11 
12 namespace irr
13 {
14 namespace scene
15 {
16 
18  {
19  EMD3_HEAD = 0,
24  };
25 
28  {
29  // Animations for both lower and upper parts of the player
36 
37  // Animations for the upper part
45 
46  // Animations for the lower part
59 
62  };
63 
65  {
74  };
75 
76 
77 // byte-align structures
78 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
79 # pragma pack( push, packing )
80 # pragma pack( 1 )
81 # define PACK_STRUCT
82 #elif defined( __GNUC__ )
83 # define PACK_STRUCT __attribute__((packed))
84 #else
85 # error compiler not supported
86 #endif
87 
89  struct SMD3Header
90  {
91  c8 headerID[4]; //id of file, always "IDP3"
92  s32 Version; //this is a version number, always 15
93  s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars
94  s32 numFrames; //number of KeyFrames
95  s32 numTags; //number of 'tags' per frame
96  s32 numMeshes; //number of meshes/skins
97  s32 numMaxSkins; //maximum number of unique skins used in md3 file. artefact md2
98  s32 frameStart; //starting position of frame-structur
99  s32 tagStart; //starting position of tag-structures
100  s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures
102  };
103 
106  {
107  c8 meshID[4]; //id, must be IDP3
108  c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars
109 
110  s32 numFrames; //number of meshframes in mesh
111  s32 numShader; //number of skins in mesh
112  s32 numVertices; //number of vertices
113  s32 numTriangles; //number of Triangles
114 
115  s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header
116  s32 offset_shaders; //size of header
117  s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header
118  s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header
120  };
121 
122 
124  struct SMD3Vertex
125  {
127  u8 normal[2];
128  };
129 
132  {
135  };
136 
138  struct SMD3Face
139  {
140  s32 Index[3];
141  };
142 
143 
144 // Default alignment
145 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
146 # pragma pack( pop, packing )
147 #endif
148 
149 #undef PACK_STRUCT
150 
153  {
155 
160  };
161 
163 
165  {
167  {
168  position.X = 0.f;
169  }
170 
171  // construct copy constructor
173  {
174  *this = copyMe;
175  }
176 
177  // construct for searching
179  : Name ( name ) {}
180 
181  // construct from a matrix
183  : Name(name), position(m.getTranslation()), rotation(m) {}
184 
185  // construct from a position and euler angles in degrees
186  SMD3QuaternionTag ( const core::vector3df &pos, const core::vector3df &angle )
187  : position(pos), rotation(angle * core::DEGTORAD) {}
188 
189  // set to matrix
190  void setto ( core::matrix4 &m )
191  {
192  rotation.getMatrix ( m, position );
193  }
194 
195  bool operator == ( const SMD3QuaternionTag &other ) const
196  {
197  return Name == other.Name;
198  }
199 
201  {
202  Name = copyMe.Name;
203  position = copyMe.position;
204  rotation = copyMe.rotation;
205  return *this;
206  }
207 
211  };
212 
215  {
217  {
219  }
220 
221  // construct copy constructor
223  {
224  *this = copyMe;
225  }
226 
228 
229  SMD3QuaternionTag* get ( const core::stringc& name )
230  {
231  SMD3QuaternionTag search ( name );
232  s32 index = Container.linear_search ( search );
233  if ( index >= 0 )
234  return &Container[index];
235  return 0;
236  }
237 
238  u32 size () const
239  {
240  return Container.size();
241  }
242 
243  void set_used ( u32 new_size)
244  {
245  s32 diff = (s32) new_size - (s32) Container.allocated_size ();
246  if ( diff > 0 )
247  {
248  SMD3QuaternionTag e ( "" );
249  for ( s32 i = 0; i < diff; ++i )
250  Container.push_back ( e );
251  }
252  }
253 
254  const SMD3QuaternionTag& operator[](u32 index) const
255  {
256  return Container[index];
257  }
258 
260  {
261  return Container[index];
262  }
263 
264  void push_back ( const SMD3QuaternionTag& other )
265  {
266  Container.push_back ( other );
267  }
268 
270  {
271  Container = copyMe.Container;
272  return *this;
273  }
274 
275  private:
277  };
278 
279 
282  {
284  {
285  MD3Header.numFrames = 0;
286  }
287 
288  virtual ~SMD3Mesh()
289  {
290  for (u32 i=0; i<Buffer.size(); ++i)
291  Buffer[i]->drop();
292  }
293 
298  };
299 
300 
303  {
304  public:
305 
307  virtual void setInterpolationShift ( u32 shift, u32 loopMode ) = 0;
308 
310  virtual SMD3QuaternionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) = 0;
311 
313  virtual SMD3Mesh * getOriginalMesh () = 0;
314  };
315 
316 } // end namespace scene
317 } // end namespace irr
318 
319 #endif
320 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Tue Jun 5 2012 17:57:11 by Doxygen (1.8.1)