KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 316 forks source link

Enhancement request - What is the neutral bone for? Add a warning when neutral bone is being added. - Add hook to change neutral_bone #2303

Closed ronh991 closed 2 weeks ago

ronh991 commented 1 month ago

Describe the bug The neutral bone is causing me trouble. What is if for? THE MSFS build process does not like it - it's a naming issue. Does the neutral bone get use numerous times? Is there a way to stop it from being added to the glTF files?

I know there is nothing you can do directly - I am just trying to figure out how to not add it to my exporter gltf.

scurest commented 1 month ago

1151

ronh991 commented 1 month ago

Thankyou - Now it was not my intension to have missing vertices for skinning, I'll change this to an enhancement requires to push a warning out to the console that a neutral bone is being added and display what mesh it's being added to.

For 3.6 and 4.2 LTS

ronh991 commented 1 month ago

I am trying to understand how to fix my issue. Are you saying that parenting an armature to a mesh and the automatic weights have some vertices set to zero (or blue) is forcing a vertex to be associated to a neutral_bone?

If the mesh vertex did not have a zero weight then the neutral bone would not be needed?

Is this neutral bone added to multiple armatures if my blend file has more than one?

ronh991 commented 1 month ago

Can I use a hook to remove this neutral?

ronh991 commented 1 month ago

Further to this. An additional enhancement request - Since the exporter may be used for game requirements, Perhaps other ganes need unique naming for the meshes and armatures.

In MSFS we use two gltf files and combine them. If both glTF files have the same name for armature bones then I get a naming conflict.

Additional enhancement is to make the neutral_bone name _neutral_bone

Still requesting a log warning in the console

ronh991 commented 1 month ago

Is there a hook I can use to find this neutral_bone and change it's name in my add-on?

ronh991 commented 1 month ago

I can't seem to get gather_scene_hook or gather_gltf_hook to work. vtree is not accessible

ronh991 commented 1 month ago

In order to properly use your neutral_bone - require access to the vtree - or somehow I need to add an extension to that added bone. Can you suggest a way - or add vtree to be modified?

You add this

        {
            "name":"neutral_bone",
            "rotation":[
                -0.7071067690849304,
                0,
                0,
                0.7071067690849304
            ]
        },

I need to be able to modify it to add

        {
            "extensions":{
                "ASOBO_unique_id":{
                    "id":"neutral_bone1"
                }
            },
            "name":"neutral_bone1",
            "rotation":[
                -0.7071067690849304,
                0,
                0,
                0.7071067690849304
            ]
        },

I have to be able to change the name and add the extension

ronh991 commented 1 month ago

Any chance you can add a hook in the add_neutral_bones function in gltf2_blender_gather_tree.py with the neutral_bone as an argument?

This way I could change the name and add the extension as a gltf2_node.

julienduroure commented 1 month ago

Hello,

Can I use a hook to remove this neutral?

No, remove it is a bad idea. This will generate a not valid glTF file. A better idea is to fix your model to be sure that any vertices are skinned, if you want to avoid this neutral bone.

enhancement requires to push a warning out to the console that a neutral bone is being added and display what mesh it's being added to

Yes, Added in TODO list

Are you saying that parenting an armature to a mesh and the automatic weights have some vertices set to zero (or blue) is forcing a vertex to be associated to a neutral_bone?

Yes. If there are some 0 weights => The neutral bone will be added. If no 0 weights => Not added

Is this neutral bone added to multiple armatures if my blend file has more than one?

Have to double check, but yes, if I remember correctly, a neutral bone is added for each armature/skeleton where needed.

Perhaps other ganes need unique naming for the meshes and armatures.

Unique naming is not part of the glTF specification. Having a pipeline based on naming in probably not a good idea.

Any chance you can add a hook in the add_neutral_bones function in gltf2_blender_gather_tree.py with the neutral_bone as an argument?

Yes, added in TODO list

ronh991 commented 1 month ago

Yes!! Thanks very much for the consideration and detail answers.