Duckcpp 2.1.0
Duckcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
IAnimatedMeshMD3.hpp
1// Copyright (C) 2007-2012 Nikolaus Gebhardt / Thomas Alten
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in duckcpp/duckcpp.hpp
4
5#ifndef DCPP_I_ANIMATED_MESH_MD3_HPP_INCLUDED
6#define DCPP_I_ANIMATED_MESH_MD3_HPP_INCLUDED
7
8#include <duckcpp/core/engine/IAnimatedMesh.hpp>
9#include <duckcpp/core/engine/IQ3Shader.hpp>
10#include <duckcpp/core/engine/quaternion.hpp>
11
12namespace dcpp
13{
14namespace scene
15{
16
17 enum eMD3Models
18 {
19 EMD3_HEAD = 0,
20 EMD3_UPPER,
21 EMD3_LOWER,
22 EMD3_WEAPON,
23 EMD3_NUMMODELS
24 };
25
28 {
29 // Animations for both lower and upper parts of the player
30 EMD3_BOTH_DEATH_1 = 0,
31 EMD3_BOTH_DEAD_1,
32 EMD3_BOTH_DEATH_2,
33 EMD3_BOTH_DEAD_2,
34 EMD3_BOTH_DEATH_3,
35 EMD3_BOTH_DEAD_3,
36
37 // Animations for the upper part
38 EMD3_TORSO_GESTURE,
39 EMD3_TORSO_ATTACK_1,
40 EMD3_TORSO_ATTACK_2,
41 EMD3_TORSO_DROP,
42 EMD3_TORSO_RAISE,
43 EMD3_TORSO_STAND_1,
44 EMD3_TORSO_STAND_2,
45
46 // Animations for the lower part
47 EMD3_LEGS_WALK_CROUCH,
48 EMD3_LEGS_WALK,
49 EMD3_LEGS_RUN,
50 EMD3_LEGS_BACK,
51 EMD3_LEGS_SWIM,
52 EMD3_LEGS_JUMP_1,
53 EMD3_LEGS_LAND_1,
54 EMD3_LEGS_JUMP_2,
55 EMD3_LEGS_LAND_2,
56 EMD3_LEGS_IDLE,
57 EMD3_LEGS_IDLE_CROUCH,
58 EMD3_LEGS_TURN,
59
62 };
63
65 {
66 public:
75 };
76
77
78// byte-align classes
79#include <duckcpp/core/engine/irrpack.hpp>
80
83 {
84 public:
85 c8 headerID[4]; //id of file, always "IDP3"
86 i32 Version; //this is a version number, always 15
87 i8 fileName[68];//sometimes left Blank... 65 chars, 32bit aligned == 68 chars
88 i32 numFrames; //number of KeyFrames
89 i32 numTags; //number of 'tags' per frame
90 i32 numMeshes; //number of meshes/skins
91 i32 numMaxSkins;//maximum number of unique skins used in md3 file. artefact md2
92 i32 frameStart; //starting position of frame-structur
93 i32 tagStart; //starting position of tag-classes
94 i32 tagEnd; //ending position of tag-classes/starting position of mesh-classes
95 i32 fileSize;
96 } PACK_CLASS;
97
100 {
101 public:
102 c8 meshID[4]; //id, must be IDP3
103 c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars
104
105 i32 numFrames; //number of meshframes in mesh
106 i32 numShader; //number of skins in mesh
107 i32 numVertices; //number of vertices
108 i32 numTriangles; //number of Triangles
109
110 i32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header
111 i32 offset_shaders; //size of header
112 i32 offset_st; //starting position of texvector data, relative to start of Mesh_Header
113 i32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header
114 i32 offset_end;
115 } PACK_CLASS;
116
117
120 {
121 public:
122 i16 position[3];
123 u8 normal[2];
124 } PACK_CLASS;
125
128 {
129 public:
130 f32 u;
131 f32 v;
132 } PACK_CLASS;
133
136 {
137 public:
138 i32 Index[3];
139 } PACK_CLASS;
140
141
142// Default alignment
143#include <duckcpp/core/engine/irrunpack.hpp>
144
147 {
148 public:
149 SMD3MeshHeader MeshHeader;
150
151 nub::string Shader;
152 nub::array < i32 > Indices;
155 };
156
158
160 {
161 public:
162 // construct for searching
163 SMD3QuaternionTag( const nub::string& name )
164 : Name ( name ) {}
165
166 // construct from a position and euler angles in degrees
167 SMD3QuaternionTag ( const nub::vector3df &pos, const nub::vector3df &angle )
168 : position(pos), rotation(angle * nub::DEGTORAD) {}
169
170 // set to matrix
171 void setto ( nub::matrix4 &m )
172 {
173 rotation.getMatrix ( m, position );
174 }
175
176 bool operator == ( const SMD3QuaternionTag &other ) const
177 {
178 return Name == other.Name;
179 }
180
181 nub::string Name;
182 nub::vector3df position;
183 nub::quaternion rotation;
184 };
185
188 {
189 public:
191 {
192 Container.setAllocStrategy(nub::ALLOC_STRATEGY_SAFE);
193 }
194
195 SMD3QuaternionTag* get(const nub::string& name)
196 {
197 SMD3QuaternionTag search ( name );
198 const i32 index = Container.linear_search ( search );
199 if ( index >= 0 )
200 return &Container[index];
201 return 0;
202 }
203
204 u32 size () const
205 {
206 return Container.size();
207 }
208
209 void set_used(u32 new_size)
210 {
211 const i32 diff = (i32) new_size - (i32) Container.allocated_size();
212 if ( diff > 0 )
213 {
214 SMD3QuaternionTag e("");
215 for ( i32 i = 0; i < diff; ++i )
216 Container.push_back(e);
217 }
218 }
219
220 const SMD3QuaternionTag& operator[](u32 index) const
221 {
222 return Container[index];
223 }
224
225 SMD3QuaternionTag& operator[](u32 index)
226 {
227 return Container[index];
228 }
229
230 void push_back(const SMD3QuaternionTag& other)
231 {
232 Container.push_back(other);
233 }
234
235 private:
237 };
238
239
242 {
243 public:
244 SMD3Mesh ()
245 {
246 MD3Header.numFrames = 0;
247 }
248
249 virtual ~SMD3Mesh()
250 {
251 for (u32 i=0; i<Buffer.size(); ++i)
252 Buffer[i]->drop();
253 }
254
255 nub::string Name;
257 SMD3QuaternionTagList TagList;
258 SMD3Header MD3Header;
259 };
260
261
264 {
265 public:
266
268 virtual void setInterpolationShift(u32 shift, u32 loopMode) =0;
269
271 virtual SMD3QuaternionTagList* getTagList(i32 frame, i32 detailLevel, i32 startFrameLoop, i32 endFrameLoop) =0;
272
275 };
276
277} // end namespace scene
278} // end namespace dcpp
279
280#endif
Base class of most objects of the Duckcpp Engine.
Definition IReferenceCounted.hpp:46
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.hpp:126
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Quaternion class for representing rotations.
Definition quaternion.hpp:32
matrix4 getMatrix() const
Creates a matrix from this quaternion.
Definition quaternion.hpp:348
Interface for using some special functions of MD3 meshes.
Definition IAnimatedMeshMD3.hpp:264
virtual SMD3QuaternionTagList * getTagList(i32 frame, i32 detailLevel, i32 startFrameLoop, i32 endFrameLoop)=0
get the tag list of the mesh.
virtual SMD3Mesh * getOriginalMesh()=0
get the original md3 mesh.
virtual void setInterpolationShift(u32 shift, u32 loopMode)=0
tune how many frames you want to render in between.
Interface for an animated mesh.
Definition IAnimatedMesh.hpp:21
Definition IAnimatedMeshMD3.hpp:65
i32 first
First frame.
Definition IAnimatedMeshMD3.hpp:68
i32 looping
Looping frames.
Definition IAnimatedMeshMD3.hpp:72
i32 fps
Frames per second.
Definition IAnimatedMeshMD3.hpp:74
i32 num
Last frame.
Definition IAnimatedMeshMD3.hpp:70
Triangle Index.
Definition IAnimatedMeshMD3.hpp:136
this holds the header info of the MD3 file
Definition IAnimatedMeshMD3.hpp:83
Holding Frame Data for a Mesh.
Definition IAnimatedMeshMD3.hpp:147
this holds the header info of an MD3 mesh section
Definition IAnimatedMeshMD3.hpp:100
Holding Frames Buffers and Tag Infos.
Definition IAnimatedMeshMD3.hpp:242
holds a associative list of named quaternions
Definition IAnimatedMeshMD3.hpp:188
hold a tag info for connecting meshes
Definition IAnimatedMeshMD3.hpp:160
Texture Coordinate.
Definition IAnimatedMeshMD3.hpp:128
Compressed Vertex Data.
Definition IAnimatedMeshMD3.hpp:120
const f32 DEGTORAD
32bit Constant for converting from degrees to radians
Definition irrMath.hpp:72
EMD3_ANIMATION_TYPE
Animation list.
Definition IAnimatedMeshMD3.hpp:28
@ EMD3_ANIMATION_COUNT
Not an animation, but amount of animation types.
Definition IAnimatedMeshMD3.hpp:61
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
char c8
8 bit character variable.
Definition irrTypes.hpp:37
signed short i16
16 bit signed variable.
Definition irrTypes.hpp:54
signed int i32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.hpp:24
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
signed char i8
8 bit signed variable.
Definition irrTypes.hpp:32

Duckcpp    @cppfx.xyz