Loading...
Searching...
No Matches
IAnimatedMeshMD3.h
Go to the documentation of this file.
// Copyright (C) 2007-2012 Nikolaus Gebhardt / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_MD3_H_INCLUDED__
#define __I_ANIMATED_MESH_MD3_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "IQ3Shader.h"
#include "quaternion.h"
namespace irr
{
namespace scene
{
enum eMD3Models
{
EMD3_HEAD = 0,
EMD3_UPPER,
EMD3_LOWER,
EMD3_WEAPON,
EMD3_NUMMODELS
};
enum EMD3_ANIMATION_TYPE
{
// Animations for both lower and upper parts of the player
EMD3_BOTH_DEATH_1 = 0,
EMD3_BOTH_DEAD_1,
EMD3_BOTH_DEATH_2,
EMD3_BOTH_DEAD_2,
EMD3_BOTH_DEATH_3,
EMD3_BOTH_DEAD_3,
// Animations for the upper part
EMD3_TORSO_GESTURE,
EMD3_TORSO_ATTACK_1,
EMD3_TORSO_ATTACK_2,
EMD3_TORSO_DROP,
EMD3_TORSO_RAISE,
EMD3_TORSO_STAND_1,
EMD3_TORSO_STAND_2,
// Animations for the lower part
EMD3_LEGS_WALK_CROUCH,
EMD3_LEGS_WALK,
EMD3_LEGS_RUN,
EMD3_LEGS_BACK,
EMD3_LEGS_SWIM,
EMD3_LEGS_JUMP_1,
EMD3_LEGS_LAND_1,
EMD3_LEGS_JUMP_2,
EMD3_LEGS_LAND_2,
EMD3_LEGS_IDLE,
EMD3_LEGS_IDLE_CROUCH,
EMD3_LEGS_TURN,
EMD3_ANIMATION_COUNT
};
struct SMD3AnimationInfo
{
s32 first;
s32 num;
s32 looping;
s32 fps;
};
// byte-align structures
#include "irrpack.h"
struct SMD3Header
{
c8 headerID[4]; //id of file, always "IDP3"
s32 Version; //this is a version number, always 15
s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars
s32 numFrames; //number of KeyFrames
s32 numTags; //number of 'tags' per frame
s32 numMeshes; //number of meshes/skins
s32 numMaxSkins; //maximum number of unique skins used in md3 file. artefact md2
s32 frameStart; //starting position of frame-structur
s32 tagStart; //starting position of tag-structures
s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures
s32 fileSize;
} PACK_STRUCT;
struct SMD3MeshHeader
{
c8 meshID[4]; //id, must be IDP3
c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars
s32 numFrames; //number of meshframes in mesh
s32 numShader; //number of skins in mesh
s32 numVertices; //number of vertices
s32 numTriangles; //number of Triangles
s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header
s32 offset_shaders; //size of header
s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header
s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header
s32 offset_end;
} PACK_STRUCT;
struct SMD3Vertex
{
s16 position[3];
u8 normal[2];
} PACK_STRUCT;
struct SMD3TexCoord
{
f32 u;
f32 v;
} PACK_STRUCT;
struct SMD3Face
{
s32 Index[3];
} PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
struct SMD3MeshBuffer : public IReferenceCounted
{
SMD3MeshHeader MeshHeader;
core::stringc Shader;
core::array < s32 > Indices;
core::array < SMD3Vertex > Vertices;
core::array < SMD3TexCoord > Tex;
};
struct SMD3QuaternionTag
{
virtual ~SMD3QuaternionTag()
{
position.X = 0.f;
}
// construct copy constructor
SMD3QuaternionTag( const SMD3QuaternionTag & copyMe )
{
*this = copyMe;
}
// construct for searching
SMD3QuaternionTag( const core::stringc& name )
: Name ( name ) {}
// construct from a position and euler angles in degrees
SMD3QuaternionTag ( const core::vector3df &pos, const core::vector3df &angle )
: position(pos), rotation(angle * core::DEGTORAD) {}
// set to matrix
void setto ( core::matrix4 &m )
{
rotation.getMatrix ( m, position );
}
bool operator == ( const SMD3QuaternionTag &other ) const
{
return Name == other.Name;
}
SMD3QuaternionTag & operator=( const SMD3QuaternionTag & copyMe )
{
Name = copyMe.Name;
position = copyMe.position;
rotation = copyMe.rotation;
return *this;
}
core::stringc Name;
core::vector3df position;
core::quaternion rotation;
};
struct SMD3QuaternionTagList
{
SMD3QuaternionTagList()
{
Container.setAllocStrategy(core::ALLOC_STRATEGY_SAFE);
}
// construct copy constructor
SMD3QuaternionTagList(const SMD3QuaternionTagList& copyMe)
{
*this = copyMe;
}
virtual ~SMD3QuaternionTagList() {}
SMD3QuaternionTag* get(const core::stringc& name)
{
SMD3QuaternionTag search ( name );
s32 index = Container.linear_search ( search );
if ( index >= 0 )
return &Container[index];
return 0;
}
u32 size () const
{
return Container.size();
}
void set_used(u32 new_size)
{
s32 diff = (s32) new_size - (s32) Container.allocated_size();
if ( diff > 0 )
{
SMD3QuaternionTag e("");
for ( s32 i = 0; i < diff; ++i )
Container.push_back(e);
}
}
const SMD3QuaternionTag& operator[](u32 index) const
{
return Container[index];
}
SMD3QuaternionTag& operator[](u32 index)
{
return Container[index];
}
void push_back(const SMD3QuaternionTag& other)
{
Container.push_back(other);
}
SMD3QuaternionTagList& operator = (const SMD3QuaternionTagList & copyMe)
{
Container = copyMe.Container;
return *this;
}
private:
core::array < SMD3QuaternionTag > Container;
};
struct SMD3Mesh: public IReferenceCounted
{
SMD3Mesh ()
{
MD3Header.numFrames = 0;
}
virtual ~SMD3Mesh()
{
for (u32 i=0; i<Buffer.size(); ++i)
Buffer[i]->drop();
}
core::stringc Name;
core::array<SMD3MeshBuffer*> Buffer;
SMD3QuaternionTagList TagList;
SMD3Header MD3Header;
};
class IAnimatedMeshMD3 : public IAnimatedMesh
{
public:
virtual void setInterpolationShift(u32 shift, u32 loopMode) =0;
virtual SMD3QuaternionTagList* getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) =0;
virtual SMD3Mesh* getOriginalMesh() =0;
};
} // end namespace scene
} // end namespace irr
#endif
IAnimatedMesh.h
IQ3Shader.h
irr::IReferenceCounted::drop
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.h:116
irr::IReferenceCounted::IReferenceCounted
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:46
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
irr::core::quaternion
Quaternion class for representing rotations.
Definition quaternion.h:27
irr::scene::IAnimatedMesh
Interface for an animated mesh.
Definition IAnimatedMesh.h:63
irr::scene::IAnimatedMeshMD3
Interface for using some special functions of MD3 meshes.
Definition IAnimatedMeshMD3.h:287
irr::scene::IAnimatedMeshMD3::getOriginalMesh
virtual SMD3Mesh * getOriginalMesh()=0
get the original md3 mesh.
irr::scene::IAnimatedMeshMD3::setInterpolationShift
virtual void setInterpolationShift(u32 shift, u32 loopMode)=0
tune how many frames you want to render inbetween.
irr::scene::IAnimatedMeshMD3::getTagList
virtual SMD3QuaternionTagList * getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop)=0
get the tag list of the mesh.
irrpack.h
irrunpack.h
irr::core
Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
Definition aabbox3d.h:15
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::core::ALLOC_STRATEGY_SAFE
@ ALLOC_STRATEGY_SAFE
Definition irrAllocator.h:114
irr::core::stringc
string< c8 > stringc
Typedef for character strings.
Definition irrString.h:1358
irr::scene
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CDynamicMeshBuffer.h:16
irr::scene::PACK_STRUCT
struct irr::scene::SMD3Header PACK_STRUCT
irr::scene::EMD3_ANIMATION_TYPE
EMD3_ANIMATION_TYPE
Animation list.
Definition IAnimatedMeshMD3.h:28
irr::scene::EMD3_BOTH_DEAD_3
@ EMD3_BOTH_DEAD_3
Definition IAnimatedMeshMD3.h:35
irr::scene::EMD3_ANIMATION_COUNT
@ EMD3_ANIMATION_COUNT
Not an animation, but amount of animation types.
Definition IAnimatedMeshMD3.h:61
irr::scene::EMD3_TORSO_ATTACK_1
@ EMD3_TORSO_ATTACK_1
Definition IAnimatedMeshMD3.h:39
irr::scene::EMD3_BOTH_DEAD_2
@ EMD3_BOTH_DEAD_2
Definition IAnimatedMeshMD3.h:33
irr::scene::EMD3_LEGS_IDLE_CROUCH
@ EMD3_LEGS_IDLE_CROUCH
Definition IAnimatedMeshMD3.h:57
irr::scene::EMD3_LEGS_WALK
@ EMD3_LEGS_WALK
Definition IAnimatedMeshMD3.h:48
irr::scene::EMD3_BOTH_DEAD_1
@ EMD3_BOTH_DEAD_1
Definition IAnimatedMeshMD3.h:31
irr::scene::EMD3_TORSO_DROP
@ EMD3_TORSO_DROP
Definition IAnimatedMeshMD3.h:41
irr::scene::EMD3_LEGS_JUMP_2
@ EMD3_LEGS_JUMP_2
Definition IAnimatedMeshMD3.h:54
irr::scene::EMD3_LEGS_LAND_1
@ EMD3_LEGS_LAND_1
Definition IAnimatedMeshMD3.h:53
irr::scene::EMD3_LEGS_LAND_2
@ EMD3_LEGS_LAND_2
Definition IAnimatedMeshMD3.h:55
irr::scene::EMD3_LEGS_RUN
@ EMD3_LEGS_RUN
Definition IAnimatedMeshMD3.h:49
irr::scene::EMD3_LEGS_BACK
@ EMD3_LEGS_BACK
Definition IAnimatedMeshMD3.h:50
irr::scene::EMD3_LEGS_IDLE
@ EMD3_LEGS_IDLE
Definition IAnimatedMeshMD3.h:56
irr::scene::EMD3_LEGS_JUMP_1
@ EMD3_LEGS_JUMP_1
Definition IAnimatedMeshMD3.h:52
irr::scene::EMD3_BOTH_DEATH_3
@ EMD3_BOTH_DEATH_3
Definition IAnimatedMeshMD3.h:34
irr::scene::EMD3_BOTH_DEATH_2
@ EMD3_BOTH_DEATH_2
Definition IAnimatedMeshMD3.h:32
irr::scene::EMD3_LEGS_SWIM
@ EMD3_LEGS_SWIM
Definition IAnimatedMeshMD3.h:51
irr::scene::EMD3_LEGS_WALK_CROUCH
@ EMD3_LEGS_WALK_CROUCH
Definition IAnimatedMeshMD3.h:47
irr::scene::EMD3_TORSO_STAND_1
@ EMD3_TORSO_STAND_1
Definition IAnimatedMeshMD3.h:43
irr::scene::EMD3_TORSO_RAISE
@ EMD3_TORSO_RAISE
Definition IAnimatedMeshMD3.h:42
irr::scene::EMD3_TORSO_STAND_2
@ EMD3_TORSO_STAND_2
Definition IAnimatedMeshMD3.h:44
irr::scene::EMD3_LEGS_TURN
@ EMD3_LEGS_TURN
Definition IAnimatedMeshMD3.h:58
irr::scene::EMD3_TORSO_ATTACK_2
@ EMD3_TORSO_ATTACK_2
Definition IAnimatedMeshMD3.h:40
irr::scene::EMD3_BOTH_DEATH_1
@ EMD3_BOTH_DEATH_1
Definition IAnimatedMeshMD3.h:30
irr::scene::EMD3_TORSO_GESTURE
@ EMD3_TORSO_GESTURE
Definition IAnimatedMeshMD3.h:38
irr::scene::eMD3Models
eMD3Models
Definition IAnimatedMeshMD3.h:18
irr::scene::EMD3_NUMMODELS
@ EMD3_NUMMODELS
Definition IAnimatedMeshMD3.h:23
irr::scene::EMD3_WEAPON
@ EMD3_WEAPON
Definition IAnimatedMeshMD3.h:22
irr::scene::EMD3_HEAD
@ EMD3_HEAD
Definition IAnimatedMeshMD3.h:19
irr::scene::EMD3_UPPER
@ EMD3_UPPER
Definition IAnimatedMeshMD3.h:20
irr::scene::EMD3_LOWER
@ EMD3_LOWER
Definition IAnimatedMeshMD3.h:21
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::f32
float f32
32 bit floating point variable.
Definition irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::s16
signed short s16
16 bit signed variable.
Definition irrTypes.h:48
irr::u8
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
irr::c8
char c8
8 bit character variable.
Definition irrTypes.h:31
irr::s32
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
irr::s8
signed char s8
8 bit signed variable.
Definition irrTypes.h:26
quaternion.h
irr::scene::SMD3AnimationInfo
Definition IAnimatedMeshMD3.h:65
irr::scene::SMD3AnimationInfo::first
s32 first
First frame.
Definition IAnimatedMeshMD3.h:67
irr::scene::SMD3AnimationInfo::fps
s32 fps
Frames per second.
Definition IAnimatedMeshMD3.h:73
irr::scene::SMD3AnimationInfo::num
s32 num
Last frame.
Definition IAnimatedMeshMD3.h:69
irr::scene::SMD3AnimationInfo::looping
s32 looping
Looping frames.
Definition IAnimatedMeshMD3.h:71
irr::scene::SMD3Face
Triangle Index.
Definition IAnimatedMeshMD3.h:131
irr::scene::SMD3Face::Index
s32 Index[3]
Definition IAnimatedMeshMD3.h:132
irr::scene::SMD3Header
this holds the header info of the MD3 file
Definition IAnimatedMeshMD3.h:82
irr::scene::SMD3Header::numFrames
s32 numFrames
Definition IAnimatedMeshMD3.h:86
irr::scene::SMD3Header::tagEnd
s32 tagEnd
Definition IAnimatedMeshMD3.h:92
irr::scene::SMD3Header::numTags
s32 numTags
Definition IAnimatedMeshMD3.h:87
irr::scene::SMD3Header::frameStart
s32 frameStart
Definition IAnimatedMeshMD3.h:90
irr::scene::SMD3Header::numMeshes
s32 numMeshes
Definition IAnimatedMeshMD3.h:88
irr::scene::SMD3Header::Version
s32 Version
Definition IAnimatedMeshMD3.h:84
irr::scene::SMD3Header::numMaxSkins
s32 numMaxSkins
Definition IAnimatedMeshMD3.h:89
irr::scene::SMD3Header::tagStart
s32 tagStart
Definition IAnimatedMeshMD3.h:91
irr::scene::SMD3Header::fileName
s8 fileName[68]
Definition IAnimatedMeshMD3.h:85
irr::scene::SMD3Header::headerID
c8 headerID[4]
Definition IAnimatedMeshMD3.h:83
irr::scene::SMD3Header::fileSize
s32 fileSize
Definition IAnimatedMeshMD3.h:93
irr::scene::SMD3MeshBuffer
Holding Frame Data for a Mesh.
Definition IAnimatedMeshMD3.h:141
irr::scene::SMD3MeshBuffer::Vertices
core::array< SMD3Vertex > Vertices
Definition IAnimatedMeshMD3.h:146
irr::scene::SMD3MeshBuffer::Shader
core::stringc Shader
Definition IAnimatedMeshMD3.h:144
irr::scene::SMD3MeshBuffer::Indices
core::array< s32 > Indices
Definition IAnimatedMeshMD3.h:145
irr::scene::SMD3MeshBuffer::Tex
core::array< SMD3TexCoord > Tex
Definition IAnimatedMeshMD3.h:147
irr::scene::SMD3MeshBuffer::MeshHeader
SMD3MeshHeader MeshHeader
Definition IAnimatedMeshMD3.h:142
irr::scene::SMD3MeshHeader
this holds the header info of an MD3 mesh section
Definition IAnimatedMeshMD3.h:98
irr::scene::SMD3MeshHeader::numFrames
s32 numFrames
Definition IAnimatedMeshMD3.h:102
irr::scene::SMD3MeshHeader::meshID
c8 meshID[4]
Definition IAnimatedMeshMD3.h:99
irr::scene::SMD3MeshHeader::numVertices
s32 numVertices
Definition IAnimatedMeshMD3.h:104
irr::scene::SMD3MeshHeader::numTriangles
s32 numTriangles
Definition IAnimatedMeshMD3.h:105
irr::scene::SMD3MeshHeader::offset_st
s32 offset_st
Definition IAnimatedMeshMD3.h:109
irr::scene::SMD3MeshHeader::offset_triangles
s32 offset_triangles
Definition IAnimatedMeshMD3.h:107
irr::scene::SMD3MeshHeader::meshName
c8 meshName[68]
Definition IAnimatedMeshMD3.h:100
irr::scene::SMD3MeshHeader::offset_end
s32 offset_end
Definition IAnimatedMeshMD3.h:111
irr::scene::SMD3MeshHeader::numShader
s32 numShader
Definition IAnimatedMeshMD3.h:103
irr::scene::SMD3MeshHeader::offset_shaders
s32 offset_shaders
Definition IAnimatedMeshMD3.h:108
irr::scene::SMD3MeshHeader::vertexStart
s32 vertexStart
Definition IAnimatedMeshMD3.h:110
irr::scene::SMD3Mesh
Holding Frames Buffers and Tag Infos.
Definition IAnimatedMeshMD3.h:266
irr::scene::SMD3Mesh::Name
core::stringc Name
Definition IAnimatedMeshMD3.h:278
irr::scene::SMD3Mesh::MD3Header
SMD3Header MD3Header
Definition IAnimatedMeshMD3.h:281
irr::scene::SMD3Mesh::~SMD3Mesh
virtual ~SMD3Mesh()
Definition IAnimatedMeshMD3.h:272
irr::scene::SMD3Mesh::Buffer
core::array< SMD3MeshBuffer * > Buffer
Definition IAnimatedMeshMD3.h:279
irr::scene::SMD3Mesh::SMD3Mesh
SMD3Mesh()
Definition IAnimatedMeshMD3.h:267
irr::scene::SMD3Mesh::TagList
SMD3QuaternionTagList TagList
Definition IAnimatedMeshMD3.h:280
irr::scene::SMD3QuaternionTag
hold a tag info for connecting meshes
Definition IAnimatedMeshMD3.h:153
irr::scene::SMD3QuaternionTag::Name
core::stringc Name
Definition IAnimatedMeshMD3.h:192
irr::scene::SMD3QuaternionTag::~SMD3QuaternionTag
virtual ~SMD3QuaternionTag()
Definition IAnimatedMeshMD3.h:154
irr::scene::SMD3QuaternionTag::SMD3QuaternionTag
SMD3QuaternionTag(const core::stringc &name)
Definition IAnimatedMeshMD3.h:166
irr::scene::SMD3QuaternionTag::setto
void setto(core::matrix4 &m)
Definition IAnimatedMeshMD3.h:174
irr::scene::SMD3QuaternionTag::operator=
SMD3QuaternionTag & operator=(const SMD3QuaternionTag &copyMe)
Definition IAnimatedMeshMD3.h:184
irr::scene::SMD3QuaternionTag::position
core::vector3df position
Definition IAnimatedMeshMD3.h:193
irr::scene::SMD3QuaternionTag::operator==
bool operator==(const SMD3QuaternionTag &other) const
Definition IAnimatedMeshMD3.h:179
irr::scene::SMD3QuaternionTag::SMD3QuaternionTag
SMD3QuaternionTag(const core::vector3df &pos, const core::vector3df &angle)
Definition IAnimatedMeshMD3.h:170
irr::scene::SMD3QuaternionTag::rotation
core::quaternion rotation
Definition IAnimatedMeshMD3.h:194
irr::scene::SMD3QuaternionTag::SMD3QuaternionTag
SMD3QuaternionTag(const SMD3QuaternionTag &copyMe)
Definition IAnimatedMeshMD3.h:160
irr::scene::SMD3QuaternionTagList
holds a associative list of named quaternions
Definition IAnimatedMeshMD3.h:199
irr::scene::SMD3QuaternionTagList::get
SMD3QuaternionTag * get(const core::stringc &name)
Definition IAnimatedMeshMD3.h:213
irr::scene::SMD3QuaternionTagList::SMD3QuaternionTagList
SMD3QuaternionTagList()
Definition IAnimatedMeshMD3.h:200
irr::scene::SMD3QuaternionTagList::~SMD3QuaternionTagList
virtual ~SMD3QuaternionTagList()
Definition IAnimatedMeshMD3.h:211
irr::scene::SMD3QuaternionTagList::operator[]
const SMD3QuaternionTag & operator[](u32 index) const
Definition IAnimatedMeshMD3.h:238
irr::scene::SMD3QuaternionTagList::operator[]
SMD3QuaternionTag & operator[](u32 index)
Definition IAnimatedMeshMD3.h:243
irr::scene::SMD3QuaternionTagList::operator=
SMD3QuaternionTagList & operator=(const SMD3QuaternionTagList &copyMe)
Definition IAnimatedMeshMD3.h:253
irr::scene::SMD3QuaternionTagList::size
u32 size() const
Definition IAnimatedMeshMD3.h:222
irr::scene::SMD3QuaternionTagList::set_used
void set_used(u32 new_size)
Definition IAnimatedMeshMD3.h:227
irr::scene::SMD3QuaternionTagList::SMD3QuaternionTagList
SMD3QuaternionTagList(const SMD3QuaternionTagList &copyMe)
Definition IAnimatedMeshMD3.h:206
irr::scene::SMD3QuaternionTagList::push_back
void push_back(const SMD3QuaternionTag &other)
Definition IAnimatedMeshMD3.h:248
irr::scene::SMD3TexCoord
Texture Coordinate.
Definition IAnimatedMeshMD3.h:124
irr::scene::SMD3TexCoord::v
f32 v
Definition IAnimatedMeshMD3.h:126
irr::scene::SMD3TexCoord::u
f32 u
Definition IAnimatedMeshMD3.h:125
irr::scene::SMD3Vertex
Compressed Vertex Data.
Definition IAnimatedMeshMD3.h:117
irr::scene::SMD3Vertex::position
s16 position[3]
Definition IAnimatedMeshMD3.h:118
irr::scene::SMD3Vertex::normal
u8 normal[2]
Definition IAnimatedMeshMD3.h:119
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0