Download

CineCameraComponent and UpdateCameraLens

If someone can help me to understand what I might be doing wrong, I’d greatly appreciate it. I’ve been able to successfully mount a CineCameraComponent to my character component, and I can adjust some parameters for the camera, but the ones I want to adjust the most aren’t getting applied. I’ve tried many things, but have so far been unable to get it to work.

Here is my current attempt at trying to make it work. Unfortunately, all the asserted-to-work examples that I have found online are all blueprints. I’ve tried my best to mimic them all, but none seems to work. I hope I can manage to update the camera lens without having to dive into any camera manager stuff.

#include "MyCineCameraComponent.h"
#include "Camera/CameraTypes.h"
#include "Engine/Scene.h"
#include "Math/Color.h"

MyCineCameraComponent::MyCineCameraComponent()
{
	FCameraLensSettings cs;
	cs.DiaphragmBladeCount = 8;
	cs.MaxFocalLength = 2000.0f;
	cs.MinFocalLength = 10.0f;
	cs.MaxFStop = 2.8f;
	cs.MinFStop = 1.8f;
	cs.MinimumFocusDistance = 10.0f;
	LensSettings = cs;

	FCameraFocusSettings fs;
	fs.bDrawDebugFocusPlane = true;
	fs.DebugFocusPlaneColor = FColor(255.0f, 0.0f, 0.0f, 1.0f);
	FocusSettings = fs;

	DefaultLensFocalLength = 24.0f;
	DefaultLensFStop = 2.0f;

	CurrentFocalLength = 12.0f;
}

void MyCineCameraComponent::TickComponent(float deltaTime, ELevelTick tick, FActorComponentTickFunction *fn)
{
	Super::TickComponent(deltaTime, tick, fn);

	FPostProcessSettings post;
	post.bOverride_DepthOfFieldFocalDistance = true;
	post.bOverride_DepthOfFieldFstop = true;
	post.bOverride_DepthOfFieldMinFstop = true;
	post.bOverride_SceneColorTint = true;
	post.bOverride_VignetteIntensity = true;
	post.bOverride_DepthOfFieldVignetteSize = true;

	post.DepthOfFieldFstop = 2.0f;
	post.DepthOfFieldMinFstop = 1.8f;
	post.DepthOfFieldFocalDistance = 12.0f;
	post.DepthOfFieldVignetteSize = 50.0f;
	post.MotionBlurAmount = 0.0f;
	post.MotionBlurMax = 0.0f;
	post.SceneColorTint = FLinearColor(255.0f, 0.0f, 0.0f, 1.0f);
	post.VignetteIntensity = 1.0f;

	FMinimalViewInfo cl;
	cl.AspectRatio = 16.0f / 9.0f;
	cl.bConstrainAspectRatio = true;
	cl.DesiredFOV = 120.0f;
	cl.FOV = 120.0f;
	cl.PostProcessBlendWeight = 1.0f;
	cl.PostProcessSettings = post;

	UpdateCameraLens(deltaTime, cl);
}