Gltf-blender-io: Shapekeys names

Created on 14 Mar 2019  路  17Comments  路  Source: KhronosGroup/glTF-Blender-IO

Shapekeys exported named like "Morph 0".
With glTF-Blender-Exporter i can myself name to shapekeys. Its very convenient.

Mesh_&_Object enhancement exporter

Most helpful comment

Importer part: targetNames has now priority in any cases

All 17 comments

FYI, glTF-Blender-Exporter accomplished this by setting mesh.extras.targetNames on the mesh instance:

https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/7933fbfdd80628875910c5da36fd28e40474fb43/scripts/addons/io_scene_gltf2/gltf2_generate.py#L1511

glTF has no proper mechanism for naming morph targets, but this workaround is accepted in a few tools.

^Probably the importer could use the same properties.

Thanks for the reply. I'm trying to make Makehuman models into a ingame character generator for Godot. And it turned out about 200 shape keys. Without names, it's a nightmare.
glTF-Blender-Exporter has some errors when exporting.
Animated characters not good. Some of the verticles (around 5 pieces from 14 000), standing to the random side. In the blender all fine. The weights are painted correctly.
glTF-Blender-IO work good, all verticles in their places. But can't naming shapekeys.
Sorry for my english.

For sure! I agree with this feature request, I'm just adding more information for others to weigh in. :)

@Lexpartizan, here's a temporary workaround:

Before exporting, put this in the text editor and run it

import bpy
for m in bpy.data.meshes:
    target_names = [kb.name
        for kb in (m.shape_keys.key_blocks if m.shape_keys else [])
        if kb != kb.relative_key]
    if target_names:
        m['targetNames'] = target_names

then when you export make sure the General > Custom Properties box is ticked.

@Lexpartizan, here's a temporary workaround:

Before exporting, put this in the text editor and run it
then when you export make sure the General > Custom Properties box is ticked.

Thank you very much, it helped me a lot!

OK, added it on my TODO list for importer

Importer can now read extras data to name shapeKeys ( b3a78e0 )

@julienduroure :+1:
Do you think the extras.targetNames property should take precedence over getting the names from the accessors in the first primitive's morph targets?

@scurest Seems _extras.targetNames_ is already used in some other few tools.
I am ok to change it if there are some more used conventions

No, what I mean is that the importer already uses those accessor names to set keyblock names

https://github.com/KhronosGroup/glTF-Blender-IO/blob/b3a78e002384970790b4fec39162bf36d67375ef/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py#L170-L179

and since it does this after it sets from extras.targetNames, the accessor names currently take priority over extras.targetNames. Do you think it should be the other way around?

Ah, you're right, my test cases didn't have default weights for shape keys, so it was not overwritten. Will change it

Hello, I am wondering on the status of getting this in the exporter. I would really appreciate having this functionality built into the blender 2.80 exporter.
Also, @scurest thank you for the work around script.

Importer part: targetNames has now priority in any cases

could also really use the ability to export shape key names, preferably without the user having to run a script in blender first! :) thanks for the great work

I'll work on exporter implementation.

Opened https://github.com/KhronosGroup/glTF-Blender-IO/pull/491, tests and/or reviews welcome. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quinten123 picture Quinten123  路  4Comments

UX3D-nopper picture UX3D-nopper  路  4Comments

rainclaws picture rainclaws  路  3Comments

donmccurdy picture donmccurdy  路  5Comments

Quinten123 picture Quinten123  路  5Comments