I created a custom blueprint node for that returns the world coordinates for the centers of the top, left, bottom and right frustum planes.
To test it I’ve made it so that at game start a fire particle is initiated at the center of each of the planes. The cube represents the camera position.
http://i.stack.imgur.com/x0BxC.png
http://i.stack.imgur.com/eDwQi.png
Blueprint usage
http://i.stack.imgur.com/5wH6X.png
CameraUtils.h
#pragma once
#include "Camera/CameraActor.h"
#include "CameraUtils.generated.h"
/**
*
*/
UCLASS()
class PROJECTNAME_API ACameraUtils : public ACameraActor
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure,
meta = (
DisplayName = "Get Camera Edges from Frustum",
Keywords = "Camera Edges Frustum"
),
Category = "Camera|Utility")
static void GetCameraFrustumEdges(UCameraComponent* camera, FVector& topCenter, FVector& leftCenter, FVector& bottomCenter, FVector& rightCenter);
};
CameraUtils.cpp
#include "ProjectName.h"
#include "CameraUtils.h"
void ACameraUtils::GetCameraFrustumEdges(UCameraComponent* camera, FVector& topCenter, FVector& leftCenter, FVector& bottomCenter, FVector& rightCenter)
{
// Assumptions: Camera is orthographic, Z axis is upwards, Y axis is right, X is forward
FMinimalViewInfo cameraView;
camera->GetCameraView(0.0f, cameraView);
float width = cameraView.OrthoWidth;
float height = width / cameraView.AspectRatio;
topCenter.Set(cameraView.Location.X,
cameraView.Location.Y,
cameraView.Location.Z + height/2.0f);
bottomCenter.Set(cameraView.Location.X,
cameraView.Location.Y,
cameraView.Location.Z - height / 2.0f);
leftCenter.Set(cameraView.Location.X,
cameraView.Location.Y - width / 2.0f,
cameraView.Location.Z);
rightCenter.Set(cameraView.Location.X,
cameraView.Location.Y + width / 2.0f,
cameraView.Location.Z);
}