Skip to content

Commit

Permalink
Support custom RTY2 blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
eArmada8 committed Apr 23, 2024
1 parent dcb073b commit b80044e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ys8_it3_export_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ def process_it3 (it3_filename, complete_maps = complete_vgmaps_default, preserve
write_fmt_ib_vb(meshes[i]["meshes"][j], it3_filename[:-4] +\
'/meshes/{0}_{1:02d}'.format(safe_filename, j),\
node_list = meshes[i]["node_list"], complete_maps = complete_maps)
rty2_blocks = [j for j in range(len(it3_contents)) if it3_contents[j]['type'] == 'RTY2'\
and it3_contents[j]['info_name'] == meshes[i]["name"]]
if len(rty2_blocks) > 0:
with open(it3_filename[:-4] + '/meshes/{0}.rty2'.format(safe_filename), 'wb') as f2:
f2.write(json.dumps(it3_contents[rty2_blocks[0]]['data'], indent = 4).encode('utf-8'))
print("Writing textures")
use_alpha = {}
for i in range(len(textures)):
Expand Down
15 changes: 15 additions & 0 deletions ys8_it3_import_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ def create_bon3 (bonemap, node_name):
+ create_data_blocks(b'') + create_data_blocks(b'')
return(b'BON3' + struct.pack("<I", len(bon3_block_data)) + bon3_block_data)

def create_rty2 (rty2_data):
rty2_block_data = struct.pack("<I", rty2_data['material_variant']) \
+ struct.pack("<B", rty2_data['unknown']) \
+ struct.pack("<3f", *rty2_data['v0'])
return(b'RTY2' + struct.pack("<I", len(rty2_block_data)) + rty2_block_data)

def rapid_parse_it3 (f):
file_length = f.seek(0,2)
f.seek(0,0)
Expand Down Expand Up @@ -309,6 +315,11 @@ def process_it3 (it3_filename, import_noskel = False):
bonemap = read_struct_from_json(it3_filename[:-4] + '/meshes/{}.bonemap'.format(section))
bon3_block = create_bon3(bonemap, section)
custom_bonemap = True
custom_rty2 = False
if os.path.exists(it3_filename[:-4] + '/meshes/{}.rty2'.format(section)):
rty2_data = read_struct_from_json(it3_filename[:-4] + '/meshes/{}.rty2'.format(section))
rty2_block = create_rty2(rty2_data)
custom_rty2 = True
while f.tell() < it3_contents[section]['offset']+it3_contents[section]['length']:
section_info = {}
section_info["type"] = f.read(4).decode('ASCII')
Expand All @@ -329,6 +340,10 @@ def process_it3 (it3_filename, import_noskel = False):
f.seek(section_info["size"],1)
if len(submeshfiles) > 0:
new_it3 += bon3_block
elif (section_info["type"] == 'RTY2') and custom_rty2 == True:
f.seek(section_info["size"],1)
if len(submeshfiles) > 0:
new_it3 += rty2_block
elif (section_info["type"] == 'TEXI'):
f.seek(section_info["size"],1)
else:
Expand Down

0 comments on commit b80044e

Please sign in to comment.