johnzero7 / XNALaraMesh

Blender addon Import/Export XPS Models, Poses
525 stars 94 forks source link

Unable to import Tomb Raider binary mesh files #102

Closed nik6ena closed 1 year ago

nik6ena commented 1 year ago
Reading Header
Reading Bones
****************************************
pos len 66
pos str 178
pos 178
len 112
str b'\x00\x00\x8c\x00\x00\x00P(\x00\x00\x9c\x00\x00\x00@\x02\x00\x00\xa0\x00\x00\x00\x80(\x00\x00\xb0\x00\x00\x00\x00\x03\x00\x00\xb4\x00\x00\x00\xa0(\x00\x00\xc4\x00\x00\x00\xc0\x03\x00\x00\xc8\x00\x00\x00\xc0(\x00\x00\xd8\x00\x00\x00 \x07\x00\x00\xdc\x00\x00\x00p*\x00\x00\x00\x01\x00\x00\xb0&\x00\x00\x08\x01\x00\x00\x00\x0c\x00\x008\x01\x00\x000\x0c\x00\x00h\x01\x00\x00\x80\x0c\x00\x00\x98\x01\x00\x00\xd0\x0c'
Traceback (most recent call last):
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/bin_ops.py", line 87, in readString
    string = decodeBytes(byteString)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/bin_ops.py", line 107, in decodeBytes
    return bytes.decode(xps_const.ENCODING_READ)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/encodings/utf_8_sig.py", line 23, in decode
    (output, consumed) = codecs.utf_8_decode(input, errors, True)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8c in position 2: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/xps_tools.py", line 164, in execute
    status = import_xnalara_model.getInputFilename(xpsSettings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 78, in getInputFilename
    status = xpsImport()
             ^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 140, in xpsImport
    xpsData = loadXpsFile(xpsSettings.filename)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 104, in loadXpsFile
    xpsData = read_bin_xps.readXpsModel(filename)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/read_bin_xps.py", line 375, in readXpsModel
    bones = readBones(ioStream, xpsHeader)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/read_bin_xps.py", line 271, in readBones
    boneName = readFilesString(file)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/read_bin_xps.py", line 83, in readFilesString
    string = bin_ops.readString(file, length)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/bin_ops.py", line 95, in readString
    string = decodeBytes(byteString)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/bin_ops.py", line 107, in decodeBytes
    return bytes.decode(xps_const.ENCODING_READ)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/encodings/utf_8_sig.py", line 23, in decode
    (output, consumed) = codecs.utf_8_decode(input, errors, True)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8c in position 2: invalid start byte

Python 3.11 Blender 3.5 The mesh file is from the Tomb Raider 2013 game.

nik6ena commented 1 year ago

So I changed the byte codec to 'iso-8859-1' and got past that error

Reading Header
Reading Bones
Read 89 Bones
Reading Meshes
Read 0 Meshes
Importing Armature 89 bones
Traceback (most recent call last):
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/xps_tools.py", line 164, in execute
    status = import_xnalara_model.getInputFilename(xpsSettings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 78, in getInputFilename
    status = xpsImport()
             ^^^^^^^^^^^
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 155, in xpsImport
    importBones(armature_ob)
  File "/home/nik/.config/blender/3.5/scripts/addons/XNALaraMesh/import_xnalara_model.py", line 350, in importBones
    editBone.parent = armature_ob.data.edit_bones[bone.parentId]
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
IndexError: bpy_prop_collection[index]: index 2048 out of range, size 89
nik6ena commented 1 year ago

Probably it's file format and tool incompatibility.

Looks like I will have to reverse engineer my way out of this.