Exemplo n.º 1
0
	public void Set(SteamVR vr, Valve.VR.EVREye eye)
	{
		int i = (int)eye;
		if (hiddenAreaMeshes[i] == null)
			hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[i]);
		meshFilter.mesh = hiddenAreaMeshes[i];
	}
Exemplo n.º 2
0
 public void Set(SteamVR vr, EVREye eye)
 {
     if (SteamVR_CameraMask.hiddenAreaMeshes[(int)eye] == null)
     {
         SteamVR_CameraMask.hiddenAreaMeshes[(int)eye] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[(int)eye]);
     }
     this.meshFilter.mesh = SteamVR_CameraMask.hiddenAreaMeshes[(int)eye];
 }
Exemplo n.º 3
0
 bool GetIsPressed(SteamVR vr, uint controller)
 {
     if (controller == 0)
         return false;
     var state = new VRControllerState_t();
     var success = vr.hmd.GetControllerState(controller, ref state);
     return (state.ulButtonPressed & SteamVR_Controller.ButtonMask.Trigger) != 0;
 }
Exemplo n.º 4
0
    public void Set(SteamVR vr, Valve.VR.EVREye eye)
    {
        int i = (int)eye;

        if (hiddenAreaMeshes[i] == null)
        {
            hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye, Valve.VR.EHiddenAreaMeshType.k_eHiddenAreaMesh_Standard), vr.textureBounds[i]);
        }
        meshFilter.mesh = hiddenAreaMeshes[i];
    }
Exemplo n.º 5
0
    private void Dispose(bool disposing)
    {
        SteamVR_Utils.Event.Remove("initializing", OnInitializing);
        SteamVR_Utils.Event.Remove("calibrating", OnCalibrating);
        SteamVR_Utils.Event.Remove("out_of_range", OnOutOfRange);
        SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
        SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);

        _instance = null;
    }
Exemplo n.º 6
0
    private void Dispose(bool disposing)
    {
        SteamVR_Events.Initializing.Remove(OnInitializing);
        SteamVR_Events.Calibrating.Remove(OnCalibrating);
        SteamVR_Events.OutOfRange.Remove(OnOutOfRange);
        SteamVR_Events.DeviceConnected.Remove(OnDeviceConnected);
        SteamVR_Events.NewPoses.Remove(OnNewPoses);

        _instance = null;
    }
Exemplo n.º 7
0
    //public IEnumerator ActivatorVR(string YesVR) {
    //    XRSettings.LoadDeviceByName("YesVR");
    //    yield return null;
    //    //XRSettings.enabled = true;
    //    SteamVR.enabled = true;
    //}

    public IEnumerator EnableVR()
    {
        print("Enabling VR...");
        SteamVR.Initialize(true);
        SteamVR_Behaviour.instance.enabled = true;
        XRSettings.LoadDeviceByName("OpenVR");
        yield return(null);

        XRSettings.enabled = true;
    }
Exemplo n.º 8
0
    bool GetTopButtonIsPressed(SteamVR vr, uint controller)
    {
        if (controller == 0)
        {
            return(false);
        }
        var state   = new VRControllerState_t();
        var success = vr.hmd.GetControllerState(32, ref state, 2);

        return((state.ulButtonPressed & SteamVR_Controller.ButtonMask.ApplicationMenu) != 0);
    }
Exemplo n.º 9
0
 void OnDestroy()
 {
     FindObjectOfType <InputEmulator>()?.DisableAllDeviceWorldPosOffset();
     if (XRSettings.loadedDeviceName != "None")
     {
         XRSettings.LoadDeviceByName("None");
     }
     SteamVR.SafeDispose();
     XRSettings.enabled = false;
     OpenVR.Shutdown();
 }
Exemplo n.º 10
0
    bool GetIsPressed(SteamVR vr, uint controller)
    {
        if (controller == 0)
        {
            return(false);
        }
        var state   = new VRControllerState_t();
        var success = vr.hmd.GetControllerState(controller, ref state);

        return((state.ulButtonPressed & SteamVR_Controller.ButtonMask.Trigger) != 0);
    }
