Moguri / blend2bam

A CLI tool to convert Blender blend files to Panda3D BAM files
MIT License
66 stars 17 forks source link

Incorrect Texture Path #49

Closed thetestgame closed 3 years ago

thetestgame commented 3 years ago

When trying to convert a fbx model from the Unity AssetStore to blend then to bam via blend2bam I discovered blend2bam tries to read the image texture based on its name not its actual file name. This fbx file uses a name different then the set filename for the image.

:gobj(error): Texture::read() - couldn't read: %E8%B4%B4%E5%9B%BE%20740.png
:gobj(error): Unable to find texture "%E8%B4%B4%E5%9B%BE%20740.png" on model-path /d/dev/Nxt Games/lowpoly/assets/models/cliffs;/c/Users/nxtla/AppData/Local/Temp;/c/Panda3D-1.11.0-x64/python/Scripts/blend2bam.exe;/c/Panda3D-1.11.0-x64/etc/..;/c/Panda3D-1.11.0-x64/etc/../models
Could not find texture for key: 0

Got: %E8%B4%B4%E5%9B%BE%20740.png (https://gyazo.com/02deffbf6c7d4d79465b7f88846e012e) Expected: ZLPP_Plant.tif

rdb commented 3 years ago

Yes, I can confirm this. This is a pressing issue, because this results in any models with a texture whose name does not match its filename to fail to be exported with textures, with this message:

Warning: Failed to find image data for texture-file-basename-without-extension-here, skipping
Traceback (most recent call last):
  File "/home/rdb/lab/blend2bam/blend2bam/blend2gltf/../blender_script_common.py", line 32, in convert_files
    convertfn(settings, src, dst)
  File "/home/rdb/lab/blend2bam/blend2bam/blend2gltf/blender28_script.py", line 179, in export_gltf
    fix_image_uri(gltf_data)
  File "/home/rdb/lab/blend2bam/blend2bam/blend2gltf/blender28_script.py", line 85, in fix_image_uri
    if blender_img.source == 'FILE':
AttributeError: 'NoneType' object has no attribute 'source'
rdb commented 3 years ago

The mechanism that blend2bam is using to match Blender images to glTF images is extremely fragile, since the glTF exporter uses a relatively complex mechanism to determine the name. It needs to be rethought, but let me see if I can come up with a quick stopgap solution for the common case.