Class 3 - Week 7 - Locking Knees to a Surface

"Kneel Sir Knight, that I may bestow onto you great honors." What's
that? You don't know how to get down to your knee? Well, let me show
you...

Basic:

In this first section, I'll go over the method I use to lock elbows
down to a surface, while still giving me the ability to make sure
the animation stays consistent. Okay, enough jibberjabbing, let's
get started!

*Edit: With version 94 of Stewie, the knee PV controls are hidden. To show them again use this mel command select stewie_ac_L_foot_pv_ctrl; to select the proper control and then you can unhide the PV and properly lock the knee to the ground.

  • Select the Foot Control Curve, the diamond controller behind the foot, and set the "Knee PV" to 1. This will turn on a controller that allows you to orient the knee.
  • Select the PV Control that just popped up and set "Knee IK" to 1. This will now cause the knee joint to snap to the PV Control.
  • Also, set the Knee Ik to 1; Foot Follow to 0; and Layout Follow to 1. This will keep the knee from moving along with the body and effectively lock it to wherever you place the Knee PV control.

But what's this? You say that now the upper and lower legs are
stretching and destroying the rig? Sadly, this is a side effect of
planting the knee. Now you can just animate it by eye and hope that
the length stays consistent. But, more often than not, you'll end up
with a wiggle in the legs. Fortunately we have a secret weapon that
will help us with this: the Distance Tool!

You'll find it under "Create > Measurement Tools > Distance Tool".
Once you have it activated, just click twice on any surface. This
will create two locators connected with a line that will
automatically calculate the distance between both locators.

With the Distance Tool, we'll be able to measure the length of
Stewie's leg while it's in its default position, then use that
number to make sure that his legs don't stretch or shrink while his
knee is planted.

To set this up properly, the first thing you'll need to do is make
Stewie's geometry selectable. To do that, select his main layout
control (the big circle around his feet) and hit the right arrow
button. This will select the "stewie_ac_C_visibility" node where you
can find the "Geo Display" attribute. Set this from "Referenced" to
"Normal" and you'll now be able to select all of Stewie's geometry.

Next,

  • Use the Distance tool to create two locators with the measurement between them.
  • Select the upper leg of the planting elbow, then select one of the measurement locators.
  • Go to "Constrain > Parent Constrain > Options".
  • Make sure "Maintain Offset" is unchecked and hit "Add".
  • Now select the knee, then the second measurement locator.
  • Parent Constrain this the same way as before.

That's one down, one more to go.
You'll want to create a new pair of measurement locators, but this
time, constrain one to the knee and the other to the foot geometry.
To select the foot geometry, select the rectangular heel control
under his foot and hit the up arrow key.

You should now have a system that tells
you the exact length of the leg at all times.
By default, Stewie's legs should be around:

Upper leg: 4.883106
Lower leg: 5.621173

If you don't want to see so many digits, select
the number, open the attribute editor and under
the "Extra Attributes" section, you'll find "Precision"
which will allow you to set how many decimal
points there are. This is great because lots of
numbers can be quite a mess at times, although I
would recommend not going below 3 decimals as
it could lead to some slight wiggling.


Now you'll be able to keep the leg at a consistent length as you're
animating. This will still require a bit of fiddling to keep it from
stretching but it does beat having to do it all by eye.


Intermediate:

We've got the basics for planting the knee but all this counter
animating to keep the leg from stretching can be quite a pain. What
we need is a way to keep the leg at a consistent length without
having to constantly tweak it. Sadly, we won't be able to do that
with the upper leg as that would cause the knee to unplant itself,
but we can do something for the lower leg!

Before we get started, I have to warn you that this following setup
is made so you can easily animate the foot while the knee is
planted. However, if the foot is also planted, or if he's pushing
off the ground with his toes, it can lead to some counter animating.
While it is a lot easier to counter animate the foot compared to the
length of the leg, it's still somewhat of a hassle.

This will be much easier to set up while Stewie is in his default "T"
pose as rotations will line up much nicer.

First, create a Nurbs Circle by going to "Create > Nurbs > Circle"
and give it a new name by double clicking it's name in the channel
box. For my example, I'll be naming it "pKnee_Control".

Now we need to connect the Nurbs Circle to the Knee PV. Normally, a
parent constraint would work for this situation but due to all the
constraints that are already built into the knee, it will only cause
errors down the line. So instead, we'll be connecting the translate
attributes using the Connection Editor.

