Ejemplo n.º 1
0
        public void SubmitCards(string playerId, IEnumerable <Guid> cardIds)
        {
            var cards = cardIds.ToList();

            CurrentRound.SubmitCards(playerId, cards);
            cards.ForEach(k => Hands.Get(playerId).CardsInHand.Remove(k));
        }
Ejemplo n.º 2
0
 protected virtual void OnDisable()
 {
     if (_isActive)
     {
         var hand = Hands.Get(whichHand);
         WhenGestureDeactivated(hand, DeactivationReason.CancelledGesture);
         _isActive = false;
     }
 }
Ejemplo n.º 3
0
    void Update()
    {
        Hand hand = Hands.Get(whichHand);

        if (hand != null)
        {
            this.transform.position = (hand.WristPosition - hand.Arm.Direction * 0.04F).ToVector3();
            this.transform.rotation = hand.Arm.Rotation.ToQuaternion();
        }
    }
    // Update is called once per frame
    void Update()
    {
        var hand = Hands.Get(Chirality.Right);

        if (hand != null)
        {
            var indexPosition  = hand.Fingers[1].TipPosition;
            var middlePosition = hand.Fingers[2].TipPosition;
            var ringPosition   = hand.Fingers[3].TipPosition;
            var pinkyPosition  = hand.Fingers[4].TipPosition;
            var thumbPosition  = hand.Fingers[0].TipPosition;

            float[] index  = { 0, 0, 0 };
            float[] middle = { 0, 0, 0 };
            float[] ring   = { 0, 0, 0 };
            float[] pinky  = { 0, 0, 0 };
            float[] thumb  = { 0, 0, 0 };

            for (uint i = 0; i < 3; i++)
            {
                index[i] = indexPosition[i];
            }
            for (uint i = 0; i < 3; i++)
            {
                middle[i] = middlePosition[i];
            }
            for (uint i = 0; i < 3; i++)
            {
                ring[i] = ringPosition[i];
            }
            for (uint i = 0; i < 3; i++)
            {
                pinky[i] = pinkyPosition[i];
            }
            for (uint i = 0; i < 3; i++)
            {
                thumb[i] = thumbPosition[i];
            }

            float[] fingertips = { index[0], index[1], index[2], middle[0], middle[1], middle[2], ring[0], ring[1], ring[2], pinky[0], pinky[1], pinky[2], thumb[0], thumb[1], thumb[2] };

            for (int i = 0; i < 15; i++)
            {
                fingertips[i] = Mathf.Round(fingertips[i] * 1000) / 1000;
            }
            //Debug.Log(fingertips[10]);
            OscMessage message = new OscMessage();
            message.address = "/wek/inputs";
            for (int i = 0; i < 15; i++)
            {
                message.values.Add(fingertips[i]);
            }
            osc.Send(message);
        }
    }
Ejemplo n.º 5
0
        void Update()
        {
            Hand hand = Hands.Get(whichHand);

            if (hand != null)
            {
                brush.transform.position = hand.GetPinchPosition();

                if (hand.IsPinching() && !brush.IsBrushing())
                {
                    brush.Begin();
                }

                if (!hand.IsPinching() && brush.IsBrushing())
                {
                    brush.End();
                }
            }
        }
    void Update()
    {
        if (_intObj.isGrasped)
        {
            var sourceHand = Hands.Get(Chirality.Right) != null?Hands.Get(Chirality.Right) : Hands.Get(Chirality.Left);

            if (sourceHand != null)
            {
                Vector3 rot    = sourceHand.Rotation.ToQuaternion().eulerAngles;
                float   newRot = -1 * rot.z + 360;

                if (this.minRotationZ <= newRot && newRot <= this.maxRotationZ)
                {
                    transform.localRotation = Quaternion.Euler(0, 0, newRot);
                }
            }
        }
        else
        {
            transform.localRotation = Quaternion.Euler(0, 0, 0);
        }
    }