Exemplo n.º 11
0
        private static System.IntPtr GetNativeObject()
        {
            var error         = SteamVR.HmdError.HmdError_None;
            var pNativeObject = SteamVR.Init(ref error);

            if (error != SteamVR.HmdError.HmdError_None)
            {
                Debug.Log(error);
            }
            return(pNativeObject);
        }
Exemplo n.º 12
0
        void Start()
        {
#if UNITY_2019_3_OR_NEWER
            XRInputSupported = true;
#endif

#if STEAM_VR_SDK
            SteamVRSupport = true;
            SteamVR.Initialize();
#endif
        }
Exemplo n.º 13
0
    float GetTouchPadY(SteamVR vr, uint controller)
    {
        if (controller == 0)
        {
            return(0);
        }
        var state   = new VRControllerState_t();
        var success = vr.hmd.GetControllerState(32, ref state, 2);

        return(state.rAxis0.y);
    }
Exemplo n.º 14
0
        // Start is called before the first frame update
        private IEnumerator Start()
        {
            SteamVR.InitializeStandalone(EVRApplicationType.VRApplication_Overlay);
            SteamVR_Settings.instance.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated;

            while (SteamVR.initializedState == SteamVR.InitializedStates.None || SteamVR.initializedState == SteamVR.InitializedStates.Initializing)
            {
                yield return(null);
            }

            Debug.Log("tracking space: " + SteamVR_Settings.instance.trackingSpace);
        }
Exemplo n.º 15
0
    private void Dispose(bool disposing)
    {
        SteamVR_Utils.Event.Remove("initializing", OnInitializing);
        SteamVR_Utils.Event.Remove("calibrating", OnCalibrating);
        SteamVR_Utils.Event.Remove("out_of_range", OnOutOfRange);
        SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
        SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);

        SetUnityRenderCallback(System.IntPtr.Zero);
        ShutdownSystems();
        _instance = null;
    }
Exemplo n.º 16
0
    private void OnPostRender()
    {
        SteamVR  instance     = SteamVR.instance;
        Camera   component    = base.GetComponent <Camera>();
        float    num          = this.scale * component.aspect / instance.aspect;
        float    x            = -this.scale;
        float    x2           = this.scale;
        float    y            = num;
        float    y2           = -num;
        Material blitMaterial = SteamVR_Camera.blitMaterial;

        blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(component.hdr);
        GL.PushMatrix();
        GL.LoadOrtho();
        blitMaterial.SetPass(0);
        GL.Begin(7);
        GL.TexCoord2(0f, 0f);
        GL.Vertex3(x, y, 0f);
        GL.TexCoord2(1f, 0f);
        GL.Vertex3(x2, y, 0f);
        GL.TexCoord2(1f, 1f);
        GL.Vertex3(x2, y2, 0f);
        GL.TexCoord2(0f, 1f);
        GL.Vertex3(x, y2, 0f);
        GL.End();
        GL.PopMatrix();
        SteamVR_Overlay instance2 = SteamVR_Overlay.instance;

        if (instance2 && instance2.texture && SteamVR_GameView.overlayMaterial && this.drawOverlay)
        {
            Texture texture = instance2.texture;
            SteamVR_GameView.overlayMaterial.mainTexture = texture;
            float x3 = 0f;
            float y3 = 1f - (float)Screen.height / (float)texture.height;
            float x4 = (float)Screen.width / (float)texture.width;
            float y4 = 1f;
            GL.PushMatrix();
            GL.LoadOrtho();
            SteamVR_GameView.overlayMaterial.SetPass((QualitySettings.activeColorSpace != ColorSpace.Linear) ? 0 : 1);
            GL.Begin(7);
            GL.TexCoord2(x3, y3);
            GL.Vertex3(-1f, -1f, 0f);
            GL.TexCoord2(x4, y3);
            GL.Vertex3(1f, -1f, 0f);
            GL.TexCoord2(x4, y4);
            GL.Vertex3(1f, 1f, 0f);
            GL.TexCoord2(x3, y4);
            GL.Vertex3(-1f, 1f, 0f);
            GL.End();
            GL.PopMatrix();
        }
    }
