lsalzman / iqm

Inter-Quake Model format development kit
MIT License
239 stars 73 forks source link

Manual export of vertex weights without exporting skeleton data #58

Open z-adams opened 1 year ago

z-adams commented 1 year ago

Unless I'm misunderstanding something about the exporter, the only way you can export vertex weights is by also exporting the skeleton. This makes it difficult to create modular assets such as clothing, backpacks, or other soft worn articles, since it would require a lot more legwork on the application's part to de-duplicate the rig and associate the items with whatever pose buffer is used to store the wearer's rig state.

This modification to the export script adds an additional checkbox "Vertex weights" which allows for explicit control over whether or not vertex weights are exported. When exporting a rig this should always be checked, but it can also be checked when exporting a rigged object that will later be slaved to the skeleton in the final application, without exporting the actual rig data. This is similar to exporting one IQM file containing multiple meshes which reference the same rig, but much more modular as it allows the resulting assets to exist in separate files without duplicate data. The exported vertex bone IDs will be the same as usual, only that the bones they reference don't exist within that same file. When the mesh is loaded by the application it will be up to the application to make sure that the object is associated with the correct armature object/pose buffer, rather than creating a new one.

This is just a suggestion, I'm not sure if this change is consistent with the IQM file spec or purpose of the format. If this seems like a reasonable idea, before it gets merged it might make sense to add a warning or error to ensure "Vertex weights" is checked when exporting the rig, since exporting a rigged object without vertex weights doesn't make much sense.