// Clear the class buffer for Positions/AvatarBoneLengths/HumanBoneVectors/HumanBoneLengths/Rotations/LocalRotations/FKPositions public void AllClear() { Positions.Clear(); AvatarBoneLengths.Clear(); HumanBoneVectors.Clear(); HumanBoneLengths.Clear(); Rotations.Clear(); LocalRotations.Clear(); FKPositions.Clear(); }
// Clear the class buffer for Positions/HumanToAvatarTransformRotations/AvatarBoneLengths/HumanBoneVectors/HumanBoneLengths/Rotations/LocalRotations/FKPositions public void Clear() { Positions.Clear(); HumanToAvatarTransformRotations.Clear(); AvatarBoneLengths.Clear(); HumanBoneVectors.Clear(); HumanBoneLengths.Clear(); Rotations.Clear(); LocalRotations.Clear(); FKPositions.Clear(); }
// AllClear is called for clearing the class buffer for Positions/AvatarBoneLengths/Rotations/LocalRotations/HumanBoneVectors/HumanBoneLengths/FKPositions and Frame/UseAbsoluteCoordinate/UseLocalRotation/UseForwardKinematics/SetFootOnGround public void AllClear() { Frame = 0; Positions.Clear(); AvatarBoneLengths.Clear(); UseAbsoluteCoordinate = false; UseLocalRotation = false; UseForwardKinematics = false; SetFootOnGround = false; Rotations.Clear(); LocalRotations.Clear(); HumanBoneVectors.Clear(); HumanBoneLengths.Clear(); FKPositions.Clear(); }
// CalculateBoneLengths is called for calculating the bone lengths of avatar public void CalculateBoneLengths() { // Positions of human joint keypoints are in the MPII order int[] boneJoints = new int[] { // 16 human bones in total and 6 means pelvis(hip) 6, 2, // rightHipBone 2, 1, // rightThigh 1, 0, // rightCalf 6, 3, // leftHipBone 3, 4, // leftThigh 4, 5, // leftCalf 6, 7, // waist 7, 8, // chest 8, 9, // neck 9, 10, // head 8, 13, // rightClavicle 13, 12, // rightUpperArm 12, 11, // rightForearm 8, 14, // leftClavicle 14, 15, // leftUpperArm 15, 16, // leftForearm }; var positions = Positions.ToList(); for (int i = 0; i < 16; i++) { int src = boneJoints[2 * i]; int dst = boneJoints[2 * i + 1]; var translate = positions[dst] - positions[src]; // vector points to dst from src HumanBoneVectors.Add(translate); // local vector var boneLength = translate.magnitude; HumanBoneLengths.Add(boneLength); } }