Exemplo n.º 17
0
        private void Awake()
        {
            SteamVR.Initialize();
            //SteamVR_Input.Initialize();

            if (DataVR.Instance.input.currentActionSets != null && activateOnStart)
            {
                for (int i = 0; i < DataVR.Instance.input.currentActionSets.Length; i++)
                {
                    DataVR.Instance.input.currentActionSets[i].Activate(sources, priority, disableAllOtherActionSets);
                }
            }
        }
Exemplo n.º 18
0
    public void initializeVR(QTClient client)
    {
        return;

        if (OpenVR.IsHmdPresent())
        {
            XRGeneralSettings.Instance.Manager.loaders.Add(OpenVRLoader);
            XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
            XRGeneralSettings.Instance.Manager.StartSubsystems();

            SteamVR.Initialize();
        }
    }
Exemplo n.º 19
0
 private void InitSteamVR()
 {
     try
     {
         SteamVR.Initialize();
         SteamVR_Settings.instance.pauseGameWhenDashboardVisible = true;
         OpenVR.Input.SetActionManifestPath(Helper.Manifest.ModFolderPath + @"\bindings\actions.json");
     }
     catch
     {
         FatalErrorChecker.ThrowSteamVRError();
     }
 }
Exemplo n.º 20
0
        void Start()
        {
            SetTrackingOriginMode(TrackingOrigin);

#if UNITY_2019_3_OR_NEWER
            XRInputSupported = true;
#endif

#if STEAM_VR_SDK
            SteamVRSupport = true;
            SteamVR.Initialize();
#endif
        }
Exemplo n.º 21
0
        // Token: 0x06002075 RID: 8309 RVA: 0x000A03D8 File Offset: 0x0009E5D8
        private IEnumerator Start()
        {
            this.playerInstance = Player.instance;
            if (!this.playerInstance)
            {
                Debug.LogError("No player instance found in Hand Start()");
            }
            this.overlappingColliders = new Collider[16];
            if (this.noSteamVRFallbackCamera)
            {
                yield break;
            }
            for (;;)
            {
                yield return(new WaitForSeconds(1f));

                if (this.controller != null)
                {
                    break;
                }
                if (this.startingHandType == Hand.HandType.Left || this.startingHandType == Hand.HandType.Right)
                {
                    int deviceIndex  = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost, ETrackedDeviceClass.Controller, 0);
                    int deviceIndex2 = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost, ETrackedDeviceClass.Controller, 0);
                    if (deviceIndex != -1 && deviceIndex2 != -1 && deviceIndex != deviceIndex2)
                    {
                        int index  = (this.startingHandType == Hand.HandType.Right) ? deviceIndex2 : deviceIndex;
                        int index2 = (this.startingHandType == Hand.HandType.Right) ? deviceIndex : deviceIndex2;
                        this.InitController(index);
                        if (this.otherHand)
                        {
                            this.otherHand.InitController(index2);
                        }
                    }
                }
                else
                {
                    SteamVR instance = SteamVR.instance;
                    int     num      = 0;
                    while ((long)num < 16L)
                    {
                        if (instance.hmd.GetTrackedDeviceClass((uint)num) == ETrackedDeviceClass.Controller && SteamVR_Controller.Input(num).valid&& (!(this.otherHand != null) || this.otherHand.controller == null || num != (int)this.otherHand.controller.index))
                        {
                            this.InitController(num);
                        }
                        num++;
                    }
                }
            }
            yield break;
        }
