Пример #1
0
        public HmdMatrix44 GetProjectionMatrix(HmdEye Eye, float NearZ, float FarZ, GraphicsAPIConvention ProjType)
        {
            CheckIfUsable();


            return(NativeHelpers.ConvertStruct <HmdMatrix44>(NativeMethods.VR_Hmd_GetProjectionMatrix((int)Eye, NearZ, FarZ, (int)ProjType), Marshal.SizeOf(typeof(HmdMatrix44))));
        }
        public HmdMatrix44 GetProjectionMatrix(HmdEye Eye, float NearZ, float FarZ, GraphicsAPIConvention ProjType)
        {
            CheckIfUsable();


            return NativeHelpers.ConvertStruct<HmdMatrix44>(NativeMethods.VR_Hmd_GetProjectionMatrix((int)Eye, NearZ, FarZ, (int)ProjType), Marshal.SizeOf(typeof(HmdMatrix44)));
        }
        public void GetEyeOutputViewport(HmdEye Eye, GraphicsAPIConvention APIType, out uint X, out uint Y, out uint Width, out uint Height)
        {
            CheckIfUsable();

            X = 0;
            Y = 0;
            Width = 0;
            Height = 0;

            NativeMethods.VR_Hmd_GetEyeOutputViewport((int)Eye, (int)APIType, ref X, ref Y, ref Width, ref Height);
        }
Пример #4
0
        public void GetEyeOutputViewport(HmdEye Eye, GraphicsAPIConvention APIType, out uint X, out uint Y, out uint Width, out uint Height)
        {
            CheckIfUsable();

            X      = 0;
            Y      = 0;
            Width  = 0;
            Height = 0;

            NativeMethods.VR_Hmd_GetEyeOutputViewport((int)Eye, (int)APIType, ref X, ref Y, ref Width, ref Height);
        }
Пример #5
0
 public abstract HmdMatrix44_t GetProjectionMatrix(Hmd_Eye eEye,float fNearZ,float fFarZ,GraphicsAPIConvention eProjType);
Пример #6
0
 public abstract VROverlayError SetOverlayTexture(ulong ulOverlayHandle,GraphicsAPIConvention eTextureType,IntPtr pTexture);
Пример #7
0
 public abstract VRCompositorError Submit(Hmd_Eye eEye,GraphicsAPIConvention eTextureType,IntPtr pTexture,ref VRTextureBounds_t pBounds,VRSubmitFlags_t nSubmitFlags);
Пример #8
0
 public static extern HmdMatrix44_t GetProjectionMatrix(System.IntPtr pHmd, Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType);
internal static extern HmdMatrix44_t SteamAPI_vr_IHmd_GetProjectionMatrix(IntPtr instancePtr, Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType);
Пример #10
0
 public static extern HmdMatrix44_t GetProjectionMatrix(System.IntPtr pHmd, Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType);
Пример #11
0
 internal static extern void VR_IVRCompositor_SetSkyboxOverride(IntPtr instancePtr, GraphicsAPIConvention eTextureType, IntPtr pFront, IntPtr pBack, IntPtr pLeft, IntPtr pRight, IntPtr pTop, IntPtr pBottom);
Пример #12
0
 public override VRCompositorError Submit(Hmd_Eye eEye,GraphicsAPIConvention eTextureType,IntPtr pTexture,ref VRTextureBounds_t pBounds,VRSubmitFlags_t nSubmitFlags)
 {
     CheckIfUsable();
     VRCompositorError result = VRNativeEntrypoints.VR_IVRCompositor_Submit(m_pVRCompositor,eEye,eTextureType,pTexture,ref pBounds,nSubmitFlags);
     return result;
 }
Пример #13
0
 public override void SetSkyboxOverride(GraphicsAPIConvention eTextureType,IntPtr pFront,IntPtr pBack,IntPtr pLeft,IntPtr pRight,IntPtr pTop,IntPtr pBottom)
 {
     CheckIfUsable();
     VRNativeEntrypoints.VR_IVRCompositor_SetSkyboxOverride(m_pVRCompositor,eTextureType,pFront,pBack,pLeft,pRight,pTop,pBottom);
 }
