コード例 #1
0
    private IEnumerator Calibration()
    {
        Debug.Log("Activate calibration");

        while (true)
        {
            handController.enabled = false;
            openHandPanel.SetActive(true);
            Show();

            lastTrimmerValues = inputController.GetValues();

            yield return(WaitUntilResting());

            for (int i = 0; i < fingerJointCount; i++)
            {
                if (handController.GetFingerAt(i).HasPositiveRotation())
                {
                    lowerBounds[i] = lastTrimmerValues[i];
                }
                else
                {
                    highBounds[i] = lastTrimmerValues[i];
                }
            }

            openHandPanel.SetActive(false);
            closedHandPanel.SetActive(true);

            yield return(WaitUntilResting());

            for (int i = 0; i < fingerJointCount; i++)
            {
                if (handController.GetFingerAt(i).HasPositiveRotation())
                {
                    highBounds[i] = lastTrimmerValues[i];
                }
                else
                {
                    lowerBounds[i] = lastTrimmerValues[i];
                }
            }

            closedHandPanel.SetActive(false);

            if (hasErrorChecking)
            {
                bool hasFinishedCalibration = true;
                for (int i = 0; i < lastTrimmerValues.Count; i++)
                {
                    if (highBounds[i] <= lowerBounds[i])
                    {
                        Debug.LogError("Min val is higher than or equal to max. Restarting calibration!");
                        hasFinishedCalibration = false;
                        break;
                    }
                }

                if (hasFinishedCalibration)
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }

        handController.enabled = true;
        handController.SetBounds(lowerBounds, highBounds);

        Hide();

        CalibrateRotation();
    }