DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
model_hlmdl.h
Go to the documentation of this file.
1/*
2Copyright (C) 2021 David Knapp (Cloudwalk)
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20
21#ifndef MODEL_HLMDL_H
22#define MODEL_HLMDL_H
23
24#include "qtypes.h"
25#include "qdefs.h"
26
27/*
28 * The Half-Life MDL format is Valve's format for models in GoldSrc engine.
29 *
30 * These headers were added based on information found at
31 * https://github.com/malortie/assimp/wiki/MDL:-Half-Life-1-file-format
32 */
33
34#define HLPOLYHEADER (('T' << 24) + ('S' << 16) + ('D' << 8) + 'I')
35#define HLMDLHEADER "IDST"
36#define HLSEQHEADER "IDSQ"
37
38// Flags
39#define HLMDLFLAG_FLAT 0x1
40#define HLMDLFLAG_CHROME 0x2
41#define HLMDLFLAG_FULLBRIGHT 0x4
42
43// Header
44typedef struct dhlmdl_header_s
45{
46 int32_t id; // Should be IDST
47 int32_t version; // Should be 10
48 int8_t name[64];
49 int32_t filesize;
52 vec3_t bbmin, bbmax;
53 int32_t flags;
54
55 int32_t num_bones;
56 int32_t ofs_bones;
57
60
61 int32_t num_hitboxes;
62 int32_t ofs_hitboxes;
63
64 int32_t num_seq;
65 int32_t ofs_seq;
66
69
70 int32_t num_textures;
71 int32_t ofs_textures;
73
74 int32_t num_skins;
76 int32_t ofs_skins;
77
80
83
84 int32_t soundtable;
85 int32_t soundindex;
86
89
93
94typedef struct dhlmdl_sequence_header_s
95{
96 int32_t id; // Should be IDSQ
97 int32_t version; // Should be 10
98 int8_t name[64];
99 int32_t size;
101
102typedef struct dhlmdl_texture_s
103{
104 int8_t name[64];
105 int32_t flags;
106 int32_t w, h;
107 int32_t ofs;
109
110typedef struct dhlmdl_bone_s
111{
112 int8_t name[32];
113 int32_t parent;
114 int32_t flags;
115 int32_t bonecontroller[6];
116 float value[6];
117 float scale[6];
119
120typedef struct dhlmdl_bone_controller_s
121{
122 int32_t bone;
123 int32_t type;
124 float start;
125 float end;
126 int32_t rest;
127 int32_t index;
129
130typedef struct dhlmdl_hitbox_s
131{
132 int32_t bone;
133 int32_t group;
134 vec3_t bbmin, bbmax;
136
137typedef struct dhlmdl_sequence_group_s
138{
139 int8_t label[32];
140 int8_t name[64];
141 int64_t unused;
143
144typedef struct dhlmdl_sequence_description_s
145{
146 int8_t label[32];
147 float fps;
148 int32_t flags;
149 int32_t activity;
150 int32_t actweight;
151
152 int32_t num_events;
153 int32_t ofs_events;
154
155 int32_t num_frames;
156
157 int64_t unused0;
158
159 int32_t motiontype;
160 int32_t motionbone;
162 int64_t unused1;
163 vec3_t bbmin, bbmax;
164
165 int32_t num_blends;
166
167 int32_t ofs_anim;
168
169 int32_t blendtype[2];
170 float blendstart[2], blendend[2];
171 int32_t unused2; // blendparent
172 int32_t seqgroup;
173 int32_t entrynode;
174 int32_t exitnode;
175 int32_t nodeflags;
176 int32_t unused3; // nextseq
178
179typedef uint16_t dhlmdl_animoffset_t[6];
180
181typedef union dhlmdl_animvalue_s
182{
183 struct {
184 uint8_t valid;
185 uint8_t total;
186 } num;
187 int16_t value;
189
190typedef struct dhlmdl_animevent_s
191{
192 int32_t frame;
193 int32_t event;
194 int32_t unused;
195 int8_t options[64];
197
198typedef struct dhlmdl_attachment_s
199{
200 int8_t unused0[36];
201 int32_t type;
202 int32_t bone;
204 vec3_t unused1[3];
206
207typedef struct dhlmdl_bodypart_s
208{
209 int8_t name[64];
210 int32_t num_models;
211 int32_t base;
212 int32_t ofs_models;
214
215typedef struct dhlmdl_s
216{
217 int8_t name[64];
218 int64_t unused0;
219
220 int32_t num_mesh;
221 int32_t ofs_mesh;
222
223 int32_t num_verts;
225 int32_t ofs_verts;
226
227 int32_t num_norms;
229 int32_t ofs_norms;
230
231 int64_t unused1;
232} dhlmdl_t;
233
234typedef struct dhlmdl_mesh_s
235{
236 int32_t num_tris;
237 int32_t ofs_tris;
238 int32_t ofs_skins;
239 int64_t unused;
241
242typedef struct dhlmdl_trivert_s
243{
244 int16_t vertindex;
245 int16_t normindex;
246 int16_t s, t;
248
249#endif
float scale
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
GLsizei const GLfloat * value
Definition glquake.h:740
const GLchar * name
Definition glquake.h:601
#define min(A, B)
Definition mathlib.h:37
uint16_t dhlmdl_animoffset_t[6]
vec_t vec3_t[3]
Definition qtypes.h:71
int32_t num_bones
Definition model_hlmdl.h:55
int32_t num_skingroups
Definition model_hlmdl.h:75
int32_t ofs_textures
Definition model_hlmdl.h:71
int32_t ofs_bodyparts
Definition model_hlmdl.h:79
int32_t num_soundgroups
Definition model_hlmdl.h:87
int32_t num_attachments
Definition model_hlmdl.h:81
int32_t num_hitboxes
Definition model_hlmdl.h:61
int32_t num_bonecontrollers
Definition model_hlmdl.h:58
int32_t num_seqgroups
Definition model_hlmdl.h:67
int32_t ofs_skins
Definition model_hlmdl.h:76
int32_t num_skins
Definition model_hlmdl.h:74
int32_t num_bodyparts
Definition model_hlmdl.h:78
int32_t ofs_soundgroups
Definition model_hlmdl.h:88
int32_t soundindex
Definition model_hlmdl.h:85
int32_t ofs_bonecontrollers
Definition model_hlmdl.h:59
int32_t ofs_seqgroups
Definition model_hlmdl.h:68
int32_t ofs_texturedata
Definition model_hlmdl.h:72
int32_t soundtable
Definition model_hlmdl.h:84
int32_t ofs_attachments
Definition model_hlmdl.h:82
int32_t num_transitions
Definition model_hlmdl.h:90
int32_t num_textures
Definition model_hlmdl.h:70
int32_t ofs_transitions
Definition model_hlmdl.h:91
int32_t ofs_hitboxes
Definition model_hlmdl.h:62
int32_t ofs_bones
Definition model_hlmdl.h:56
int32_t num_tris
int32_t ofs_tris
int32_t ofs_skins
int32_t ofs_norminfo
int64_t unused0
int32_t ofs_mesh
int32_t num_verts
int32_t ofs_verts
int32_t ofs_norms
int64_t unused1
int32_t ofs_vertinfo
int32_t num_mesh
int32_t num_norms