Jump to content

Creating an animation rig in Blender: Difference between revisions

Added the "Adding bone constraints to rig controller bones and drivers" header
(Added the "Adding bone constraints to rig controller bones and drivers" header)
Line 578: Line 578:
|}
|}


==Adding bone constraints to rig controller bones and drivers, and ==
==Adding bone constraints to rig controller bones and drivers==
This is the final section of this tutorial. Now we just have to add the Pose Matching functionality, so we can constrain the rig to imported animations in Pose 1 and Pose 2 collections. We do that by adding two new bones to the rig, bone constraints to the rig controller bones and then drivers which will control the influence of the bone constraints through the Z location of the newly added bones. We will also  
This is the final section of this tutorial. Now we just have to add the Pose Matching functionality, so we can constrain the rig to imported animations in Pose 1 and Pose 2 collections. We do that by adding two new bones to the rig, bone constraints to the rig controller bones and then drivers which will control the influence of the bone constraints through the Z location of the newly added bones. We will also  


#<li value="83">Go to Edit mode and select the Pose Matching layer.
#<li value="83">Select the rig, go to Edit mode and select the Pose Matching layer.
#Add a new bone named ''Pose1''.  
#Add a new bone named ''Pose1''.  
#Set its transforms as listed below (or make it as big as you want, this is purely a visual/ergonomic matter):
#Set its transforms as listed below (or make it as big as you want, this is purely a visual/ergonomic matter):
Line 594: Line 594:
##You can also set the Scale to 10 and disable the ''Scale to Bone Length'' checkbox for them if you want.
##You can also set the Scale to 10 and disable the ''Scale to Bone Length'' checkbox for them if you want.
#For now, move both Pose 1 and Pose 2 in Global Z axis so that they are below the "floor" (XY plane).
#For now, move both Pose 1 and Pose 2 in Global Z axis so that they are below the "floor" (XY plane).
#Select the Torso and all of the FK layers in the Rig Layers panel.
#Select the Torso layer and all of the FK layers in the Rig Layers panel.
#Select the ''hips'' bone.
##Add ''three'' Copy Rotation bone constraints, and move the one without the suffix to the bottom of the list (so the order of the bone constraints going from the top to bottom is ''Copy Rotation.001'', ''Copy Rotation.002'', ''Copy Rotation''). ''Copy Rotation.001'' and ''Copy Rotation.002'' will be used for pose matching, ''Copy Rotation'' will be used for axis correction.
##In the ''Copy Rotation'' constraint, set the ''Mix'' to ''After Original''.
#Now we'll have to add the drivers controlling the influence of each Copy Rotation constraint. As shown in Pierrick Picaut's tutorial, you can do that by right clicking on the Influence value and pressing ''Add Driver'' (same applies to any other property in any other constraint). Once you add a driver, you can edit it either through ''Edit Driver'' or through the Driver Editor - both are selectable within the same menu.
##Add a driver to the ''Influence'' of each ''Copy Rotation'' constraint in accordance with the table below:
{| class="wikitable"
|-
! Copy Rotation.001 !! Copy Rotation.002 !! Copy Rotation
|-
|
*Driver Type: ''Scripted Expression'' (default setting)
*Expression: ''var''
*Amount of input variables: one (default setting)
*Input Variable type: ''Transform Channel'' (default setting)
*Input Variable name: ''var'' (default setting)
*Object: ''rig''
*Bone: ''Pose1''
*Type: ''Z Location''
*Space: ''World Space'' (default setting)
||
Same settings as in Copy Rotation.001, with the exception of:
*Bone: ''Pose2''
||
*Driver Type: ''Scripted Expression'' (default setting)
*Expression: ''max(var1,var2)'' (press Enter to get rid of the invalid expression error, if you have it)
*Amount of input variables: two ('''press ''Add Input Variable''''')




First input variable:
*Input Variable type: ''Transform Channel'' (default setting)
*Input Variable name: ''var1''
*Object: ''rig''
*Bone: ''Pose1''
*Type: ''Z Location''
*Space: ''World Space'' (default setting)


Second input variable:
*Input Variable type: ''Transform Channel'' ('''be sure to change it to this''', added variables have ''Single Property'' set as default)
*Input Variable name: ''var2''
*Object: ''rig''
*Bone: ''Pose2''
*Type: ''Z Location''
*Space: ''World Space'' (default setting)
|}
#<li value="94">You can check if the drivers are working by moving Pose1 and Pose2 bones along global Z axis and checking if the Influence of Copy Rotation bone constraints in ''hips'' or Input Variable values in their drivers change.
#Copy the bone constraints from the ''hips'' bone to the following bones:
#*tweak_spine.001
#*chest
#*shoulder.R
#*shoulder.L
#*neck
#*head
#*upper_arm_fk.R
#*upper_arm_fk.L
#*forearm_fk.R
#*forearm_fk.L
#*hand_fk.R
#*hand_fk.L
#*thigh_fk.R
#*thigh_fk.L
#*shin_fk.R
#*shin_fk.L
#*foot_fk.L
#*foot_fk.R
#Unfortunately, because Blender at this moment does not copy drivers when copying bone constraints, the bone constraints you've just copied are lacking the drivers. Because of this, you have to copy the drivers manually - simply right click on the ''Influence'' value of ''Copy Rotation'' constraint, press ''Copy Driver'', and go through all bones in the upper list and ''Paste Driver'' onto the Influence of the ''Copy Rotation'' in each bone. '''Do this for all three ''Copy Rotation'' bone constraints.'''
#Add two ''Copy Location'' constraints to ''torso'' and ''torso_pivot'' bones, and make sure they're named ''Copy Location.001'' and ''Copy Location.002''.
#Copy Influence Drivers from any of the bones in point 96 and paste them into the ''Influence'' of ''Copy Location'' constraints in ''torso'' and ''torso_pivot'', in accordance with the numbers of bone constraints (e.g. copy the driver from ''hips''' ''Copy Rotation.001'' Influence and paste it into Influence of ''Copy Location.001'' in ''torso'' and ''torso_pivot'').
#Set the ''Copy Rotation'' constraints' Axis correction ''Target'' in accordance with the table below.
{| class="wikitable"
|-
! Bone !! Copy Rotation target
|-
| hips || RACSpine
|-
| tweak_spine.001 || RACHead
|-
| chest || RACSpine
|-
| neck || RACHead
|-
| head || RACHead
|-
| shoulder.R  || RACLimbs
|-
| shoulder.L || RACLimbs
|-
| upper_arm_fk.R || RACLimbs
|-
| upper_arm_fk.L || RACLimbs
|-
| forearm_fk.R || RACLimbs
|-
| forearm_fk.L || RACLimbs
|-
| hand_fk.R  || RACHandL
|-
| hand_fk.L || RACHandR
|-
| thigh_fk.R || RACLimbs
|-
| thigh_fk.L || RACLimbs
|-
| shin_fk.R || RACLimbs
|-
| shin_fk.L || RACLimbs
|-
| foot_fk.R || RACFeet
|-
| foot_fk.L || RACFeet
|}
[[Image:RigFinished.png|200px|right|thumb|Finished rig showing the pose matching functionality]]
#<li value="100"> Select any FK (green) bone and set the IK-FK slider to 1. Do this for all four limbs. This has to be done because pose matching works only through FK.
# Using the [https://wiki.oni2.net/Blender#Rig_bone_constraint_target_setting_script RigBoneConstraintTargetSetter script], set the targets for the ''Copy Rotation.001'' and ''Copy Rotation.002'' bone constraints. You can do that by having the rig in Pose mode, going to the Scripting tab, copying and pasting the script, and running it with <code>prefix</code> value set to 1, and then set to 2.
# If you didn't get any errors, move one of the Pose bones in the global Z axis above the XY plane - the T-posed character should now snap to one of the animations in the ''Pose'' collections, as shown in the screenshot on the right.
# Congratulations! The rig is now ready to be used.


[[Category:Modding tutorials]]
[[Category:Modding tutorials]]
191

edits