-
Notifications
You must be signed in to change notification settings - Fork 2
/
CustomScreenCapture.h
55 lines (42 loc) · 1.8 KB
/
CustomScreenCapture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ref: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1627098-get-image-from-scenecapture2d
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Engine/Classes/Camera/CameraComponent.h"
#include "Engine/Classes/Components/SceneCaptureComponent2D.h"
#include "Engine/Classes/Engine/TextureRenderTarget2D.h"
#include <string>
#include "CustomScreenCapture.generated.h"
UCLASS()
class BP_TOPDOWN_W_MEOWCAM_API ACustomScreenCapture : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACustomScreenCapture();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Create the image in texture
void FillTexture();
// Textures need to be power of 2
// Texture has to be a square
uint32_t internResolution;
UTextureRenderTarget2D* renderTarget;
class USceneCaptureComponent2D* sceneCapture;
class UCameraComponent* ourCamera;
uint32_t tickCount;
std::string baseFilename;
std::string basePathFolder;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere, Category = "Output Information", meta = (ClampMin = "32", ClampMax = "4096", UIMin = "32", UIMax = "4096"))
uint32 resolutionX;
UPROPERTY(EditAnywhere, Category = "Output Information", meta = (ClampMin = "32", ClampMax = "4096", UIMin = "32", UIMax = "4096"))
uint32 resolutionY;
UPROPERTY(EditAnywhere, Category = "Output Information", meta = (ClampMin = "20.0", ClampMax = "179.9", UIMin = "20.0", UIMax = "179.9"))
float field_of_view;
UPROPERTY(EditAnywhere, Category = "Output Information")
FString outputFolderPath;
};