public static LEAP_HAND CreateHand(Hand hand)
        {
            LEAP_HAND leapHand = new LEAP_HAND();

            leapHand.id             = (uint)hand.Id;
            leapHand.flags          = 0;
            leapHand.type           = hand.IsLeft ? eLeapHandType.eLeapHandType_Right : eLeapHandType.eLeapHandType_Left; //HACK: flip due to coordinate space handedness
            leapHand.confidence     = hand.Confidence;
            leapHand.visible_time   = (uint)(hand.TimeVisible * 1000);
            leapHand.grab_angle     = hand.GrabAngle;
            leapHand.grab_strength  = hand.GrabStrength;
            leapHand.pinch_distance = hand.PinchDistance;
            leapHand.pinch_strength = hand.PinchStrength;

            LEAP_PALM palm = new LEAP_PALM();

            palm.position            = new LEAP_VECTOR(hand.PalmPosition);
            palm.stabilized_position = Vector3.zero.ToCVector(); //HACK: stabilized position is sometimes NaN, ignore it
            palm.velocity            = new LEAP_VECTOR(hand.PalmVelocity);
            palm.normal    = new LEAP_VECTOR(hand.PalmNormal);
            palm.width     = hand.PalmWidth;
            palm.direction = new LEAP_VECTOR(hand.Direction);
            // palm.orientation = new LEAP_QUATERNION(hand.Rotation);

            leapHand.palm = palm;
            leapHand.arm  = CreateBone(hand.Arm);

            for (int i = 0; i < hand.Fingers.Count; i++)
            {
                Finger finger = hand.Fingers[i];
                switch (finger.Type)
                {
                case Finger.FingerType.TYPE_THUMB:
                    leapHand.thumb = CreateDigit(finger);
                    break;

                case Finger.FingerType.TYPE_INDEX:
                    leapHand.index = CreateDigit(finger);
                    break;

                case Finger.FingerType.TYPE_MIDDLE:
                    leapHand.middle = CreateDigit(finger);
                    break;

                case Finger.FingerType.TYPE_RING:
                    leapHand.ring = CreateDigit(finger);
                    break;

                case Finger.FingerType.TYPE_PINKY:
                    leapHand.pinky = CreateDigit(finger);
                    break;

                default:
                    throw new Exception("Unexpected Finger Type " + finger.Type);
                }
            }

            return(leapHand);
        }
        public static IntPtr CreateHandArray(Frame frame)
        {
            _ids.Clear();

            var    hands     = frame.Hands;
            IntPtr handArray = StructAllocator.AllocateArray <LEAP_HAND>(hands.Count);

            for (int i = 0; i < hands.Count; i++)
            {
                if (_ids.Contains(hands[i].Id))
                {
                    Debug.LogWarning("Found multiple hands with the same id");
                    continue;
                }

                LEAP_HAND hand = CreateHand(hands[i]);
                StructMarshal <LEAP_HAND> .CopyIntoArray(handArray, ref hand, i);

                _ids.Add(hands[i].Id);
            }

            return(handArray);
        }