godotengine / godot-blender-exporter

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

Invisible mesh after export to godot #43

Closed dodgyville closed 5 years ago

dodgyville commented 6 years ago

Hi,

I have an fbx that I open in blender - it looks fine and the animation (of a woman standing idle) plays fine. When I open the escn file in godot created by this exporter, it all appears to load (the layers and animationplayer are there) but the meshes are invisible. The animation seems to play but I can't see the character. The meshes (body, shoes, clothes, etc) are visible in the inspector but not in the editor window. Any suggestions appreciated!

Here's the fbx file (~36mb) https://drive.google.com/open?id=1-2tAMi7XbvjBJqJDYc8mPVgJZnRXR1B2

Zireael07 commented 6 years ago

What was the scale/units in blender? Most likely your mesh is very very tiny in Godot.

Jason0214 commented 6 years ago

in fbx the armature scale is 0.01, when I manually set it to 1 and export, the issue still exists, so it is a bug.

In Godot when I move all the mesh out of Skeleton node, they all got correctly visualized. Mostly likely the issue exists in bone weights exporting, (I remember Godot will not display a mesh under Skeleton but with no bone weights).

dodgyville commented 6 years ago

So from #44 are we saying that the bounding box of the parent node of mesh should be larger than the children AABBs?

I had a quick look at doing it in gdscript using a code snippet like this:

func _ready():
    var armature = get_node("Armature") # a Skeleton
    var new_aabb = armature.get_aabb()
    for mesh_instance in armature.get_children():
        new_aabb = new_aabb.merge(mesh_instance.get_aabb())
    armature.aabb = new_aabb

but Skeleton does not appear to have an bounding box at all

Jason0214 commented 6 years ago

ah seems my fault, yes, Skeleton has no AABB, ( I will delete that comment

Jason0214 commented 6 years ago

checked this issue again,

in the Armature node there is no bone listed image

when play the bone animation, you can see the bounding box move image

so I suppose the bone is imported but not get displayed, maybe some bone names cause issue?

OBKF commented 5 years ago

I have the same error when using Mixamo animations (a lot of people do) and not only this exporter if you try Better Collada or any other exporter it will happen. I got this error when I imported the model (a lot of other similar errors and another ones that I couldn't get because of the short history on the windows console): ERROR: get_bone_rest: Index p_bone=6 out of size (bones.size()=0) At: scene/3d/skeleton.cpp:496 ERROR: mesh_surface_get_index_array: Condition ' surface->index_array_len == 0 ' is true. returned: PoolVector<uint8_t>()

OBKF commented 5 years ago

Actually if you change the parent of the mesh to be the root it will show-up so the Skeleton is the problem here image

OBKF commented 5 years ago

I made it work

image

image

The problem was in the naming of the armature, bones and vertex groups, I made a small Python script that you can run in Blender to change the names of the bones and vertex groups:

import bpy

for rig in bpy.context.selected_objects:
    if rig.type == 'ARMATURE':
        for mesh in rig.children:
            for vg in mesh.vertex_groups:
                #print(vg.name)
                new_name = vg.name
                new_name = new_name.replace("mixamorig:","")
                #print(new_name)
                rig.pose.bones[vg.name].name = new_name
                vg.name = new_name
        for bone in rig.pose.bones:
            #print(bone.name.replace("mixamorig:",""))
            bone.name = bone.name.replace("mixamorig:","")

for action in bpy.data.actions:
    print(action.name)
    fc = action.fcurves
    for f in fc:
        #print(f.data_path)    
        f.data_path = f.data_path.replace("mixamorig:","")
Jason0214 commented 5 years ago

@OBKF so the ':' is the illegal character for bone name right? if you are willing, you can make a PR to add a filtering for bone names here and here, it would be very simple and useful. (Or I can do that for you

Thank you very much for spending time investigate this issue.

OBKF commented 5 years ago

One of the errors was:

ERROR: add_bone: Condition ' p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1 ' is true.
   At: scene/3d/skeleton.cpp:375

So as long as the name isn't empty or contains ":" or "/" it should be fine. I really don't have that mush time and it's 23:22 here, so please do the PR yourself.

Jason0214 commented 5 years ago

Ok, I will do it, thank you very much!

OBKF commented 5 years ago

You are welcome, I hope you can do the same for the Better Collada exporter as well as it's more used.

Jason0214 commented 5 years ago

I would create an issue in collada exporter, I don't familiar their code base so I am able to solve it immediately

akien-mga commented 5 years ago

Fixed by #105.

OBKF commented 5 years ago

Well done :D

dodgyville commented 5 years ago

Yes, I don't want to add to everyone's emails but it's so great this is fixed!

Favkis commented 1 year ago

2023, bug still not fixed, item is invisible, even though AABB box shows like its okay image

ClintochX commented 9 months ago

@Favkis Same is still have the sane issue, meshinstance is invisible when it has a skeleton.

I'm using bone names such as ss1, ss2, ss3, aa1, aa2, aa3...., origin, Transformer.

But I'm still having invisible sketal meshes