Retargeting Solving

The following sections outline the process required at each frame to project the current position of your source character onto your target character.

Step 1. Updating the source HIKCharacterState

When you call the retargeting solver at each frame, you must provide the current position of your source character, derived from your original forward-kinematics animation. You provide this current stance in the HIKCharacterState you created for your source character in the initialization phase.

HumanIK provides several options for synchronizing the Nodes of your HIKCharacterState with the current FK position and rotation of the character’s joints in the game engine. For detailed information on all the available options, see Setting and Retrieving Animation Data.

One common method is to call the HIKSetNodeStateTQSfv() function for each Node in the HIKCharacterState. This function requires the following arguments:

For example:

HIKSetNodeStateTQSfv (MySrcCharacter, MySrcCharState, RightHandNodeId,
                                                      myModel.GetTrans(RightHandNodeId),
                                                      myModel.GetQuatRot(RightHandNodeId),
                                                      myModel.GetScale(RightHandNodeId)}

Step 2. Setting the IK solving step

The inverse kinematics solving process is broken down into several steps, each of which calculates new positions for a selected joint chain, the effect of a constraint such as Pull, or the result of a special transformation such as floor contact (see Foot and Hand Contact) or Squash ’n’ Stretch (see Using Squash 'n' Stretch).

To determine the solving steps that will performed when the retargeting solver calls the inverse kinematics solver, call the HIKSetIKSolvingStep() function. This function takes two arguments:

For example:

You can specify multiple solving steps listed in the HIKSolvingStep enumeration by concatenating them with the | operator (bitwise OR). For example:

You can also set the solving step to 0 to effectively skip the IK solving pass.

Step 3. Setting up the target Character Properties

You can control the HumanIK retargeting solver by changing the configuration settings in the HIKPropertySetState you created for your target character. For example, you can configure Reach, Pull and Resist settings for several of your character’s Nodes. For detailed information on the configuration options available in HIKPropertySetStates, and how to set those properties, see Character Properties, and Retargeting-Specific Properties.

The HIKPropertySetState of your source character is only used to retrieve the property HIKFootBottomToAnkleId, which the inverse kinematics solver needs in order to adapt the height of the source character to the target character. You only need to specify this one setting for your source character, only if you are using foot contact (see Foot and Hand Contact), and only if the ankles of your source and target characters are not at the same distance from the floor in their default T-stances.

Step 4. Launching the solver

To launch the HumanIK retargeting solver, call the HIKSolveForCharacter() function. This function requires the following arguments:

For example:

HIKSolveForCharacter (MyTargetChar, MyTargetCharState, MySrcChar, MySrcCharState, 
MyEffectorSet, MyTargetPropertySet, MySrcPropertySet);

The retargeting solver proceeds as follows:

  1. It copies the orientation of all Nodes in the source character’s HIKCharacterState to the target character’s HIKCharacterState.
  2. It sets up the HIKEffectorSetState you provide. This step primarily consists of setting the Reach, Pull and Resist values of each Effector to match the values of the Reach, Pull and Resist character properties in the target character’s HIKPropertySetState. See Retargeting-Specific Properties.
  3. It calls the inverse kinematics solver to perform an IK pass on the target character’s HIKCharacterState. This pass applies the Reach, Pull and Resist settings that you initially provided in the target character’s HIKPropertySetState, and performs any additional special effects such as floor contact.

Step 5. Retrieving the target HIKCharacterState

The retargeting solver stores the pose it generates for your target character in the same HIKCharacterState you passed in for that character as an argument. You must retrieve the translation, orientation and scaling of each Node in this HIKCharacterState, and apply it back to your game engine character.

HumanIK provides many options for retrieving the three-dimensional position, rotation and scaling of the Nodes in an HIKCharacterState. For detailed information on all the available options, see Setting and Retrieving Animation Data.

One common method of retrieving the pose calculated for the character is call the HIKGetNodeStateTQSfv() function for each Node in the HIKCharacterState. This function requires the following arguments:

For example:

const float trans[4];
const float quatRot[4];
const float scale[4];
HIKGetNodeStateTQSfv (MyCharState, RightHandNodeId, trans, quatRot, scale); 
... // apply retrieved values back to game engine here 

It is up to you to re-apply the retrieved values for each Node back to the corrensponding joint of the character in your game engine.