The following sections outline the process required at each frame to project the current position of your source character onto your target character.
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:
HIKSetNodeStateTQSfv (MySrcCharacter, MySrcCharState, RightHandNodeId, myModel.GetTrans(RightHandNodeId), myModel.GetQuatRot(RightHandNodeId), myModel.GetScale(RightHandNodeId)}
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:
HIKSetIKSolvingStep (MyEffectorState, HIKSolvingStepAll);
You can specify multiple solving steps listed in the HIKSolvingStep enumeration by concatenating them with the | operator (bitwise OR). For example:
HIKSetIKSolvingStep (MyEffectorState, HIKSolvingStepBodyPull | HIKSolvingStepLeftShoulder | HIKSolvingStepLeftArm | HIKSolvingStepLeftHand);
You can also set the solving step to 0 to effectively skip the IK solving pass.
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.
To launch the HumanIK retargeting solver, call the HIKSolveForCharacter() function. This function requires the following arguments:
HIKSolveForCharacter (MyTargetChar, MyTargetCharState, MySrcChar, MySrcCharState, MyEffectorSet, MyTargetPropertySet, MySrcPropertySet);
The retargeting solver proceeds as follows:
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:
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.