Ejemplo n.º 1
0
    IEnumerator calibration()
    {
        calibrating = true;

        VRAdapter adapter = VRAdapter.Instance;

        adapter.SendAutocalibrationResult(0, 0);        //0-> Started

        Transform cam = Camera.main.transform;
        Vector3   previousAngles;
        Vector3   angles   = cam.eulerAngles;
        float     elapsed  = 0;
        float     yawDrift = 0;    //keep track of how much rotation happened

        while (calibrating)
        {
            yield return(null);

            elapsed += Time.deltaTime;

            previousAngles = angles;
            angles         = cam.eulerAngles;

            //get difference in yaw since last frame
            yawDrift += Mathf.DeltaAngle(previousAngles.y, angles.y);

            if (elapsed >= 5 * 60)           //stop automatically after 5 minutes
            {
                calibrating = false;
            }
        }

        //Done - compute how much drift per second happened
        DriftPerSecond = yawDrift / elapsed;

        adapter.SendAutocalibrationResult(1, DriftPerSecond);        //1-> Finished (with result)
    }
 private void OnDestroy()
 {
     Instance   = null;
     sendStatus = false;
 }
 private void Start()
 {
     Instance = this;
 }