Setting and Retrieving Effector Data Using Matrices

The following procedures describe how to set and retrieve data for multiple Effectors in an HIKEffectorSetState using a data set that contains a transform matrix to represent each Node’s translation, orientation and scaling values.

Setting Effector data in an HIKEffectorSetState

Step 1. Construct your data blocks

In a memory buffer aligned on 16 bytes, store the following items for each Effector:

  • A matrix for each Effector in your HIKEffectorSetState that follows the format introduced under Transform Matrices. The offset of each matrix within the data set must be aligned on 16 bytes.
  • An array of four floating-point values that indicate the desired values for the Effector’s Reach Translation, Reach Rotation, Pull and Resist constraints. These values must be between 0.0 and 1.0.

For example:

// first Node's data block 
// -- matrix data
{-45.95f, 87.81f, -205.81f, 0.0f, 
 -0.54f, 0.0f, -0.05f, 0.83f,
 0.16f, 0.16f, 0.16f, 1.0f,
 -36.91f, 85.10f, -203.83f, 0.0f,
// -- constraint data
 0.5f, 0.5f, 1.0f, 0.0f},
// second Node's data block 
// -- matrix data
{-36.91f, 85.10f, -203.83f, 0.0f,
 -0.39f, 0.57f, -0.40f, 0.58f,
 0.16f, 0.16f, 0.16f, 1.0f
 -37.17f, 47.86f, -218.01f, 0.0f,
// -- constraint data
 0.5f, 0.5f, 1.0f, 0.0f},
},
// third Node's data block 
...

Step 2. Build your data description

This data description must be an instance of the HIKEffectorDataDescriptionMatrix structure. You must specify the following items for your data description:

  • The offset of each matrix within each Effector’s data block. This value is typically 0, unless each of your data blocks contains custom information unused by HumanIK before each matrix.
  • The offset of the constraint data within each Effector’s data block.
  • The stride, or size of each data block. As each matrix is an array of 16 floating-point numbers, plus each data block contains four floating-point constraint percentages, this value is typically equivalent to sizeof(float) * 20.
  • An array containing the unique IDs of all Effectors whose matrices are stored in the data set, in the order in which those matrices are stored. The last element in this array must be the special enumeration value HIKLastNode.

    This array may also include the special value HIKNotUsed, which instructs HumanIK to skip the corresponding data block.

For example:

int myUsedEffectors[] = {HipsEffectorId, 
                         LeftAnkleNodeId,
                         RightAnkleNodeId,
                         ...
                         RightFootPinkyEffectorId,
                         HIKLastNode
                         };
HIKEffectorDataDescriptionMatrix myDesc = {0,
                                           64,
                                           sizeof(float)*20,
                                           myUsedEffectors
                                           };

Step 3. Pass the data to HumanIK

Call the HIKSetEffectorStateData() function to apply the translation, rotation, scaling and IK constraint values contained in your data set to your HIKCharacter.

For example:

HIKSetEffectorStateData(lEffectorState,
                        &myDesc,
                        (void *)goalBuffer[frameId]);

Retrieving Effector data from an HIKEffectorSetState

To retrieve Effector data from an HIKEffectorSetState State using transform matrices for the translation, quaternion rotation and scaling values of each Effector, you must follow a process similar to that described under Setting and Retrieving Effector Data Using Matrices above, except that: