public void Remove(Pointable pointable) { Pointables.Remove(pointable); Finger f = pointable as Finger; if (f != null) { Fingers.Remove(f); } else { Tools.Remove(pointable as Tool); } }
public Bone CreateBone(string handType, Pointables finger, List <List <float> > basis, Vector PreJoint, Vector NextJoint, Bone.BoneType type) { // Build Bine Bone bone = new Bone (PreJoint, // prevJoint - The proximal end of the bone (closest to the body) NextJoint, // nextJoint - The distal end of the bone (furthest from the body) (PreJoint + NextJoint) * 0.5f, // center - The midpoint of the bone PreJoint + NextJoint, // direction - The unit direction vector pointing from prevJoint to nextJoint. PreJoint.DistanceTo(NextJoint), // length - The estimated length of the bone. finger.width, // width - The estimated average width of the bone. type, // type - The type of finger bone. CreateLeapQuater(basis, handType)); // basis - The matrix representing the orientation of the bone. return(bone); }
public List <Hand> GetRemoteHand(FrameData Jframe) { List <Hand> hands = new List <Hand>(); for (int i = 0; i < Jframe.hands.Count; i++) { Hands hand = Jframe.hands[i]; //---------------------------------------------------------------------------------------------------------- // Arm Vector elbow = toVec3(hand.elbow); Vector wrist = toVec3(hand.wrist); Arm arm = new Arm (elbow, wrist, (elbow + wrist) * 0.5f, (wrist - elbow).Normalized, wrist.DistanceTo(elbow), hand.armWidth, CreateLeapQuater(hand.armBasis, hand.type)); //---------------------------------------------------------------------------------------------------------- // Fingers List <Finger> fingers = new List <Finger>(); if (Jframe.pointables == null || Jframe.pointables.Count == 0) { Debug.Log("JSON Data Error: The Pointables have nothing from hands building!"); return(hands); } Pointables pointable = new Pointables(); for (int j = 0; j < FingersNumbers; j++) { for (int i_finger = 0; i_finger < Jframe.pointables.Count; i_finger++) { pointable = Jframe.pointables[i_finger]; if (pointable.handId == hand.id && pointable.type == j) { break; } } if (pointable.handId != hand.id || pointable.type != j) { Console.ReadKey(); } Bone metacarpal = CreateBone(hand.type, pointable, pointable.bases[0], toVec3(pointable.carpPosition), toVec3(pointable.mcpPosition), Bone.BoneType.TYPE_METACARPAL); Bone proximal = CreateBone(hand.type, pointable, pointable.bases[1], toVec3(pointable.mcpPosition), toVec3(pointable.pipPosition), Bone.BoneType.TYPE_PROXIMAL); Bone intermediate = CreateBone(hand.type, pointable, pointable.bases[2], toVec3(pointable.pipPosition), toVec3(pointable.dipPosition), Bone.BoneType.TYPE_INTERMEDIATE); Bone distal = CreateBone(hand.type, pointable, pointable.bases[3], toVec3(pointable.dipPosition), toVec3(pointable.btipPosition), Bone.BoneType.TYPE_DISTAL); Finger f = new Finger (Jframe.id, pointable.handId, pointable.id, pointable.timeVisible, toVec3(pointable.tipPosition), toVec3(pointable.tipVelocity), toVec3(pointable.direction), toVec3(pointable.stabilizedTipPosition), pointable.width, pointable.length, pointable.extended, (Finger.FingerType)pointable.type, metacarpal, // metacarpal - The first bone of the finger (inside the hand). proximal, // proximal - The second bone of the finger intermediate, // intermediate - The third bone of the finger. distal); // distal - The end bone. fingers.Add(f); } //---------------------------------------------------------------------------------------------------------- // Hands Hand RemoteHand = new Hand (Jframe.id, hand.id, hand.confidence, hand.grabStrength, hand.grabAngle, hand.pinchStrength, hand.pinchDistance, hand.palmWidth, (hand.type == "left") ? true : false, hand.timeVisible, arm, // Arm fingers, // Finger List toVec3(hand.palmPosition), toVec3(hand.stabilizedPalmPosition), toVec3(hand.palmVelocity), toVec3(hand.palmNormal), toVec3(hand.direction), toVec3(hand.wrist)); hands.Add(RemoteHand); } return(hands); }