I am working on an application that has several body shapes of different sizes (tall, short, slim, full) and some clothing to attach based on user input. Both the bodies and clothing models (all GLTF) are rigged in the same way.
When a body is selected, I save the skeleton and then when a piece of clothing is selected, I overwrite its skeleton with the saved one using code something like this:
I don’t think that clothing will adapt/morph to a different shaped skeleton unless the new skeletons only difference is that the bones scaling brings it into the new body shape… then its possible for the cloths to rescale since the are rigged to the same bones…
but I feel like my 3D/vector math is sorely lacking and this is plain wrong or incomplete… For example, when I use this approach to move the hands, both hands move in the same direction even though the delta in the XML file has one positive and one negative.
Any knowledgable people in this field know what I am likely doing wrong?
When exporting GLTF, there is a transformation from Z up to Y up coordinate space.
Once you export your model to GLTF, any external data/deltas you had beforehand will no longer apply to the exported GLTF unless you convert that data to Y up also. This means, swapping the Y and Z values on all vectors, and possibly negating X. For rotations/quaternions… it probably involves applying a 90 degree rotation to rotate the Z onto the Y axis. Yuck.
Alternatively You can try disabling the up vector conversion behavior in the Blender exporter in the GLTF export settings-> Transform tab-> uncheck +Y up. This might keep your models matching the space of your data.
Your models will come in lying on their back, but thats easy to correct by putting the whole thing under a new node or just applying a rotation to the top most non-animated node.
should cover it, (and might be overkill… you can probably just do bone.updateMatrix() or even nothing at all, assuming its matrixAutoUpdate = true (the default )… it should recompute the whole hierarachies matrix+matrixWorld at the next render.