Closed PinkyAcorn closed 2 years ago
Script for unpacking .bin files
#!/usr/bin/env python3
from dataclasses import dataclass
from struct import iter_unpack, unpack
from sys import argv
from os import makedirs, path
HEADER_SIZE = 0x50
HEADER_FORMAT = '<68sIIxxxx'
@dataclass
class FileHeader:
name: str
size: int
offset: int
def read_data_offset(file):
file_offset = file.tell()
file.seek(0x48)
offset, = unpack('<I', file.read(0x4))
file.seek(file_offset)
return offset
def unpack_bin(binpath):
with open(binpath, 'rb') as bin:
data_offset = read_data_offset(bin)
header_count = int(data_offset / HEADER_SIZE)
headers = []
for i in range(header_count):
name, size, offset = unpack(HEADER_FORMAT, bin.read(HEADER_SIZE))
headers.append(FileHeader(
name.decode('shift_jis').rstrip('\0'),
size,
offset
))
_, binname = path.split(binpath)
base = path.join('out', binname)
makedirs(base, exist_ok=True)
for header in headers:
entrypath, entryname = path.split(header.name)
outdir = path.join(base, entrypath)
outfile = path.join(outdir, entryname)
makedirs(outdir, exist_ok=True)
with open(outfile, 'wb') as ofile:
print(f'Unpacking {header.name}')
bin.seek(header.offset)
ofile.write(bin.read(header.size))
if __name__ == '__main__':
for binpath in argv[1:]:
unpack_bin(binpath)
I'll see if I can get onto this at some point, thank you for letting me know!
Added support in the latest release
Just looking at game recources this weekend
The main data is located in "stash" dir as .bin files Bin files are simple containers with multiple files inside Main file types includes .snm, .sno, .svr
Using this plugin blender loads .sno files successfully but i really can't tell if it was loaded correctly I'm expecting to see game models but it looks like skeletons?