Skip to content
Snippets Groups Projects
Commit 513331d0 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Initial Commit

parents
No related branches found
No related tags found
No related merge requests found
# Visual Studio 2015 user specific files
.vs/
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
# *.lib
# Executables
*.exe
*.out
*.app
*.ipa
# These project files can be generated by the engine
*.xcodeproj
*.xcworkspace
*.sln
*.suo
*.opensdf
*.sdf
*.VC.db
*.VC.opendb
# Precompiled Assets
SourceArt/**/*.png
SourceArt/**/*.tga
# Binary Files
Binaries/*
Plugins/*/Binaries/*
# Builds
Build/*
# Whitelist PakBlacklist-<BuildConfiguration>.txt files
!Build/*/
Build/*/**
!Build/*/PakBlacklist*.txt
# Don't ignore icon files in Build
!Build/**/*.ico
# Built data for maps
*_BuiltData.uasset
# Configuration files generated by the Editor
Saved/*
# Compiled source files for the engine to use
Intermediate/*
Plugins/*/Intermediate/*
# Cache files for the editor to use
DerivedDataCache/*
/Credentials.json
#Include Files installed by makefile
/Source/ThirdParty/Include
/Source/Thirdparty/build
File added
File added
File added
File added
Resources/Icon128.png

19.5 KiB

// Fill out your copyright notice in the Description page of Project Settings.
#include "Camera.h"
#include "SlateMaterialBrush.h"
#include "Components/Image.h"
#include "Components/SceneCaptureComponent2D.h"
#include "Engine/TextureRenderTarget2D.h"
#include "Engine/UserInterfaceSettings.h"
#include "Widgets/Images/SImage.h"
// Sets default values
ACamera::ACamera()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SetRootComponent(CreateDefaultSubobject<USceneComponent>("Root"));
CameraMesh = CreateDefaultSubobject<UStaticMeshComponent>("CameraMesh");
CameraMesh->SetupAttachment(GetRootComponent());
SceneCapture = CreateDefaultSubobject<USceneCaptureComponent2D>("SceneCapture");
SceneCapture->SetupAttachment(GetRootComponent());
SceneCapture->bCaptureOnMovement = false;
SceneCapture->bCaptureEveryFrame = true;
SceneCapture->HiddenActors.Add(this);
static ConstructorHelpers::FObjectFinder<UMaterial> CameraDisplayMaterialFinder(TEXT("Material'/VideoRecordingHelper/CameraDisplayMaterial.CameraDisplayMaterial'"));
CameraDisplayMaterial = CameraDisplayMaterialFinder.Object;
static ConstructorHelpers::FObjectFinder<UMaterial> WindowDisplayMaterialFinder(TEXT("Material'/VideoRecordingHelper/WindowDisplayMaterial.WindowDisplayMaterial'"));
WindowDisplayMaterial = WindowDisplayMaterialFinder.Object;
static ConstructorHelpers::FObjectFinder<UStaticMesh> CameraModel(TEXT("StaticMesh'/VideoRecordingHelper/CameraModel.CameraModel'"));
CameraMesh->SetStaticMesh(CameraModel.Object);
}
// Called when the game starts or when spawned
void ACamera::BeginPlay()
{
Super::BeginPlay();
RenderTarget = NewObject<UTextureRenderTarget2D>(this);
RenderTarget->InitAutoFormat(RenderSize.X,RenderSize.Y);
RenderTarget->ClearColor = FLinearColor::Red;
RenderTarget->UpdateResource();
SceneCapture->TextureTarget = RenderTarget;
CameraDisplayMaterialDynamic = UMaterialInstanceDynamic::Create(CameraDisplayMaterial, this);
WindowDisplayMaterialDynamic = UMaterialInstanceDynamic::Create(WindowDisplayMaterial, this);
CameraDisplayMaterialDynamic->SetTextureParameterValue("Texture", RenderTarget);
WindowDisplayMaterialDynamic->SetTextureParameterValue("Texture", RenderTarget);
WindowBrush = new FSlateMaterialBrush(*WindowDisplayMaterialDynamic, RenderSize);
CameraMesh->SetMaterial(1, CameraDisplayMaterialDynamic);
CreateWindow();
}
void ACamera::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
RenderTarget->ReleaseResource();
if(Window.IsValid()) Window->HideWindow();
}
void ACamera::CreateWindow()
{
// Create Slate Window
Window = SNew(SWindow)
/* set all properties we got passed with the call */
.Title(FText::FromString("Capture Window"))
.ScreenPosition({0,0})
.ClientSize(RenderSize)
.UseOSWindowBorder(false)
.bDragAnywhere(true)
.CreateTitleBar(true)
/* set a few more interesting ones, just to show they exist */
.AutoCenter(EAutoCenter::None)
.SaneWindowPlacement(true)
.SizingRule(ESizingRule::UserSized)
.Type(EWindowType::GameWindow)
.InitialOpacity(1.0f)
.HasCloseButton(true)
.MaxHeight(9999)
.MaxWidth(9999)
.SupportsTransparency(EWindowTransparency::PerWindow)
.LayoutBorder(FMargin {2, 2})
.AdjustInitialSizeAndPositionForDPIScale(false)
;
// Add our new window to the Slate subsystem (which essentially opens it)
FSlateApplication::Get().AddWindow(Window.ToSharedRef());
// Make sure our new window doesn't hide behind some others
Window.Get()->BringToFront(true);
Image = SNew(SImage);
Image->SetImage(WindowBrush);
Window->SetContent(Image.ToSharedRef());
}
// Copyright Epic Games, Inc. All Rights Reserved.
#include "VideoRecordingHelper.h"
#define LOCTEXT_NAMESPACE "FVideoRecordingHelperModule"
void FVideoRecordingHelperModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FVideoRecordingHelperModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FVideoRecordingHelperModule, VideoRecordingHelper)
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "SlateMaterialBrush.h"
#include "GameFramework/Actor.h"
#include "Camera.generated.h"
UCLASS()
class VIDEORECORDINGHELPER_API ACamera : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACamera();
UPROPERTY(EditAnywhere) FVector2D RenderSize = {1920,1080};
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UStaticMeshComponent* CameraMesh;
USceneCaptureComponent2D* SceneCapture;
UTextureRenderTarget2D* RenderTarget;
UMaterial* CameraDisplayMaterial;
UMaterialInstanceDynamic* CameraDisplayMaterialDynamic;
UMaterial* WindowDisplayMaterial;
UMaterialInstanceDynamic* WindowDisplayMaterialDynamic;
FSlateMaterialBrush* WindowBrush;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
void CreateWindow();
TSharedPtr<SWindow> Window = nullptr;
TSharedPtr<SImage> Image = nullptr;
};
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FVideoRecordingHelperModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class VideoRecordingHelper : ModuleRules
{
public VideoRecordingHelper(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"UMG"
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "VideoRecordingHelper",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "VideoRecordingHelper",
"Type": "Runtime",
"LoadingPhase": "Default"
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment