@@ -22,7 +22,7 @@ typedef struct {
22
22
// 0x40 = normal ??
23
23
24
24
25
- uint32_t drawCount ;
25
+ uint32_t textureCount ;
26
26
uint32_t always0_a ;
27
27
uint32_t vertexCount ;
28
28
uint32_t always0_b ;
@@ -36,7 +36,9 @@ typedef struct {
36
36
37
37
uint32_t faceCount ; // triangle count without degenerates ?!
38
38
uint32_t always0_c [4 ];
39
- uint32_t unk [16 + 38 - 7 ];
39
+ uint32_t unk [16 + 38 - 7 - 2 ];
40
+ uint32_t drawCount ;
41
+ uint32_t unk2 ;
40
42
uint32_t indexCount ;
41
43
uint32_t always0_d [7 ];
42
44
} Header ;
@@ -73,6 +75,7 @@ int main(int argc, char* argv[]) {
73
75
d = header .unk [i ];
74
76
printf ("[%d] = 0x%08X [%d]\t\t%f\n" , i , d , d , * (float * )& d ); // Unknown
75
77
}
78
+ // assert(header.unk[45] == header.drawCount);
76
79
77
80
bool hasNormal = false; // atoi(argv[3]);
78
81
@@ -94,6 +97,7 @@ int main(int argc, char* argv[]) {
94
97
hasNormal |= (header .unk0 == 4163 && header .unk1 == 0x05232001 );
95
98
hasNormal |= (header .unk0 == 4161 && header .unk1 == 0x1E0F2001 );
96
99
hasNormal |= (header .unk0 == 4163 && header .unk1 == 0x321E2001 );
100
+ hasNormal |= (header .unk0 == 4163 && header .unk1 == 0x0F4B2001 );
97
101
98
102
for (unsigned int i = 0 ; i < header .vertexCount ; i ++ ) {
99
103
Vector position ;
@@ -139,7 +143,8 @@ int main(int argc, char* argv[]) {
139
143
for (unsigned int i = 0 ; i < header .drawCount ; i ++ ) {
140
144
141
145
typedef struct {
142
- uint32_t unk0 ;
146
+ uint16_t unk0a ; // Texture index?
147
+ uint16_t unk0b ;
143
148
uint32_t unk1 ;
144
149
uint32_t unk2 ; // Sometimes matches vertexCount ?!
145
150
uint32_t indexCount ;
@@ -148,15 +153,16 @@ int main(int argc, char* argv[]) {
148
153
Draw draw ;
149
154
fread (& draw , sizeof (draw ), 1 , in );
150
155
151
- printf ("[%d] = 0x%08X 0x%08X 0x%08X, indexCount: %d\n" ,
156
+ printf ("[%d] = 0x%04X 0x%04X 0x%08X 0x%08X, indexCount: %d\n" ,
152
157
i ,
153
- draw .unk0 ,
158
+ draw .unk0a ,
159
+ draw .unk0b ,
154
160
draw .unk1 ,
155
161
draw .unk2 ,
156
162
draw .indexCount );
157
163
158
164
fprintf (out , "g %s/draw%d\n" , basename (outPath ), i );
159
- fprintf (out , "usemtl %s/draw %d\n" , mtlFile , i );
165
+ fprintf (out , "usemtl %s/texture %d\n" , mtlFile , draw . unk0a );
160
166
161
167
for (unsigned int j = 0 ; j < draw .indexCount ; j ++ ) {
162
168
@@ -203,18 +209,20 @@ int main(int argc, char* argv[]) {
203
209
fclose (out );
204
210
out = fopen (mtlPath , "wb" );
205
211
206
- for (unsigned int i = 0 ; i < header .drawCount ; i ++ ) {
212
+ for (unsigned int i = 0 ; i < header .textureCount ; i ++ ) {
207
213
typedef struct {
208
214
uint16_t file ;
209
215
uint16_t resource ;
210
216
uint8_t always0 [20 ];
211
217
} TextureReference ;
212
218
219
+ printf ("Reading tex at %d\n" , ftell (in ));
220
+
213
221
TextureReference texture ;
214
222
fread (& texture , sizeof (texture ), 1 , in );
215
223
printf ("[%d] = resource: %d, index: %d\n" , i , texture .resource , texture .file );
216
224
217
- fprintf (out , "newmtl %s/draw %d\n" , mtlFile , i );
225
+ fprintf (out , "newmtl %s/texture %d\n" , mtlFile , i );
218
226
fprintf (out , "map_Kd -s 1 1 %d-%d.tga\n" , texture .resource , texture .file );
219
227
}
220
228
0 commit comments