Topics : Constraints, Expressions, Scripts, IK, Inheritance and Custom Parameters
By Michael Donovan
Inspired by : Dave Gallegher, Alex Alvarez, and Stefan Andersson
EST Completion time:
Newbie : 1 Hour
Experienced : 5 minutes (once you’ve done this already)
This tutorial will show one way to set up an IK rig for legs in XSI. It has complete heel toe controls, and only uses one conditional expression that prevents the foot from penetrating the ground. Most of the control is derived from the use of constraints.
This rig will include two independent hierarchies. The 1st one will include only skeletal objects. The second one will include only control objects. All of your animation will occur on the Control hierarchy.
Drag and Drop the following scripts onto a custom toolbar. These scripts will create custom control Icons to be used in this tutorial. These controls are wireframe objects that do not show up as shaded in the viewport and don’t render. (Implicit objects, while they do not render, still show up as shaded in the viewport by default … so you would need to assign a local view type and then turn off override object properties … which is a pain in the ass.)
First make sure you are working in the Right viewport. This will avoid any confusion with preferred axis, etc.
Turn snap on. By default “snap to reference plane” is activated. Since we are using the world as our reference plane we will snap to the viewport grid.
Now build the Leg by drawing a two bone 2D chain. (Note these are Global coordinates ... see the reference image)
Start the leg at T(0,10,0)
Place the knee at T(0,5,2)
Click a third time to place the effector at T(0,1,0). (fig. 1)
Build the Foot by starting a new chain at T(0,1,0) and clicking again at T(0,0,2)
Build the Toe by starting a new chain at T(0,0,2) and clicking again at T(0,0,4)
Make any another viewport a schematic view.
Use the hotkey CTRL-R to rearrange the schematic view (cleans up the view).
I find renaming, constraining and parenting operations easier in this view than in any other view. The reason for this is because you can pick the nodes easily and the hierarchical representation of these nodes lends itself to logical thinking.
Tip: Double clicking a node in the schematic view will open up it’s general property page. This is useful for renaming. Follow the chart below and rename all the parts of your skeleton. This will allow you to quickly select all the effectors, or all the bones etc by typing something like *BN* in the selection box on the MCP (Master Control Panel). The first initial is for the local body proximity (Left or Right). So L_Rt_Leg can be read Left Root Leg.
Root |
L_Rt_Leg |
Bone |
L_Bn_Femur |
Bone1 |
L_Bn_Tibia |
Eff |
L_Eff_Leg |
|
|
Root1 |
L_Rt_Foot |
Bone2 |
L_Bn_Metatarsus |
Eff1 |
L_Eff_Foot |
|
|
Root2 |
L_Rt_Toe |
Bone3 |
L_Bn_Phalanx |
Eff2 |
L_Eff_Toe |
Your schematic view should now resemble FIG. 2
Since the pieces of the leg are not parented we need to lock them together through position constraints.
Select L_Rt_Foot then click Constrain-Position and pick the L_Eff_Leg.
Select L_Rt_Toe then click Constrain-Position and pick the L_Eff_Foot.
First create a null that will serve as a master parent to our Control Rig. Name it CTRL_RIG.
Now we need to create an null that will server as an origin for our control objects.
Unless you like gimble lock, you need this null. Rotate it 90 degrees in Y. This will allow the control objects to rotate around the axis you would expect. (z will rotate on the hinge of the joint etc.)
We will also create an ankle null that will serve control the position and rotation of the ankle.
Using Get-Primative-Null create a null object.
Color it Bright Green by setting their wire color using the palette view.
Create two RotIcons (Using the scripts mentioned at the beginning of the tutorial)
Scale them down so they have a span of about 1.5 XSI grid units.
Freeze their scale using Transform-Freeze Scaling
Freeze its operator stack by clicking the Freeze button in the Edit section of the MCP. (This removes the "Center Operator" from the stack that was created when you froze teh scaling)
Color them Yellow by setting their wire color using the palette view.
Create one TransIcon
Scale it down so it has a span of about 2 XSI grid units.
Freeze its scale using Transform-Freeze Scaling
Freeze its operator stack by clicking the Freeze button in the Edit section of the MCP.
Color it Yellow by setting its wire color using the palette view.
Name these objects according to the following table.
Null |
CTRL_RIG |
Null |
L_Null_CtrlOrigin |
Null |
L_Null_Ankle |
Trans Icon |
L_Ctrl_Heel |
Rot Icon |
L_Ctrl_ToeRoll |
Rot Icon |
L_Ctrl_BallRoll |
Align these nulls to the following objects using Transform-AlignObjects.
The alignment tool is very flexible to a fault in XSI. Here is an example of how to align two objects. This will align L_Null_Ankle to L_Eff_Leg.
Select L_Eff_Leg
Holding shift down, select L_Null_Ankle
Click the Transform button in the MCP and select Align Objects.
A really overblown alignment dialogue will appear (Fig. 4).
Set the following parameters according to the table below.
Move |
All objects except first |
Which Axis… |
Check all three |
What to Align - On Affected Objects |
Middle, Middle, Middle |
What to Align to - Reference |
Middle of the First Selected Objects (All three) |
Magically (or not so) the L_Null_Ankle will align to L_Eff_Leg.
Align L_Ctrl_Heel to L_Null_Ankle
Translate heel down until is reaches the ground plane (in this case y=0). This will be the pivot point of your characters heel.
Align L_Ctrl_ToeRoll to L_Eff_Toe
Align L_Ctrl_BallRoll to L_Eff_Foot
Now we need to align the orientation of the ctrl object to match that of the bones they will be rotating.
Select L_CTRL_BallRoll.
Click Constrain-Orientation from the MCP.
Pick L_Bn_Metatarsus
Click Constrain-Remove Constraint from the MCP
Select L_CTRL_ToeRoll.
Click Constrain-Orientation from the MCP.
Pick L_Bn_Phalanx
Click Constrain-Remove Constraint from the MCP
Select L_Eff_Leg
Click the Constrain button in the MCP and select Position from the top of the list of available constraints.
Pick L_Null_Ankle
TIP: Since we first aligned the L_Ctrl_Ankle to L_Eff_Leg, the leg should not move at all during this process.
Position Constrain L_Eff_Toe to L_Ctrl_Toe
Position Constrain L_Eff_Foot to L_Ctrl_Ball
TIP: Remember that XSI remembers the last operation of each button. You can middle click the constrain button once to create position constraints if you have performed this operation at least once.
Make L_Ctrl_Heel the L_Ctrl_ToeRoll
Make L_Ctrl_Heel the parent of L_Ctrl_ToeRoll
Make L_Ctrl_ToeRoll the Parent of L_Ctrl_BallRoll
Make L_Ctrl_BallRoll the Parent of L_NullAnkle
Make L_Rt_Foot a child of L_Eff_Leg
Make L_Rt_Toe a child of L_Eff_Foot
Ctrl-R in the schematic view to re-arrange the view
What you may have noticed, is that in effect what we have done by parenting these objects in this order (from the toe back) we have created a reverse hierarchy for the foot that will allow us to rotate the different bones at each of their effectors instead of their roots. Because the Root of each bone is constrained to the effector of the previous bone, this allows this inverse motion.
Select L_Null_Ankle, L_Null_CtrlOrigin and CTRL_RIG and press H to Hide Them. We will never touch these objects. Their animation is being driven through the constraints and hierarchy we just set up.
BRANCH SELECT the L_Ctrl_Heel node. Rotate this selection on the LOCAL Z axis.
The whole foot should rotate around the pivot point of L_Ctrl_Heel in X,Y and Z. This Ctrl will also be used to key the translation of the Foot.
BRANCH SELECT the L_Ctrl_BallRoll node. Rotate this selection on the LOCAL Z axis. The Heel should rotate up, but the toe will remain stationed flat on the ground (foot roll effect).
BRANCH SELECT the L_Ctrl_ToeRoll node. Rotate this selection on the LOCAL Z axis.
The whole foot should rotate around the pivot point of the L_Ctrl_ToeRoll.
You may have noticed that the rig breaks if you rotate too far. Lets fix this by setting up some rotational limits on these objects.
Why is this step optional ??
Because many animators do not like to be restricted in any way. They want the option to over-rotate a joint. Often times applying limits can lead to stiff animation. It is the job of the TD to determine when it is appropriate to impose limits.
Select the L_Ctrl_ToeRoll node.
Right click on the Selection Button on the MCP and select Animation-Properties.
Activate the Local Transform-Rotation Limits tab.
Check Z active for both Minimum and Maximum.
Set Minimum equal to 0. Set Maximum equal to 60.
Now we need to do this to LCtrl_Ball_Roll. Use the table below to set the limits up.
L_Ctrl_ToeRoll |
|
Z Minimum |
0 |
Z Maximum |
60 |
|
|
L_Ctrl_BallRoll |
|
Z Minimum |
0 |
Z Maximum |
60 |
Create a new UVIcon (using the script mentioned earlier) and Name it L_CTRL_KNEE.
Position L_CTRL_KNEE in front of your leg.
Select L_BN_Femur
Select Create-Skeleton-Chain Up Vector from the Animation Panel.
Pick the L_CTRL_KNEE
OH NO … my leg flipped. That’s ok. Now we will fix that.
(If L_BN_Femur is not still selected .. select it now)
Hit the hotkey 8. This will open a floating explorer. With the mouse over the new window hit the hotkey E. This will isolate the current selection in this window.
Click the icon next to Kinematic Joint In the property page window, click on the Resolution Plane tab. Set Roll equal to 180. This inverts the resolution plane of the leg chain and fixes our problem by compensating 180 degrees.
Make the L_CTRL_KNEE a child of the Heel node. Make sure that it is positioned far enough in front of the knee so that it does not cause the leg to flip when the ankle is rotate to its extremes.
Tip: Since it will rotate with the heel your knee will rotate correctly. You can also animate this icon independently to control the knee on its own.
We will create custom parameters to control the Ball and Toe rolls. That way the only icon in the scene that we will need to animate will be the L_Ctrl_Heel.
Open an Explorer and select the Scene Root
From the Animate toolbar select Create-Parameter,-New Custom Parameter
Set
Name it Foot_Controls
This will create a customer parameter set under the scene node. I like to create it here instead of on an object because I usually will put controls for both feet in it and this way it is very accessible because it will show up at the top of any explorer that has its scope set to scene.
Click on the icon next to this new node. An empty Foot Controls customer parameter window will appear.
Select Create-Parameter-New Custom Parameter from the Animation panel.
Name this parameter Left_BallRoll.
Set its Value range equal the rotation limits we set for Ball_Roll (0 and 40)
Click OK.
A brand new slider appears … currently it does nothing. Lets fix that.
Select L_Ctrl_BallRoll in the active viewport. (not Left_BallRoll which is a custom parameter)
Hold the ALT key down and right click on L_Ctrl_BallRoll in an active viewport. From the context menu select animation properties.
TIP: This is just another way to get to the kinematics properties of the L_Ctrl_BallRoll node. You could right click on the Selection button and select animation properties and end up in the same place. Or you could have navigated through the explorer and clicked on the icon next to the kinematics node. XSI has many ways to get to the same information.
Right click on the animation icon (green square) next to the Z Rotation parameter on the Local Transform tab. Select Expression Editor.
In the Expression Editor Click the Object button and navigate to and select the FootControls.Left_BallRoll parameter.
Click Validate to make sure you do not have any syntax errors.
Click Apply to activate this simple expression.
Close the Expression Editor.
You will see an equals sign on the animation icon of the local z rotation of L_Ctrl_BallRoll. This indicates that there is an expression driving this parameter.
Close the property page.
TEST THE NEW CUSTOM PARAMETER.
Hit the hot key 8 to open a floating explorer. Click the icon next to the FootControls node to open the slider window.
Close the explorer.
Slide the slider and watch in geek amazement as you have just created your first custom control.
Repeat the steps above for the L_Ctrl_ToeRoll
Wouldn’t it be nice if the feet did not penetrate the ground ? Or even better, wouldn’t it be nice if the feet did not go below a certain arbitrary height in your scene that was defined by a moveable icon … thus allowing you to adjust the level of the floor (so your rig could walk up the stairs).
Well … let’s set that up
then.
First create a NULL using
Get-Primative-Null.
Set the scale values for this null to 1.5 in the X and Z.
Translate the Icon to zero in Y.
Rename this NULL to
L_Ctrl_FloorHeight
Set L_Ctrl_FloorHeight's wire
color to RED by using the wirecolors under the palette
panel.
Select
L_Ctrl_Heel
Right click on the selection button on
the MCP and select Animation
Properties.
On the Global-Pose tab right click on the animation icon for Position Y and select expression editor.
In the expression editor click the
Function button and select
condition. This will insert the syntax for the condition function into the
expression editor for you.
Replace the syntax helper with the following expression. You can use the object button to help you fill in the variables.
cond(
L_Ctrl_Heel.kine.global.posy<L_Ctrl_FloorHeight.kine.global.posy ,
L_Ctrl_FloorHeight.kine.global.posy
,L_Ctrl_Heel.kine.global.posy )
Click Validate to make sure you do not have any syntax errors.
Click Apply to activate this simple expression.
It would be super cool if the
L_Ctrl_FloorHeight null followed the L_CTRL_Heel Icon. That way it would always
be readily available and close to your character. To do this all we need to do
is set two simple expressions.
Select the L_Ctrl_FloorHeight
object.
Rightclick on the selection button on
the MCP panel and select Animation
Properties.
Right Click on the animation icon next
to Local Transform-Position
X and select expression editor.
Click the object button in the
expression editor and select the Local X
translation of the Heel. (L_Ctrl_Heel.kine.global.posx)
Right Click on the animation icon next
to Local Transform-Position
Z and select expression editor.
Click the object button in the
expression editor and select the Local Z
translation of the Heel. (L_Ctrl_Heel.kine.global.posz)
The biggest danger with this setup is that you MUST BRANCH SELECT THE L_CTRL_HEEL to manipulate it in any way. If you do not do this you are screwed. So lets make this a bit easier. We will make a button that you will click that will branch select it for you.
Use the hot key CTRL-SHIFT-A to unselect all objects.
Middle Mouse click the L_Ctrl_Heel to BRANCH SELECT it.
Open the script editor but clicking the ! button
From the upper pane highlight the following lines.
DeselectAll
SelectObj "L_Ctrl_Heel", "BRANCH", True
Drag this selection to your custom tool panel and name the script “BRANCH L HEEL”
Now all you need to do is click this button to branch select the L_Ctrl_Heel and start animating.
Coming Soon