Exemplo n.º 22
0
    protected override void Awake()
    {
        base.Awake();

#if ZED_SVR_2_0_INPUT
        if (!useLegacySteamVRInput)
        {
            if (!SteamVR.active)
            {
                SteamVR.Initialize(true);                 //Force SteamVR to activate, so we can use the input system.
            }
        }
#endif
    }
Exemplo n.º 23
0
 public void Set(SteamVR vr, Valve.VR.EVREye eye)
 {
     try
     {
         int i = (int)eye;
         if (hiddenAreaMeshes[i] == null)
         {
             hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[i]);
         }
         meshFilter.mesh = hiddenAreaMeshes[i];
     } catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 24
0
        private void Setup()
        {
            WeaponArchetypeVRData.Setup();


            SteamVR.Initialize(false);
            gameObject.AddComponent <VRInput>();
            Invoke("SetupOverlay", .25f);
            gameObject.AddComponent <HMD>();
            gameObject.AddComponent <Controllers>();
            VR_Resolution        = new Resolution();
            VR_Resolution.height = (int)SteamVR.instance.sceneHeight;
            VR_Resolution.width  = (int)SteamVR.instance.sceneWidth;

            DontDestroyOnLoad(gameObject);
        }
Exemplo n.º 25
0
 public static bool InitializeSteamVR()
 {
     LogInfo("Initializing SteamVR...");
     SteamVR.Initialize();
     if (!(SteamVR.initializedState == SteamVR.InitializedStates.InitializeSuccess))
     {
         LogError("Problem Initializing SteamVR");
         return(false);
     }
     if (!SteamVR_Input.initialized)
     {
         LogError("Problem Initializing SteamVR_Input");
         return(false);
     }
     return(true);
 }
    protected override void Awake()
    {
        base.Awake();

#if ZED_SVR_2_0_INPUT
        if (!useLegacySteamVRInput)
        {
            if (!SteamVR.active)
            {
                SteamVR.Initialize(true);                 //Force SteamVR to activate, so we can use the input system.
            }
            //script binding example
            //fireBinding = SteamVR_Input._default.inActions.GrabGrip; //...
        }
#endif
    }
Exemplo n.º 27
0
        public static void InitializeHandles()
        {
            if (!Application.isPlaying || s_actionInitialized)
            {
                return;
            }
            s_actionInitialized = true;

            InitializePaths();

            SteamVR.Initialize();
#if VIU_STEAMVR_2_2_0_OR_NEWER
            SteamVR_ActionSet_Manager.UpdateActionStates();
#elif VIU_STEAMVR_2_1_0_OR_NEWER
            SteamVR_ActionSet_Manager.UpdateActionSetsState();
#else
            SteamVR_ActionSet.UpdateActionSetsState();
#endif

            var vrInput = OpenVR.Input;
            if (vrInput == null)
            {
                Debug.LogError("Fail loading OpenVR.Input");
                return;
            }

            pressActions.ResolveHandles(vrInput);
            touchActions.ResolveHandles(vrInput);
            v1Actions.ResolveHandles(vrInput);
            v2Actions.ResolveHandles(vrInput);
            vibrateActions.ResolveHandles(vrInput);

            s_actionSetHandle = SafeGetActionSetHandle(vrInput, ACTION_SET_PATH);

            skeletonActionHandleLeft  = SafeGetActionHandle(vrInput, ACTION_SET_PATH + "/in/viu_skeleton_left");
            skeletonActionHandleRight = SafeGetActionHandle(vrInput, ACTION_SET_PATH + "/in/viu_skeleton_right");

            if (skeletonActionHandleLeft == OpenVR.k_ulInvalidActionHandle)
            {
                Debug.LogWarning("Skeleton action for left hand is not found: " + ACTION_SET_PATH + "/in/viu_skeleton_left");
            }

            if (skeletonActionHandleRight == OpenVR.k_ulInvalidActionHandle)
            {
                Debug.LogWarning("Skeleton action for right hand is not found: " + ACTION_SET_PATH + "/in/viu_skeleton_right");
            }
        }