Ejemplo n.º 7
0
        void Update()
        {
            Hand brushHand = Hands.Get(indexBrushHand);

            if (brushHand != null)
            {
                Hand controlHand = Hands.Get(pinchControlHand);
                if (controlHand != null)
                {
                    brush.transform.position = brushHand.GetIndex().TipPosition.ToVector3();

                    if (controlHand.IsPinching() && !brush.IsBrushing())
                    {
                        brush.Begin();
                    }
                    if (!controlHand.IsPinching() && brush.IsBrushing())
                    {
                        brush.End();
                    }
                }
            }
        }
        private void Update()
        {
            Hand tipHand   = Hands.Get(tipHandChirality);
            Hand brushHand = Hands.Get(brushHandChirality);

            _isTipHandTracked   = tipHand != null;
            _isBrushHandTracked = brushHand != null;

            if (_isTipHandTracked)
            {
                var tipFinger = tipHand.Fingers[(int)tipFingerType];

                _pointBeginPosition = tipFinger.bones[1].PrevJoint.ToVector3()
                                      + tipFinger.bones[1].Direction.ToVector3()
                                      * (tipFinger.Length + tipDistance);
            }

            var brushHandIsPinching = _isBrushHandTracked && brushHand.PinchStrength > 0.65f;

            if (_isBrushHandTracked)
            {
                var pinchPosition = brushHand.GetPredictedPinchPosition();

                brush.transform.position = pinchPosition;

                if (brushHandIsPinching &&
                    Vector3.Distance(pinchPosition, _pointBeginPosition)
                    < tipRadius &&
                    !brush.IsBrushing())
                {
                    brush.Begin();
                }
            }

            if ((!_isBrushHandTracked || !brushHandIsPinching) && brush.IsBrushing())
            {
                brush.End();
            }
        }
Ejemplo n.º 9
0
        private void updatePose()
        {
            var hand = Hands.Get(whichHand);

            if (hand != null)
            {
                this.transform.position = hand.WristPosition.ToVector3();

                var trackedArmDirection = hand.WristPosition.ToVector3().From(hand.Arm.PrevJoint.ToVector3()).normalized;
                var fakeArmDirection    = hand.DistalAxis();

                var useArmDirection = Vector3.Slerp(fakeArmDirection, trackedArmDirection, useTrackedArmWeight);

                // IK arm direction (FABRIK)
                var target         = hand.WristPosition.ToVector3();
                var cameraSideways = (whichHand == Chirality.Left ? -1 : 1) * Camera.main.transform.right;
                var approxShoulder = Camera.main.transform.position
                                     - Camera.main.transform.up * 0.10f
                                     + (cameraSideways * 0.20f);
                armPointsIK[0]  = approxShoulder;
                armLengthsIK[0] = upperArmIKLength;
                armPointsIK[1]  = (approxShoulder + Vector3.down * upperArmIKLength + cameraSideways * 0.15f).normalized * upperArmIKLength;
                armLengthsIK[1] = foreArmIKLength;
                armPointsIK[2]  = armPointsIK[1] + Camera.main.transform.forward * foreArmIKLength;
                var fabrikChain = new IK.FABRIK.FABRIKChain(armPointsIK, armLengthsIK, target);
                IK.FABRIK.BackwardSolve(fabrikChain, warmStartDir: -fakeArmDirection);
                IK.FABRIK.ForwardSolve(fabrikChain);
                IK.FABRIK.Solve(fabrikChain);
                var ikResultArmDirection = armPointsIK[2].From(armPointsIK[1]).normalized;

                useArmDirection = Vector3.Slerp(useArmDirection, ikResultArmDirection, useIKArmWeight);

                this.transform.rotation = Quaternion.LookRotation(useArmDirection, hand.PalmarAxis())
                                          .Then(Quaternion.Euler(new Vector3(90f, 0f, 0f)));
            }
        }