Пример #1
0
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
    {
        if (args.state.source.kind == InteractionSourceKind.Hand)
        {
            handObject.SetActive(true);
            UtilitiesScript.Instance.ChangeObjectColor(trackingHand.hand, Color.white);
            //Get hand position and illustrate it
            if (args.state.sourcePose.TryGetPosition(out Vector3 pos))
            {
                handObject.transform.position = pos;
            }

            //Define if it's the right hand
            bool IsRightHand = UtilitiesScript.Instance.IsRightFromHead(pos);
            trackingHand = new HandStruct(handObject, IsRightHand);
            // Control calibration
            if (HandCalibrationMode)
            {
                if (!flowController.IsHandCalibrated(IsRightHand))
                {
                    calibrationController = new CalibrationController(IsRightHand);
                    startTime             = Time.time;
                    RightPoseInProgress   = true;
                }
                else
                {
                    if (uiController.greekEnabled)
                    {
                        string handText = IsRightHand ? "Δεξί" : "Αριστερό";
                        uiController.PrintText(handText + " χέρι έχει ήδη βαθμονομηθεί");
                        audioSource.Stop();
                        audioSource.clip = IsRightHand ? uiController.rightAlreadyCalibClip : uiController.leftAlreadyCalibClip;
                        audioSource.Play();
                    }
                    else
                    {
                        string handText = IsRightHand ? "Right" : "Left";
                        uiController.PrintText(handText + " hand already calibrated");
                        TextToSpeech.Instance.StopSpeaking();
                        TextToSpeech.Instance.StartSpeaking(handText + "already calibrated");
                    }
                }
            }
            //Gather hand data
            if (DataCollectionMode) //Gather values for every hand movement
            {
                float height = Mathf.Abs(pos.y - Camera.main.transform.position.y);
                dataScript.AddValue(pos, height, trackingHand.rightHand);
            }
        }
    }