Exemplo n.º 28
0
        private void Setup()
        {
            DontDestroyOnLoad(gameObject);

            SteamVR.Initialize(false);
            var res = SteamVR_Camera.GetSceneResolution();

            Log.Info($"SteamVR Setup - HMD Res: {res.width}x{res.height}");
            WeaponArchetypeVRData.Setup();
            SteamVR_InputHandler.Setup();
            gameObject.AddComponent <HMD>();
            gameObject.AddComponent <Controllers>();
            gameObject.AddComponent <VRKeyboard>();
            gameObject.AddComponent <VRAssets>();
            // Delay the overlay setup so we don't 'hitch' the player's camera while everything else loads.
            Invoke(nameof(VRSystems.SetupOverlay), .5f);
        }
Exemplo n.º 29
0
    public static VRControllerDisplayManager.VRControllerType GetActiveControllerType()
    {
        SteamVR instance = SteamVR.instance;
        string  text     = instance.hmd_TrackingSystemName.ToLowerInvariant();
        bool    flag     = text.Contains("lighthouse");
        bool    flag2    = text.Contains("oculus");

        if (flag)
        {
            return(VRControllerDisplayManager.VRControllerType.Vive);
        }
        if (flag2)
        {
            return(VRControllerDisplayManager.VRControllerType.OculusTouch);
        }
        return(VRControllerDisplayManager.VRControllerType.Unknown);
    }
Exemplo n.º 30
0
        private void FadeToCompositor(float fadeTime, bool fadeToCompositor)
        {
            switch (m_OverlayMode)
            {
            case OverlayMode.Steam:
                SteamVR rVR = SteamVR.instance;
                if (rVR != null && rVR.compositor != null)
                {
                    rVR.compositor.FadeGrid(fadeTime, fadeToCompositor);
                }
                break;

            case OverlayMode.OVR:
                FadeBlack(fadeTime, fadeToCompositor);
                break;
            }
        }
Exemplo n.º 31
0
    public void UpdateOverlay(SteamVR vr)
    {
        if (texture != null)
        {
            var settings = new Compositor_OverlaySettings();
            settings.size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_OverlaySettings));
            settings.curved = curved;
            settings.antialias = antialias;
            settings.scale = scale;
            settings.distance = distance;
            settings.alpha = alpha;
            settings.uOffset = uvOffset.x;
            settings.vOffset = uvOffset.y;
            settings.uScale = uvOffset.z;
            settings.vScale = uvOffset.w;
            settings.gridDivs = gridDivs;
            settings.gridWidth = gridWidth;
            settings.gridScale = gridScale;

            var vrcam = SteamVR_Render.Top();
            if (vrcam != null && vrcam.origin != null)
            {
                var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform);
                offset.pos.x /= vrcam.origin.localScale.x;
                offset.pos.y /= vrcam.origin.localScale.y;
                offset.pos.z /= vrcam.origin.localScale.z;
                settings.transform = offset.ToHmdMatrix44();

                // The overlay transform is always rendered in standing space, so we transform it here
                // to seated space when using the seated universe origin in Unity.
                if (SteamVR_Render.instance.trackingSpace == TrackingUniverseOrigin.TrackingUniverseSeated)
                {
                    var seated = vr.hmd.GetSeatedZeroPoseToStandingAbsoluteTrackingPose();
                    offset = new SteamVR_Utils.RigidTransform(seated) * offset;
                    settings.transform = offset.ToHmdMatrix44();
                }
            }

            vr.compositor.SetOverlay(texture.GetNativeTexturePtr(), ref settings);
        }
        else
        {
            vr.compositor.ClearOverlay();
        }
    }
