Automatically weighted skinned mesh?

This should be really simple to do (in theory).
I want to take any armor piece (e.g. torso armor from some free monster I downloaded and added to my game) or EVEN a rigid piece of armor from some non-animated statue that happened to be a separate mesh. Given very little input from me (like I might position it, scale it, and rotate it over my rigged character) and then I want to create a skinned mesh from it that is auto-weighted to the nearest bones in my rig. Let’s say that torso armor had the stubby arms pointed outward, well then I just have to make sure my character is in a T-pose before doing the auto-weighting. After running the algorithm, the skinned mesh should look PRETTY CLOSE to the same rigid piece until I animate the bones.
The calculations should be fairly straight-forward and I should be able to get a lot of armor pieces to work (somewhat) with my characters. Is there anything out there right now that can do this? Any code samples? I would greatly appreciate any guidance. As of now, I only have rigid objects for my characters (like swords, axes, shields, and helmets). Yes, they’re naked.
Thanks in advance!! :slight_smile:

p.s. I do understand that not everything is going to work automatically. I might have parts of the body extruding through a shirt and it requires manual intervention with Blender. But, if I can get the majority of my armor pieces looking okay without leaving Unity, that would be great! Better yet, I’d like to make small adjustments right inside the Unity editor! But, for now, I just want to auto-weight meshes to my rigs.

If the objects are only rigid objects at this time have you attempted to parent to the desired bone - instead of adding to the skin?

Just wondering why your trying to add to a skinned mesh rather than just parent to the bone that controls the local area the rigid piece is located.

Parenting a rigid piece of armor works for some things but not all. A helmet, for example, does not need to flex so I can take it, as is, and parent it to the head bone. I do have some meshes, like a torso mesh, that I only have as a rigid mesh that I’d like to be a skinned mesh. Or, more importantly, I have other skinned meshes like body armor and leg armor that I want to get working with my rig so I’d like to automatically weight it to my rig somehow.
Last night, I did try to take a stab at this problem but my procedurally generated GameObject with SkinnedMeshRenderer had nothing visible at all even though its mesh showed having over a thousand verts and triangles. I did notice that it didn’t properly calculate the bounds though (it said it was 0x0x0).
I’m hoping someone has done something like this and I could use their code.

@ChristmasEve ,

Any chance you found the simplest solution to this. I am looking at this now and wondered if you would share some hard-earned wisdom… ?

I too like doing everything in Unity, however when it comes to rigging models I have found blender to be the best free option.

Blender can be a bit daunting to use with all its options but for rigging it’s pretty good. And most of all it has automatic weights.

Afraid I don’t have any unity scripts for automated weighting.

1 Like

I want to recreate blender’s automatic weight for procedural rigging purposes.

Here is the blender automatic weight source code, blender/source/blender/editors/armature/meshlaplacian.cc at main · blender/blender · GitHub

Apparently it was based on this paper https://people.csail.mit.edu/ibaran/papers/2007-SIGGRAPH-Pinocchio.pdf. I believe it was from chapter 4 “skin attachment”.

I also found this implementation using c++ that probably do similar stuff, Pinocchio/Pinocchio/attachment.cpp at master · pmolodo/Pinocchio · GitHub

But those codes are written in c++.
I don’t really understand c++.

So…
Can someone help recreate it for me?