添加 camera 的subsystem 进行管理
This commit is contained in:
parent
d10f4763e7
commit
f682b3b460
@ -78,7 +78,7 @@ void ACameraCaptureActor::BuildViewCaptures()
|
||||
|
||||
USceneCaptureComponent2D* Capture = NewObject<USceneCaptureComponent2D>(this);
|
||||
Capture->SetupAttachment(GetRootComponent());
|
||||
Capture->RegisterComponent();
|
||||
Capture->RegisterComponent();
|
||||
|
||||
Capture->TextureTarget = RT;
|
||||
Capture->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
|
||||
|
||||
@ -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<class USceneCaptureComponent2D*> ViewCaptures;
|
||||
|
||||
|
||||
31
Plugins/CameraCapture/Source/CameraCaptureSubSystem.h
Normal file
31
Plugins/CameraCapture/Source/CameraCaptureSubSystem.h
Normal file
@ -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<TWeakObjectPtr<ACameraCaptureActor>> AllCaptureCameras;
|
||||
|
||||
|
||||
};
|
||||
33
Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp
Normal file
33
Plugins/CameraCapture/Source/CameraCaptureSubsystem.cpp
Normal file
@ -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<ACameraCaptureActor> It(GetWorld()); It; ++It)
|
||||
{
|
||||
|
||||
ACameraCaptureActor* CameraCaptureActor = Cast<ACameraCaptureActor>(*It);
|
||||
if (CameraCaptureActor)
|
||||
{
|
||||
AllCaptureCameras.Emplace(CameraCaptureActor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user