Пример #14
0
    private SteamVR(System.IntPtr pHmd, System.IntPtr pCompositor, System.IntPtr pOverlay)
    {
        hmd = new CVRSystem(pHmd);
        Debug.Log("Connected to " + hmd_TrackingSystemName + ":" + hmd_SerialNumber);

        compositor = new CVRCompositor(pCompositor);
        overlay = new CVROverlay(pOverlay);

        var capacity = compositor.GetLastError(null, 0);
        if (capacity > 1)
        {
            var result = new System.Text.StringBuilder((int)capacity);
            compositor.GetLastError(result, capacity);
            Debug.Log("Compositor - " + result);
        }

        // Setup render values
        uint w = 0, h = 0;
        hmd.GetRecommendedRenderTargetSize(ref w, ref h);
        sceneWidth = (float)w;
        sceneHeight = (float)h;

        float l_left = 0.0f, l_right = 0.0f, l_top = 0.0f, l_bottom = 0.0f;
        hmd.GetProjectionRaw(Hmd_Eye.Eye_Left, ref l_left, ref l_right, ref l_top, ref l_bottom);

        float r_left = 0.0f, r_right = 0.0f, r_top = 0.0f, r_bottom = 0.0f;
        hmd.GetProjectionRaw(Hmd_Eye.Eye_Right, ref r_left, ref r_right, ref r_top, ref r_bottom);

        tanHalfFov = new Vector2(
            Mathf.Max(-l_left, l_right, -r_left, r_right),
            Mathf.Max(-l_top, l_bottom, -r_top, r_bottom));

        textureBounds = new VRTextureBounds_t[2];

        textureBounds[0].uMin = 0.5f + 0.5f * l_left / tanHalfFov.x;
        textureBounds[0].uMax = 0.5f + 0.5f * l_right / tanHalfFov.x;
        textureBounds[0].vMin = 0.5f - 0.5f * l_bottom / tanHalfFov.y;
        textureBounds[0].vMax = 0.5f - 0.5f * l_top / tanHalfFov.y;

        textureBounds[1].uMin = 0.5f + 0.5f * r_left / tanHalfFov.x;
        textureBounds[1].uMax = 0.5f + 0.5f * r_right / tanHalfFov.x;
        textureBounds[1].vMin = 0.5f - 0.5f * r_bottom / tanHalfFov.y;
        textureBounds[1].vMax = 0.5f - 0.5f * r_top / tanHalfFov.y;

        Unity.SetSubmitParams(textureBounds[0], textureBounds[1], VRSubmitFlags_t.Submit_Default);

        // Grow the recommended size to account for the overlapping fov
        sceneWidth = sceneWidth / Mathf.Max(textureBounds[0].uMax - textureBounds[0].uMin, textureBounds[1].uMax - textureBounds[1].uMin);
        sceneHeight = sceneHeight / Mathf.Max(textureBounds[0].vMax - textureBounds[0].vMin, textureBounds[1].vMax - textureBounds[1].vMin);

        aspect = tanHalfFov.x / tanHalfFov.y;
        fieldOfView = 2.0f * Mathf.Atan(tanHalfFov.y) * Mathf.Rad2Deg;

        eyes = new SteamVR_Utils.RigidTransform[] {
            new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(Hmd_Eye.Eye_Left)),
            new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(Hmd_Eye.Eye_Right)) };

        if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
            graphicsAPI = GraphicsAPIConvention.API_OpenGL;
        else
            graphicsAPI = GraphicsAPIConvention.API_DirectX;

        SteamVR_Utils.Event.Listen("initializing", OnInitializing);
        SteamVR_Utils.Event.Listen("calibrating", OnCalibrating);
        SteamVR_Utils.Event.Listen("out_of_range", OnOutOfRange);
        SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
        SteamVR_Utils.Event.Listen("new_poses", OnNewPoses);
    }
Пример #15
0
 internal static extern VROverlayError VR_IVROverlay_SetOverlayTexture(IntPtr instancePtr, ulong ulOverlayHandle, GraphicsAPIConvention eTextureType, IntPtr pTexture);
Пример #16
0
 internal static extern HmdMatrix44_t VR_IVRSystem_GetProjectionMatrix(IntPtr instancePtr, Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType);
Пример #17
0
 internal static extern VRCompositorError VR_IVRCompositor_Submit(IntPtr instancePtr, Hmd_Eye eEye, GraphicsAPIConvention eTextureType, IntPtr pTexture, ref VRTextureBounds_t pBounds, VRSubmitFlags_t nSubmitFlags);
Пример #18
0
 /** The projection matrix for the specified eye */
 public HmdMatrix44_t GetProjectionMatrix(Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType)
 {
     return(SteamVR.GetProjectionMatrix(m_pNativeObject, eEye, fNearZ, fFarZ, eProjType));
 }
Пример #19
0
 public override VROverlayError SetOverlayTexture(ulong ulOverlayHandle,GraphicsAPIConvention eTextureType,IntPtr pTexture)
 {
     CheckIfUsable();
     VROverlayError result = VRNativeEntrypoints.VR_IVROverlay_SetOverlayTexture(m_pVROverlay,ulOverlayHandle,eTextureType,pTexture);
     return result;
 }
