Moguri / BlenderPanda

Blender addon for integrating Panda3D
MIT License
76 stars 11 forks source link

Error exporting models built with Sprytile #36

Closed ZedCode closed 6 years ago

ZedCode commented 6 years ago

I'm not sure why:

Read prefs: ~/.config/blender/2.79/config/userpref.blend
found bundled python: ~/.steam/steam/steamapps/common/Blender/2.79/python
Read blend: ~/development/games/blenderPandaTest2/assets/level.blend
Starting build
Read assets from: ~/development/games/blenderPandaTest2/assets/
Export them to: ~/development/games/blenderPandaTest2/game/assets/
Ignoring file patterns: ['*.blend1', '*.blend2']
Adding ~/development/games/blenderPandaTest2/assets/level.blend to conversion list to satisfy ~/development/games/blenderPandaTest2/game/assets/level.bam
Skip building file level.blend1 that matched ignore pattern *.blend1
Read prefs: ~/.config/blender/2.79/config/userpref.blend
found bundled python: ~/.steam/steam/steamapps/common/Blender/2.79/python
Converting .blend file (~/development/games/blenderPandaTest2/assets/level.blend) to .bam (~/development/games/blenderPandaTest2/game/assets/level.bam)
Read blend: ~/development/games/blenderPandaTest2/assets/level.blend
Error: Traceback (most recent call last):
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/operators.py", line 78, in execute
    data = blendergltf.export_gltf(scene_delta, gltf_settings)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in export_gltf
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in <dictcomp>
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1794, in <listcomp>
    for data in state['input'].get(exporter.blender_key, [])
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in export_mesh
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in <dictcomp>
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in __init__
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in <genexpr>
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
IndexError: bpy_prop_collection[index]: index 0 out of range, size 0

location: ~/.steam/steam/steamapps/common/Blender/2.79/scripts/modules/bpy/ops.py:189

Traceback (most recent call last):
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/operators.py", line 78, in execute
    data = blendergltf.export_gltf(scene_delta, gltf_settings)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in export_gltf
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in <dictcomp>
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1794, in <listcomp>
    for data in state['input'].get(exporter.blender_key, [])
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in export_mesh
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in <dictcomp>
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in __init__
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in <genexpr>
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
IndexError: bpy_prop_collection[index]: index 0 out of range, size 0

location: ~/.steam/steam/steamapps/common/Blender/2.79/scripts/modules/bpy/ops.py:189

location: ~/.steam/steam/steamapps/common/Blender/2.79/scripts/modules/bpy/ops.py:189
Error: Traceback (most recent call last):
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/operators.py", line 78, in execute
    data = blendergltf.export_gltf(scene_delta, gltf_settings)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in export_gltf
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in <dictcomp>
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1794, in <listcomp>
    for data in state['input'].get(exporter.blender_key, [])
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in export_mesh
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys(Traceback (most recent call last):
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/pman/pman/../pman/pman_build.py", line 43, in <module>
    main()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/pman/pman/../pman/pman_build.py", line 39, in main
    bpy.ops.panda_engine.export_bam(filepath=dst, copy_images=False, skip_up_to_date=True)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/modules/bpy/ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/operators.py", line 78, in execute
    data = blendergltf.export_gltf(scene_delta, gltf_settings)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in export_gltf
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1795, in <dictcomp>
    ] for exporter in exporters
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 1794, in <listcomp>
    for data in state['input'].get(exporter.blender_key, [])
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in export_mesh
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 785, in <dictcomp>
    vert_list = {Vertex(mesh, loop): 0 for loop in mesh.loops}.keys()
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in __init__
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
  File "~/.steam/steam/steamapps/common/Blender/2.79/scripts/addons/BlenderPanda/blendergltf/blendergltf.py", line 109, in <genexpr>
    self.uvs = tuple(layer.data[loop_idx].uv[:] for layer in mesh.uv_layers)
IndexError: bpy_prop_collection[index]: index 0 out of range, size 0

location: ~/.steam/steam/steamapps/common/Blender/2.79/scripts/modules/bpy/ops.py:189

... truncated
Blender quit
Build took 0.6751s

The error leads me to believe it has something to do with the way this plug-in sets up UVs?

ZedCode commented 6 years ago

This is interesting...I updated my operators.py file starting at line 93 to look like this:

try:
    json.dump(data, f)
except:
    print(data)

Now when I try to run the conversion I see:

