This addon is inspired by the character rig file from the Blender open source movie Sprit Fright.
In the original file, hair particles are rigged using a script. Since scripting isn't for most Blender users, I make this addon to help artists to animate hair particles more easily without scripting.
This addon works pretty much the same way as the original script does, a handler function will constantly set the hair key locations with the target mesh vertex locations by indices, so that any deformation made on the target mesh, the hair particles will follow.
Install the .zip file like any other addons
You will see the Hair Rig tab in the N panel
Select any object that has hair particle modifier, a uilist will show up
Hit the add button to add a hair rig layer
A hair rig layer is a custom property stored in each object, each layer stores 3 sub-properties:
- update: an on/off switch of the layer update state
- particle system: name of the particle system that you want to control by the target
- target object: a pointer to the target object that you want to use to control the hair particles
You can either create target mesh from hair, or create hair from target mesh
Comb the hair any shape you like, you can change hair keys as well, hair keys doesn't have to be uniform
Select a target object, target object has to be 'MESH' type, in this example I select a cube. Go to the Target Mesh Specials menu, hit the Hair to Mesh button
Now the target mesh is generated
Add a Simple Deform modifier
Turn on layer update and global update, now the hair particles follow the deformation
Rules for the target mesh:
- Target mesh must contain only mesh lines (vertices, edges, no faces)
- No branches (no vertex links to more than 2 edges)
- No single vertex (no vertex links to 0 edges)
In this example I make a braid mesh.
Go to the Target Mesh Specials menu, hit the Mesh to Hair button
Note that this operator does allow random vertex order, but there's one limitation.
Each hair particle(strand) has it's own direction like curves, in each strand, end vertex(vertex links to only 1 edge,each strand has two ends) with a lower index number defines the root to generate hair from, the order of the rest of the vertices does not affect the result. However if the root vertex is wrong, the hair strand will flip (sorry currently I can't think of a better way to find root vertex...)
Use the measureit addon that comes with blender to visualize vertex indices.
One way to make sure that the vertex order is right is to convert the target mesh to curve, go to curve edit mode, turn on draw normals under viewport overlays, you can see if the curves are pointing in the right direction (in most cases should be pointing away from the particle emitter), if not, switch curve direction, and convert back to mesh.
Now the hair is generated
Tweak some settings if you like
Bind the target mesh to an armature with automatic weights
Turn on layer update and global update, now you can use armature to control hair particles
Hair rig layer data are stored in Object level and will not lose when objects being linked to other files, but the hair rig object list is stored in Scene level, this list will be read by the handler function, so even an object has hair rig layer data, if it is not in the list, hair particles will not update, this design is mainly for performance efficiency. To recalculate the list, simply press the Initialize button right beside the Global Update switch, and you're good to go.