-
Notifications
You must be signed in to change notification settings - Fork 1
/
modelheaders.h
301 lines (257 loc) · 5.55 KB
/
modelheaders.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#ifndef MODELHEADERS_H
#define MODELHEADERS_H
typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned int uint32;
typedef int int32;
#pragma pack(push,1)
struct ModelHeader {
char id[4];
uint8 version[4];
uint32 nameLength;
uint32 nameOfs;
uint32 type;
uint32 nGlobalSequences;
uint32 ofsGlobalSequences;
uint32 nAnimations;
uint32 ofsAnimations;
uint32 nC;
uint32 ofsC;
uint32 nD;
uint32 ofsD;
uint32 nBones;
uint32 ofsBones;
uint32 nF;
uint32 ofsF;
uint32 nVertices;
uint32 ofsVertices;
uint32 nViews;
uint32 ofsViews;
uint32 nColors;
uint32 ofsColors;
uint32 nTextures;
uint32 ofsTextures;
uint32 nTransparency; // H
uint32 ofsTransparency;
uint32 nI; // always unused ?
uint32 ofsI;
uint32 nTexAnims; // J
uint32 ofsTexAnims;
uint32 nK;
uint32 ofsK;
uint32 nTexFlags;
uint32 ofsTexFlags;
uint32 nY;
uint32 ofsY;
uint32 nTexLookup;
uint32 ofsTexLookup;
uint32 nTexUnitLookup; // L
uint32 ofsTexUnitLookup;
uint32 nTransparencyLookup; // M
uint32 ofsTransparencyLookup;
uint32 nTexAnimLookup;
uint32 ofsTexAnimLookup;
float floats[14];
uint32 nBoundingTriangles;
uint32 ofsBoundingTriangles;
uint32 nBoundingVertices;
uint32 ofsBoundingVertices;
uint32 nBoundingNormals;
uint32 ofsBoundingNormals;
uint32 nO;
uint32 ofsO;
uint32 nP;
uint32 ofsP;
uint32 nQ;
uint32 ofsQ;
uint32 nLights; // R
uint32 ofsLights;
uint32 nCameras; // S
uint32 ofsCameras;
uint32 nT;
uint32 ofsT;
uint32 nRibbonEmitters; // U
uint32 ofsRibbonEmitters;
uint32 nParticleEmitters; // V
uint32 ofsParticleEmitters;
};
// block B - animations
struct ModelAnimation {
uint32 animID;
uint32 timeStart;
uint32 timeEnd;
float moveSpeed;
uint32 loopType;
uint32 flags;
uint32 d1;
uint32 d2;
uint32 playSpeed; // note: this can't be play speed because it's 0 for some models
Vec3D boxA, boxB;
float rad;
int16 s[2];
};
// sub-block in block E - animation data
struct AnimationBlock {
int16 type; // interpolation type (0=none, 1=linear, 2=hermite)
int16 seq; // global sequence id or -1
uint32 nRanges;
uint32 ofsRanges;
uint32 nTimes;
uint32 ofsTimes;
uint32 nKeys;
uint32 ofsKeys;
};
// block E - bones
struct ModelBoneDef {
int32 animid;
int32 flags;
int16 parent; // parent bone index
int16 geoid;
AnimationBlock translation;
AnimationBlock rotation;
AnimationBlock scaling;
Vec3D pivot;
};
struct ModelTexAnimDef {
AnimationBlock trans, rot, scale;
};
struct ModelVertex {
Vec3D pos;
uint8 weights[4];
uint8 bones[4];
Vec3D normal;
Vec2D texcoords;
int unk1, unk2; // always 0,0 so this is probably unused
};
struct ModelView {
uint32 nIndex, ofsIndex; // Vertices in this model (index into vertices[])
uint32 nTris, ofsTris; // indices
uint32 nProps, ofsProps; // additional vtx properties
uint32 nSub, ofsSub; // materials/renderops/submeshes
uint32 nTex, ofsTex; // material properties/textures
int32 lod; // LOD bias?
};
/// One material + render operation
struct ModelGeoset {
uint16 d1; // mesh part id?
uint16 d2; // ?
uint16 vstart; // first vertex
uint16 vcount; // num vertices
uint16 istart; // first index
uint16 icount; // num indices
uint16 d3; // number of bone indices
uint16 d4; // offset into bone index list
uint16 d5; // ?
uint16 d6; // root bone?
Vec3D v;
};
/// A texture unit (sub of material)
struct ModelTexUnit{
// probably the texture units
// size always >=number of materials it seems
uint16 flags; // Flags
uint16 order; // ?
uint16 op; // Material this texture is part of (index into mat)
uint16 op2; // Always same as above?
int16 colorIndex; // color or -1
uint16 flagsIndex; // more flags...
uint16 texunit; // Texture unit (0 or 1)
uint16 d4; // ? (seems to be always 1)
uint16 textureid; // Texture id (index into global texture list)
uint16 texunit2; // copy of texture unit value?
uint16 transid; // transparency id (index into transparency list)
uint16 texanimid; // texture animation id
};
// block X - render flags
struct ModelRenderFlags {
uint16 flags;
uint16 blend;
};
// block G - color defs
struct ModelColorDef {
AnimationBlock color;
AnimationBlock opacity;
};
// block H - transp defs
struct ModelTransDef {
AnimationBlock trans;
};
struct ModelTextureDef {
uint32 type;
uint32 flags;
uint32 nameLen;
uint32 nameOfs;
};
struct ModelLightDef {
int16 type;
int16 bone;
Vec3D pos;
AnimationBlock ambColor;
AnimationBlock ambIntensity;
AnimationBlock color;
AnimationBlock intensity;
AnimationBlock attStart;
AnimationBlock attEnd;
AnimationBlock unk1;
};
struct ModelCameraDef {
int32 id;
float fov, farclip, nearclip;
AnimationBlock transPos;
Vec3D pos;
AnimationBlock transTarget;
Vec3D target;
AnimationBlock rot;
};
struct ModelParticleParams {
float mid;
uint32 colors[3];
float sizes[3];
int16 d[10];
float unk[3];
float scales[3];
float slowdown;
float rotation;
float f2[16];
};
struct ModelParticleEmitterDef {
int32 id;
int32 flags;
Vec3D pos;
int16 bone;
int16 texture;
int32 nZero1;
int32 ofsZero1;
int32 nZero2;
int32 ofsZero2;
int16 blend;
int16 type;
int16 s1;
int16 s2;
int16 cols;
int16 rows;
AnimationBlock params[10];
ModelParticleParams p;
AnimationBlock unk;
};
struct ModelRibbonEmitterDef {
int32 id;
int32 bone;
Vec3D pos;
int32 nTextures;
int32 ofsTextures;
int32 nUnknown;
int32 ofsUnknown;
AnimationBlock color;
AnimationBlock opacity;
AnimationBlock above;
AnimationBlock below;
float res, length, unk;
int16 s1, s2;
AnimationBlock unk1;
AnimationBlock unk2;
};
#pragma pack(pop)
#endif