Deform Armature

This is a small autotasking script for creating a Deform Armature.
It basically makes a copy of the rig’s “deform bones” into a new clean armature, and assign transform constraints in relation to the bones of the control rig.
It should be usefull for people who need to export clean armatures to game engines, or in general anyone who usually use a second armature.

cool thanks! :smiley:

I wrote another script which bakes all the actions from the Control rig to the deform armature

it`s currently written as a script and not an addon, but I might combine it later with the deform armature addon

the script is also a task automatization, for the “bake action” function in blender.
select the control rig and the deform armature that you want to bake to, the deform armature should be the active selection.
and run the script
it goes through all the actions and bakes them into the active rig.
the new baked actions get the same name, while the old action have “_control” added to their name.
Once you restart the file they will be deleted (in order to keep them you need to activate fake user)
recommended always to use a new file for baking.

using deform armature and baking the actions is currently the best way I could export animations into unity, espcially for mecanim.
When I try to export rigify into fbx with “only deform bones” checked, the rig when imported always seemed to contain still all the helper bones.

hey there snot_nose! I nedded to and took the freedom to turn your very useful couple of scripts into an interface, and now I’d like to take the freedom to share it with you :slight_smile:
I made a little tweak, though: the copy transform contraints use ‘LOCAL’ now for owner_space and target_space, making it a little easier to, say, adjust the “deform armature” to different character proportions. It also renames the new armature properly - it just put “Armature_deform” as the name.

I added myself as co-author, but since most of the work is yours I’d be happy to just be listed as collaborator inside the code or something

the now-addon: (2.06 KB)

Hope you find it useful!

Hi Shonosh
This is great, I wanted to make a simple UI but didn’t have time for it, so I’m glad you already did it.

I tried your version with an existing complex animation, but it didn’t work out because of the local constraints. I would recommend to stay with world space, because local can always cause problems when u move the character too much around. the proportions should be anyway the same between the rig and the deform armature. Otherwise we could also add a checkbox, but right now Local doesn’t work for me at all.

I would prefer the panel to be on the toolbar (this is where I searched for it in the beginning), but this is not so important

Yup, been testing it further with Pitchipoy’s Rigify and it only works properly with the default WORLD space v.v

Here you have it with the trustful WORLD space: (2.22 KB)
I also added a “Optimize Rigify Rig for Unity” button, which uses only the “ORG-” bones for the new rig. That’s because the ORG- bones are not split in two in the limbs like the DEF- ones are and Unity’s Avatar system likes that better.

Happy blending!

Wow, thx a lot for this addon guys.

I’m really new to rigging for games (specially for Unity), and the programmer from my project was having a really hard time with all the “trash” that comes with rigify once he imports the .blend, so I think this will come really in handy.

Btw, the “Create Deform from Rig” generated rig, with the actions baked and than after replacing the rig from the armature modifier in the meshes worked fine (that’s not supposed to be automated, is it? I’m asking because I may be using the addon incorrectly), but the “Optimise Rigify Rig for Unity” didn’t. I think that’s due to the naming of the bones. How can I make the optimized one work?

Another question: I can’t move any of the bones of the generated rig, is that how it’s supposed to be?

Thx a lot again!

Hi Raphael
“Create Deform from Rig” Just creates a copy of the deform bones from your rig. it is still not baked and you are NOT suppose to animate the deform armature, you would still animate with your old “control” rig, and use the armature deform only for exporting. so the mesh would be skinned to the armature_deform which is then constrained to the original rig.
The animations however are still not baked, if you export it with the mesh with armature_deform u will get no animations, or just the current clip baked. if you want to get all the actions into the armature you can use “bake actions”, after finishing with animating of course (preferbly on a separate file). you need first to select your control rig, then the armature deform and then hit bake.
You should be carefull, though, if you have more then one character in your scene, then it will bake also the actions from the other character. so you should have each character actions on a separate file when baking ALL the actions.

Regarding “Optimise Rigify for unity” Its works similiar to “Create Deform from Rig” but exporting the ORG bones instead. I think Shonosh added this to work with Humanoid character setup in mecanim, which uses less bones, but I`m not sure, I still havent used it

Hope my explanation helps

