/// <summary> /// Lefts the hand. /// </summary> /// <returns>The hand.</returns> /// <param name="hand">Frame.</param> /// <param name="jt"></param> private static IEnumerable<BodyPart> CreateHand(Hand hand, JointType jt) { var palmNormal = hand.PalmNormal; var handPosition = hand.PalmPosition; var handPart = new BodyPart { Id = jt.ToInt(), Rotation = new Vector4(palmNormal.x, palmNormal.y, palmNormal.z, 0), Position = new Vector3(handPosition.x, handPosition.y, handPosition.z), Velocity = new Vector3(hand.PalmVelocity.x, hand.PalmVelocity.y, hand.PalmVelocity.z) }; // TODO: should we add the hand palm to the list? var parts = new List<BodyPart> { }; parts.AddRange( hand.Fingers.Select( finger => CreateFinger(finger, FingerType2JointType(finger.Type, JointType.HAND_LEFT == jt ? 1 : -1)) ).SelectMany(x => x) ); return parts; }
private static JointType BoneType2JointType(JointType fingerType, Bone.BoneType type) { int jt; switch (type) { case Bone.BoneType.TYPE_METACARPAL: jt = 1; break; case Bone.BoneType.TYPE_PROXIMAL: jt = 2; break; case Bone.BoneType.TYPE_INTERMEDIATE: jt = 3; break; case Bone.BoneType.TYPE_DISTAL: jt = 4; break; default: return JointType.UNSPECIFIED; } jt += fingerType.ToInt(); return (JointType) jt; }