示例#1
0
	// * * * * * * * * * * * * *
	
	// SetInitialCalibrationState
	// We call this before we start the Update loop to see if
	// Mag has been set by Calibration tool
	public void SetInitialCalibarationState()
	{
		if(OVRDevice.IsMagCalibrated(0) && OVRDevice.IsYawCorrectionEnabled(0))
		{
			MagCalState = MagCalibrationState.MagReady;
		}
	}
示例#2
0
    // * * * * * * * * * * * * *

    // SetInitialCalibrationState
    // We call this before we start the Update loop to see if
    // Mag has been set by Calibration tool
    public void SetInitialCalibarationState()
    {
        if (OVRDevice.IsMagCalibrated(0) && OVRDevice.IsYawCorrectionEnabled(0))
        {
            MagCalState = MagCalibrationState.MagReady;
        }
    }
示例#3
0
    /// <summary>
    /// Updates the mag yaw drift correction.
    /// </summary>
    public void UpdateMagYawDriftCorrection()
    {
        // If uncalibrated, do not bother turning it on or off
        if (MagCalState == MagCalibrationState.MagUncalibrated)
        {
            return;
        }

        if (MagCalState == MagCalibrationState.MagReady)
        {
            // Turn off Mag calibration
            if (Input.GetKeyDown(KeyCode.X))
            {
                MagCalState = MagCalibrationState.MagDisabled;
                OVRDevice.EnableMagYawCorrection(false);
                MagShowGeometry = false;
                ShowGeometry(MagShowGeometry);
            }
            // Toggle showing geometry either on or off
            else if (Input.GetKeyDown(KeyCode.F6))
            {
                if (MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
        else if (MagCalState == MagCalibrationState.MagDisabled)
        {
            // Turn on Mag calibration
            if (Input.GetKeyDown(KeyCode.X))
            {
                MagCalState = MagCalibrationState.MagReady;
                EnableYawCorrection();
            }
        }
    }
    // UpdateMagYawDriftCorrection
    public void UpdateMagYawDriftCorrection()
    {
        if (Input.GetKeyDown(KeyCode.Z) == true)
        {
            if (MagCalState == MagCalibrationState.MagDisabled)
            {
                // Start calibration process
                if (MagAutoCalibrate == true)
                {
                    OVRDeviceImposter.BeginMagAutoCalibration(0);
                    MagCalState = MagCalibrationState.MagCalibrating;
                }
                else
                {
                    // Go to pre-manual calibration state (to allow for
                    // setting refrence point)
                    MagCalState = MagCalibrationState.MagManualGetReady;
                    return;
                }
            }
            else if (MagCalState == MagCalibrationState.MagManualGetReady)
            {
                OVRDeviceImposter.SetMagReference(0);
                OVRDeviceImposter.EnableMagYawCorrection(0, true);

                Quaternion q = Quaternion.identity;
                if ((CameraController != null) && (CameraController.PredictionOn == true))
                {
                    OVRDeviceImposter.GetPredictedOrientation(0, ref q);
                }
                else
                {
                    OVRDeviceImposter.GetOrientation(0, ref q);
                }

                CurEulerRef = q.eulerAngles;

                // Begin manual calibration
                OVRDeviceImposter.BeginMagManualCalibration(0);
                MagCalState = MagCalibrationState.MagCalibrating;
            }
            else
            {
                // Reset calibration process
                if (MagAutoCalibrate == true)
                {
                    OVRDeviceImposter.StopMagAutoCalibration(0);
                }
                else
                {
                    OVRDeviceImposter.StopMagManualCalibration(0);
                }

                OVRDeviceImposter.EnableMagYawCorrection(0, false);

                MagCalState = MagCalibrationState.MagDisabled;

                // Do not show geometry
                MagShowGeometry = false;
                ShowGeometry(MagShowGeometry);

                return;
            }
        }


        // Check to see if calibration is completed
        if (MagCalState == MagCalibrationState.MagCalibrating)
        {
            if (MagAutoCalibrate == true)
            {
                OVRDeviceImposter.UpdateMagAutoCalibration(0);
            }
            else
            {
                OVRDeviceImposter.UpdateMagManualCalibration(0);
            }

            if (OVRDeviceImposter.IsMagCalibrated(0) == true)
            {
                if (MagAutoCalibrate == true)
                {
                    MagCalState = MagCalibrationState.MagCalibrated;
                }
                else
                {
                    // Manual Calibration take account of having set the
                    // reference orientation.
                    MagCalState = MagCalibrationState.MagReady;
                }
            }
        }

        // If we are calibrated, we will set mag reference and
        // enable yaw correction on a buton press
        if ((MagCalState == MagCalibrationState.MagCalibrated) ||
            (MagCalState == MagCalibrationState.MagReady))
        {
            if (Input.GetKeyDown(KeyCode.X) == true)
            {
                OVRDeviceImposter.SetMagReference(0);
                OVRDeviceImposter.EnableMagYawCorrection(0, true);
                MagCalState = MagCalibrationState.MagReady;

                Quaternion q = Quaternion.identity;
                if ((CameraController != null) && (CameraController.PredictionOn == true))
                {
                    OVRDeviceImposter.GetPredictedOrientation(0, ref q);
                }
                else
                {
                    OVRDeviceImposter.GetOrientation(0, ref q);
                }

                CurEulerRef = q.eulerAngles;
            }

            if ((MagCalState == MagCalibrationState.MagReady) &&
                (Input.GetKeyDown(KeyCode.F6)))
            {
                // Toggle showing geometry either on or off
                if (MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
    }
    // UpdateMagYawDriftCorrection
    public void UpdateMagYawDriftCorrection()
    {
        bool calibrateInput = false;

        // Auto
        if(Input.GetKeyDown (KeyCode.X) == true)
        {
            MagAutoCalibrate = true;
            calibrateInput = true;
        }

        // Manual
        if(Input.GetKeyDown (KeyCode.Z) == true)
        {
            MagAutoCalibrate = false;
            calibrateInput = true;
        }

        if(calibrateInput == true)
        {
            if(MagCalState == MagCalibrationState.MagDisabled)
            {
                // Start calibration process
                if(MagAutoCalibrate == true)
                {
                    OVRDevice.BeginMagAutoCalibration(0);
                    MagCalState = MagCalibrationState.MagCalibrating;
                }
                else
                {
                    // Go to pre-manual calibration state (to allow for
                    // setting refrence point)
                    MagCalState = MagCalibrationState.MagManualGetReady;
                    return;
                }
            }
            else if(MagCalState == MagCalibrationState.MagManualGetReady)
            {
                // We will set yaw correction before calibration for
                // Manual mode
                EnableYawCorrection(0);

                // Begin manual calibration
                OVRDevice.BeginMagManualCalibration(0);
                MagCalState = MagCalibrationState.MagCalibrating;
            }
            else
            {
                // Reset calibration process
                if(MagAutoCalibrate == true)
                    OVRDevice.StopMagAutoCalibration(0);
                else
                    OVRDevice.StopMagManualCalibration(0);

                OVRDevice.EnableMagYawCorrection(0,false);

                MagCalState = MagCalibrationState.MagDisabled;

                // Do not show geometry
                MagShowGeometry = false;
                ShowGeometry(MagShowGeometry);

                return;
            }
        }

        // Check to see if calibration is completed
        if(MagCalState == MagCalibrationState.MagCalibrating)
        {
            if(MagAutoCalibrate == true)
                OVRDevice.UpdateMagAutoCalibration(0);
            else
            {
                // Check to see if we have aborted manual calibration
                OVRDevice.UpdateMagManualCalibration(0);
            }
            if(OVRDevice.IsMagCalibrated(0) == true)
            {
                if(MagAutoCalibrate == true)
                {
                    // Manual Calibration took account of having set the
                    // reference orientation at the start; with Auto, we
                    // set it now
                    EnableYawCorrection(0);
                }

                MagCalState = MagCalibrationState.MagReady;
            }
        }

        if (MagCalState == MagCalibrationState.MagReady)
        {
            // Toggle showing geometry either on or off
            if (Input.GetKeyDown (KeyCode.F6))
            {
                if(MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
    }
    /// <summary>
    /// Updates the mag yaw drift correction.
    /// </summary>
    public void UpdateMagYawDriftCorrection()
    {
        // If uncalibrated, do not bother turning it on or off
        if(MagCalState == MagCalibrationState.MagUncalibrated)
            return;

        if (MagCalState == MagCalibrationState.MagReady)
        {
            // Turn off Mag calibration
            if (Input.GetKeyDown( KeyCode.X))
            {
                MagCalState = MagCalibrationState.MagDisabled;
                OVRDevice.EnableMagYawCorrection(false);
                MagShowGeometry = false;
                ShowGeometry (MagShowGeometry);
            }
            // Toggle showing geometry either on or off
            else if (Input.GetKeyDown (KeyCode.F6))
            {
                if(MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
        else if (MagCalState == MagCalibrationState.MagDisabled)
        {
            // Turn on Mag calibration
            if (Input.GetKeyDown(KeyCode.X))
            {
                MagCalState = MagCalibrationState.MagReady;
                EnableYawCorrection();
            }
        }
    }
    // UpdateMagYawDriftCorrection
    public void UpdateMagYawDriftCorrection()
    {
        bool calibrateInput = false;

        // Auto
        if (Input.GetKeyDown(KeyCode.X) == true)
        {
            MagAutoCalibrate = true;
            calibrateInput   = true;
        }

        // Manual
        if (Input.GetKeyDown(KeyCode.Z) == true)
        {
            MagAutoCalibrate = false;
            calibrateInput   = true;
        }

        if (calibrateInput == true)
        {
            if (MagCalState == MagCalibrationState.MagDisabled)
            {
                // Start calibration process
                if (MagAutoCalibrate == true)
                {
                    OVRDevice.BeginMagAutoCalibration(0);
                    MagCalState = MagCalibrationState.MagCalibrating;
                }
                else
                {
                    // Go to pre-manual calibration state (to allow for
                    // setting refrence point)
                    MagCalState = MagCalibrationState.MagManualGetReady;
                    return;
                }
            }
            else if (MagCalState == MagCalibrationState.MagManualGetReady)
            {
                // We will set yaw correction before calibration for
                // Manual mode
                EnableYawCorrection(0);

                // Begin manual calibration
                OVRDevice.BeginMagManualCalibration(0);
                MagCalState = MagCalibrationState.MagCalibrating;
            }
            else
            {
                // Reset calibration process
                if (MagAutoCalibrate == true)
                {
                    OVRDevice.StopMagAutoCalibration(0);
                }
                else
                {
                    OVRDevice.StopMagManualCalibration(0);
                }

                OVRDevice.EnableMagYawCorrection(0, false);

                MagCalState = MagCalibrationState.MagDisabled;

                // Do not show geometry
                MagShowGeometry = false;
                ShowGeometry(MagShowGeometry);

                return;
            }
        }

        // Check to see if calibration is completed
        if (MagCalState == MagCalibrationState.MagCalibrating)
        {
            if (MagAutoCalibrate == true)
            {
                OVRDevice.UpdateMagAutoCalibration(0);
            }
            else
            {
                // Check to see if we have aborted manual calibration
                OVRDevice.UpdateMagManualCalibration(0);
            }
            if (OVRDevice.IsMagCalibrated(0) == true)
            {
                if (MagAutoCalibrate == true)
                {
                    // Manual Calibration took account of having set the
                    // reference orientation at the start; with Auto, we
                    // set it now
                    EnableYawCorrection(0);
                }

                MagCalState = MagCalibrationState.MagReady;
            }
        }

        if (MagCalState == MagCalibrationState.MagReady)
        {
            // Toggle showing geometry either on or off
            if (Input.GetKeyDown(KeyCode.F6))
            {
                if (MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
    }
示例#8
0
    // UpdateMagYawDriftCorrection
    public void UpdateMagYawDriftCorrection()
    {
        if(Input.GetKeyDown (KeyCode.Z) == true)
        {
            if(MagCalState == MagCalibrationState.MagDisabled)
            {
                // Start calibration process
                if(MagAutoCalibrate == true)
                {
                    OVRDevice.BeginMagAutoCalibration(0);
                    MagCalState = MagCalibrationState.MagCalibrating;
                }
                else
                {
                    // Go to pre-manual calibration state (to allow for
                    // setting refrence point)
                    MagCalState = MagCalibrationState.MagManualGetReady;
                    return;
                }
            }
            else if(MagCalState == MagCalibrationState.MagManualGetReady)
            {
                OVRDevice.SetMagReference(0);
                OVRDevice.EnableMagYawCorrection(0,true);

                Quaternion q = Quaternion.identity;
                if((CameraController != null) && (CameraController.PredictionOn == true))
                    OVRDevice.GetPredictedOrientation(0, ref q);
                else
                    OVRDevice.GetOrientation(0, ref q);

                CurEulerRef = q.eulerAngles;

                // Begin manual calibration
                OVRDevice.BeginMagManualCalibration(0);
                MagCalState = MagCalibrationState.MagCalibrating;
            }
            else
            {
                // Reset calibration process
                if(MagAutoCalibrate == true)
                    OVRDevice.StopMagAutoCalibration(0);
                else
                    OVRDevice.StopMagManualCalibration(0);

                OVRDevice.EnableMagYawCorrection(0,false);

                MagCalState = MagCalibrationState.MagDisabled;

                // Do not show geometry
                MagShowGeometry = false;
                ShowGeometry(MagShowGeometry);

                return;
            }
        }

        // Check to see if calibration is completed
        if(MagCalState == MagCalibrationState.MagCalibrating)
        {
            if(MagAutoCalibrate == true)
                OVRDevice.UpdateMagAutoCalibration(0);
            else
                OVRDevice.UpdateMagManualCalibration(0);

            if(OVRDevice.IsMagCalibrated(0) == true)
            {
                if(MagAutoCalibrate == true)
                    MagCalState = MagCalibrationState.MagCalibrated;
                else
                    // Manual Calibration take account of having set the
                    // reference orientation.
                    MagCalState = MagCalibrationState.MagReady;

            }
        }

        // If we are calibrated, we will set mag reference and
        // enable yaw correction on a buton press
        if( (MagCalState == MagCalibrationState.MagCalibrated) ||
            (MagCalState == MagCalibrationState.MagReady) )
        {
            if(Input.GetKeyDown (KeyCode.X) == true)
            {
                OVRDevice.SetMagReference(0);
                OVRDevice.EnableMagYawCorrection(0,true);
                MagCalState = MagCalibrationState.MagReady;

                Quaternion q = Quaternion.identity;
                if((CameraController != null) && (CameraController.PredictionOn == true))
                    OVRDevice.GetPredictedOrientation(0, ref q);
                    else
                OVRDevice.GetOrientation(0, ref q);

                CurEulerRef = q.eulerAngles;
            }

            if((MagCalState == MagCalibrationState.MagReady) &&
               (Input.GetKeyDown (KeyCode.F6)))
            {

                // Toggle showing geometry either on or off
                if(MagShowGeometry == false)
                {
                    MagShowGeometry = true;
                    ShowGeometry(MagShowGeometry);
                }
                else
                {
                    MagShowGeometry = false;
                    ShowGeometry(MagShowGeometry);
                }
            }

            UpdateGeometry();
        }
    }