@snot_nose Thx for the thorough explanation. Regarding the the Optimise Rigify for Unity, I think it doesn’t work (in my case at least) because all the vertex groups on the mesh that were originally deformed by Rigify had DEF in them instead of ORG, so, when I create the optimized one (which is made all of ORG bones), bake the animations to them (it worked fine until this point) and try to reparent this new rig to the mesh, it doesn’t work due to nomenclature.

Sorry if I misinterpreted how the optimized version is supposed to work or skipped one step that would make it work, is just that I am really new to this whole rigging (specially for games) thing :stuck_out_tongue:

Hey @RaphaelBarros

I should have added an explanation there or something ^^’ The “optimise for unity” button, as snot_nose explained, does nothing more than search for the ‘ORG-’ bones, which are the ones that you set up as the metarig, and use them instead of the deforming ones. I did this to relieve myself from having to change all the metarig’s bone tags no not generate the extra stretch-and-squatch bones it makes, which e.g.: require to split the arm and forearm bones in two. That creates a complex hierarchy that unity’s Avatar system doesn’t like at all.
You could simply go with the original “create def. rig” button if you go and tweak the metarig so it doesn’t generate that extra bones :wink:

Regarding the skinning: you shouldn’t skin with the metarig nor rigify if you are going to use an alternative, simpler deformation rig for game engines. Create the Rigify, extract the deformation rig and skin directly to that last one. Then you can animate :wink:

After you are done animating, save a new file (a *_export.blend maybe). From there, clean everything so you only have the deformation rig, the rigify rig and the skinned mesh, the actions you want to export and then you can bake safely.

That’s my workflow anyway, and the way I use the addon (and the reason I turned it into an addon in the first place xD)

Hope this helps :slight_smile:

Reading snot_nose’s reply, we could figure out a way to only bake the rig’s NLA tracks

Sorry for the late response, and thx a lot for the explanation. I still didn’t understand some of the concepts, even though most of what you said is enough for what I need, so thx a lot!

The optimized version for Unity (the one with the org bones) you create to animate inside unity, is that correct?
They’re not supposed to be deform bones inside blender? When I make rigify generate the optimized version for unity, the resulting bones have the “deform” option off, so, if I skin it to the mesh, and control using the rigify controls, even though the “org rig” follows the controls, the mesh doesn’t follow the org rig, it only follows it if I select it in object mode, and move, like in normal parenting.

By “tweak the metarig so it doesn’t generate that extra bones”, do you mean coding? I couldn’t find any option to generate a rig without the extra bones in the metarig.

Sorry if my questions sound a stupid, but I’m really new to rigging. Actually, some projects are appearing and I hadn’t the time to study it as much as I should, so I try to rely on the automatic ways as much as possible.

No problem!

The extra bones I mentioned are the “complex arm/leg” rig option you find in the “bone” tab of the properties panel while selecting an arm/leg bone of the metarig. Disabling those prevents the addon from generating those stretch & squatch bones in the control rig that Unity’s Humanoid system won’t tolerate at all.

The ORG- bones come out with the deformation off because they’re a copy of rigify’s ORG- bones, which also have the option disabled. You are supposed to turn it on as needed (since it is usually more comfortable for me). You can use alt+W to enable the deformation for all the selected bones (it will disable it actually but the f6 menu lets you change that).

Sure the addon needs more documentation v.v Sorry for the inconveniences it may cause to you. I should update it ASAP.

Haha, no problem. Your addon helped me a lot already (and specially the guy programming, since he wouldn’t have to clean all the controls from Rigify inside unity). Thx a lot!

This was just what I needed. Thanks alot guys :slight_smile:

Defrom Armature addon now includes also a UI list for all the actions.

This is usefull, before you export all the animation you would want to go through all the animations quickly to see if everything looks ok (sometimes the settings of one clip influence another)
So instead of going to the action editor and selecting each time a different action, you can just hit play, select and run quickly through all the clips in the ui list. On every selection the timeline will jump back to frame 1.
This makes the process much faster to go through all the animations.

There is a checkbox to activate and deactivate the UI list. I added this checkbox because the list contains a handler that runs all the time, so when a different action is selected in the action editor. it will be updated in the UI list as well.
The handler might consume a bit of memory, so you could turn it off with the checkbox

get it from my github
Will be glad to get some testing and feedbacks