Setting and Retrieving Effector Data Using Separate TQS Values

The following procedures describe how to set and retrieve data for multiple Effectors in an HIKEffectorSetState using a data set that contains separate number arrays to represent each Node’s translation, orientation, scaling and IK constraint 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 Node:

  • Four floating-point numbers that define the translation of the Effector in global space.
  • Four floating-point numbers that define the orientation of the Effector in global space, expressed as a quaternion.
  • Four floating-point numbers that define the scaling of the Effector in global space.
  • Four floating-point numbers that define the values of the Reach Translation, Reach Rotation, Pull and Resist constraints respectively for the Effector. These values must be between 0.0 and 1.0.

Each of the items listed above must be aligned on 16 bytes.

These values do not need to be in the order listed above; for example, the scaling values may precede the translation values.

For example:

// first Effector 
//----translation values------\\  //---orientation values---\\ //----scaling values----\\
{-45.95f, 87.81f, -205.81f, 0.0f, -0.54f, 0.0f, -0.05f, 0.83f, 0.16f, 0.16f, 0.16f, 1.0f,
//--constraint values--\\
 0.5, 0.5, 1.0, 0.0},
// second Effector 
//----translation values------\\  //---orientation values---\\ //----scaling values----\\
{-36.91f, 85.10f, -203.83f, 0.0f, -0.39f, 0.57f, -0.40f, 0.58f, 0.16f, 0.16f, 0.16f, 1.0f,
//--constraint values--\\
 0.75, 0.75, 0.5, 0.0},
// third Effector 
//----translation values------\\  //---orientation values---\\ //----scaling values----\\
{-37.17f, 47.86f, -218.01f, 0.0f, -0.21f, 0.66f, -0.24f, 0.67f, 0.16f, 0.16f, 0.16f, 1.0f,
//--constraint values--\\
 1.0, 1.0, 0.5, 0.25},
...

Step 2. Build your data description

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

  • The offset of the translation data within each Effector’s data block. This offset must be aligned on 16 bytes.
  • The offset of the orientation data within each Effector’s data block. This offset must be aligned on 16 bytes.
  • The offset of the scaling data within each Effector’s data block. This offset must be aligned on 16 bytes.
  • The offset of the IK constraint values within each Effector’s data block. This offset must be aligned on 16 bytes.
  • The stride, or size of each data block. As each data block contains three arrays of four floating-point numbers, plus four floating-point numbers for the constraint values, this value is typically equivalent to sizeof(float) * 16, unless your data blocks contain additional custom information not used by HumanIK.
  • 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
                         };
HIKEffectorDataDescription myDesc = {0,
                                     16,
                                     32,
                                     48,
                                     sizeof(float)*16,
                                     myUsedEffectors
                                     };

Step 3. Pass the data to HumanIK

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

For example:

HIKSetEffectorStateDataTQS(lEffectorSetState,
                           &myDesc,
                           (void *)goalBuffer[frameId]);

Retrieving Effector data from an HIKEffectorSetState

To retrieve Effector data from an HIKEffectorSetState using separate number arrays 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 Separate TQS Values above, except that: