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
76
77
78// byte-align classes
79#include <duckcpp/core/engine/irrpack.hpp>
80
83 {
84 public:
85 dcpp::char_kt headerID[4]; //id of file, always "IDP3"
86 dcpp::int32_kt Version; //this is a version number, always 15
87 dcpp::int8_kt fileName[68];//sometimes left Blank... 65 chars, 32bit aligned == 68 chars
88 dcpp::int32_kt numFrames; //number of KeyFrames
89 dcpp::int32_kt numTags; //number of 'tags' per frame
90 dcpp::int32_kt numMeshes; //number of meshes/skins
91 dcpp::int32_kt numMaxSkins;//maximum number of unique skins used in md3 file. artefact md2
92 dcpp::int32_kt frameStart; //starting position of frame-structur
93 dcpp::int32_kt tagStart; //starting position of tag-classes
94 dcpp::int32_kt tagEnd; //ending position of tag-classes/starting position of mesh-classes
95 dcpp::int32_kt fileSize;
96 } PACK_CLASS;
97
100 {
101 public:
102 dcpp::char_kt meshID[4]; //id, must be IDP3
103 dcpp::char_kt meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars
104
105 dcpp::int32_kt numFrames; //number of meshframes in mesh
106 dcpp::int32_kt numShader; //number of skins in mesh
107 dcpp::int32_kt numVertices; //number of vertices
108 dcpp::int32_kt numTriangles; //number of Triangles
109
110 dcpp::int32_kt offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header
111 dcpp::int32_kt offset_shaders; //size of header
112 dcpp::int32_kt offset_st; //starting position of texvector data, relative to start of Mesh_Header
113 dcpp::int32_kt vertexStart; //starting position of vertex data,relative to start of Mesh_Header
114 dcpp::int32_kt offset_end;
115 } PACK_CLASS;
116
117
120 {
121 public:
122 dcpp::int16_kt position[3];
123 dcpp::uint8_kt normal[2];
124 } PACK_CLASS;
125
128 {
129 public:
132 } PACK_CLASS;
133
136 {
137 public:
138 dcpp::int32_kt 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 dcpp::nub::string Shader;
155 };
156
158
160 {
161 public:
162 // construct for searching
164 : Name ( name ) {}
165
166 // construct from a position and euler angles in degrees
168 : position(pos), rotation(angle * dcpp::nub::DEGTORAD) {}
169
170 // set to matrix
171 void setto ( dcpp::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
182 dcpp::nub::vector3df position;
183 dcpp::nub::quaternion rotation;
184 };
185
188 {
189 public:
191 {
192 Container.setAllocStrategy(dcpp::nub::ALLOC_STRATEGY_SAFE);
193 }
194
195 SMD3QuaternionTag* get(const dcpp::nub::string& name)
196 {
197 SMD3QuaternionTag search ( name );
198 const dcpp::int32_kt index = Container.linear_search ( search );
199 if ( index >= 0 )
200 return &Container[index];
201 return 0;
202 }
203
204 dcpp::uint32_kt size () const
205 {
206 return Container.size();
207 }
208
209 void set_used(dcpp::uint32_kt new_size)
210 {
211 const dcpp::int32_kt diff = (dcpp::int32_kt) new_size - (dcpp::int32_kt) Container.allocated_size();
212 if ( diff > 0 )
213 {
214 SMD3QuaternionTag e("");
215 for ( dcpp::int32_kt i = 0; i < diff; ++i )
216 Container.push_back(e);
217 }
218 }
219
220 const SMD3QuaternionTag& operator[](dcpp::uint32_kt index) const
221 {
222 return Container[index];
223 }
224
225 SMD3QuaternionTag& operator[](dcpp::uint32_kt 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 (dcpp::uint32_kt i=0; i<Buffer.size(); ++i)
252 Buffer[i]->drop();
253 }
254
257 SMD3QuaternionTagList TagList;
258 SMD3Header MD3Header;
259 };
260
261
264 {
265 public:
266
268 virtual void setInterpolationShift(dcpp::uint32_kt shift, dcpp::uint32_kt loopMode) =0;
269
271 virtual SMD3QuaternionTagList* getTagList(dcpp::int32_kt frame, dcpp::int32_kt detailLevel, dcpp::int32_kt startFrameLoop, dcpp::int32_kt 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
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
Interface for using some special functions of MD3 meshes.
Definition IAnimatedMeshMD3.hpp:264
virtual SMD3QuaternionTagList * getTagList(dcpp::int32_kt frame, dcpp::int32_kt detailLevel, dcpp::int32_kt startFrameLoop, dcpp::int32_kt endFrameLoop)=0
get the tag list of the mesh.
virtual SMD3Mesh * getOriginalMesh()=0
get the original md3 mesh.
virtual void setInterpolationShift(dcpp::uint32_kt shift, dcpp::uint32_kt 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
dcpp::int32_kt looping
Looping frames.
Definition IAnimatedMeshMD3.hpp:72
dcpp::int32_kt fps
Frames per second.
Definition IAnimatedMeshMD3.hpp:74
dcpp::int32_kt num
Last frame.
Definition IAnimatedMeshMD3.hpp:70
dcpp::int32_kt first
First frame.
Definition IAnimatedMeshMD3.hpp:68
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 dcpp::float32_kt 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 shared_device.hpp:34
signed char int8_kt
8 bit signed variable.
Definition irrTypes.hpp:32
char char_kt
8 bit character variable.
Definition irrTypes.hpp:37
unsigned char uint8_kt
8 bit unsigned variable.
Definition irrTypes.hpp:24
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72
signed short int16_kt
16 bit signed variable.
Definition irrTypes.hpp:54

Duckcpp    @cppfx.xyz