Getting camera Frustum geometry in C++ or BP

I have multiple cameras in the scene as seen below, I can see the camera Frustum by enabling it in the editor via Show > Advanced > Camera Frustums.

However, I would like to get the FVector(s) that defines the geometry of the camera Frustum.
How can I get that information?

The following code suggested by GitHub copilot does not compile:

UCameraComponent* CameraComponent;
		CameraComponent->GetFrustumVertices();

Any ideas?

the Camera Frustum is not defined as vectors directly, it is defined as 6 semi-tangible planes connected to the camera.

depending on what you need to do you might find some of this thread of interest

might also want to look at post 14 for a blueprint method as well.

if you need to figure out if something is being rendered at all there are some “easier” and less exacting methods the doing full frustum calculations, with WasRecentlyRendered() or doing a projection from say the mouse pointer, or the forward vector of the camera.

1 Like

I am dynamically building a scene with actors, cameras, animations etc that will be eventually used to generate a movie sequence with few shots. Since the actor locations are not known and they are dynamically spawned, I need to calculate in advance what cameras can be used on what actors, and can one camera shot potentially capture multiple actors in the scene or just one.

For that purpose, I was hoping to get the camera Frustum in order to build a simple collision mesh from the Frustum that can easily tell me if the actor will be visible in specific shot or not, so that I can go on and create camera shot for actors that are not yet been captured/shown by the previous camera movie shot.

I’ve seen your suggestion, but I doubt that it would work as I’ll be using CineCamera actors most likely and I’m not sure yet if they will be attached to the player.

So there is no way to get the pyramid shape out of the camera that represents the viewport of the camera?

I’m not worried about actors overlaping and hidding each other as I can control them and move/alpha them as needed.

GetViewFrustumBounds() is what you want, probably.

I ended up raycasting manually based on camera FOV, since there is no easy solution on it. It’s not great but it works for now untill i find a better way.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.