Exemple #1
0
	// RIFT DETECTION
	
	// CheckIfRiftPresent
	// Checks to see if HMD and / or sensor is available, and displays a 
	// message if it is not
	void CheckIfRiftPresent()
	{
		HMDPresent = OVRDevice.IsHMDPresent();
		SensorPresent = OVRDevice.IsSensorPresent(0); // 0 is the main head sensor
		
		if((HMDPresent == false) || (SensorPresent == false))
		{
			RiftPresentTimeout = 5.0f; // Keep message up for 10 seconds
			
			if((HMDPresent == false) && (SensorPresent == false))
				strRiftPresent = "NO HMD AND SENSOR DETECTED";
			else if (HMDPresent == false)
				strRiftPresent = "NO HMD DETECTED";
			else if (SensorPresent == false)
				strRiftPresent = "NO SENSOR DETECTED";
		}
	}
Exemple #2
0
    private void doYawFiltering(float deltaT)
    {
        switch (driftingSensor)
        {
        case DriftingRotation.OculusRift:
            if (OVRDevice.IsSensorPresent(oculusID))
            {
                OVRDevice.GetOrientation(oculusID, ref driftingRot);
                if (oculusCamController)
                {
                    // In the future OVR SDK oculusCamController will have oculusID?
                    oculusCamController.SetYRotation(-finalYawDifference.eulerAngles.y);
                }
            }
            break;

        case DriftingRotation.RazerHydra:
            // TODO
            //driftingRot = hydraRotation;
            break;

        case DriftingRotation.InputTransform:
            if (driftingTransform)
            {
                driftingRot = driftingTransform.rotation;
            }
            break;
        }

        if (driftingDirectionVisualizer != null)
        {
            driftingDirectionVisualizer.transform.rotation = driftingRot;
        }

        driftingEuler = driftingRot.eulerAngles;

        switch (compass)
        {
        case CompassSource.Kinect:
            if (!skeletonManager || !skeletonManager.skeletons[kinectPlayerID].isTracking)
            {
                break;
            }
            else
            {
                compassData = skeletonManager.GetJointData(compassJoint, kinectPlayerID);

                // First check for high confidence value
                if (compassData != null && compassData.rotationConfidence >= 1.0f)
                {
                    updateDifferenceKalman(compassData.rotation.eulerAngles,
                                           driftingEuler, deltaT);
                }
            }
            break;

        case CompassSource.PSMove:

            if (inputManager)
            {
                compassMove = inputManager.GetMoveWand(PSMoveID);
                if (compassMove)
                {
                    updateDifferenceKalman(compassMove.localRotation.eulerAngles,
                                           driftingEuler, deltaT);
                }
            }
            break;

        case CompassSource.InputTransform:
            if (compassTransform != null)
            {
                updateDifferenceKalman(compassTransform.rotation.eulerAngles,
                                       driftingEuler, deltaT);
            }
            break;
        }

        float normalizedT = Mathf.Clamp01(deltaT * driftCorrectionRate);

        if (normalizedT != 0)
        {
            finalYawDifference = Quaternion.Lerp(finalYawDifference, filteredYawDifference,
                                                 normalizedT);
        }

        if (correctedDirectionVisualizer != null)
        {
            correctedDirectionVisualizer.transform.rotation = Quaternion.Euler(
                new Vector3(driftingEuler.x,
                            (360 + driftingEuler.y
                             - finalYawDifference.eulerAngles.y) % 360,
                            driftingEuler.z));
        }
        //driftingRotation*Quaternion.Inverse(finalDifference);
        if (correctedDirectionVisualizer != null && driftVisualizerPosition != null)
        {
            correctedDirectionVisualizer.transform.position = driftVisualizerPosition.position;
        }
    }
Exemple #3
0
    void Start()
    {
        //check whether the kinect camera is actually connected
        if (enableKinect)
        {
            OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
            if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid)
            {
                Debug.LogError("Could not start OpenNI! Check your Kinect connection.");
                GetComponentInChildren <RUISKinectDisabler>().KinectNotAvailable();
            }
            else
            {                   // If PSMove is enabled, it's better to load the floor normal from XML (if such exists)
                if (kinectFloorDetection)
                {
                    StartFloorDetection();
                }
            }
        }

        if (enablePSMove)
        {
            RUISPSMoveWand[] controllers = GetComponentsInChildren <RUISPSMoveWand>();
            moveControllers = new RUISPSMoveWand[controllers.Length];
            foreach (RUISPSMoveWand controller in controllers)
            {
                moveControllers[controller.controllerId] = controller;
            }
        }

        OVRCameraController oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController;

        if (oculusCamController && OVRDevice.IsSensorPresent(oculusID))
        {
            RUISOculusHUD ruisOculusHUD = FindObjectOfType(typeof(RUISOculusHUD)) as RUISOculusHUD;
            if (riftMagnetometerMode == RiftMagnetometer.AutomaticCalibration)
            {
                if (ruisOculusHUD)
                {
                    ruisOculusHUD.StartAutoCalibration();
                }
                else
                {
                    Debug.LogError("Your settings indicate that you want to start automatic yaw drift correction "
                                   + "process for Oculus Rift in the beginning of the scene, but no RUISOculusHUD "
                                   + "script is found!");
                }
            }
            if (riftMagnetometerMode == RiftMagnetometer.ManualCalibration)
            {
                if (ruisOculusHUD)
                {
                    ruisOculusHUD.StartManualCalibration();
                }
                else
                {
                    Debug.LogError("Your settings indicate that you want to start manual yaw drift correction "
                                   + "process for Oculus Rift in the beginning of the scene, but no RUISOculusHUD "
                                   + "script is found!");
                }
            }
        }
    }