Exemplo n.º 32
0
    private void OnEnable()
    {
        SteamVR instance = SteamVR.instance;

        if (instance == null)
        {
            if (this.head != null)
            {
                this.head.GetComponent <SteamVR_GameView>().enabled      = false;
                this.head.GetComponent <SteamVR_TrackedObject>().enabled = false;
            }
            if (this.flip != null)
            {
                this.flip.enabled = false;
            }
            base.enabled = false;
            return;
        }
        this.Expand();
        if (SteamVR_Camera.blitMaterial == null)
        {
            SteamVR_Camera.blitMaterial = new Material(Shader.Find("Custom/SteamVR_Blit"));
        }
        Camera component = base.GetComponent <Camera>();

        component.fieldOfView  = instance.fieldOfView;
        component.aspect       = instance.aspect;
        component.eventMask    = 0;
        component.orthographic = false;
        component.enabled      = false;
        if (component.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
        {
            Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
            QualitySettings.antiAliasing = 0;
        }
        Camera component2 = this.head.GetComponent <Camera>();

        if (component2 != null)
        {
            component2.hdr           = component.hdr;
            component2.renderingPath = component.renderingPath;
        }
        this.ears.GetComponent <SteamVR_Ears>().vrcam = this;
        SteamVR_Render.Add(this);
    }
Exemplo n.º 33
0
 private void UpdateHandPoses()
 {
     if (this.controller != null)
     {
         SteamVR instance = SteamVR.instance;
         if (instance != null)
         {
             TrackedDevicePose_t trackedDevicePose_t  = default(TrackedDevicePose_t);
             TrackedDevicePose_t trackedDevicePose_t2 = default(TrackedDevicePose_t);
             if (instance.compositor.GetLastPoseForTrackedDeviceIndex(this.controller.index, ref trackedDevicePose_t, ref trackedDevicePose_t2) == EVRCompositorError.None)
             {
                 SteamVR_Utils.RigidTransform rigidTransform = new SteamVR_Utils.RigidTransform(trackedDevicePose_t2.mDeviceToAbsoluteTracking);
                 base.transform.localPosition = rigidTransform.pos;
                 base.transform.localRotation = rigidTransform.rot;
             }
         }
     }
 }
        private void OnEnable()
        {
            if (_newPosesAction != null)
            {
                _newPosesAction.enabled = true;
            }

            _instance = SteamVR.instance;
            if (_instance == null)
            {
                return;
            }

            _deviceIndex        = (int)_steamVrTrackedObject.index;
            _deviceType         = GetDeviceType((uint)_deviceIndex);
            _deviceSerialNumber =
                _instance.GetStringProperty(ETrackedDeviceProperty.Prop_SerialNumber_String, (uint)_deviceIndex);
        }
Exemplo n.º 35
0
    void RenderEye(SteamVR vr, Hmd_Eye eye, LayerMask mask)
    {
        int i = (int)eye;
        SteamVR_Render.eye = eye;

        if (cameraMask != null)
            cameraMask.Set(vr, eye);

        foreach (var c in cameras)
        {
            c.transform.localPosition = vr.eyes[i].pos;
            c.transform.localRotation = vr.eyes[i].rot;

            // Update position to keep from getting culled
            cameraMask.transform.position = c.transform.position;

            var camera = c.GetComponent<Camera>();
            camera.targetTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);
            int cullingMask = camera.cullingMask;
            camera.cullingMask |= mask;
            camera.Render();
            camera.cullingMask = cullingMask;
        }
    }
Exemplo n.º 36
0
	private void Dispose(bool disposing)
	{
		SteamVR_Utils.Event.Remove("initializing", OnInitializing);
		SteamVR_Utils.Event.Remove("calibrating", OnCalibrating);
		SteamVR_Utils.Event.Remove("out_of_range", OnOutOfRange);
		SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
		SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);

		ShutdownSystems();
		_instance = null;
	}
