Beispiel #1
0
    /// <summary>
    /// Gets the given eye's projection matrix.
    /// </summary>
    /// <param name="eyeId">Specifies the eye.</param>
    /// <param name="nearClip">The distance to the near clipping plane.</param>
    /// <param name="farClip">The distance to the far clipping plane.</param>
    public Matrix4x4 GetProjection(int eyeId, float nearClip, float farClip)
    {
#if !UNITY_ANDROID || UNITY_EDITOR
        FovPort fov = OVRManager.capiHmd.GetDesc().DefaultEyeFov[eyeId];

        return(Hmd.GetProjection(fov, nearClip, farClip, true).ToMatrix4x4());
#else
        return(new Matrix4x4());
#endif
    }
    /// <summary>
    /// Gets the given eye's projection matrix.
    /// </summary>
    /// <param name="eyeId">Specifies the eye.</param>
    /// <param name="nearClip">The distance to the near clipping plane.</param>
    /// <param name="farClip">The distance to the far clipping plane.</param>
    public Matrix4x4 GetProjection(int eyeId, float nearClip, float farClip)
    {
#if !UNITY_ANDROID || UNITY_EDITOR
        FovPort fov = OVRManager.capiHmd.GetDesc().DefaultEyeFov[eyeId];

        uint projectionModFlags = (uint)Hmd.ProjectionModifier.RightHanded;

        return(Hmd.GetProjection(fov, nearClip, farClip, projectionModFlags).ToMatrix4x4());
#else
        return(new Matrix4x4());
#endif
    }
    /// <summary>
    /// Gets the camera projection matrix.
    /// </summary>
    /// <returns><c>true</c>, if camera projection matrix was gotten, <c>false</c> otherwise.</returns>
    /// <param name="eyeId">Eye Id - Left = 0, Right = 1.</param>
    /// <param name="nearClip">Near Clip Plane of the camera.</param>
    /// <param name="farClip">Far Clip Plane of the camera.</param>
    /// <param name="mat">The generated camera projection matrix.</param>
    public static bool GetCameraProjection(int eyeId, float nearClip, float farClip, ref Matrix4x4 mat)
    {
        if (HMD == null || !SupportedPlatform)
        {
            return(false);
        }

        ovrFovPort fov = HMD.GetDesc().DefaultEyeFov[eyeId];

        mat = Hmd.GetProjection(fov, nearClip, farClip, true).ToMatrix4x4();

        return(true);
    }