void Start()
    {
        RUISInputManager inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

        if (useRazerHydra && inputManager && !inputManager.enableRazerHydra)
        {
            useRazerHydra = false;
//			Debug.LogWarning(	"Your settings indicate that you want to use Razer Hydra for "
//							 +	"character locomotion controls, but you have disabled Razer "
//							 +	"Hydra from " + typeof(RUISInputManager));
        }

        if (usePSNavigationController && inputManager && !inputManager.enablePSMove)
        {
            usePSNavigationController = false;
//			Debug.LogWarning(	"Your settings indicate that you want to use PS Navigation "
//							 +	"controller for character locomotion controls, but you have "
//							 +	"disabled PS Move from RUIS InputManager.");
        }

        if (useOpenVrController && !RUISDisplayManager.IsOpenVrAccessible())
        {
            useOpenVrController = false;
        }
    }
示例#2
0
    private void updateCalibratableDevices()
    {
        List <string> dropDownChoices = new List <string>();

        string currentSelection = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection;

        //dropDownChoices.Add ("Select device(s)");
        if (inputManager.enableKinect)
        {
            dropDownChoices.Add("Kinect 1 floor data");
        }
        if (inputManager.enableKinect2)
        {
            dropDownChoices.Add("Kinect 2 floor data");
        }

        // NOTE: The dropDownChoices determine the device pair to be calibrated, and they must follow the format "Device A - Device B".
        //       The string must correspond the options in the Awake() method of RUISCoordinateCalibration script
        if (inputManager.enableKinect && inputManager.enableKinect2)
        {
            dropDownChoices.Add("Kinect 1 - Kinect2");
        }
        if (inputManager.enableKinect && inputManager.enablePSMove)
        {
            dropDownChoices.Add("Kinect 1 - PSMove");
        }
        if (inputManager.enableKinect2 && inputManager.enablePSMove)
        {
            dropDownChoices.Add("Kinect 2 - PSMove");
        }
        if (RUISDisplayManager.IsOpenVrAccessible() && inputManager.enableKinect2)
        {
            dropDownChoices.Add("Kinect 2 - OpenVR (controller)");
        }
        if (RUISDisplayManager.IsHmdPresent() && inputManager.enableKinect2)
        {
            dropDownChoices.Add("Kinect 2 - OpenVR (HMD)");
        }
        if (RUISDisplayManager.IsHmdPresent() && inputManager.enablePSMove)
        {
            dropDownChoices.Add("PSMove - OpenVR (HMD)");
        }
        if (RUISDisplayManager.IsHmdPresent() && inputManager.enableKinect)
        {
            dropDownChoices.Add("Kinect 1 - OpenVR (HMD)");
        }


        if (dropDownChoices.Count == 0)
        {
            dropDownChoices.Add("Select device(s)");
        }

        this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().items = dropDownChoices;
        if (!dropDownChoices.Contains(currentSelection))
        {
            this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection = dropDownChoices[0];
        }
    }
示例#3
0
    void Awake()
    {
        string[] names = System.Enum.GetNames(typeof(RUISDevice));
        foreach (string device in names)
        {
            RUISDevice device1Enum = (RUISDevice)System.Enum.Parse(typeof(RUISDevice), device, true);
            RUISCalibrationResultsFloorPitchRotation[device1Enum] = Quaternion.identity;
            RUISCalibrationResultsDistanceFromFloor[device1Enum]  = 0.0f;
            foreach (string device2 in names)
            {
                if (device != device2)
                {
                    string devicePairString = device + "-" + device2;
                    RUISCalibrationResultsInVector3[devicePairString]    = new Vector3(0, 0, 0);
                    RUISCalibrationResultsInQuaternion[devicePairString] = Quaternion.identity;
                    RUISCalibrationResultsIn4x4Matrix[devicePairString]  = Matrix4x4.identity;
                }
            }
        }

        if (loadFromXML)
        {
            if (!LoadMultiXML(coordinateXmlFile))
            {
                createExampleXML(coordinateXmlFile);
            }
        }

        inputManager = FindObjectOfType <RUISInputManager>();
        if (switchToAvailableDevice && inputManager)
        {
            bool       needToSwitch   = false;
            RUISDevice previousDevice = rootDevice;

            switch (rootDevice)
            {
            case RUISDevice.Kinect_1:
                if (!inputManager.enableKinect)
                {
                    needToSwitch = true;
                }
                break;

            case RUISDevice.Kinect_2:
                if (!inputManager.enableKinect2)
                {
                    needToSwitch = true;
                }
                break;

            case RUISDevice.PS_Move:
                if (!inputManager.enablePSMove)
                {
                    needToSwitch = true;
                }
                break;

            case RUISDevice.OpenVR:             // If OpenVR can't accessed AND a HMD can't be detected
                if (!RUISDisplayManager.IsOpenVrAccessible() && !RUISDisplayManager.IsHmdPresent())
                {
                    needToSwitch = true;
                }
                break;
            }

            if (needToSwitch)
            {
                // Try to determine if Kinect2 can be used (because this method is run before RUISInputManager can disable enableKinect2)
                bool kinect2FoundBySystem = false;
                if (inputManager.enableKinect2)
                {
                    try
                    {
                        Kinect2SourceManager kinect2SourceManager = FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;
                        if (kinect2SourceManager != null && kinect2SourceManager.GetSensor() != null && kinect2SourceManager.GetSensor().IsOpen)
                        {
                            // IsOpen seems to return false mostly if Kinect 2 drivers are not installed?
                            //					Debug.Log("Kinect 2 was detected by the system.");
                            kinect2FoundBySystem = true;
                        }
                    }
                    catch
                    {}
                }

                if (RUISDisplayManager.IsHmdPositionTrackable())
                {
                    rootDevice = RUISDevice.OpenVR;
                }
                else if (inputManager.enableKinect2 && kinect2FoundBySystem)
                {
                    rootDevice = RUISDevice.Kinect_2;
                }
                else if (inputManager.enableKinect)
                {
                    rootDevice = RUISDevice.Kinect_1;
                }
                else if (inputManager.enablePSMove)
                {
                    rootDevice = RUISDevice.PS_Move;
                }

                if (rootDevice != previousDevice)
                {
                    if (previousDevice == RUISDevice.OpenVR)
                    {
                        Debug.LogWarning("Switched 'Master Coordinate System Sensor' from " + previousDevice + " to " + rootDevice + " "
                                         + "because OpenVR could not be accessed! Is SteamVR installed?");
                    }
                    else
                    {
                        Debug.LogWarning("Switched 'Master Coordinate System Sensor' from " + previousDevice + " to " + rootDevice + " "
                                         + "because the former was not enabled in " + typeof(RUISInputManager) + " while the latter was!");
                    }
                }
            }
        }
    }