void HandleOnPointsRightReceived(HandInformation information)
    {
        position = information.position;
        // handPointer.transform.rotation = information.quaternion;
        confiance = information.confianceLevel;
        switch (information.confianceLevel)
        {
        case 0:
            color = Color.red;
            break;

        case 1:
            color = Color.yellow;
            break;

        case 2:
            color = Color.green;
            break;

        case 3:
            color = Color.blue;
            break;

        default:
            break;
        }
    }
示例#2
0
    private void ReceivePointData()
    {
        Server = new UdpClient(port);
        while (true)
        {
            try {
                IPEndPoint  anyIp      = new IPEndPoint(IPAddress.Any, 0);
                byte[]      data       = Server.Receive(ref anyIp);
                string      jsonString = Encoding.UTF8.GetString(data);
                HandsPacket packet     = JsonUtility.FromJson <HandsPacket> (jsonString);


                Debug.Log("Packete recivido");

                Vector3         handPointRight   = packet.right;
                HandInformation informationRight = new HandInformation(handPointRight, packet.q_right, packet.right_level);

                Vector3         handPointLeft   = packet.left;
                HandInformation informationLeft = new HandInformation(handPointLeft, packet.q_left, packet.left_level);

                if (OnPointsRightReceived != null)
                {
                    OnPointsRightReceived(informationRight);
                }
                if (OnPointsLeftReceived != null)
                {
                    OnPointsLeftReceived(informationLeft);
                }
            } catch (Exception err) {
                Debug.Log("Exception --> " + err.ToString());
            }
        }
    }
示例#3
0
    FrameInformation fetchFrameInformation()
    {
        FrameInformation frameInfo = new FrameInformation();

        frameInfo.grabHeld  = grabHeld;
        frameInfo.pinchHeld = pinchHeld;
        foreach (Leap.Finger f in hand.Fingers)
        {
            FingerInformation fingerInfo = new FingerInformation();
            fingerInfo.isExtended   = f.IsExtended;
            fingerInfo.direction    = f.Direction.ToVector3();
            fingerInfo.padDirection = Vector3.Cross(fingerInfo.direction, Vector3.Cross(fingerInfo.direction, f.bones[1].Direction.ToVector3()));
            fingerInfo.tipPosition  = f.TipPosition.ToVector3();
            fingerInfo.tipVelocity  = f.TipVelocity.ToVector3();
            switch (f.Type)
            {
            case Leap.Finger.FingerType.TYPE_INDEX:
                frameInfo.index = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_MIDDLE:
                frameInfo.middle = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_RING:
                frameInfo.ring = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_PINKY:
                frameInfo.pinky = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_THUMB:
                frameInfo.thumb = fingerInfo;
                break;
            }
        }
        if (handedness == "Right")
        {
            hand = Hands.Right;
        }
        else
        {
            hand = Hands.Left;
        }
        HandInformation handInfo = new HandInformation();

        handInfo.direction    = hand.Direction.ToVector3();
        handInfo.pitch        = hand.Direction.Pitch;
        handInfo.roll         = hand.Direction.Roll;
        handInfo.yaw          = hand.Direction.Yaw;
        handInfo.palmPosition = hand.PalmPosition.ToVector3();
        handInfo.palmVelocity = hand.PalmVelocity.ToVector3();
        handInfo.palmNormal   = hand.PalmNormal.ToVector3();
        handInfo.rotation     = hand.Rotation.ToQuaternion();
        frameInfo.hand        = handInfo;
        return(frameInfo);
    }