Go to "Window > General Editors > Connection Editor".


  • Select the Knee PV and in the Connection Editor, hit Reload Left.
  • Select the pKnee_Control and hit Reload Right.
  • Make sure the Editor is set to "from -> to".
  • Find and select the "translate" attribute from both the left then the right list and it will connect those attributes, making it so the pKnee_Control's translates will always equal those of the Knee PV.

Next, create a new Nurbs circle, which I will be naming
"pAnkle_Control". We'll be snapping this to the foot's pivot.
To do that,

  • Make sure the foot is not separated from the lower leg (it should be fine if Stewie is still in his default pose).
  • Switch to wireframe mode by hitting the "4" key.
  • Select the pAnkle_Control and while holding down the "c" key, middle mouse drag along one of the lower leg's vertical isoparms (the lines that make up the lower leg).
  • This will "curve snap" the control curve to the isoparm of the leg and if you drag all the way down to the ankle where all 8 of the lower leg's isoparms meet, you will have the pAnkle_Control exactly at the pivot point of the foot.

Now we need to parent constrain the foot control (the diamond shaped
control curve) to the pAnkle_Control, then parent constrain the
pAnkle_Control to the pKnee_Control.

What we have just created is basically a Fk/Ik hybrid and it will
allow you to rotate the pKnee_Control ring to animate the lower leg
while the knee is planted and the pAnkle_Control ring to animate the
foot rotation. This completely removes the need to counter animate
the lower leg as well as making it a bit easier to get nice arcs.
Just remember, once you've turned on this control system, avoid
animating the Translation, Rotation, or Footroll of the foot control
as it will just end up snapping back or causing the foot to become
misaligned.

But what if you need your character to lift his knee off the surface
afterwards? To turn off this system, key the foot control curve to
create a "blend parent" attribute and set it to 0. Then select the
Knee PV and set Knee Ik to 0; Layout Follow to 0; Foot Follow to 1.
This will allow you to animate the foot as usual.


Advanced:

Our system now allows you to plant the knee and animate it without
much counter animation, but turning it on/off whenever the knee
plants or lifts off the surface is quite the headache, especially
with all the attributes you need to change everywhere. So why not
automate it for us?

To begin with, we'll need a new attribute that will allow us to
control everything. Select the foot control and go to "Modify > Add
Attribute".



Name the new attribute something you'll remember. I'll be calling
mine "KneePlant". Also set the Data Type to "Boolean" to make the
attribute an on/off switch.

Now that we've got our new attribute, we need to set what it
controls. To do this, go to "Animate > Set Driven Key > Set..."
which will allow us to key other attributes to a value when the
KneePlant attribute is set to off and another value when it's set to
on, effectively making a switch.

Select the foot control and in the Set Driven Key window, hit the
"Load Driver" and in the top right pane, select the "Knee Plant"
attribute. We now have the attribute that will control the rest, but
what are the attributes that will need to be controlled? Here's a
list of which objects and attributes we'll need. Select each of the
objects below and load them as the Driven in the Set Driven Key
window.



  • From the foot control, we'll need the "Blend Parent" attribute.
  • From the Knee PV, we'll need the "Knee Ik", "Layout Follow", and
  • "Foot Follow" attributes.
  • From the pElbow_Control, we'll need the "Visibility".
  • From the pAnkle_Control, we'll need the "Visibility".

We now have everything we need to get started.

  • To begin, set the Knee Plant attribute to On.
  • Blend Parent to 1.
  • Knee Ik to 1.
  • Layout Follow to 1.
  • Foot Follow to 0.
  • Both Visibility attributes to 1.

In the Set Driven Key window, make sure that the "Knee Plant"
attribute is selected for the Driver then select each of the Driven
attributes listed above one by one and hit the Key button at the
bottom left of the window. For example, make sure the Knee Plant
attribute is selected then under the pKnee_Control, select the
Visibility attribute and hit the key button.

That's half the switch. Let's get it so it can turn off now.

The process is exactly the same but this time set the attributes as
follows:

  • Knee Plant attribute to Off.
  • Blend Parent to 0.
  • Knee Ik to 0.
  • Layout Follow to 0.
  • Foot Follow to 1.
  • Both Visibility to 0.

Key them all individually as you did earlier and with that, you
should now have a system that allows you to plant a knee solidly
onto a surface, animate the lower leg without having to counter
anything, and even turn it all on and off with the change of the
Knee Plant attribute!

There you have it. If you've made it all the way to the end of this
tutorial, congrats and thank you. I hope some of it has been helpful
to you and please remember that the intermediate and advanced
sections are not needed and will not give you a fantastic looking
animation. They only thing they help with making the constraints
easier to manage. So if you find it too difficult or if it just
isn't working for you, don't worry about just leaving it behind.

No comments:

Post a Comment