Example #1
0
 /*--------------------------------------------------------------------------------------------*/
 private void UpdateForPalm(Hand pLeapHand)
 {
     IsAvailable = true;
     Position    = pLeapHand.PalmPosition.ToUnityScaled();
     Rotation    = LeapUtil.CalcQuaternion(pLeapHand.Basis);          //GC_ALLOC
     Size        = pLeapHand.PalmWidth * SizeScaleFactor;
 }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void UpdateInput()
        {
            Frame leapFrame = LeapUtil.GetValidLeapFrame(vLeapControl);

            vMenuL.Rebuild(LeapUtil.GetValidLeapHand(leapFrame, true));
            vMenuR.Rebuild(LeapUtil.GetValidLeapHand(leapFrame, false));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void UpdateInput()
        {
            Frame leapFrame = vLeapProvider.CurrentFrame;

            vSettings.DistanceFromPalm       = DistanceFromPalm;
            vSettings.NavBackGrabThreshold   = NavigationBackGrabThreshold;
            vSettings.NavBackUngrabThreshold = NavigationBackUngrabThreshold;

            vMenuL.Rebuild(LeapUtil.GetValidLeapHand(leapFrame, true));
            vMenuR.Rebuild(LeapUtil.GetValidLeapHand(leapFrame, false));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void UpdateInput()
        {
            Frame frame     = LeapUtil.GetValidLeapFrame(vLeapControl);
            Hand  leapHandL = LeapUtil.GetValidLeapHand(frame, true);
            Hand  leapHandR = LeapUtil.GetValidLeapHand(frame, false);

            if (!IsEnabled)
            {
                leapHandL = null;
                leapHandR = null;
            }

            foreach (InputCursor cursor in vCursors)
            {
                cursor.UpdateWithHand(vSideMap[cursor.Type] ? leapHandL : leapHandR);
            }
        }
        /*--------------------------------------------------------------------------------------------*/
        internal void Rebuild(Hand pLeapHand)
        {
            if (pLeapHand == null)
            {
                IsAvailable          = false;
                Position             = Vector3.zero;
                Rotation             = Quaternion.identity;
                Radius               = 0;
                NavigateBackStrength = 0;
                DisplayStrength      = 0;
                return;
            }

            IsAvailable = true;
            Position    = pLeapHand.PalmPosition.ToUnityScaled();
            Rotation    = LeapUtil.CalcQuaternion(pLeapHand.Basis);          //GC_ALLOC
            Radius      = 0.01f;

            FingerList leapFingers = pLeapHand.Fingers;             //GC_ALLOC

            for (int i = 0; i < leapFingers.Count; i++)
            {
                Finger leapFinger = leapFingers[i];                 //GC_ALLOC

                if (leapFinger == null || !leapFinger.IsValid)
                {
                    continue;
                }

                Vector3    palmToFinger = leapFinger.TipPosition.ToUnityScaled() - Position; //GC_ALLOC
                Bone       bone         = leapFinger.Bone(Bone.BoneType.TYPE_DISTAL);        //GC_ALLOC
                Quaternion boneRot      = LeapUtil.CalcQuaternion(bone.Basis);               //GC_ALLOC

                Radius   = Math.Max(Radius, palmToFinger.sqrMagnitude);
                Rotation = Quaternion.Slerp(Rotation, boneRot, 0.1f);
            }

            Radius    = (float)Math.Sqrt(Radius);
            Position += Rotation * Vector3.down * vSettings.DistanceFromPalm * Radius;

            NavigateBackStrength = pLeapHand.GrabStrength / vSettings.NavBackGrabThreshold;
            NavigateBackStrength = Mathf.Clamp(NavigateBackStrength, 0, 1);

            DisplayStrength = Vector3.Dot(pLeapHand.PalmNormal.ToUnity(), vSettings.PalmDirection);
            DisplayStrength = Mathf.Clamp((DisplayStrength - 0.7f) / 0.25f, 0, 1);
        }
Example #6
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateForFinger(Hand pLeapHand, Finger.FingerType pLeapFingerType)
        {
            Finger leapFinger = LeapUtil.GetValidFinger(pLeapHand, pLeapFingerType);

            if (leapFinger == null)
            {
                UpdateForNull();
                return;
            }

            Bone bone = leapFinger.Bone(Bone.BoneType.TYPE_DISTAL);             //GC_ALLOC

            IsAvailable = true;
            Position    = leapFinger.TipPosition.ToUnityScaled();       //GC_ALLOC
            Rotation    = LeapUtil.CalcQuaternion(bone.Basis);          //GC_ALLOC

            Size = leapFinger.Width * SizeScaleFactor;
        }
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateForFinger(Hand pLeapHand, Finger.FingerType pLeapFingerType)
        {
            Finger leapFinger = pLeapHand.Fingers
                                .FingerType(pLeapFingerType)
                                .FirstOrDefault(f => f.IsValid);

            if (leapFinger == null)
            {
                UpdateForNull();
                return;
            }

            Bone bone = leapFinger.Bone(Bone.BoneType.TYPE_DISTAL);

            IsAvailable = true;
            Position    = leapFinger.TipPosition.ToUnityScaled();
            Rotation    = LeapUtil.CalcQuaternion(bone.Basis);
            Size        = leapFinger.Width * SizeScaleFactor;
        }
Example #8
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public InputCursor(CursorType pType)
 {
     Type            = pType;
     vLeapFingerType = LeapUtil.GetFingerType(pType);
     vIsPalm         = CursorTypeUtil.IsPalm(pType);
 }