Пример #20
0
    private SteamVR(System.IntPtr pHmd, System.IntPtr pCompositor, System.IntPtr pOverlay)
    {
        hmd = new CVRSystem(pHmd);
        Debug.Log("Connected to " + hmd_TrackingSystemName + ":" + hmd_SerialNumber);

        compositor = new CVRCompositor(pCompositor);
        overlay    = new CVROverlay(pOverlay);

        var capacity = compositor.GetLastError(null, 0);

        if (capacity > 1)
        {
            var result = new System.Text.StringBuilder((int)capacity);
            compositor.GetLastError(result, capacity);
            Debug.Log("Compositor - " + result);
        }

        // Hook up the render thread event.
        var error = HmdError.None;

        SetUnityRenderCallback(OpenVR.GetGenericInterface(IVRHmdDistortPresent_Version, ref error));

        // Setup render values
        uint w = 0, h = 0;

        hmd.GetRecommendedRenderTargetSize(ref w, ref h);
        sceneWidth  = (float)w;
        sceneHeight = (float)h;

        float l_left = 0.0f, l_right = 0.0f, l_top = 0.0f, l_bottom = 0.0f;

        hmd.GetProjectionRaw(Hmd_Eye.Eye_Left, ref l_left, ref l_right, ref l_top, ref l_bottom);

        float r_left = 0.0f, r_right = 0.0f, r_top = 0.0f, r_bottom = 0.0f;

        hmd.GetProjectionRaw(Hmd_Eye.Eye_Right, ref r_left, ref r_right, ref r_top, ref r_bottom);

        tanHalfFov = new Vector2(
            Mathf.Max(-l_left, l_right, -r_left, r_right),
            Mathf.Max(-l_top, l_bottom, -r_top, r_bottom));

        textureBounds = new VRTextureBounds_t[2];

        textureBounds[0].uMin = 0.5f + 0.5f * l_left / tanHalfFov.x;
        textureBounds[0].uMax = 0.5f + 0.5f * l_right / tanHalfFov.x;
        textureBounds[0].vMin = 0.5f - 0.5f * l_bottom / tanHalfFov.y;
        textureBounds[0].vMax = 0.5f - 0.5f * l_top / tanHalfFov.y;

        textureBounds[1].uMin = 0.5f + 0.5f * r_left / tanHalfFov.x;
        textureBounds[1].uMax = 0.5f + 0.5f * r_right / tanHalfFov.x;
        textureBounds[1].vMin = 0.5f - 0.5f * r_bottom / tanHalfFov.y;
        textureBounds[1].vMax = 0.5f - 0.5f * r_top / tanHalfFov.y;

        // Grow the recommended size to account for the overlapping fov
        sceneWidth  = sceneWidth / Mathf.Max(textureBounds[0].uMax - textureBounds[0].uMin, textureBounds[1].uMax - textureBounds[1].uMin);
        sceneHeight = sceneHeight / Mathf.Max(textureBounds[0].vMax - textureBounds[0].vMin, textureBounds[1].vMax - textureBounds[1].vMin);

        aspect      = tanHalfFov.x / tanHalfFov.y;
        fieldOfView = 2.0f * Mathf.Atan(tanHalfFov.y) * Mathf.Rad2Deg;

        eyes = new SteamVR_Utils.RigidTransform[] {
            new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(Hmd_Eye.Eye_Left)),
            new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(Hmd_Eye.Eye_Right))
        };

        if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
        {
            graphicsAPI = GraphicsAPIConvention.API_OpenGL;
        }
        else
        {
            graphicsAPI = GraphicsAPIConvention.API_DirectX;
        }

        SteamVR_Utils.Event.Listen("initializing", OnInitializing);
        SteamVR_Utils.Event.Listen("calibrating", OnCalibrating);
        SteamVR_Utils.Event.Listen("out_of_range", OnOutOfRange);
        SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
        SteamVR_Utils.Event.Listen("new_poses", OnNewPoses);
    }
Пример #21
0
 public override HmdMatrix44_t GetProjectionMatrix(Hmd_Eye eEye,float fNearZ,float fFarZ,GraphicsAPIConvention eProjType)
 {
     CheckIfUsable();
     HmdMatrix44_t result = VRNativeEntrypoints.VR_IVRSystem_GetProjectionMatrix(m_pVRSystem,eEye,fNearZ,fFarZ,eProjType);
     return result;
 }
Пример #22
0
 /** The projection matrix for the specified eye */
 public HmdMatrix44_t GetProjectionMatrix(Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType)
 {
     return SteamVR.GetProjectionMatrix(m_pNativeObject, eEye, fNearZ, fFarZ, eProjType);
 }
Пример #23
0
 public abstract void SetSkyboxOverride(GraphicsAPIConvention eTextureType,IntPtr pFront,IntPtr pBack,IntPtr pLeft,IntPtr pRight,IntPtr pTop,IntPtr pBottom);