Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapekeys names #362

Closed
Lexpartizan opened this issue Mar 14, 2019 · 17 comments · Fixed by #491
Closed

Shapekeys names #362

Lexpartizan opened this issue Mar 14, 2019 · 17 comments · Fixed by #491
Assignees
Labels
enhancement New feature or request exporter This involves or affects the export process Mesh_&_Object

Comments

@Lexpartizan
Copy link

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

@donmccurdy
Copy link
Contributor

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.

@donmccurdy donmccurdy added enhancement New feature or request exporter This involves or affects the export process importer This involves or affects the import process labels Mar 14, 2019
@donmccurdy
Copy link
Contributor

^Probably the importer could use the same properties.

@Lexpartizan
Copy link
Author

Lexpartizan commented Mar 14, 2019

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.

@donmccurdy
Copy link
Contributor

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

@scurest
Copy link
Contributor

scurest commented Mar 15, 2019

@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
Copy link
Author

@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!

@julienduroure
Copy link
Collaborator

OK, added it on my TODO list for importer

@julienduroure
Copy link
Collaborator

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

@julienduroure julienduroure removed the importer This involves or affects the import process label Mar 16, 2019
@scurest
Copy link
Contributor

scurest commented Mar 16, 2019

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

@julienduroure
Copy link
Collaborator

@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

@scurest
Copy link
Contributor

scurest commented Mar 17, 2019

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

# set default weights for shape keys, and names
if pymesh.weights is not None:
for i in range(max_shape_to_create):
if i < len(pymesh.weights):
if gltf.shapekeys[i] is None: # No default value if shapekeys was not created
continue
obj.data.shape_keys.key_blocks[gltf.shapekeys[i]].value = pymesh.weights[i]
if gltf.data.accessors[pymesh.primitives[0].targets[i]['POSITION']].name is not None:
obj.data.shape_keys.key_blocks[gltf.shapekeys[i]].name = \
gltf.data.accessors[pymesh.primitives[0].targets[i]['POSITION']].name

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?

@julienduroure
Copy link
Collaborator

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

@tlf30
Copy link

tlf30 commented Mar 25, 2019

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.

@julienduroure
Copy link
Collaborator

Importer part: targetNames has now priority in any cases

@imgntn
Copy link

imgntn commented May 3, 2019

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

@donmccurdy
Copy link
Contributor

I'll work on exporter implementation.

@donmccurdy
Copy link
Contributor

Opened #491, tests and/or reviews welcome. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exporter This involves or affects the export process Mesh_&_Object
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants