3#include <Foundation/Math/Mat4.h>
5namespace plGraphicsUtils
20 PL_FOUNDATION_DLL
plResult ConvertWorldPosToScreenPos(
const plMat4& mModelViewProjection,
const plUInt32 uiViewportX,
const plUInt32 uiViewportY,
21 const plUInt32 uiViewportWidth,
const plUInt32 uiViewportHeight,
const plVec3& vPoint,
plVec3& out_vScreenPos,
42 PL_FOUNDATION_DLL
plResult ConvertScreenPosToWorldPos(
const plMat4& mInverseModelViewProjection,
const plUInt32 uiViewportX,
43 const plUInt32 uiViewportY,
const plUInt32 uiViewportWidth,
const plUInt32 uiViewportHeight,
const plVec3& vScreenPos,
plVec3& out_vPoint,
44 plVec3* out_pDirection =
nullptr,
48 PL_FOUNDATION_DLL
plResult ConvertScreenPosToWorldPos(
const plMat4d& mInverseModelViewProjection,
const plUInt32 uiViewportX,
49 const plUInt32 uiViewportY,
const plUInt32 uiViewportWidth,
const plUInt32 uiViewportHeight,
const plVec3& vScreenPos,
plVec3& out_vPoint,
50 plVec3* out_pDirection =
nullptr,
55 PL_FOUNDATION_DLL
bool IsTriangleFlipRequired(
const plMat3& mTransformation);
58 PL_FOUNDATION_DLL
void ConvertProjectionMatrixDepthRange(
64 PL_FOUNDATION_DLL
void ExtractPerspectiveMatrixFieldOfView(
const plMat4& mProjectionMatrix,
plAngle& out_fovX,
plAngle& out_fovY);
84 PL_FOUNDATION_DLL
plResult ExtractNearAndFarClipPlaneDistances(
float& out_fNear,
float& out_fFar,
const plMat4& mProjectionMatrix,
88 enum class FrustumPlaneInterpolation
103 PL_FOUNDATION_DLL
plPlane ComputeInterpolatedFrustumPlane(FrustumPlaneInterpolation dir,
float fLerpFactor,
const plMat4& mProjectionMatrix,
108 PL_FOUNDATION_DLL
plMat4 CreatePerspectiveProjectionMatrix(
float fViewWidth,
float fViewHeight,
float fNearZ,
float fFarZ,
113 PL_FOUNDATION_DLL
plMat4 CreatePerspectiveProjectionMatrix(
float fLeft,
float fRight,
float fBottom,
float fTop,
float fNearZ,
float fFarZ,
119 PL_FOUNDATION_DLL
plMat4 CreatePerspectiveProjectionMatrixFromFovX(
plAngle fieldOfViewX,
float fAspectRatioWidthDivHeight,
float fNearZ,
125 PL_FOUNDATION_DLL
plMat4 CreatePerspectiveProjectionMatrixFromFovY(
plAngle fieldOfViewY,
float fAspectRatioWidthDivHeight,
float fNearZ,
131 PL_FOUNDATION_DLL
plMat4 CreateOrthographicProjectionMatrix(
float fViewWidth,
float fViewHeight,
float fNearZ,
float fFarZ,
136 PL_FOUNDATION_DLL
plMat4 CreateOrthographicProjectionMatrix(
float fLeft,
float fRight,
float fBottom,
float fTop,
float fNearZ,
float fFarZ,
143 PL_FOUNDATION_DLL
plMat3 CreateLookAtViewMatrix(
147 PL_FOUNDATION_DLL
plMat3 CreateInverseLookAtViewMatrix(
152 PL_FOUNDATION_DLL
plMat4 CreateLookAtViewMatrix(
const plVec3& vEyePos,
const plVec3& vLookAtPos,
const plVec3& vUpDir,
156 PL_FOUNDATION_DLL
plMat4 CreateInverseLookAtViewMatrix(
const plVec3& vEyePos,
const plVec3& vLookAtPos,
const plVec3& vUpDir,
166 PL_FOUNDATION_DLL
plMat4 CreateInverseViewMatrix(
const plVec3& vPosition,
const plVec3& vForwardDir,
const plVec3& vRightDir,
const plVec3& vUpDir,
172 PL_FOUNDATION_DLL
void DecomposeViewMatrix(
plVec3& out_vPosition,
plVec3& out_vForwardDir,
plVec3& out_vRightDir,
plVec3& out_vUpDir,
197 const float fDist = (sphere.m_vCenter - vCameraPosition).GetLength();
198 const float fHalfHeight =
plMath::Tan(perspectiveCameraFov * 0.5f) * fDist;
199 return sphere.m_fRadius / fHalfHeight;
212 inline float CalculateSphereScreenCoverage(
float fSphereRadius,
float fOrthoCameraDimensions)
214 const float fHalfHeight = fOrthoCameraDimensions * 0.5f;
215 return fSphereRadius / fHalfHeight;
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
PL_ALWAYS_INLINE float Tan(plAngle a)
Takes an angle, returns its tangent.
Definition MathFloat_inl.h:72
Enum
Definition Declarations.h:79
static PL_FOUNDATION_DLL Enum Default
Holds the default value for the projection depth range on each platform. This can be overridden by re...
Definition Declarations.h:87
Enum
Definition Declarations.h:102
@ Regular
Creates a regular projection matrix.
Definition Declarations.h:103
static PL_FOUNDATION_DLL Enum Default
Holds the default handedness value to use. pl uses 'LeftHanded' by default.
Definition Declarations.h:124
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54