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

Export Armature and Animations Only - Exclude Mesh #822

Closed
sketchpunk opened this issue Dec 9, 2019 · 15 comments · Fixed by #1582
Closed

Export Armature and Animations Only - Exclude Mesh #822

sketchpunk opened this issue Dec 9, 2019 · 15 comments · Fixed by #1582
Labels
Animation enhancement New feature or request

Comments

@sketchpunk
Copy link

I would like to be able to export only the animations. THe idea is that I export the mesh+armature in one file, then export animations+armature in as other files. I do not want them together in one large file for specific reasons.

@julienduroure julienduroure added Animation enhancement New feature or request labels Dec 9, 2019
@julienduroure
Copy link
Collaborator

Did you try to select only armature (and parents from armature to root of the scene), and export using "Selected Objects" ?
Seems to do what you are looking for, except if I misunderstand something.

@sketchpunk
Copy link
Author

sketchpunk commented Dec 10, 2019

I tried that before. The animation gets exported but not the armature. When I open the GLTF file, I see the animation element has channels and samples, the nodes for the bones are there too but, the SKIN element is missing. Without that, I do not know the order of the bones to properly export the data to the shader. The only way I can get the SKIN data to be saved to the file is if I also select at least one Mesh thats attached to the armature.

So yea. there is no way to just export the Armature and Animations only. I have my own parser, so I would like to be able to just render all the bones and animate them, but without skin element, i'm stuck.

@julienduroure
Copy link
Collaborator

I understand.
The problem is that skin must be attached to a mesh node, so not sure the glTF specification can answer your specific requirement.
We can't export "empty meshes", because primitives array must have minimum 1 element.
Maybe #732 will help you to export specific data that you need (currently not merged)

@donmccurdy
Copy link
Contributor

I'm not aware of any requirement in the specification that a node having a skin must also have a mesh. The closest language I can find is...

A skin is instanced within a node using a combination of the node's mesh and skin properties. The mesh for a skin instance is defined in the mesh property. The skin property contains the index of the skin to instance.

...which is probably more ambiguous than it should be, and we should clarify it either way. But unless there are side effects I haven't thought of, I believe we should allow a skin to be attached to a node without a mesh. That should be useful for exporting skinning animations in standalone files, as just an animated skeleton.

However, morph target / shape key animation would not be valid without a mesh.

@lexaknyazev
Copy link
Member

I'm not aware of any requirement in the specification that a node having a skin must also have a mesh.

It's in the schema.

@sketchpunk
Copy link
Author

Here's the thing. The Bone Nodes and the Animation all gets exported now. The only thing thats missing is the skin element. Its a root element, all it does is give you the order of the bones plus the Node index for each bone. There is no possible bad side effect of having it included. In all honestly, the way it works now feels wrong.

I select armature ONLY to export but the exporter only saves bone nodes and animations but excludes skin which ties the other two bits together. If Skin needs a mesh, then why are Bone Nodes and animations being exported? They're useless without the skin data. Thats a flaw in my opinion.

So I think either fix the export to say, you can not export armature+animations without a mesh or just put the skin data in and let it work as an animation asset export.

@donmccurdy
Copy link
Contributor

It's in the schema.

I see. This is perhaps worth revisiting in KhronosGroup/glTF#1665 (or perhaps out of scope, I'm not sure).

@Snouf-ID
Copy link

Snouf-ID commented Dec 3, 2021

I need to export armature + animation to gltf. I have fbx files with the model, and fbx files with only the frame and an animation. Cannot export this files only with armature in GLTF.
There is news on how to export only the armature in 2021?

@donmccurdy
Copy link
Contributor

@Snouf-ID some kind of mesh will have to be attached to the armature to export. That could just be a cube weighted to a single bone, I think, and then you'd connect it to the final mesh in another application.

@julienduroure
Copy link
Collaborator

So,
Having a node with "skin" property without "mesh" property is not allowed (cf Schema)
But it seems we can add a "skins" at root of glTF file, without any "skin" reference to element of "skins" element, seems to be allowed.

Can someone confirm (or not)? @donmccurdy ?

@lyuma
Copy link

lyuma commented Feb 28, 2022

@julienduroure It is perfectly valid in the glTF spec to do your second point. (EDIT: Sorry, I misread your post. The first is indeed not allowed, but the second thing you said is)
I already have written a plugin for Godot which uses unused skins as an armature hint while porting files from FBX.

The glTF spec does not state any normative behavior when an unused skin object is encountered, but multiple applications use this as a signal of intent by the user to indicate that an armature is desired rather than a node tree.

Here is an example of an XBot avatar with a few animation tracks embedded:
xbot_rig_anim.zip

You can see here that Three.js, Blender, and Godot already support this de facto behavior. Screenshots at bottom.

Finally, you can see here from the validator (screenshot below) that a single Note is created for the unused skin object, but no Warning or Error is issued for this case, as it is legal to include unused objects.

@donmccurdy If it hasn't already been done, I would suggest that this behavior ought to be written as an Implementor's Note in the glTF 2.0 specification, given the prevalence of apps that take an unused skin as a hint for an armature to be created.

Godot:
Godot, showing a Skeleton object
Blender:
Blender, showing an Armature object
Three.js (I imported another copy on the right without the skin to illustrate the difference):
Three.js showing a Skeleton on the left
glTF Validator:
glTF validator showing This object may be unused. /skins/0

@julienduroure
Copy link
Collaborator

This is my conclusion too, that there is nothing that seems to prohibit it.
But I prefer to double check, and if possible without the assumption that this is allowed because software(s) manage it.
Validator is a first good answer.

@donmccurdy
Copy link
Contributor

What is the proposed change in glTF-Blender-IO here? Something like:

  1. Provide option to exclude all meshes from export
  2. Export animated node hierarchy
  3. Export unused skin(s) identifying nodes as joints

All of that sounds fine to me. The validator's message that the skin "may be unused" can be ignored safely. We may need to be careful that the skin exported in this case is identical to the skin exported when a mesh is attached — otherwise applications attempting to retarget the animation may run into problems. So, using the same joints, in the same order, with the same inverse bind matrices.

I would suggest that this behavior ought to be written as an Implementor's Note in the glTF 2.0 specification...

Personally I think I see this as one more example of the general use case of 'unused' resources – unused meshes, textures, and materials are also there for applications to use as data resources rather than directly as part of the scene. But if there's some wording you feel would be helpful, I'd recommend opening a PR – the use case of animations in a separate file is popular enough.

@julienduroure
Copy link
Collaborator

julienduroure commented Feb 28, 2022

Hello,
Thanks for your feedback Don.

Here is my proposition:

Currently:
When an armature is exported, but not the skined mesh (when user select only the armature and export with "limit to selection"), no skins array is exported

To be:
When an armature is exported, but not the skined mesh (when user select only the armature and export with "limit to selection"), an (not used) skins array is exported

@julienduroure
Copy link
Collaborator

A PR is available here : #1582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Animation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants