Setting up Squash 'n' Stretch

Setting up Squash ’n’ Stretch requires you to configure a set of character properties that define your character’s elasticity, and to set up your HIKEffectorSetState with the necessary solving step.

Step 1. Setting the solving step

When you call the HIKSetIKSolvingStep() function to set the solving step in your HIKEffectorSetState, you must include in the HIKEffectorSetState you provide to the HumanIK solver any or all of the following steps, depending on which limbs you want to be treated by the Squash ’n’ Stretch engine.

For details on IK solving steps, see Solving Selected Body Parts.

Arms and legs

Squash ’n’ Stretch for the arms and legs is performed by the following solving steps:

For example:

Note that these solving steps are not included in the HIKSolvingStepAllParts and HIKSolvingStepAll steps.

Spine and neck

Squash ’n’ Stretch for the spine and neck is performed by the HIKSolvingStepSpine and HIKSolvingStepHead solving steps respectively.

Note that these solving steps are included in the HIKSolvingStepAllParts and HIKSolvingStepAll steps. If you use either of these solving steps, you do not need to specify the HIKSolvingStepSpine or HIKSolvingStepHead steps explicitly. Squash ’n’ Stretch is therefore always evaluated for the character’s spine and neck, but it has no effect unless you also set stretch reach for the spine or neck as instructed in step 3 below.

Step 2. Configuring Reach Translation for the joint chain

In order for the Squash ’n’ Stretch engine to apply to a joint chain, the Effector at the end of that joint chain must have a positive amount of Reach Translation applied to it. The Effectors concerned are the following:

If you are performing an inverse kinematics solve, you must set this Reach Translation in the HIKEffectorSetState you pass to the inverse kinematics solver. See Inverse Kinematics Solving.

If you are performing a retargeting, you must set this Reach Translation in the HIKPropertySetState you pass to the retargeting solver for the target character. See Retargeting Solving, and Retargeting-Specific Properties.

Step 3. Configuring the stretch reach for the joint chain

When you apply Reach Translation to the Effector at the end of one of your character’s limb, HumanIK can use several different strategies in order to satisfy the requirement and place the corresponding Nodes at the desired position. It can bend or straighten the limb (subject to any Resist that might be configured for elbows and knees), it can use the Pull engine to make the rest of the body contribute to the final position (if Pull is also applied to the Effector), or it can squash and stretch the limb.

The inverse kinematics solver uses a set of character properties to define the "stretch reach" of each joint chain. This stretch reach determines how strongly the Squash ’n’ Stretch engine should contribute to the final solution relative to other strategies such as pulling the rest of the body.

Stretch reach is configured independently for each joint chain that can be affected by Squash ’n’ Stretch, using the following character properties:

To set the stretch reach for a joint chain, set the corresponding property to the desired percentage. For example:

Step 4. Configuring the freedom of the joint chain (optional)

You can configure the maximum amount of squash and stretch that HumanIK can apply to each of your joint chains. This "freedom" is determined by a set of character properties, which are interpreted differently for the arms and legs than for the spine and neck.

This step is marked as optional because the character properties involved have default values pre-set. For these defaults, see the corresponding property descriptions under General Properties.

Arms and legs

Arms and legs never squash shorter than their original length, they only stretch. Their freedom to stretch is determined by two percentage values:

  • The percentage of the original length at which the limb can begin to stretch in order to place its Effector at the desired position. This is defined for both arms and legs by the HIKStretchStartArmsAndLegs character property.
  • The percentage of the original length at which the limb stops stretching freely. This is defined for both arms and legs by the HIKStretchStopArmsAndLegs character property.

This is a soft limit; to avoid "popping," the limb will continue to stretch past this limit in order to reach distant goal points. However, the amount of stretch applied to the limb decreases exponentially once this threshold has been passed.

To set the freedom for the arms or legs, set each of these properties to the desired percentage. For example:

Spine and neck

The freedom of the spine and neck is determined by translation limits that you specify for each Node,. These limits determine how close each Node is allowed to be squashed toward its parent Node, and how far each Node is allowed to be stretched away from its parent Node. These limits are expressed as percentage values of the original translation from the parent Node (i.e. the original length of the bone leading to each Node).

You can set these limits for each Node in the spine or neck by calling the HIKSetTranslationLimitsf() or HIKSetTranslationLimitsd() function.

For example:

f_minSnSTranslation = 0.92f;
f_maxSnSTranslation = 1.08f;
b_isActive = true;
HIKSetTranslationLimitsf(MyHIKCharacter, Spine1NodeId, f_minSnSTranslation, f_maxSnSTranslation, b_isActive);

Spine children

You can configure the inverse kinematics solver to reflect a percentage of the compression or expansion applied to the spine in the child Nodes of the spine. Depending on the way your character’s skeleton is contructed and the way its mesh is skinned, this may tend to preserve the proportions of the upper body.

The following Nodes are affected:

The propagation of Squash ’n’ Stretch from the spine to these child Nodes is determined by the HIKSnSScaleSpineChildren property. Set this property to the desired percentage as follows:

Step 5. Configuring the scaling of the joint chain (optional)

By default, the Squash ’n’ Stretch solver alters the length of your character’s limbs by manipulating the translations and rotations of their Nodes. Instead, you can configure the inverse kinematics solver to apply some or all of the change in the length of the limb by changing the scale of the Nodes in the limb. Depending on your character’s skinning, this can help to offset the change in the character’s proportions caused by the squash or stretch.

The inverse kinematics solver uses a set of character properties to define the scaling percentage of each joint chain.

Scaling is configured using the following character properties:

To set the scaling value for a joint chain, set the corresponding property to the desired percentage. For example: