Setting and Retrieving Node Data Using Matrices

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

Setting Node data in an HIKCharacterState

To set your Node state from a data set containing matrices, follow the steps outlined below.

Step 1. Construct your data blocks

In a memory buffer aligned on 16 bytes, store a matrix for each Node in your HIKCharacterState that follows the format introduced under Transform Matrices. This matrix is the only information required for each Node; therefore, each matrix typically represents a data block on its own.

The offset of each matrix within the data set must be aligned on 16 bytes.

For example:

// first Node 
{-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},
// second Node 
{-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},
// third Node 
...

Step 2. Build your data description

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

  • An enumeration value that indicates whether the matrices are provided in global space or local space. This value may be either HIKGlobalSpace or HIKLocalSpace.
  • The offset of each matrix within its data block. This value is typically 0, unless each of your data blocks contains custom information unused by HumanIK before each matrix.
  • The stride, or size of each data block. As each matrix is an array of 16 floating-point numbers, this value is typically equivalent to sizeof(float) * 16.
  • An array containing the unique Node IDs of all Nodes 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 myUsedNodes[] = {HipsNodeId, 
                     LeftHipNodeId,
                     RightHipNodeId,
                     ...
                     RightFootPinkyDNodeId,
                     HIKLastNode
                     };
HIKDataDescriptionMatrix myDescription = {HIKGlobalSpace,
                                          0,
                                          sizeof(float)*16,
                                          myUsedNodes
                                          };

Step 3. Pass the data to HumanIK

Call the HIKSetCharacterStateTransform() function to apply the transform matrices contained in your data set to your HIKCharacter.

For example:

HIKSetCharacterStateTransform(lCharacter,
                              lCharacterState,
                              &myDescription,
                              (void *)gSrcAnimTQS[frameId]);

Retrieving Node data from an HIKCharacterState

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