/** * Copies the data from an internal finger definition into a finger. * * @param leapBone The internal finger definition to be copied into this finger. * @param type The finger type of this finger. * @param frameId The frame id of the frame this finger belongs to. * @param handId The hand id of the hand this finger belongs to. * @param timeVisible The time in seconds that this finger has been visible. */ public static Finger CopyFrom(this Finger finger, LEAP_DIGIT leapBone, Finger.FingerType type, int handId, float timeVisible) { finger.Id = (handId * 10) + leapBone.finger_id; finger.HandId = handId; finger.TimeVisible = timeVisible; Bone metacarpal = finger.bones[0]; Bone proximal = finger.bones[1]; Bone intermediate = finger.bones[2]; Bone distal = finger.bones[3]; metacarpal.CopyFrom(leapBone.metacarpal, Leap.Bone.BoneType.TYPE_METACARPAL); proximal.CopyFrom(leapBone.proximal, Leap.Bone.BoneType.TYPE_PROXIMAL); intermediate.CopyFrom(leapBone.intermediate, Leap.Bone.BoneType.TYPE_INTERMEDIATE); distal.CopyFrom(leapBone.distal, Leap.Bone.BoneType.TYPE_DISTAL); finger.TipPosition = distal.NextJoint; finger.Direction = intermediate.Direction; finger.Width = intermediate.Width; finger.Length = (leapBone.finger_id == 0 ? 0.0f : 0.5f * proximal.Length) + intermediate.Length + 0.77f * distal.Length; //The values 0.5 for proximal and 0.77 for distal are used in platform code for this calculation finger.IsExtended = leapBone.is_extended != 0; finger.Type = type; return(finger); }
/** * Copies the data from an internal finger definition into a finger. * * @param leapBone The internal finger definition to be copied into this finger. * @param type The finger type of this finger. * @param frameId The frame id of the frame this finger belongs to. * @param handId The hand id of the hand this finger belongs to. * @param timeVisible The time in seconds that this finger has been visible. */ public static Finger CopyFrom(this Finger finger, LEAP_DIGIT leapBone, Finger.FingerType type, int handId, float timeVisible) { finger.Id = (handId * 10) + leapBone.finger_id; finger.HandId = handId; finger.TimeVisible = timeVisible; Bone metacarpal = finger.bones[0]; Bone proximal = finger.bones[1]; Bone intermediate = finger.bones[2]; Bone distal = finger.bones[3]; metacarpal.CopyFrom(leapBone.metacarpal, Leap.Bone.BoneType.TYPE_METACARPAL); proximal.CopyFrom(leapBone.proximal, Leap.Bone.BoneType.TYPE_PROXIMAL); intermediate.CopyFrom(leapBone.intermediate, Leap.Bone.BoneType.TYPE_INTERMEDIATE); distal.CopyFrom(leapBone.distal, Leap.Bone.BoneType.TYPE_DISTAL); finger.TipPosition = distal.NextJoint; finger.TipVelocity = leapBone.tip_velocity.ToLeapVector(); finger.Direction = intermediate.Direction; finger.StabilizedTipPosition = leapBone.stabilized_tip_position.ToLeapVector(); finger.Width = intermediate.Width; finger.Length = proximal.Length + intermediate.Length + (distal.Length * 0.77f); //0.77 is used in platform code for this calculation finger.IsExtended = leapBone.is_extended != 0; finger.Type = type; return(finger); }