80 lines
1.8 KiB
C++
80 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Camera/CameraActor.h"
|
|
#include "CameraCaptureActor.generated.h"
|
|
|
|
|
|
#define CAMERA_WIDTH_NUMS 3
|
|
#define CAMERA_HEIGHTH_NUMS 3
|
|
|
|
const int32 AtlasGridX = 3;
|
|
const int32 AtlasGridY = 3;
|
|
const int32 ViewWidth = 1024;
|
|
const int32 ViewHeight = 1024;
|
|
|
|
|
|
|
|
UENUM(BlueprintType)
|
|
enum class EViewDistribution : uint8
|
|
{
|
|
LinearHorizontal UMETA(DisplayName = "Linear Horizontal"),
|
|
Circular UMETA(DisplayName = "Circular")
|
|
};
|
|
|
|
|
|
class USceneCaptureComponent2D;
|
|
class UTextureRenderTarget2D;
|
|
|
|
|
|
|
|
UCLASS()
|
|
class CAMERACAPTURE_API ACameraCaptureActor : public ACameraActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
ACameraCaptureActor();
|
|
|
|
USceneCaptureComponent2D* GetViewCapture() { return ViewCapture; }
|
|
UTextureRenderTarget2D* GetViewRT() { return ViewRT; }
|
|
|
|
|
|
// ===== 多视图参数 =====
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView")
|
|
int32 ViewCount = 1;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView")
|
|
float Baseline = 5.0f; // cm
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView")
|
|
EViewDistribution Distribution = EViewDistribution::LinearHorizontal;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView")
|
|
bool bCaptureEveryFrame = true;
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
|
|
#if WITH_EDITOR
|
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
void BuildViewCaptures();
|
|
void UpdateViewTransforms(const int32 Index);
|
|
void CaptureViews();
|
|
|
|
private:
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<USceneCaptureComponent2D> ViewCapture;
|
|
|
|
UPROPERTY(Transient)
|
|
TObjectPtr<UTextureRenderTarget2D> ViewRT;
|
|
|
|
}; |