datadescriptiontqs.h

datadescriptiontqs.h

This code example shows how to set and retrieve character animations using a data set that follows the HIKDataDescription structure, in conjunction with the HIKSetCharacterStateTransformTQS() / HIKGetCharacterStateTransformTQS() functions.

#include <humanik.h>
int gTQSNode[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 23, 24,
41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, HIKDataDescription::HIKLastNode
};
// Each data description applies to a single character. Other characters may share the same data description ONLY if their skeletons contain
// the same Nodes.
HIKGlobalSpace, 0, 16, 32, sizeof(float)*12, gTQSNode
};
// For the purposes of this example, the animation data set is hard-coded below. In your game, this should be replaced with the data from your
// FK character animations.
// PLEASE NOTE that the data set MUST be aligned on 16 bytes.
__declspec(align(16)) float gSrcAnimTQS[][71][12] = {
// First frame of animation.
{
{ 0.0000f, 0.0000f, 0.0000f, 0.0000f, 0.7071f, 0.0000f, 0.0000f, -0.7071f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -45.9543f, 87.8138f, -205.8150f, 0.0000f, -0.5467f, 0.0041f, -0.0513f, 0.8357f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -36.9173f, 85.1093f, -203.8390f, 0.0000f, -0.3937f, 0.5796f, -0.4090f, 0.5847f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -37.1718f, 47.8651f, -218.0180f, 0.0000f, -0.2165f, 0.6683f, -0.2402f, 0.6700f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -37.5291f, 22.2028f, -251.2470f, 0.0000f, 0.5176f, -0.5323f, 0.5517f, -0.3799f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -55.4791f, 86.7912f, -204.7580f, 0.0000f, 0.1685f, 0.7450f, 0.1959f, 0.6150f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
...
{ -66.7533f, 94.0136f, -212.6590f, 0.0000f, 0.6980f, 0.6422f, -0.2323f, -0.2155f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -66.9745f, 90.7422f, -212.5030f, 0.0000f, 0.6980f, 0.6422f, -0.2323f, -0.2155f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -67.1179f, 88.6202f, -212.4020f, 0.0000f, 0.6980f, 0.6422f, -0.2323f, -0.2155f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
{ -67.2390f, 86.8291f, -212.3160f, 0.0000f, 0.6980f, 0.6421f, -0.2323f, -0.2155f, 0.1650f, 0.1650f, 0.1650f, 1.0000f },
},
// Second frame of animation.
{
...
},
// Other animation frames...
...
};
void main()
{
// Initialize your game engine.
...
// The usual HumanIK initialization code goes here.
HIKCharacterState* lCharacterState;
// Other initialization that must be carried out before the game loop starts.
....
// Game loop.
for(;;)
{
// Update the game world, and retrieve FK joint animation from the animation curve.
...
// Data flow from your game engine to the HumanIK engine.
HIKSetCharacterStateTransformTQS(lCharacterState, &gTQSDD, (void *)gSrcAnimTQS[ gametime ]);
// Call the HumanIK IK solver.
// Data flow from the HumanIK engine to your game engine.
HIKGetCharacterStateTransformTQS(lCharacterState, &gTQSDD, (void *)gSrcAnimTQS[ gametime ]);
// Render your scene.
...
}
// Clean up your game engine.
...
// The usual HumanIK cleanup code goes here.
....
}