-
Notifications
You must be signed in to change notification settings - Fork 0
/
PPM.bt
259 lines (224 loc) · 5.39 KB
/
PPM.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
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
//------------------------------------------------
//--- 010 Editor v13.0.2 Binary Template
//
// File: PPM.bt
// Authors: WarpZephyr
// Version: 1.0.0
// Purpose: Armored Core Formula Front PPM model files.
// Category: Models
// File Mask: *.ppm
// ID Bytes: 50 50 4D 20
// History:
//------------------------------------------------
LittleEndian();
// Helper Structs
//------------------------------------------------
typedef struct
{
ubyte null; Assert(null == 0);
} Null <bgcolor=cBlack, optimize=false>;
typedef struct
{
float x;
float y;
float z;
} Vector3 <read=ReadVector3>;
string ReadVector3(Vector3& vec)
{
string str;
SPrintf(str, "<%7.2f, %7.2f, %7.2f>", vec.x, vec.y, vec.z);
return str;
}
typedef struct
{
float x;
float y;
float z;
float w;
} Vector4 <read=ReadVector4>;
string ReadVector4(Vector4& vec)
{
string str;
SPrintf(str, "<%7.2f, %7.2f, %7.2f, %7.2f>", vec.x, vec.y, vec.z, vec.w);
return str;
}
// Structs
//------------------------------------------------
typedef struct
{
char magic[4]; Assert(magic == "PPM "); // Probably stands for Playstation Portable Model
short unk04;
short unk06;
int fileSize;
int unk0C;
Null null_1[32];
int unk30;
Null null_2[28];
Vector3 boundingBoxMin;
Vector3 boundingBoxMax;
int materialCount;
int boneCount;
int lightObjectCount; // Never seen
int primitiveInfoCount;
int textureCount;
int vertexBufferSize;
int indicesBufferSize;
int dummyCount;
int countUnkStruct9;
int countUnkStruct10; // Never seen
int materialsOffset;
int bonesOffset;
int lightObjectsOffset; // Never seen
int primitiveInfosOffset;
int texturesOffset;
int vertexBufferOffset;
int indicesOffset;
int dummiesOffset;
int offsetUnkStruct9s;
int offsetUnkStruct10s; // Never seen
} Header <bgcolor=cLtRed>;
typedef struct
{
ubyte color[4]; // Divide by 255
ubyte unk04[4];
ubyte ambient_color[4]; // Divide by 255
ubyte unk0C[8];
float specular_exp;
ubyte unk[24];
} Material <bgcolor=cLtGreen, optimize=false>;
typedef struct
{
Vector3 relative_position;
Vector3 relative_angle;
Vector3 relative_scale;
Vector3 world_position;
Vector3 world_angle;
Vector4 world_scale;
Vector3 boundingBoxMin;
Vector3 boundingBoxMax;
int unk64;
int primitiveCount;
int unk6C;
char name[8];
} Bone <bgcolor=cGreen, read=ReadBone, optimize=false>;
string ReadBone(Bone& bone)
{
return bone.name;
}
typedef struct
{
Assert(false); // Never seen
} LightObject <bgcolor=cDkGreen, optimize=false>;
typedef struct
{
short unk00; Assert(unk00 >= 0 || unk00 <= 6);
ubyte unk02; Assert(unk02 == 1);
ubyte unk03; Assert(unk03 == 4);
ubyte unk04;
ubyte unk05;
short unk06 <hidden=true>; Assert(unk06 == 0);
int unk08;
int vertexBufferOffset;
int primitiveNodeCount;
int unk14 <hidden=true>; Assert(unk14 == 0);
} PrimitiveInfo <bgcolor=cLtYellow, optimize=false>;
typedef struct
{
char name[24];
} Texture <bgcolor=cYellow, read=ReadTexture, optimize=false>;
string ReadTexture(Texture& texture)
{
return texture.name;
}
typedef struct
{
ubyte buffer[header.vertexBufferSize];
} VertexBuffer <bgcolor=cDkYellow>;
typedef struct
{
short indices[header.indicesBufferSize / 2];
} Indices <bgcolor=cLtAqua>;
typedef struct
{
Vector3 position;
Vector3 forward;
ubyte color[4];
int unk1C;
int unk20;
} Dummy <bgcolor=cAqua, read=ReadDummy, optimize=false>;
string ReadDummy(Dummy& dummy)
{
local string str;
return SPrintf(str, "%s", ReadVector3(dummy.position));
}
typedef struct
{
Null null[64];
} UnkStruct9 <bgcolor=cDkAqua, optimize=false>;
typedef struct
{
Assert(false); // Never seen
} UnkStruct10 <bgcolor=cLtPurple, optimize=false>;
// Read
//------------------------------------------------
Header header;
if (header.materialCount > 0)
{
Assert(header.materialsOffset > 0);
FSeek(header.materialsOffset);
Material materials[header.materialCount];
}
if (header.boneCount > 0)
{
Assert(header.bonesOffset > 0);
FSeek(header.bonesOffset);
Bone bones[header.boneCount];
}
// Never seen
if (header.lightObjectCount > 0)
{
Assert(header.lightObjectsOffset > 0);
FSeek(header.lightObjectsOffset);
LightObject lightObjects[header.exLightObjectCount];
}
if (header.primitiveInfoCount > 0)
{
Assert(header.primitiveInfosOffset > 0);
FSeek(header.primitiveInfosOffset);
PrimitiveInfo primitiveInfos[header.primitiveInfoCount];
}
if (header.textureCount > 0)
{
Assert(header.texturesOffset > 0);
FSeek(header.texturesOffset);
Texture textures[header.textureCount];
}
if (header.dummyCount > 0)
{
Assert(header.dummiesOffset > 0);
FSeek(header.dummiesOffset);
Dummy dummies[header.dummyCount];
}
if (header.countUnkStruct9 > 0)
{
Assert(header.offsetUnkStruct9s > 0);
FSeek(header.offsetUnkStruct9s);
UnkStruct9 unkStruct9s[header.countUnkStruct9];
}
// Never seen
if (header.countUnkStruct10 > 0)
{
Assert(header.offsetUnkStruct10s > 0);
FSeek(header.offsetUnkStruct10s);
UnkStruct10 unkStruct10s[header.countUnkStruct10];
}
if (header.vertexBufferOffset > 0)
{
FSeek(header.vertexBufferOffset);
VertexBuffer vertexBuffer;
}
if (header.indicesOffset > 0)
{
FSeek(header.indicesOffset);
Indices indices;
}