public virtual void UpdateAvatar(Int64 UserID)
{
if (!gameObject.activeInHierarchy)
return;
// Get the KinectManager instance
if (kinectManager == null)
{
kinectManager = KinectManager.Instance;
}
// move the avatar to its Kinect position
MoveAvatar(UserID);
for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++)
{
if (!bones[boneIndex])
continue;
if (boneIndex2JointMap.ContainsKey(boneIndex))
{
KinectInterop.JointType joint = !mirroredMovement ? boneIndex2JointMap[boneIndex] : boneIndex2MirrorJointMap[boneIndex];
TransformBone(UserID, joint, boneIndex, !mirroredMovement);
}
else if (specIndex2JointMap.ContainsKey(boneIndex))
{
// special bones (clavicles)
List<KinectInterop.JointType> alJoints = !mirroredMovement ? specIndex2JointMap[boneIndex] : specIndex2MirrorJointMap[boneIndex];
if (alJoints.Count >= 2)
{
//Debug.Log(alJoints[0].ToString());
Vector3 baseDir = alJoints[0].ToString().EndsWith("Left") ? Vector3.left : Vector3.right;
TransformSpecialBone(UserID, alJoints[0], alJoints[1], boneIndex, baseDir, !mirroredMovement);
}
}
}
}