From f682b3b460ab8b2eb3c30ced71354ebf7ea4190c Mon Sep 17 00:00:00 2001 From: Hong Date: Wed, 4 Mar 2026 17:57:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20camera=20=E7=9A=84subsyste?= =?UTF-8?q?m=20=E8=BF=9B=E8=A1=8C=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/CameraCaptureActor.cpp | 2 +- .../CameraCapture/Source/CameraCaptureActor.h | 8 +++-- .../Source/CameraCaptureSubSystem.h | 31 +++++++++++++++++ .../Source/CameraCaptureSubsystem.cpp | 33 +++++++++++++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 Plugins/CameraCapture/Source/CameraCaptureSubSystem.h create mode 100644 Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp diff --git a/Plugins/CameraCapture/Source/CameraCaptureActor.cpp b/Plugins/CameraCapture/Source/CameraCaptureActor.cpp index 33aa258..77b08ca 100644 --- a/Plugins/CameraCapture/Source/CameraCaptureActor.cpp +++ b/Plugins/CameraCapture/Source/CameraCaptureActor.cpp @@ -78,7 +78,7 @@ void ACameraCaptureActor::BuildViewCaptures() USceneCaptureComponent2D* Capture = NewObject(this); Capture->SetupAttachment(GetRootComponent()); - Capture->RegisterComponent(); + Capture->RegisterComponent(); Capture->TextureTarget = RT; Capture->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR; diff --git a/Plugins/CameraCapture/Source/CameraCaptureActor.h b/Plugins/CameraCapture/Source/CameraCaptureActor.h index 218f921..781a9a4 100644 --- a/Plugins/CameraCapture/Source/CameraCaptureActor.h +++ b/Plugins/CameraCapture/Source/CameraCaptureActor.h @@ -22,7 +22,7 @@ public: // ===== 多视图参数 ===== UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView") - int32 ViewCount = 9; + int32 ViewCount = 1; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiView") float Baseline = 5.0f; // cm @@ -45,7 +45,7 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Atlas") int32 AtlasGridX = 3; - + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Atlas") int32 AtlasGridY = 3; @@ -57,13 +57,17 @@ protected: virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; #endif + + private: + void BuildViewCaptures(); void UpdateViewTransforms(); void CaptureViews(); void GenerateAtlas(); private: + UPROPERTY(Transient) TArray ViewCaptures; diff --git a/Plugins/CameraCapture/Source/CameraCaptureSubSystem.h b/Plugins/CameraCapture/Source/CameraCaptureSubSystem.h new file mode 100644 index 0000000..053bbc6 --- /dev/null +++ b/Plugins/CameraCapture/Source/CameraCaptureSubSystem.h @@ -0,0 +1,31 @@ +// Copyright 2026 (c) Jupiter. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "Subsystems/WorldSubsystem.h" +#include "CameraCaptureSubSystem.generated.h" + + + +class ACameraCaptureActor; + + +UCLASS() +class CAMERACAPTURE_API UCameraCaptureSubSystem : public UWorldSubsystem +{ + GENERATED_BODY() + +public: + + virtual void Initialize(FSubsystemCollectionBase& Collection) override; + virtual void Deinitialize() override; + virtual void OnWorldBeginPlay(UWorld& InWorld) override; + + +private: + + TArray> AllCaptureCameras; + + +}; diff --git a/Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp b/Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp new file mode 100644 index 0000000..1dfc81e --- /dev/null +++ b/Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp @@ -0,0 +1,33 @@ +// Copyright 2026 (c) Jupiter. All Rights Reserved. + +#include "CameraCaptureSubSystem.h" +#include "CameraCaptureActor.h" + +#include "EngineUtils.h" + +void UCameraCaptureSubSystem::Initialize(FSubsystemCollectionBase& Collection) +{ + Super::Initialize(Collection); + +} + +void UCameraCaptureSubSystem::Deinitialize() +{ + Super::Deinitialize(); +} + +void UCameraCaptureSubSystem::OnWorldBeginPlay(UWorld& InWorld) +{ + Super::OnWorldBeginPlay(InWorld); + + for (TActorIterator It(GetWorld()); It; ++It) + { + + ACameraCaptureActor* CameraCaptureActor = Cast(*It); + if (CameraCaptureActor) + { + AllCaptureCameras.Emplace(CameraCaptureActor); + } + } + +}