1 #ifndef __QF_iqm_h__ 2 #define __QF_iqm_h__ 3 4 #include "QF/qtypes.h" 5 6 #define IQM_MAGIC "INTERQUAKEMODEL" 7 #define IQM_SMAGIC 0x45544e49 8 #define IQM_VERSION 2 9 10 typedef struct iqmheader_s { 11 char magic[16]; 12 uint32_t version; 13 uint32_t filesize; 14 uint32_t flags; 15 uint32_t num_text, ofs_text; 16 uint32_t num_meshes, ofs_meshes; 17 uint32_t num_vertexarrays, num_vertexes, ofs_vertexarrays; 18 uint32_t num_triangles, ofs_triangles, ofs_adjacency; 19 uint32_t num_joints, ofs_joints; 20 uint32_t num_poses, ofs_poses; 21 uint32_t num_anims, ofs_anims; 22 uint32_t num_frames, num_framechannels, ofs_frames, ofs_bounds; 23 uint32_t num_comment, ofs_comment; 24 uint32_t num_extensions, ofs_extensions; 25 } iqmheader; 26 27 typedef struct iqmmesh_s { 28 uint32_t name; 29 uint32_t material; 30 uint32_t first_vertex, num_vertexes; 31 uint32_t first_triangle, num_triangles; 32 } iqmmesh; 33 34 enum { 35 IQM_POSITION = 0, 36 IQM_TEXCOORD = 1, 37 IQM_NORMAL = 2, 38 IQM_TANGENT = 3, 39 IQM_BLENDINDEXES = 4, 40 IQM_BLENDWEIGHTS = 5, 41 IQM_COLOR = 6, 42 IQM_CUSTOM = 0x10 43 }; 44 45 enum { 46 IQM_BYTE = 0, 47 IQM_UBYTE = 1, 48 IQM_SHORT = 2, 49 IQM_USHORT = 3, 50 IQM_INT = 4, 51 IQM_UINT = 5, 52 IQM_HALF = 6, 53 IQM_FLOAT = 7, 54 IQM_DOUBLE = 8 55 }; 56 57 typedef struct iqmtriangle_s { 58 uint32_t vertex[3]; 59 } iqmtriangle; 60 61 typedef struct iqmjointv1_s { 62 uint32_t name; 63 int32_t parent; 64 float translate[3], rotate[3], scale[3]; 65 } iqmjointv1; 66 67 typedef struct iqmjoint_s { 68 uint32_t name; 69 int32_t parent; 70 float translate[3], rotate[4], scale[3]; 71 } iqmjoint; 72 73 typedef struct iqmposev1_s { 74 int32_t parent; 75 uint32_t mask; 76 float channeloffset[9]; 77 float channelscale[9]; 78 } iqmposev1; 79 80 typedef struct iqmpose_s { 81 int32_t parent; 82 uint32_t mask; 83 float channeloffset[10]; 84 float channelscale[10]; 85 } iqmpose; 86 87 typedef struct iqmanim_s { 88 uint32_t name; 89 uint32_t first_frame, num_frames; 90 float framerate; 91 uint32_t flags; 92 } iqmanim; 93 94 enum { 95 IQM_LOOP = 1<<0 96 }; 97 98 typedef struct iqmvertexarray_s { 99 uint32_t type; 100 uint32_t flags; 101 uint32_t format; 102 uint32_t size; 103 uint32_t offset; 104 } iqmvertexarray; 105 106 typedef struct iqmbounds_s { 107 float bbmin[3], bbmax[3]; 108 float xyradius, radius; 109 } iqmbounds; 110 111 typedef struct iqmextension_s { 112 uint32_t name; 113 uint32_t num_data, ofs_data; 114 uint32_t ofs_extensions; // pointer to next extension 115 } iqmextension; 116 117 // QF stuff 118 119 typedef struct { 120 DualQuat_t rt; 121 quat_t shear; 122 quat_t scale; 123 } iqmframe_t; 124 125 typedef struct { 126 byte indices[4]; 127 byte weights[4]; 128 } iqmblend_t; 129 130 typedef struct { 131 char *text; 132 int num_meshes; 133 iqmmesh *meshes; 134 int num_verts; 135 byte *vertices; 136 int stride; 137 int num_elements; 138 uint16_t *elements; 139 int num_arrays; 140 iqmvertexarray *vertexarrays; 141 int num_joints; 142 iqmjoint *joints; 143 mat4_t *baseframe; 144 mat4_t *inverse_baseframe; 145 int num_frames; 146 iqmframe_t **frames; 147 int num_anims; 148 iqmanim *anims; 149 void *extra_data; 150 } iqm_t; 151 152 #endif//__QF_iqm_h__ 153