Setting and Retrieving Node Data Using Separate TQS Values

The following procedures describe how to o set and retrieve data for multiple Nodes in an HIKCharacterState using a data set that contains separate number arrays to represent each Node’s translation, quaternion rotation and scaling values.

Setting Node data in an HIKCharacterState

To set the state of a Node from a data set that contains separate translation, quaternion rotation and scaling values, follow the steps outlined below.

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 Node in global space.
  • Four floating-point numbers that define the orientation of the Node in global space, expressed as a quaternion.
  • Four floating-point numbers that define the scaling of the Node in global space.

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

Step 2. Build your data description

This data description must be an instance of the HIKDataDescription 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 the translation data within each Node’s data block. This offset must be aligned on 16 bytes.
  • The offset of the orientation data within each Node’s data block. This offset must be aligned on 16 bytes.
  • The offset of the scaling data within each Node’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, this value is typically equivalent to sizeof(float) * 12, unless your data blocks contain additional custom information not used by HumanIK.
  • 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,
                                          16,
                                          32,
                                          sizeof(float)*12,
                                          myUsedNodes
                                          };

Step 3. Pass the data set to HumanIK

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

For example:

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

Retrieving Node data from an HIKCharacterState

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

Alternative functions

You can use the following functions as alternatives to HIKSetCharacterStateTransformTQS() and HIKGetCharacterStateTransformTQS(). These functions all accept the same arguments detailed above, but read or write data in slightly different ways.

For additional details, see the description of each function in the API Reference.