Esempio n. 1
0
    private void CheckForPinchAction()
    {
        candidateHands.Clear();
        foreach (var controller in manager.interactionControllers)
        {
            var hand = controller.intHand;
            if (!controller.isTracked || hand == null)
            {
                continue;
            }

            if (hand.NoFistPinchStrength() > pinchActivateThreashold)
            {
                candidateHands.Add(hand);
            }
        }

        if (candidateHands.Count == 0)
        {
            return;
        }

        var pinchResult = DetermineBestPinchable(candidateHands);

        if (pinchResult.Item1 != null)
        {
            pinchingHand  = pinchResult.Item1;
            pinchedObject = pinchResult.Item2;
            pinchedObject.BeginPinch(pinchingHand);
        }
    }
Esempio n. 2
0
    void Update()
    {
        if (pinchingHand == null || pinchedObject == null)
        {
            CheckForPinchAction();
            return;
        }

        if (!pinchingHand.isTracked)
        {
            pinchedObject.EndPinch(pinchingHand);
            pinchedObject = null;
            pinchingHand  = null;
        }
        else
        {
            if (pinchingHand.leapHand.PinchStrength < pinchDeactivateThreashold)
            {
                pinchedObject.EndPinch(pinchingHand);
                pinchedObject = null;
                pinchingHand  = null;
            }
            else
            {
                var pos = pinchingHand.leapHand.GetPinchPosition();
                pinchedObject.UpdatePinch(pinchingHand);
            }
        }
    }
Esempio n. 3
0
    private Tuple <InteractionHand, IPinchable> DetermineBestPinchable(IEnumerable <InteractionHand> hands)
    {
        IPinchable      best        = null;
        InteractionHand bestHand    = null;
        float           minDistance = float.MaxValue;

        foreach (var hand in hands)
        {
            var pos = hand.leapHand.GetPinchPosition();

            foreach (var pinchComponent in pinchables)
            {
                pinchComponent.CheckPinchStart(hand, out bool isValid, out float distance);
                if (isValid && distance < minDistance)
                {
                    minDistance = distance;
                    best        = pinchComponent;
                    bestHand    = hand;
                }
            }
        }

        return(Tuple.Create <InteractionHand, IPinchable>(bestHand, best));
    }
Esempio n. 4
0
 public static void DeregisterPinchable(IPinchable pinchable)
 {
     pinchables.Remove(pinchable);
 }
Esempio n. 5
0
 public static void RegisterPinchable(IPinchable pinchable)
 {
     pinchables.Add(pinchable);
 }
Esempio n. 6
0
 public PinchingGRConfiguration(bool exclusive, IPinchable clientWindow, bool relativeScaling)
     : base(exclusive)
 {
     m_clientWindow = clientWindow;
     m_relativeScaling = relativeScaling;
 }
Esempio n. 7
0
 public PinchingGR(GRConfiguration configuration)
     : base(configuration)
 {
     PinchingGRConfiguration conf = (PinchingGRConfiguration)configuration;
     m_clientWindow = conf.ClientWindow;
     m_relativeScaling = conf.RelativeScaling;
 }