-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrmdl_v16.bt
222 lines (156 loc) · 6.22 KB
/
rmdl_v16.bt
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
//------------------------------------------------
//--- 010 Editor v12.0.1 Binary Template
//
// File: rmdl, rrig
// Authors: Rika
// Version: 16
// Purpose: Respawn MDL Files
// Category: Model
// File Mask: *.rmdl, *.rrig
// ID Bytes:
// History:
//------------------------------------------------
#include "../source_math.bt"
#include "../mdl/mdl_structs.bt"
#include "../rmdl/rmdl_structs.bt"
local int i = 0;
local int j = 0;
local int k = 1;
local int x = 0;
// header
studiohdr_t_v16 hdr <bgcolor=cLtBlue, read=ReadString(startof(this) + this.sznameindex)>;
// funny strings that work the same always
#include "../mdl/mdl_v52_module_mayastrings.bt"
// do bones
FSeek(hdr.boneindex);
mstudiobone_t_v16 bones[hdr.numbones] <bgcolor=cLtGreen, read=ReadString(startof(this) + this.sznameindex)>;
// do attachements
FSeek(hdr.localattachmentindex);
mstudioattachment_t_v16 attachments[hdr.numlocalattachments] <bgcolor=0xcff5ca, read=Str("%s : %s", ReadString(startof(this) + this.sznameindex), ReadString(startof(bones[this.localbone]) + bones[this.localbone].sznameindex))>;
// global hitbox for v54 since it doesn't change
#include "../rmdl/rmdl_v16_module_hitbox.bt"
FSeek(hdr.bonetablebynameindex);
ubyte bonebyname[hdr.numbones] <read=ReadString(startof(bones[this]) + bones[this].sznameindex), bgcolor=cDkGreen>;
// seqs change for v12.2, or aseq v10.
#include "../rmdl/rmdl_v16_module_sequences.bt"
// models
// these change between v12.1/v13/v14 because Respawn.
FSeek(hdr.bodypartindex);
if(hdr.numbodyparts)
{
struct {
for(i = 0; i < hdr.numbodyparts; i++)
{
FSeek(hdr.bodypartindex + (sizeof(mstudiobodyparts_t_v16) * i));
struct {
mstudiobodyparts_t_v16 bodypart <bgcolor=cGray, read=ReadString(startof(this) + this.sznameindex)>;
FSeek(startof(bodypart) + bodypart.modelindex);
for(j = 0; j < bodypart.nummodels; j++)
{
FSeek(startof(bodypart) + bodypart.modelindex + (sizeof(mstudiomodel_t_v16) * j));
struct {
mstudiomodel_t_v16 model;
FSeek(startof(model) + model.meshindex);
mstudiomesh_t_v16 meshes[model.nummeshes] <bgcolor=cLtGray>;
} model <bgcolor=cDkGray>;
}
} bodypart <read=ReadString(startof(this.bodypart) + this.bodypart.sznameindex)>;
}
} bodyparts <read=Str("%i bodyparts", hdr.numbodyparts)>;
}
// setup nodes, not fully understood
// nodes have names
if(hdr.numlocalnodes > 0)
{
FSeek(hdr.localnodenameindex);
short nodename[hdr.numlocalnodes] <bgcolor=cDkYellow, read=ReadString(hdr.localnodenameindex + this)>;
short nodedataindex[hdr.numlocalnodes] <bgcolor=cYellow>;
}
FSeek(hdr.localposeparamindex);
mstudioposeparamdesc_t_v16 poseparm[hdr.numlocalposeparameters] <bgcolor=cYellow, read=ReadString(startof(this) + this.sznameindex)>;
// do ikchains
FSeek(hdr.ikchainindex);
mstudioikchain_t_v16 ikchains[hdr.numikchains] <bgcolor=0xe8daef, read=ReadString(startof(this) + this.sznameindex)>;
local int linkCount = 0;
// get link count
for (i = 0; i < hdr.numikchains; ++i)
{
linkCount += ikchains[i].numlinks;
}
// do links
mstudioiklink_t_v54 iklinks[linkCount] <bgcolor=0x7d3c98>;
// various includes, materials, and groups
// we no longer do include model because that's handled in the rpak header.
// do textures
FSeek(hdr.textureindex);
mstudiotexture_t_v16 textures[hdr.numtextures] <bgcolor=cGreen>;
// do skingroups
FSeek(hdr.skinindex);
if(hdr.numskinfamilies)
{
struct {
short texture[hdr.numskinref] <read=ReadString(startof(textures[this]) + textures[this].sznameindex)>;
} skingroup[hdr.numskinfamilies] <bgcolor=cDkGreen>;
}
// do skingroup names if they exist
if(hdr.numskinfamilies > 1)
{
short skingroupnames[hdr.numskinfamilies - 1] <fgcolor=cDkGreen, read=ReadString(this)>;
}
// do keyvalues, this remains unchanged in all models since it's just char data.
if(hdr.keyvalueindex)
{
FSeek(hdr.keyvalueindex);
string keyvalues_char <fgcolor=cLtBlue>;
}
// basically if the name is small enough to fit into 32 bytes it isn't stored in the string block
if(hdr.sznameindex > sizeof(studiohdr_t_v16))
{
FSeek(hdr.sznameindex);
char stringtable[hdr.bonedataindex - hdr.sznameindex] <fgcolor=cLtRed>;
}
else
{
FSeek(hdr.surfacepropindex);
char stringtable[hdr.bonedataindex - hdr.surfacepropindex] <fgcolor=cLtRed>;
}
FSeek(hdr.bonedataindex);
mstudiobonedata_t_v16 bonedata[hdr.numbones] <bgcolor=cLtGreen>;
local int jigglebonecount = 0;
// get jiggle bone count
for (i = 0; i < hdr.numbones; ++i)
{
if (bonedata[i].proctype == 5) {
jigglebonecount++;
}
}
// do jigglebones
mstudiojigglebone_t_v54 jigglebones[jigglebonecount] <bgcolor=cGreen, read=ReadString(startof(bones[this.bone]) + bones[this.bone].sznameindex)>;
// related to physics bones?
if(hdr.numprocbones)
{
FSeek(hdr.procbonetableindex);
ubyte procbonetable[hdr.numprocbones] <read=ReadString(startof(bones[this]) + bones[this].sznameindex), bgcolor=0x33AA22>; // index of bone??
FSeek(hdr.linearprocboneindex);
byte linearprocbones[hdr.numbones] <bgcolor=0x558822>; // used bones are not nulled here. number is index of "flex"
}
FSeek(hdr.srcbonetransformindex);
mstudiosrcbonetransform_t srcbonetransform[hdr.numsrcbonetransform] <bgcolor=cDkGreen, read=ReadString(startof(this) + this.sznameindex)>;
#include "../rmdl/rmdl_v16_module_linearbone.bt"
// unchanged between subversions
#include "../rmdl/rmdl_v16_module_rui.bt"
/*// global string table setup, only changes for v14
#include "../rmdl/rmdl_v54_v14_module_stringtable.bt"
// unkdata headers changed in v12
#include "../rmdl/rmdl_v54_v12_module_unkdata.bt"
// unsure what this is for, same as v53
#include "../mdl/mdl_module_bone_followers.bt"
*/
if(hdr.numbonefollowers)
{
FSeek(GetRMDLOffset(hdr.bonefollowerindex));
short bone_follower[hdr.numbonefollowers] <bgcolor=cLtYellow, read=ReadString(startof(bones[this]) + GetRMDLOffset(bones[this].sznameindex))>;
}
// third set of core parts, done like this for spacing.
#include "../rmdl/rmdl_v16_vg.bt"
#include "../rmdl/rmdl_v54_v12_module_bvh4.bt"