godotengine / godot-blender-exporter

Addon for Blender to directly export to a Godot Scene
GNU General Public License v2.0
1.16k stars 132 forks source link

KeyError from export_morphs when attempting to export shape keys #412

Open JWBWork opened 2 years ago

JWBWork commented 2 years ago

OS: WIN 10

Godot version: v3.4.2-stable_win64

Blender version: 3.0

Issue description: installed the plugin, when I try to export to escn I get this error:

  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\__init__.py", line 233, in execute
    return export_godot.save(self, context, **keywords)
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\export_godot.py", line 325, in save
    exp.export()
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\export_godot.py", line 276, in export
    self.export_scene()
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\export_godot.py", line 220, in export_scene
    self.export_object(obj, root_gd_node)
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\export_godot.py", line 161, in export_object
    self.export_object(child, exported_node)
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\export_godot.py", line 130, in export_object
    exported_node = exporter(self.escn_file, self.config, obj,
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\converters\mesh.py", line 45, in export_mesh_node
    mesh_id = mesh_exporter.export_mesh(escn_file, export_settings)
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\converters\mesh.py", line 172, in export_mesh
    self.generate_surfaces(
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\converters\mesh.py", line 318, in generate_surfaces
    self.export_morphs(export_settings, surfaces)
  File "C:\Users\Jacob\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\io_scene_godot\converters\mesh.py", line 249, in export_morphs
    vertex_index = surface.vertex_index_map[loop_index]
KeyError: 9957

location: <unknown location>:-1

Since it's the export_morphs function having an issue I tried exporting again with Export Shape Key disabled, and it was able to export. There were a lot of warnings saying Vertex weights more than maximal and Skip bone fcurves of Armature object not being exported. object 'Female.Body'

JWBWork commented 2 years ago

little follow-up - I still get all the warnings, but after a fresh reinstall of blender 3.0 I was able to get a functional export. Unfortunately, not all animations are exported and my mesh looks like this...

Assuming whatever causes those warnings is causing this? Does anyone know what might be causing all these warnings to appear a lot during export?

Skip bone fcurves of Armature object not being exported. object 'Body'
Vertex weights more than maximal
JWBWork commented 2 years ago

Also while my shape keys are imported they tear apart the mesh when used

image

JWBWork commented 2 years ago

Alright, so I think a lot of these issues were the result of blender being unable to apply modifiers when you have shape keys. Thankfully this excellent addon lets you apply your modifiers and keep your shape keys which I can apply before exporting and rollback.

the escn exporter might be better, I see blend shapes on the mesh, but the mesh is invisible now

the gltf export looks better, but that doesn't import the armature as a skeleton node, just a bunch of spacial nodes

JWBWork commented 2 years ago

Alright, I've found a solution using the gltf exporter.

This problem has something to do with shape keys and modifiers. I use the addon above to apply all my modifiers except for the armature, which stays for exporting. So now gltf works as expected, but this plugin still gives me an invisible mesh when I try to export to escn