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

Blender 2.8 error trying to export with Rigify Armature. #154

Open Angeloss opened 5 years ago

Angeloss commented 5 years ago

OS: Windows 10

Blender version: 2.8

Issue description: I don't know if it is related to Rigify , but I got the error:

Traceback (most recent call last):
  File "D:\Development\GameCoder\InternalProjects\Blender-src\build_windows_Full_x64_vc15_Release\bin\Release\2.80\scripts\addons\io_scene_godot\__init__.py", line 190, in execute
    return export_godot.save(self, context, **keywords)
  File "D:\Development\GameCoder\InternalProjects\Blender-src\build_windows_Full_x64_vc15_Release\bin\Release\2.80\scripts\addons\io_scene_godot\export_godot.py", line 246, in save
    exp.export()
  File "D:\Development\GameCoder\InternalProjects\Blender-src\build_windows_Full_x64_vc15_Release\bin\Release\2.80\scripts\addons\io_scene_godot\export_godot.py", line 210, in export
    self.export_scene()
  File "D:\Development\GameCoder\InternalProjects\Blender-src\build_windows_Full_x64_vc15_Release\bin\Release\2.80\scripts\addons\io_scene_godot\export_godot.py", line 176, in export_scene
    if self.should_export_object(obj):
  File "D:\Development\GameCoder\InternalProjects\Blender-src\build_windows_Full_x64_vc15_Release\bin\Release\2.80\scripts\addons\io_scene_godot\export_godot.py", line 162, in should_export_object
    if self.config["use_export_selected"] and not obj.select:
AttributeError: 'Object' object has no attribute 'select'

location: <unknown location>:-1

I checked the "Selected Objects" option.

Minimal reproduction project:

Jason0214 commented 5 years ago

fixed by #155

Angeloss commented 5 years ago

I'm sorry but it is still not possible to export the model correctly with Rigify armature. This is the model I'm trying to export: PlayerCharacter.zip Thank you.

Jason0214 commented 5 years ago

I can confirm the exporting crashed at some point exporting rig animation. The exporter have not really take Rigify and Animation Driver into account yet, so most likely it is related to them.

Angeloss commented 5 years ago

Thank you very much for checking this out. You Rocks!

Angeloss commented 5 years ago

In an effort to try and test your changes in the pull request I opened and saved my 2.7 file(because the "better collada exporter") in 2.8 and now I can't open it back in 2.7 to export. :sweat: :cry:. Regarding the exporter, it seems that only exports the animation selected in the Dope Sheet Action Editor and sets the pose of the Mesh in that Action, but the rig imports as A-Pose in Godot and also the info of the animation is wrong.

image

image

image

Now I'm going to try to append the animations from the 2.8 file to a new 2.7 file. :disappointed:

Jason0214 commented 5 years ago

Ah, sorry for the trouble.. yeah it's annoying 2.8 blend file can not revert to 2.7.

I just made another try with the branch HEAD, it comes out fine on mine. By looking at how deformed your screenshot is, I wonder are you export to the escn file which is opened in Godot? Sometimes, it cause very wild deform. If so, try to clear the .import folder and .import file and export it again. Thanks

Angeloss commented 5 years ago

You are right. It works! I just find out that the mesh is posed as the top Action Stash while the Armature is posed in Default. To make it works the "Default Pose Action" needs to be at the top of the stash. image

image


image

image

And materials exports weird, as shader materials instead of spatial materials :sweat_smile: but that's easily fixable, thank you very much!

Now that we have this power, how can we put custom/engine properties, like if an object should have a particular script, or parameter values things like that, is it posible?

Again, thank you!! :metal:

Jason0214 commented 5 years ago

Glad you have made it work! And thanks for your patience :D

I just find out that the mesh is posed as the top Action Stash while the Armature is posed in Default. To make it works the "Default Pose Action" needs to be at the top of the stash.

Are you suggesting the A-Pose only exports when putting on the top of the stack? I am not very clear about this part. If it is something need user to pay attention only to make it work, it is bad, it should better be handled by scripts.

how can we put custom/engine properties, like if an object should have a particular script, or parameter values things like that, is it posible

I think it is exactly why this addon is brought up by community, everything is possible as any godot scene can be fully described by ESCN/TSCN. Though, still a lot work needs to be done at this addon side.

And materials exports weird, as shader materials instead of spatial materials

Actually now it is designed to exporting Shader Material.., because Shader Material is able to cover general CYCLE/EEVEE shader node tree. A little more complex shader (e.g. with any converter node) would be not able to export to Spatial Material. However, Spatial Material could be useful for shader tree with only one shader and texture input, so I opened #158.

By the way I checked your blend file, most of the materials should be successfully exported as Shader Material, but I noticed your screenshot is all black 😂. If you want, you can just open another issue about the material

Jason0214 commented 5 years ago

close this issue as the main animation bug is fixed, feel free to open new issues if you think the exporting workflow need improvement.

Angeloss commented 5 years ago

Hi! Sorry for late reply.

Are you suggesting the A-Pose only exports when putting on the top of the stack? I am not very clear about this part. If it is something need user to pay attention only to make it work, it is bad, it should better be handled by scripts.

The Mesh is posed and exported as the top action, here in the screenshot you can see that my top action is "CharacterIdle":

image

When opened in Godot, you can see that the Armature is posed in its Rest Position but the Mesh pose is the "CharacterIdle", when this happens the animations are broken because the mesh is not in sync with the armature. So yes, it is something the user needs to pay attention. I think at least should be documented somewhere.

image

It wold be nice to have spatial materials for simple Principled BSDF configurations though😄

Another think I found is that animations with "_loop" suffix are not marked as loop in Godot. I think I could open an issue about this little enhance.

Thank you so much for your help 😃

Jason0214 commented 5 years ago

you can see that the Armature is posed in its Rest Position but the Mesh pose is the "CharacterIdle", when this happens the animations are broken because the mesh is not in sync with the armature.

Got it, it is a bug (actually a regression I solved this for blender2.79) that exported mesh is deformed by armature

Angeloss commented 5 years ago

I just found out another thing the user needs to be aware off in order to export correctly. In the Blender NLA only the Armature has to be checked/selected, otherwise the export will be broken.

alldisabled

alldisabledbutone

onlyarmature

Rigards!

Jason0214 commented 5 years ago

When opened in Godot, you can see that the Armature is posed in its Rest Position but the Mesh pose is the "CharacterIdle", when this happens the animations are broken because the mesh is not in sync with the armature.

weird, I tried a lot and can not reproduces this issue 🤔, all the exported mesh is in not deformed by armature (i.e. in REST position) . Also I think the exporter has some code making sure exported mesh is not deformed. So I am kind of lost on this issue.


I just found out another thing the user needs to be aware off in order to export correctly. In the Blender NLA only the Armature has to be checked/selected, otherwise the export will be broken.

Thanks for post this here, it is a bug. I will add some fix to make sure animation can be correctly exported when the object is mute. Also update the doc.