Humanoid Movements

Function descriptions

This page describes the functions in the Humanoid Movements library. Every function comes in two flavours: a C++ style and a C style function. The C++ style function is recognizable from the Humanoid:: class declaration. C-style functions start with Humanoid_.

Humanoid* Humanoid_Constructor();

Constructor for the Humanoid object.

void Humanoid_Destructor(Humanoid *humanoid);

Destructor for the Humanoid Object.

void Humanoid::Init();
void Humanoid_Init(Humanoid *humanoid);

This will initialize the humanoid based on all bone locations. It will calculate the bone orientations, bone lengths en everything else needed to do accurate movement calculations.

For this to work, all relevant bone positions and rotation need to be set first using the SetBonePosition/SetBoneRotation functions.

void Humanoid::SetBonePosition(Humanoid::Bones boneId, Vec3 position);
void Humanoid::SetBoneRotation(Humanoid::Bones boneId, Quat rotation);
void Humanoid_SetBonePosition(Humanoid *humanoid, Humanoid::Bones boneId, Vec3 position);
void Humanoid_SetBoneRotation(Humanoid *humanoid, Humanoid::Bones boneId, Quat rotation);

Sets the position or the rotation of a bone in the avatar rig. These functions are mainly used to set the positions and rotations of the bones in the default pose before the Init() function is called. A T-pose is recommended for the default pose, but other poses can work.

Vector3 Humanoid::GetBonePosition(Humanoid::Bones boneId);
Quaternion Humanoid::GetBoneRotation(Humanoid::Bones boneId);
Vec3 Humanoid_GetBonePosition(Humanoid *humanoid, Humanoid::Bones boneId);
Quat Humanoid_GetBoneRotation(Humanoid *humanoid, Humanoid::Bones boneId);

Gets the position or rotation of a bone in the avatar rig. These functions are mainly used to get the bone positions and rotations are they are updated using the UpdateMovements() function.

void Humanoid::UpdateMovements();
void Humanoid_UpdateMovements(Humanoid *humanoid);

Calculates the position and rotation for all bones in the rig based on the positions and rotations of the targets.

void Humanoid::SetTargetPosition(Humanoid::Bones boneId, Vec3 position, float confidence);
void Humanoid::SetTargetRotation(Humanoid::Bones boneId, Quat rotation, float confidence);
void Humanoid_SetTargetPosition(Humanoid *humanoid, Humanoid::Bones boneId, Vec3 position, float confidence);
void Humanoid_SetTargetRotation(Humanoid *humanoid, Humanoid::Bones boneId, Quat rotation, float confidence);

Sets the positions and rotations of the targets for the bones. Every bone can have a target set. The amount in which the target is used for the movements depends on the confidence of the target. The confidence ranges from 0 (this target is irrelevant) to 1 (it is certain that the target is here). The most important targets are the neck, hand, hips and foot targets: those targets will mainly drive the movement calculations. Additionally other bone targets can be set to improve the resulting movements. You can limit setting the targets to a subset. Like just the head or the hands for example.

How to use

When using this library, the follow pattern should be followed.

  • Create the Humanoid object using the Constructor
  • Set all relevant bone positions and rotations for the avatar in default pose using the SetBonePosition/Rotation.
  • Call the Init() function to do the measurements on the avatar rig.
For every update
  • Set the target positions and rotations which represent the desired pose using the SetTargetPosition/Rotation
  • Call the UpdateMovements function to update the bone positions which best match the desired pose
  • Use GetBonePosition/Rotation to get the newly calculated pose of the avatar
  • Call the Destructor for the Humanoid object.