Exemplo n.º 37
0
    void RenderEye(SteamVR vr, EVREye eye)
    {
        int i = (int)eye;
        SteamVR_Render.eye = eye;

        if (cameraMask != null)
            cameraMask.Set(vr, eye);

        foreach (var c in cameras)
        {
            c.transform.localPosition = vr.eyes[i].pos;
            c.transform.localRotation = vr.eyes[i].rot;

            // Update position to keep from getting culled
            cameraMask.transform.position = c.transform.position;

            var camera = c.GetComponent<Camera>();
            camera.targetTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);
            int cullingMask = camera.cullingMask;
            if (eye == EVREye.Eye_Left)
            {
                camera.cullingMask &= ~rightMask;
                camera.cullingMask |= leftMask;
            }
            else
            {
                camera.cullingMask &= ~leftMask;
                camera.cullingMask |= rightMask;
            }
            camera.Render();
            camera.cullingMask = cullingMask;
        }
    }
Exemplo n.º 38
0
 private void Dispose(bool disposing)
 {
     ShutdownSystems();
     _instance = null;
 }
Exemplo n.º 39
0
    public void UpdateOverlay(SteamVR vr)
    {
        if (texture != null)
        {
            var error = vr.overlay.ShowOverlay(handle);
            if (error == VROverlayError.InvalidHandle || error == VROverlayError.UnknownOverlay)
            {
                if (vr.overlay.FindOverlay(key, ref handle) != VROverlayError.None)
                    return;
            }

            vr.overlay.SetOverlayTexture(handle, vr.graphicsAPI, texture.GetNativeTexturePtr());
            vr.overlay.SetOverlayAlpha(handle, alpha);
            vr.overlay.SetOverlayGamma(handle, gamma);
            vr.overlay.SetOverlayWidthInMeters(handle, scale);
            vr.overlay.SetOverlayAutoCurveDistanceRangeInMeters(handle, curvedRange.x, curvedRange.y);

            var textureBounds = new VRTextureBounds_t();
            textureBounds.uMin = (0 + uvOffset.x) * uvOffset.z;
            textureBounds.vMin = (1 + uvOffset.y) * uvOffset.w;
            textureBounds.uMax = (1 + uvOffset.x) * uvOffset.z;
            textureBounds.vMax = (0 + uvOffset.y) * uvOffset.w;
            vr.overlay.SetOverlayTextureBounds(handle, ref textureBounds);

            var vecMouseScale = new HmdVector2_t();
            vecMouseScale.v = new float[] { mouseScale.x, mouseScale.y };
            vr.overlay.SetOverlayMouseScale(handle, ref vecMouseScale);

            var vrcam = SteamVR_Render.Top();
            if (vrcam != null && vrcam.origin != null)
            {
                var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform);
                offset.pos.x /= vrcam.origin.localScale.x;
                offset.pos.y /= vrcam.origin.localScale.y;
                offset.pos.z /= vrcam.origin.localScale.z;

                offset.pos.z += distance;

                var t = offset.ToHmdMatrix34();
                vr.overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t);
            }

            vr.overlay.SetOverlayInputMethod(handle, inputMethod);

            if (curved || antialias)
                highquality = true;

            if (highquality)
            {
                vr.overlay.SetHighQualityOverlay(handle);
                vr.overlay.SetOverlayFlag(handle, VROverlayFlags.Curved, curved);
                vr.overlay.SetOverlayFlag(handle, VROverlayFlags.RGSS4X, antialias);
            }
            else if (vr.overlay.GetHighQualityOverlay() == handle)
            {
                vr.overlay.SetHighQualityOverlay(OpenVR.k_ulOverlayHandleInvalid);
            }
        }
        else
        {
            vr.overlay.HideOverlay(handle);
        }
    }
Exemplo n.º 40
0
    private void Dispose(bool disposing)
    {
        SteamVR_Utils.Event.Remove("initializing", OnInitializing);
        SteamVR_Utils.Event.Remove("calibrating", OnCalibrating);
        SteamVR_Utils.Event.Remove("out_of_range", OnOutOfRange);
        SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
        SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);

        if (callbackHandle.IsAllocated)
        {
            SetUnityRenderCallback(System.IntPtr.Zero);
            SetUnityResetCallback(System.IntPtr.Zero);
            callbackHandle.Free();
        }

        ShutdownSystems();
        _instance = null;
    }