iimachines / Maya2glTF

Maya to glTF 2.0 exporter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export only selected nodes without meshes.

1fth3n3ls3 opened this issue · comments

In my current project we usually save animation files in separate files. This animations are applied to a "static" model who contains meshes with or without skin info, nodes (cameras or locators) and deformer nodes (if mesh is skinned).
Animation files usually doesn't contain meshes, just the info of animated nodes. That way the files size is way less than if the meshes were included. Usually a character can have hundreds of animation files. So in the end be able to only export animated nodes without meshes is huge.
I don't know if it would be possible to implement that feature to the exporter. I think, being able to export only animatied nodes without meshes is quite common, so more people could benefit from it. So I really hope you could consider the posibility to add it to the current exporter.

That feature is actually already "partially" implemented in the exporter, but has never been fully tested.

Also, GLTF unfortunately doesn't have a "animation only" file format, so the approach below might not be ideal for you.

So here's my approach.

Basically: export the mesh scene once to a GLTF file, and export each animation scene to a single GLTF file.

Details:

  • ask the exporter to split the mesh and animation buffers into different files, by passing the -sma extra flag to the exporter (-splitMeshAnimation). This gives you a GLTF mesh for each GLTF animation. This has the advantage that the animation can be previewed in any GLTF tool. Also the exporter can be asked to output the same GLTF mesh buffers for all scenes, see below.

  • you might also need to pass the -fac flag so that animation channels are created even for nodes that do not animate (as in the base mesh scene, nothing will animation).

  • often each exported animation file will export exactly the same mesh GLTF file. Also the Maya mesh will usually be referenced by the animated Maya scene. You can ask the exporter to use the same filename for each identical GLTF mesh by passing -hbu -sbr. Unfortunately Maya often adds some "tweak" nodes to change the imported referenced scene, and then the mesh will not be identical, so this doesn't always work 100%.

  • I made a .NET Core tool that will re-assemble all separate animations and mesh files into a single GLTF, see Tools/ModelClipMerger

So in summary, to get started, try exporting with -sma -hbu -sbr or -sma -hbu -sbr -fac and see what this gives for you. Then either write your own code to load and re-assemble these, or use the ModelClipMerger tool to do this for you, statically.

This repository also contains MEL scripts for bulk exporting many Maya scenes at once, generating GIFs from Playblasts, etc...

This is all experimental.

PS: If commercial support is needed, feel free to request this, my company offers this.

Thank you Ziriax for the detailed explanation on how to workaround this issue. I will let you know my advances in it.