Exemplo n.º 1
0
        public static OpenVRScene Create(float nearClip, float farClip)
        {
            EVRInitError error = EVRInitError.None;
            CVRSystem    hmd   = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Scene);

            if (error != EVRInitError.None)
            {
                throw new InvalidOperationException($"Unable to initilize OpenVR: {error}");
            }

            string[] failedProps = OpenVRUtil.GetFailedRequiredComponents().ToArray();
            if (failedProps.Length != 0)
            {
                throw new InvalidOperationException($"Failed to initialize the following static properties: {string.Join(", ", failedProps)}");
            }

            int leftIndex  = hmd.LeftControllerIndex().Validate(errMsg => new InvalidOperationException(errMsg));
            int rightIndex = hmd.RightControllerIndex().Validate(errMsg => new InvalidOperationException(errMsg));

            return(new OpenVRScene(nearClip, farClip, hmd, leftIndex, rightIndex));
        }