Converting .blend file (~/development/games/reproduce/assets/tmp.blend) to .bam (~/development/games/reproduce/game/assets/tmp.bam)
Read blend: ~/development/games/reproduce/assets/tmp.blend
{'meshes': {'meshes_Cube': {'primitives': [{'indices': 'accessors_accessor_buffer_Cube_3', 'mode': 4, 'attributes': {'POSITION': 'accessors_accessor_buffer_Cube_0', 'TEXCOORD_0': 'accessors_accessor_buffer_Cube_2', 'NORMAL': 'accessors_accessor_buffer_Cube_1'}, 'material': 'materials_scifi_tiles'}], 'name': 'Cube'}}, 'scene': 'scenes_Scene', 'cameras': {'cameras_Camera': {'perspective': {'aspectRatio': 1.703595982340029, 'zfar': 100.0, 'yfov': 0.5033799409866333, 'znear': 0.10000000149011612}, 'name': 'Camera', 'type': 'perspective'}}, 'scenes': {'scenes_Scene': {'extras': {'active_camera': 'cameras_Camera', 'background_color': (0.05087608844041824, 0.05087608844041824, 0.05087608844041824), 'frames_per_second': 24, 'sprytile_mats': [<bpy id prop: owner="SCScene", name="", address=0x7fb063282628>]}, 'nodes': ['nodes_Cube', 'nodes_Lamp', 'nodes_Camera'], 'name': 'Scene', 'extensions': {'BLENDER_physics': {'gravity': -9.8100004196167}}}}, 'textures': {'textures_scifi_tiles.png': {'internalFormat': 35906, 'sampler': 'samplers_scifi_tiles.png', 'source': 'images_scifi_tiles.png', 'name': 'scifi_tiles.png', 'format': 35906}}, 'samplers': {'samplers_scifi_tiles.png': {'minFilter': 9728, 'wrapS': 10497, 'magFilter': 9728, 'name': 'scifi_tiles.png', 'wrapT': 10497}}, 'extensions': {'KHR_materials_common': {'lights': {'lights_Lamp': {'name': 'Lamp', 'type': 'point', 'point': {'color': (1.0, 1.0, 1.0), 'constantAttenuation': 1, 'linearAttenuation': 0, 'quadraticAttenuation': 0.03333335240683057}}}}}, 'bufferViews': {'bufferViews_bufferView_buffer_Cube_0': {'byteOffset': 0, 'byteLength': 1536, 'buffer': 'buffers_buffer_Cube', 'name': 'bufferView_buffer_Cube_0', 'target': 34962}, 'bufferViews_bufferView_buffer_Cube_1': {'byteOffset': 1536, 'byteLength': 144, 'buffer': 'buffers_buffer_Cube', 'name': 'bufferView_buffer_Cube_1', 'target': 34963}}, 'nodes': {'nodes_Camera': {'rotation': (0.483536034822464, 0.20870360732078552, 0.33687159419059753, 0.7804827094078064), 'camera': 'cameras_Camera', 'translation': (7.481131553649902, -6.5076398849487305, 5.34366512298584), 'name': 'Camera', 'scale': (1.0, 1.0, 1.0)}, 'nodes_Lamp': {'rotation': (0.16907575726509094, 0.27217137813568115, 0.7558802962303162, 0.570947527885437), 'translation': (4.076245307922363, 1.0054539442062378, 5.903861999511719), 'name': 'Lamp', 'extensions': {'KHR_materials_common': {'light': 'lights_Lamp'}}, 'scale': (1.0, 0.9999999403953552, 1.0)}, 'nodes_Cube': {'rotation': (0.0, 0.0, 0.0, 1.0), 'meshes': ['meshes_Cube'], 'translation': (0.0, 0.0, 0.0), 'extras': {'sprytile_gridid': 0}, 'name': 'Cube', 'scale': (1.0, 1.0, 1.0)}}, 'extensionsUsed': ['KHR_materials_common', 'BLENDER_physics'], 'asset': {'version': '1.0', 'profile': {'version': '3.0', 'api': 'OpenGL'}}, 'materials': {'materials_scifi_tiles': {'name': 'scifi_tiles', 'extensions': {'KHR_materials_common': {'technique': 'CONSTANT', 'values': {'doubleSided': False, 'transparent': True, 'transparency': 0.0, 'emission': 'textures_scifi_tiles.png', 'diffuse': 'textures_scifi_tiles.png', 'specular': [0.5, 0.5, 0.5, 1.0], 'ambient': [1.0, 1.0, 1.0, 1.0], 'shininess': 50}}}}}, 'glExtensionsUsed': [], 'accessors': {'accessors_accessor_buffer_Cube_0': {'byteOffset': 0, 'max': [2.0, 2.0, 0], 'bufferView': 'bufferViews_bufferView_buffer_Cube_0', 'byteStride': 32, 'componentType': 5126, 'type': 'VEC3', 'name': 'accessor_buffer_Cube_0', 'count': 48, 'min': [-1.0, -2.0, 0.0]}, 'accessors_accessor_buffer_Cube_3': {'byteOffset': 0, 'max': [47], 'bufferView': 'bufferViews_bufferView_buffer_Cube_1', 'byteStride': 2, 'componentType': 5123, 'type': 'SCALAR', 'name': 'accessor_buffer_Cube_3', 'count': 72, 'min': [0]}, 'accessors_accessor_buffer_Cube_2': {'byteOffset': 24, 'max': [0.3749023377895355, 0.9999290108680725], 'bufferView': 'bufferViews_bufferView_buffer_Cube_0', 'byteStride': 32, 'componentType': 5126, 'type': 'VEC2', 'name': 'accessor_buffer_Cube_2', 'count': 48, 'min': [9.765475988388062e-05, 0.7273437976837158]}, 'accessors_accessor_buffer_Cube_1': {'byteOffset': 12, 'max': [0, 0, 1.0], 'bufferView': 'bufferViews_bufferView_buffer_Cube_0', 'byteStride': 32, 'componentType': 5126, 'type': 'VEC3', 'name': 'accessor_buffer_Cube_1', 'count': 48, 'min': [0.0, 0.0, 1.0]}}, 'buffers': {'buffers_buffer_Cube': {'byteLength': 1680, 'name': 'buffer_Cube', 'type': 'arraybuffer', 'uri': 'data:application/octet-stream;base64,AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/mhkAPgV5UT8AAIA/AACAPwAAAAAAAAAAAAAAAAAAgD/NDIA+tm9RPwAAAAAAAAAAAAAAAAAAAAAAAAAAAACAP2bmfz7Xvmg/AACAvwAAgD8AAAAAAAAAAAAAAAAAAIA/ZuZ/Pln7fz8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD+aGQA+tm9RPwAAgL8AAAAAAAAAAAAAAAAAAAAAAACAP2bmfz5Z+38/AAAAQAAAgD8AAAAAAAAAAAAAAAAAAIA/ZuZ/PjQzOj8AAABAAACAvwAAAAAAAAAAAAAAAAAAgD/NzP89NDM6PwAAgD8AAIC/AAAAAAAAAAAAAAAAAACAP5oZAD4FeVE/AACAvwAAAAAAAAAAAAAAAAAAAAAAAIA/mhkAPln7fz8AAABAAAAAAAAAAAAAAAAAAAAAAAAAgD+aGQA+NDM6PwAAgD8AAADAAAAAAAAAAAAAAAAAAACAPwDMzDgFeVE/AACAPwAAgD8AAAAAAAAAAAAAAAAAAIA/zQyAPgV5UT8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD9m5n8+tm9RPwAAAAAAAADAAAAAAAAAAAAAAAAAAACAPwDMzDiHtWg/AACAv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AAAIA/zQyAPjQzOj8AAIC/AACAvwAAAAAAAAAAAAAAAAAAgD+aGQA+Wft/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAACAP5oZAD6HtWg/AAAAAAAAAEAAAAAAAAAAAAAAAAAAAIA/M/O/Poe1aD8AAIA/AACAvwAAAAAAAAAAAAAAAAAAgD+aGQA+tm9RPwAAgD8AAABAAAAAAAAAAAAAAAAAAACAPzPzvz4FeVE/AACAvwAAgL8AAAAAAAAAAAAAAAAAAIA/zcz/PVn7fz8AAAAAAACAvwAAAAAAAAAAAAAAAAAAgD/NzP89h7VoPwAAAAAAAAAAAAAAAAAAAAAAAAAAAACAP2bmfz6HtWg/DgALACIADgAiAC4ADwAXAB0ADwAdAC0AIQAIABkAIQAZAC8ACQAfABYACQAWAAMAKAAUAAIAKAACAAUAFQAmABEAFQARACAAKQAAABMAKQATABoAGwAMACwAGwAsACoAEAAjAAcAEAAHABwAKwAlABgAKwAYAA0ABAAKAAYABAAGABIAAQAnAB4AAQAeACQA'}}, 'images': {'images_scifi_tiles.png': {'name': 'scifi_tiles.png', 'uri': '../../../../Downloads/scifi_tiles.png'}}}

I'm guessing the base64 encoded junk is the issue?

ZedCode commented 6 years ago

Ah, wait, it's:

'sprytile_mats': [<bpy id prop: owner="SCScene", name="", address=0x7fb063282628>]

Is not valid JSON.

Moguri commented 6 years ago

Can you please supply a blend file demonstrating this issue? Thanks!

ZedCode commented 6 years ago

You should be able to checkout this repo: https://github.com/ZedCode/problematicBlend turn it into a BlenderPanda project and observe that it creates the intermediary file but not the final .bam file.

Moguri commented 6 years ago

The model is now exporting for me without errors with 75dd34cbf00ed3a40851ffa412457d1763af8da2. It also looks correct in pview. Do you have any other files showing issues with Sprytile?

Moguri commented 6 years ago

Closing this due to inactivity. @ZedCode, if you're still having issues, feel free to re-open this issue or create a new one.