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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from .kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
from enum import Enum
import collections
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
class RenderwareBinaryStream(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/RenderWare_binary_stream_file
"""
class Sections(Enum):
struct = 1
string = 2
extension = 3
camera = 5
texture = 6
material = 7
material_list = 8
atomic_section = 9
plane_section = 10
world = 11
spline = 12
matrix = 13
frame_list = 14
geometry = 15
clump = 16
light = 18
unicode_string = 19
atomic = 20
texture_native = 21
texture_dictionary = 22
animation_database = 23
image = 24
skin_animation = 25
geometry_list = 26
anim_animation = 27
team = 28
crowd = 29
delta_morph_animation = 30
right_to_render = 31
multitexture_effect_native = 32
multitexture_effect_dictionary = 33
team_dictionary = 34
platform_independent_texture_dictionary = 35
table_of_contents = 36
particle_standard_global_data = 37
altpipe = 38
platform_independent_peds = 39
patch_mesh = 40
chunk_group_start = 41
chunk_group_end = 42
uv_animation_dictionary = 43
coll_tree = 44
metrics_plg = 257
spline_plg = 258
stereo_plg = 259
vrml_plg = 260
morph_plg = 261
pvs_plg = 262
memory_leak_plg = 263
animation_plg = 264
gloss_plg = 265
logo_plg = 266
memory_info_plg = 267
random_plg = 268
png_image_plg = 269
bone_plg = 270
vrml_anim_plg = 271
sky_mipmap_val = 272
mrm_plg = 273
lod_atomic_plg = 274
me_plg = 275
lightmap_plg = 276
refine_plg = 277
skin_plg = 278
label_plg = 279
particles_plg = 280
geomtx_plg = 281
synth_core_plg = 282
stqpp_plg = 283
part_pp_plg = 284
collision_plg = 285
hanim_plg = 286
user_data_plg = 287
material_effects_plg = 288
particle_system_plg = 289
delta_morph_plg = 290
patch_plg = 291
team_plg = 292
crowd_pp_plg = 293
mip_split_plg = 294
anisotropy_plg = 295
gcn_material_plg = 297
geometric_pvs_plg = 298
xbox_material_plg = 299
multi_texture_plg = 300
chain_plg = 301
toon_plg = 302
ptank_plg = 303
particle_standard_plg = 304
pds_plg = 305
prtadv_plg = 306
normal_map_plg = 307
adc_plg = 308
uv_animation_plg = 309
character_set_plg = 384
nohs_world_plg = 385
import_util_plg = 386
slerp_plg = 387
optim_plg = 388
tl_world_plg = 389
database_plg = 390
raytrace_plg = 391
ray_plg = 392
library_plg = 393
plg_2d = 400
tile_render_plg = 401
jpeg_image_plg = 402
tga_image_plg = 403
gif_image_plg = 404
quat_plg = 405
spline_pvs_plg = 406
mipmap_plg = 407
mipmapk_plg = 408
font_2d = 409
intersection_plg = 410
tiff_image_plg = 411
pick_plg = 412
bmp_image_plg = 413
ras_image_plg = 414
skin_fx_plg = 415
vcat_plg = 416
path_2d = 417
brush_2d = 418
object_2d = 419
shape_2d = 420
scene_2d = 421
pick_region_2d = 422
object_string_2d = 423
animation_plg_2d = 424
animation_2d = 425
keyframe_2d = 432
maestro_2d = 433
barycentric = 434
platform_independent_texture_dictionary_tk = 435
toc_tk = 436
tpl_tk = 437
altpipe_tk = 438
animation_tk = 439
skin_split_tookit = 440
compressed_key_tk = 441
geometry_conditioning_plg = 442
wing_plg = 443
generic_pipeline_tk = 444
lightmap_conversion_tk = 445
filesystem_plg = 446
dictionary_tk = 447
uv_animation_linear = 448
uv_animation_parameter = 449
bin_mesh_plg = 1294
native_data_plg = 1296
zmodeler_lock = 61982
atomic_visibility_distance = 39055872
clump_visibility_distance = 39055873
frame_visibility_distance = 39055874
pipeline_set = 39056115
unused_5 = 39056116
texdictionary_link = 39056117
specular_material = 39056118
unused_8 = 39056119
effect_2d = 39056120
extra_vert_colour = 39056121
collision_model = 39056122
gta_hanim = 39056123
reflection_material = 39056124
breakable = 39056125
frame = 39056126
unused_16 = 39056127
SEQ_FIELDS = ["code", "size", "version", "body"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['code']['start'] = self._io.pos()
self.code = KaitaiStream.resolve_enum(self._root.Sections, self._io.read_u4le())
self._debug['code']['end'] = self._io.pos()
self._debug['size']['start'] = self._io.pos()
self.size = self._io.read_u4le()
self._debug['size']['end'] = self._io.pos()
self._debug['version']['start'] = self._io.pos()
self.version = self._io.read_u4le()
self._debug['version']['end'] = self._io.pos()
self._debug['body']['start'] = self._io.pos()
_on = self.code
if _on == self._root.Sections.geometry:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
elif _on == self._root.Sections.texture_dictionary:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
elif _on == self._root.Sections.geometry_list:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
elif _on == self._root.Sections.texture_native:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
elif _on == self._root.Sections.clump:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
elif _on == self._root.Sections.frame_list:
self._raw_body = self._io.read_bytes(self.size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.ListWithHeader(io, self, self._root)
self.body._read()
else:
self.body = self._io.read_bytes(self.size)
self._debug['body']['end'] = self._io.pos()
class StructClump(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/RpClump
"""
SEQ_FIELDS = ["num_atomics", "num_lights", "num_cameras"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['num_atomics']['start'] = self._io.pos()
self.num_atomics = self._io.read_u4le()
self._debug['num_atomics']['end'] = self._io.pos()
if self._parent.version >= 208896:
self._debug['num_lights']['start'] = self._io.pos()
self.num_lights = self._io.read_u4le()
self._debug['num_lights']['end'] = self._io.pos()
if self._parent.version >= 208896:
self._debug['num_cameras']['start'] = self._io.pos()
self.num_cameras = self._io.read_u4le()
self._debug['num_cameras']['end'] = self._io.pos()
class StructGeometry(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/RpGeometry
"""
SEQ_FIELDS = ["format", "num_triangles", "num_vertices", "num_morph_targets", "surf_prop", "geometry", "morph_targets"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['format']['start'] = self._io.pos()
self.format = self._io.read_u4le()
self._debug['format']['end'] = self._io.pos()
self._debug['num_triangles']['start'] = self._io.pos()
self.num_triangles = self._io.read_u4le()
self._debug['num_triangles']['end'] = self._io.pos()
self._debug['num_vertices']['start'] = self._io.pos()
self.num_vertices = self._io.read_u4le()
self._debug['num_vertices']['end'] = self._io.pos()
self._debug['num_morph_targets']['start'] = self._io.pos()
self.num_morph_targets = self._io.read_u4le()
self._debug['num_morph_targets']['end'] = self._io.pos()
if self._parent.version < 212992:
self._debug['surf_prop']['start'] = self._io.pos()
self.surf_prop = self._root.SurfaceProperties(self._io, self, self._root)
self.surf_prop._read()
self._debug['surf_prop']['end'] = self._io.pos()
if not (self.is_native):
self._debug['geometry']['start'] = self._io.pos()
self.geometry = self._root.GeometryNonNative(self._io, self, self._root)
self.geometry._read()
self._debug['geometry']['end'] = self._io.pos()
self._debug['morph_targets']['start'] = self._io.pos()
self.morph_targets = [None] * (self.num_morph_targets)
for i in range(self.num_morph_targets):
if not 'arr' in self._debug['morph_targets']:
self._debug['morph_targets']['arr'] = []
self._debug['morph_targets']['arr'].append({'start': self._io.pos()})
_t_morph_targets = self._root.MorphTarget(self._io, self, self._root)
_t_morph_targets._read()
self.morph_targets[i] = _t_morph_targets
self._debug['morph_targets']['arr'][i]['end'] = self._io.pos()
self._debug['morph_targets']['end'] = self._io.pos()
@property
def is_textured(self):
if hasattr(self, '_m_is_textured'):
return self._m_is_textured if hasattr(self, '_m_is_textured') else None
self._m_is_textured = (self.format & 4) != 0
return self._m_is_textured if hasattr(self, '_m_is_textured') else None
@property
def is_prelit(self):
if hasattr(self, '_m_is_prelit'):
return self._m_is_prelit if hasattr(self, '_m_is_prelit') else None
self._m_is_prelit = (self.format & 8) != 0
return self._m_is_prelit if hasattr(self, '_m_is_prelit') else None
@property
def is_textured2(self):
if hasattr(self, '_m_is_textured2'):
return self._m_is_textured2 if hasattr(self, '_m_is_textured2') else None
self._m_is_textured2 = (self.format & 128) != 0
return self._m_is_textured2 if hasattr(self, '_m_is_textured2') else None
@property
def is_native(self):
if hasattr(self, '_m_is_native'):
return self._m_is_native if hasattr(self, '_m_is_native') else None
self._m_is_native = (self.format & 16777216) != 0
return self._m_is_native if hasattr(self, '_m_is_native') else None
class GeometryNonNative(KaitaiStruct):
SEQ_FIELDS = ["prelit_colors", "tex_coords", "triangles"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
if self._parent.is_prelit:
self._debug['prelit_colors']['start'] = self._io.pos()
self.prelit_colors = [None] * (self._parent.num_vertices)
for i in range(self._parent.num_vertices):
if not 'arr' in self._debug['prelit_colors']:
self._debug['prelit_colors']['arr'] = []
self._debug['prelit_colors']['arr'].append({'start': self._io.pos()})
_t_prelit_colors = self._root.Rgba(self._io, self, self._root)
_t_prelit_colors._read()
self.prelit_colors[i] = _t_prelit_colors
self._debug['prelit_colors']['arr'][i]['end'] = self._io.pos()
self._debug['prelit_colors']['end'] = self._io.pos()
if ((self._parent.is_textured) or (self._parent.is_textured2)) :
self._debug['tex_coords']['start'] = self._io.pos()
self.tex_coords = [None] * (self._parent.num_vertices)
for i in range(self._parent.num_vertices):
if not 'arr' in self._debug['tex_coords']:
self._debug['tex_coords']['arr'] = []
self._debug['tex_coords']['arr'].append({'start': self._io.pos()})
_t_tex_coords = self._root.TexCoord(self._io, self, self._root)
_t_tex_coords._read()
self.tex_coords[i] = _t_tex_coords
self._debug['tex_coords']['arr'][i]['end'] = self._io.pos()
self._debug['tex_coords']['end'] = self._io.pos()
self._debug['triangles']['start'] = self._io.pos()
self.triangles = [None] * (self._parent.num_triangles)
for i in range(self._parent.num_triangles):
if not 'arr' in self._debug['triangles']:
self._debug['triangles']['arr'] = []
self._debug['triangles']['arr'].append({'start': self._io.pos()})
_t_triangles = self._root.Triangle(self._io, self, self._root)
_t_triangles._read()
self.triangles[i] = _t_triangles
self._debug['triangles']['arr'][i]['end'] = self._io.pos()
self._debug['triangles']['end'] = self._io.pos()
class StructGeometryList(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/Geometry_List_(RW_Section)#Structure
"""
SEQ_FIELDS = ["num_geometries"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['num_geometries']['start'] = self._io.pos()
self.num_geometries = self._io.read_u4le()
self._debug['num_geometries']['end'] = self._io.pos()
class Rgba(KaitaiStruct):
SEQ_FIELDS = ["r", "g", "b", "a"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['r']['start'] = self._io.pos()
self.r = self._io.read_u1()
self._debug['r']['end'] = self._io.pos()
self._debug['g']['start'] = self._io.pos()
self.g = self._io.read_u1()
self._debug['g']['end'] = self._io.pos()
self._debug['b']['start'] = self._io.pos()
self.b = self._io.read_u1()
self._debug['b']['end'] = self._io.pos()
self._debug['a']['start'] = self._io.pos()
self.a = self._io.read_u1()
self._debug['a']['end'] = self._io.pos()
class Sphere(KaitaiStruct):
SEQ_FIELDS = ["x", "y", "z", "radius"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['x']['start'] = self._io.pos()
self.x = self._io.read_f4le()
self._debug['x']['end'] = self._io.pos()
self._debug['y']['start'] = self._io.pos()
self.y = self._io.read_f4le()
self._debug['y']['end'] = self._io.pos()
self._debug['z']['start'] = self._io.pos()
self.z = self._io.read_f4le()
self._debug['z']['end'] = self._io.pos()
self._debug['radius']['start'] = self._io.pos()
self.radius = self._io.read_f4le()
self._debug['radius']['end'] = self._io.pos()
class MorphTarget(KaitaiStruct):
SEQ_FIELDS = ["bounding_sphere", "has_vertices", "has_normals", "vertices", "normals"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['bounding_sphere']['start'] = self._io.pos()
self.bounding_sphere = self._root.Sphere(self._io, self, self._root)
self.bounding_sphere._read()
self._debug['bounding_sphere']['end'] = self._io.pos()
self._debug['has_vertices']['start'] = self._io.pos()
self.has_vertices = self._io.read_u4le()
self._debug['has_vertices']['end'] = self._io.pos()
self._debug['has_normals']['start'] = self._io.pos()
self.has_normals = self._io.read_u4le()
self._debug['has_normals']['end'] = self._io.pos()
if self.has_vertices != 0:
self._debug['vertices']['start'] = self._io.pos()
self.vertices = [None] * (self._parent.num_vertices)
for i in range(self._parent.num_vertices):
if not 'arr' in self._debug['vertices']:
self._debug['vertices']['arr'] = []
self._debug['vertices']['arr'].append({'start': self._io.pos()})
_t_vertices = self._root.Vector3d(self._io, self, self._root)
_t_vertices._read()
self.vertices[i] = _t_vertices
self._debug['vertices']['arr'][i]['end'] = self._io.pos()
self._debug['vertices']['end'] = self._io.pos()
if self.has_normals != 0:
self._debug['normals']['start'] = self._io.pos()
self.normals = [None] * (self._parent.num_vertices)
for i in range(self._parent.num_vertices):
if not 'arr' in self._debug['normals']:
self._debug['normals']['arr'] = []
self._debug['normals']['arr'].append({'start': self._io.pos()})
_t_normals = self._root.Vector3d(self._io, self, self._root)
_t_normals._read()
self.normals[i] = _t_normals
self._debug['normals']['arr'][i]['end'] = self._io.pos()
self._debug['normals']['end'] = self._io.pos()
class SurfaceProperties(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/RpGeometry
"""
SEQ_FIELDS = ["ambient", "specular", "diffuse"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['ambient']['start'] = self._io.pos()
self.ambient = self._io.read_f4le()
self._debug['ambient']['end'] = self._io.pos()
self._debug['specular']['start'] = self._io.pos()
self.specular = self._io.read_f4le()
self._debug['specular']['end'] = self._io.pos()
self._debug['diffuse']['start'] = self._io.pos()
self.diffuse = self._io.read_f4le()
self._debug['diffuse']['end'] = self._io.pos()
class StructFrameList(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/Frame_List_(RW_Section)#Structure
"""
SEQ_FIELDS = ["num_frames", "frames"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['num_frames']['start'] = self._io.pos()
self.num_frames = self._io.read_u4le()
self._debug['num_frames']['end'] = self._io.pos()
self._debug['frames']['start'] = self._io.pos()
self.frames = [None] * (self.num_frames)
for i in range(self.num_frames):
if not 'arr' in self._debug['frames']:
self._debug['frames']['arr'] = []
self._debug['frames']['arr'].append({'start': self._io.pos()})
_t_frames = self._root.Frame(self._io, self, self._root)
_t_frames._read()
self.frames[i] = _t_frames
self._debug['frames']['arr'][i]['end'] = self._io.pos()
self._debug['frames']['end'] = self._io.pos()
class Matrix(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/Frame_List_(RW_Section)#Structure
"""
SEQ_FIELDS = ["entries"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['entries']['start'] = self._io.pos()
self.entries = [None] * (3)
for i in range(3):
if not 'arr' in self._debug['entries']:
self._debug['entries']['arr'] = []
self._debug['entries']['arr'].append({'start': self._io.pos()})
_t_entries = self._root.Vector3d(self._io, self, self._root)
_t_entries._read()
self.entries[i] = _t_entries
self._debug['entries']['arr'][i]['end'] = self._io.pos()
self._debug['entries']['end'] = self._io.pos()
class Vector3d(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/Frame_List_(RW_Section)#Structure
"""
SEQ_FIELDS = ["x", "y", "z"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['x']['start'] = self._io.pos()
self.x = self._io.read_f4le()
self._debug['x']['end'] = self._io.pos()
self._debug['y']['start'] = self._io.pos()
self.y = self._io.read_f4le()
self._debug['y']['end'] = self._io.pos()
self._debug['z']['start'] = self._io.pos()
self.z = self._io.read_f4le()
self._debug['z']['end'] = self._io.pos()
class ListWithHeader(KaitaiStruct):
"""Typical structure used by many data types in RenderWare binary
stream. Substream contains a list of binary stream entries,
first entry always has type "struct" and carries some specific
binary data it in, determined by the type of parent. All other
entries, beside the first one, are normal, self-describing
records.
"""
SEQ_FIELDS = ["code", "header_size", "version", "header", "entries"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['code']['start'] = self._io.pos()
self.code = self._io.ensure_fixed_contents(b"\x01\x00\x00\x00")
self._debug['code']['end'] = self._io.pos()
self._debug['header_size']['start'] = self._io.pos()
self.header_size = self._io.read_u4le()
self._debug['header_size']['end'] = self._io.pos()
self._debug['version']['start'] = self._io.pos()
self.version = self._io.read_u4le()
self._debug['version']['end'] = self._io.pos()
self._debug['header']['start'] = self._io.pos()
_on = self._parent.code
if _on == self._root.Sections.geometry:
self._raw_header = self._io.read_bytes(self.header_size)
io = KaitaiStream(BytesIO(self._raw_header))
self.header = self._root.StructGeometry(io, self, self._root)
self.header._read()
elif _on == self._root.Sections.texture_dictionary:
self._raw_header = self._io.read_bytes(self.header_size)
io = KaitaiStream(BytesIO(self._raw_header))
self.header = self._root.StructTextureDictionary(io, self, self._root)
self.header._read()
elif _on == self._root.Sections.geometry_list:
self._raw_header = self._io.read_bytes(self.header_size)
io = KaitaiStream(BytesIO(self._raw_header))
self.header = self._root.StructGeometryList(io, self, self._root)
self.header._read()
elif _on == self._root.Sections.clump:
self._raw_header = self._io.read_bytes(self.header_size)
io = KaitaiStream(BytesIO(self._raw_header))
self.header = self._root.StructClump(io, self, self._root)
self.header._read()
elif _on == self._root.Sections.frame_list:
self._raw_header = self._io.read_bytes(self.header_size)
io = KaitaiStream(BytesIO(self._raw_header))
self.header = self._root.StructFrameList(io, self, self._root)
self.header._read()
else:
self.header = self._io.read_bytes(self.header_size)
self._debug['header']['end'] = self._io.pos()
self._debug['entries']['start'] = self._io.pos()
self.entries = []
i = 0
while not self._io.is_eof():
if not 'arr' in self._debug['entries']:
self._debug['entries']['arr'] = []
self._debug['entries']['arr'].append({'start': self._io.pos()})
_t_entries = RenderwareBinaryStream(self._io)
_t_entries._read()
self.entries.append(_t_entries)
self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos()
i += 1
self._debug['entries']['end'] = self._io.pos()
class Triangle(KaitaiStruct):
SEQ_FIELDS = ["vertex2", "vertex1", "material_id", "vertex3"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['vertex2']['start'] = self._io.pos()
self.vertex2 = self._io.read_u2le()
self._debug['vertex2']['end'] = self._io.pos()
self._debug['vertex1']['start'] = self._io.pos()
self.vertex1 = self._io.read_u2le()
self._debug['vertex1']['end'] = self._io.pos()
self._debug['material_id']['start'] = self._io.pos()
self.material_id = self._io.read_u2le()
self._debug['material_id']['end'] = self._io.pos()
self._debug['vertex3']['start'] = self._io.pos()
self.vertex3 = self._io.read_u2le()
self._debug['vertex3']['end'] = self._io.pos()
class Frame(KaitaiStruct):
"""
.. seealso::
Source - https://www.gtamodding.com/wiki/Frame_List_(RW_Section)#Structure
"""
SEQ_FIELDS = ["rotation_matrix", "position", "cur_frame_idx", "matrix_creation_flags"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['rotation_matrix']['start'] = self._io.pos()
self.rotation_matrix = self._root.Matrix(self._io, self, self._root)
self.rotation_matrix._read()
self._debug['rotation_matrix']['end'] = self._io.pos()
self._debug['position']['start'] = self._io.pos()
self.position = self._root.Vector3d(self._io, self, self._root)
self.position._read()
self._debug['position']['end'] = self._io.pos()
self._debug['cur_frame_idx']['start'] = self._io.pos()
self.cur_frame_idx = self._io.read_s4le()
self._debug['cur_frame_idx']['end'] = self._io.pos()
self._debug['matrix_creation_flags']['start'] = self._io.pos()
self.matrix_creation_flags = self._io.read_u4le()
self._debug['matrix_creation_flags']['end'] = self._io.pos()
class TexCoord(KaitaiStruct):
SEQ_FIELDS = ["u", "v"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['u']['start'] = self._io.pos()
self.u = self._io.read_f4le()
self._debug['u']['end'] = self._io.pos()
self._debug['v']['start'] = self._io.pos()
self.v = self._io.read_f4le()
self._debug['v']['end'] = self._io.pos()
class StructTextureDictionary(KaitaiStruct):
SEQ_FIELDS = ["num_textures"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['num_textures']['start'] = self._io.pos()
self.num_textures = self._io.read_u4le()
self._debug['num_textures']['end'] = self._io.pos()
|