I distribute points (I'll call them P) on the faces of a mesh and then instantiate objects (scales) at these points, in order to cover the surface with scales:
However, the original mesh is animated via an armature, and I have trouble assigning working vertex weights for the scales. The scales instances themselves should not be deformed, but move rigidly with the point P on the surface they are attached to.
What I've tried:
- I can copy the vertex weights with a DataTransfer modifier from the original mesh to the scales. However, this does not know about which face the point P was originally placed on, so I loose that information and the result is a mess. Also, it potentially deforms the scale:
- I tried storing the index of the nearest vertex (of the original mesh) for each of the distributed surface points P in an attribute. When I create scale instances, those "inherit" this attribute, which allows me to later write a script which copies the vertex weights from the vertex with this index to the entire scale instance. This results in rigid movement, but it (obviously) looks like the scale was attached to the bones that the nearest vertex is attached to, when really it should be attached to a point on the surface (which I think is an interpolation between the face corner vertices' weights)?.
- My current idea is to store the position of the generated distributed point P and the index of the face it was placed on. Then I could determine the vertex weights of each of the corner vertices of the face and probably interpolate them depending on the point position.
Is there a function to calculate this interpolation? I think when subdividing/cutting a mesh then weights for the new vertices are calculated automatically - and I think that is the function I would need? Or is there a different, better way to achieve this?
Edit: I should have noted that I want to export the result for use in a game engine, so correct vertex weights is really the only feasible option I have.
Side note: As far as I can tell, working with a large (and varying) number of vertex groups is currently not easy in geometry nodes, so I would prefer using the geometry nodes only to create the scale instances and store necessary information and then write a python script that calculates the vertex groups/weights.