In the initialization phase, you create and set up each character to be used with HumanIK, along with the HIKCharacterStates that record their poses, the HIKPropertySetStates that define their characteristics, and the HIKEffectorSetStates that provide goal points and IK constraints to the HumanIK solvers.
Initialization for inverse kinematics: If you are planning to use the inverse kinematics solver only, follow all the steps listed on this page once to set up your character.
Initialization for retargeting: If you are planning to use the retargeting solver, you must set up two characters: the source character from which the animation is drawn, and the target character, on which the animation is applied.
Perform steps 1 to 3 twice, once for the source character and once for the target character. However, because the retargeting solver launches the inverse kinematics solver internally only for the target character, you only need one HIKEffectorSetState. Therefore, you only need to perform step 4 once.
The ultimate goal of this step is to have an HIKCharacter object that has been fully characterized with a default T-stance that accurately reflects the skeletal structure and physical geometry of the character in your game.
There are two main approaches to accomplishing this goal:
For details, see Characterizing an HIKCharacter Programmatically.
This approach has the advantage of allowing the characterization to be set up by the artists and technical directors in your organization rather than programmers, and offers immediate visual feedback on the IK results produced by the characterization.
For details, see Characterizing an HIKCharacter Visually.
See the subordinate topics for details on the different approaches to determine which is most appropriate for your project and your design pipeline.
Once you have created an HIKCharacter for your character, you need to create at least one HIKCharacterState. This HIKCharacterState contains a translation and rotation matrix for each of the character’s Nodes, and is used both as input and output for the HumanIK solvers.
To create an instance of the HIKCharacterState class, call the HIKCharacterStateCreate() function. This function requires two arguments:
HIKCharacterState * MyCharState = HIKCharacterStateCreate(MyChar, &malloc);
An HIKPropertySetState defines a variety of optional attributes for HIKCharacters, such as the way certain joints move under certain conditions, the way contact is established with the floor, whether the character’s left and right are mirrored, etc.
You must create an HIKPropertySetState for your character by calling the HIKPropertySetStateCreate() function, and passing as an argument a pointer to a callback function that will be invoked to allocate memory for the HIKPropertySetState. You can specify the standard malloc function, or any custom memory allocation method that satisfies the same type definition as malloc. See also HumanIK Objects and Memory Management.
HIKPropertySetState * MyPropertySet = HIKPropertySetStateCreate(&malloc);
Note that HIKPropertySetStates do not depend directly on an HIKCharacter or an HIKCharacterDefinition. All HIKPropertySetStates contain the same properties; only the values and modes of those properties may be different for different characters. For details on the properties available in each HIKPropertySetState, see Character Properties.
An HIKEffectorSetState contains a target point for each of your character’s Nodes, and a set of constraints for each Effector (Reach, Pull, and Resist). The HIKEffectorSetState also defines which solving steps the inverse kinematics solver should perform—i.e. which body parts will be controlled.
You must create an HIKEffectorSetState by calling the HIKEffectorSetStateCreate() function, and passing as an argument a pointer to a callback function that will be invoked to allocate memory for the HIKEffectorSetState. You can specify the standard malloc function, or any custom memory allocation method that satisfies the same type definition as malloc. See also HumanIK Objects and Memory Management.
HIKEffectorSetState * MyEffectorSet = HIKEffectorSetStateCreate(&malloc);
Because the HumanIK retargeting solver uses the inverse kinematics solver internally, you must create an HIKEffectorSetState even if you are using HumanIK only to retarget an animation.