コード例 #1
0
ファイル: OvrCapi.cs プロジェクト: benlewis/unhinged_vr
		//-------------------------------------------------------------------------------------
		// *****  Rendering API Thread Safety

		//  All of rendering functions including the configure and frame functions
		// are *NOT thread safe*. It is ok to use ConfigureRendering on one thread and handle
		//  frames on another thread, but explicit synchronization must be done since
		//  functions that depend on configured state are not reentrant.
		//
		//  As an extra requirement, any of the following calls must be done on
		//  the render thread, which is the same thread that calls ovrHmd_BeginFrame
		//  or ovrHmd_BeginFrameTiming.
		//    - ovrHmd_EndFrame
		//    - ovrHmd_GetEyeTimewarpMatrices

		//-------------------------------------------------------------------------------------
		// *****  SDK Distortion Rendering Functions

		// These functions support rendering of distortion by the SDK through direct
		// access to the underlying rendering API, such as D3D or GL.
		// This is the recommended approach since it allows better support for future
		// Oculus hardware, and enables a range of low-level optimizations.

        /// <summary>
		/// Configures rendering and fills in computed render parameters.
		/// This function can be called multiple times to change rendering settings.
		/// eyeRenderDescOut is a pointer to an array of two EyeRenderDesc structs
		/// that are used to return complete rendering information for each eye.
		///  - apiConfig provides D3D/OpenGL specific parameters. Pass null
		///    to shutdown rendering and release all resources.
		///  - distortionCaps describe desired distortion settings.
        /// </summary>
        public EyeRenderDesc[] ConfigureRendering(ref RenderAPIConfig renderAPIConfig, FovPort[] eyeFovIn, uint distortionCaps)
		{
			EyeRenderDesc[] eyeRenderDesc = new EyeRenderDesc[] { new EyeRenderDesc(), new EyeRenderDesc() };
			RenderAPIConfig_Raw rawConfig = renderAPIConfig.ToRaw();

			bool result = ovrHmd_ConfigureRendering(HmdPtr, ref rawConfig, distortionCaps, eyeFovIn, eyeRenderDesc) != 0;
            if (result)
				return eyeRenderDesc;
			return null;
		}
コード例 #2
0
	private void ConfigureEyeDesc(OVREye eye)
	{
#if !UNITY_ANDROID || UNITY_EDITOR
		HmdDesc desc = OVRManager.capiHmd.GetDesc();
		FovPort fov = desc.DefaultEyeFov[(int)eye];
		fov.LeftTan = fov.RightTan = Mathf.Max(fov.LeftTan, fov.RightTan);
		fov.UpTan = fov.DownTan = Mathf.Max(fov.UpTan, fov.DownTan);

		// Configure Stereo settings. Default pixel density is one texel per pixel.
		float desiredPixelDensity = 1f;
		Sizei texSize = OVRManager.capiHmd.GetFovTextureSize((Ovr.Eye)eye, fov, desiredPixelDensity);

		float fovH = 2f * Mathf.Rad2Deg * Mathf.Atan(fov.LeftTan);
		float fovV = 2f * Mathf.Rad2Deg * Mathf.Atan(fov.UpTan);

		eyeDescs[(int)eye] = new EyeRenderDesc()
		{
			resolution = texSize.ToVector2(),
					   fov = new Vector2(fovH, fovV)
		};
#else
		eyeDescs[(int)eye] = new EyeRenderDesc()
		{
			resolution = new Vector2(1024, 1024),
					   fov = new Vector2(90, 90)
		};
#endif
	}
コード例 #3
0
ファイル: OVRDisplay.cs プロジェクト: panzoid/Solar-System
    private void ConfigureEyeDesc(OVREye eye)
    {
        Vector2 texSize = Vector2.zero;
        Vector2 fovSize = Vector2.zero;

        #if !UNITY_ANDROID || UNITY_EDITOR
        FovPort fovPort = OVRManager.capiHmd.GetDesc().DefaultEyeFov[(int)eye];
        fovPort.LeftTan = fovPort.RightTan = Mathf.Max(fovPort.LeftTan, fovPort.RightTan);
        fovPort.UpTan = fovPort.DownTan = Mathf.Max(fovPort.UpTan, fovPort.DownTan);

        texSize = OVRManager.capiHmd.GetFovTextureSize((Ovr.Eye)eye, fovPort, OVRManager.instance.nativeTextureScale).ToVector2();
        fovSize = new Vector2(2f * Mathf.Rad2Deg * Mathf.Atan(fovPort.LeftTan), 2f * Mathf.Rad2Deg * Mathf.Atan(fovPort.UpTan));
        #else
        texSize = new Vector2(1024, 1024) * OVRManager.instance.nativeTextureScale;
        fovSize = new Vector2(90, 90);
        #endif

        eyeDescs[(int)eye] = new EyeRenderDesc()
        {
            resolution = texSize,
            fov = fovSize
        };
    }
コード例 #4
0
    private void ConfigureEyeDesc(OVREye eye)
    {
        Vector2 texSize = Vector2.zero;
        Vector2 fovSize = Vector2.zero;

        #if !UNITY_ANDROID || UNITY_EDITOR
        if (!OVRManager.instance.isVRPresent)
            return;

        OVRPlugin.Sizei size = OVRPlugin.GetEyeTextureSize((OVRPlugin.Eye)eye);
        OVRPlugin.Frustumf frustum = OVRPlugin.GetEyeFrustum((OVRPlugin.Eye)eye);

        texSize = new Vector2(size.w, size.h);
        fovSize = Mathf.Rad2Deg * new Vector2(frustum.fovX, frustum.fovY);
        #else
        texSize = new Vector2(1024, 1024) * OVRManager.instance.nativeTextureScale;
        fovSize = new Vector2(90, 90);
        #endif

        eyeDescs[(int)eye] = new EyeRenderDesc()
        {
            resolution = texSize,
            fov = fovSize
        };
    }