Hi,
SceneCaptureComponent2D.h contains the following
/** Whether a custom projection matrix will be used during rendering. */
UPROPERTY(BlueprintReadWrite, AdvancedDisplay, Category = Projection)
bool bUseCustomProjectionMatrix;
/** The custom projection matrix to use */
UPROPERTY(BlueprintReadWrite, AdvancedDisplay, Category = Projection)
FMatrix CustomProjectionMatrix;
I have tried deriving from SceneCaptureComponent2D to set a custom Matrix
#include "ARSceneCaptureComponent2D.h"
void UARSceneCaptureComponent2D::BeginPlay()
{
bUseCustomProjectionMatrix = true;
CustomProjectionMatrix = GenerateOffCenterMatrix(0.0F, 2000.0F, width,
height, skew, u0, v0, fx, fy);
}
FMatrix UARSceneCaptureComponent2D::GenerateOffCenterMatrix(float near, float far, float width, float height, float s, float u0, float v0, float fx, float fy)
{
FMatrix out;
float mat00 = 2.0F * fx / width;
float mat11 = 2.0F * fy / height;
float mat02 = (width - 2.0F * u0) / width;
float mat12 = (-height + 2.0F * v0) / height;
float mat22 = -(far + near) / (far - near);
float mat23 = -(2.0F * far * near) / (far - near);
float mat32 = -1.0F;
// Setting perspective transformation Matrix
out.SetIdentity();
out.M[0][0] = mat00;
out.M[0][1] = 0;
out.M[0][2] = mat02;
out.M[0][3] = 0;
out.M[1][0] = 0;
out.M[1][1] = mat11;
out.M[1][2] = mat12;
out.M[1][3] = 0;
out.M[2][0] = 0;
out.M[2][1] = 0;
out.M[2][2] = mat22;
out.M[2][3] = mat23;
out.M[3][0] = 0;
out.M[3][1] = 0;
out.M[3][2] = mat32;
out.M[3][3] = 0;
return out;
}
Sadly my code won’t work, the image looks exactly the same with or without setting it. Has anyone tried this before and can tell me how to fix this?