1 Star 0 Fork 0

刘俊良/UE4 RenderTargetTexture

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SCTLocationCapturer.cpp 2.56 KB
一键复制 编辑 原始数据 按行查看 历史
刘俊良 提交于 2018-08-02 11:10 . RenderTargetTexture
#include "SCTLocationCapturer.h"
#include "Engine/SceneCapture2D.h"
#include "Engine/TextureRenderTarget2D.h"
#include "Components/SceneCaptureComponent2D.h"
#include "Engine/Engine.h"
#include "GameFramework/PlayerInput.h"
#include "Kismet/GameplayStatics.h"
#include "Camera/CameraComponent.h"
#include "TypedPrimitive.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "Components/DrawFrustumComponent.h"
#include "GameFramework/SpringArmComponent.h"
#define NUM_SIDES 24
ASCTLocationCapturer* ASCTLocationCapturer::_Instance = nullptr;
ASCTLocationCapturer* ASCTLocationCapturer::GetCapturer2DInstance()
{
if (ASCTLocationCapturer::_Instance == nullptr)
{
//创建小地图摄像机并拖放到场景里
ASCTLocationCapturer::_Instance = GWorld->SpawnActor<ASCTLocationCapturer>(ASCTLocationCapturer::StaticClass());
}
return ASCTLocationCapturer::_Instance;
}
ASCTLocationCapturer::ASCTLocationCapturer()
{
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComponent"));
/*创建弹簧手臂和摄像机*/
CameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
CameraSpringArm->SetupAttachment(RootComponent);
CameraSpringArm->TargetArmLength = 500.f;
CameraSpringArm->bEnableCameraLag = false;
CameraSpringArm->bUsePawnControlRotation = true;
CameraSpringArm->bDoCollisionTest = false;
CameraSpringArm->CameraLagSpeed = 3.0f;
GetCaptureComponent2D()->SetupAttachment(CameraSpringArm);
GetCaptureComponent2D()->bCaptureEveryFrame = true;
GetCaptureComponent2D()->CaptureSource = ESceneCaptureSource::SCS_SceneColorSceneDepth;
GetCaptureComponent2D()->ProjectionType = ECameraProjectionMode::Perspective;
GetCaptureComponent2D()->OrthoWidth = 150.0f;
GetCaptureComponent2D()->CompositeMode = ESceneCaptureCompositeMode::SCCM_Overwrite;
GetCaptureComponent2D()->PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList;
}
UTextureRenderTarget2D* ASCTLocationCapturer::GetMiniMapTexture()
{
//实例化渲染贴图
MiniMapTexture = NewObject<UTextureRenderTarget2D>();
MiniMapTexture->InitAutoFormat(128.0f, 128.0f);
MiniMapTexture->ClearColor = FLinearColor(1.0f, 0, 0, 1.0f);
//将相机的渲染目标到纹理上
GetCaptureComponent2D()->TextureTarget = MiniMapTexture;
return MiniMapTexture;
}
void ASCTLocationCapturer::UpdateCapture2DTransform(FVector ArroundLocation, FRotator NormRotator)
{
CameraSpringArm->SetWorldLocation(ArroundLocation);
CameraSpringArm->SetWorldRotation(NormRotator);
}
void ASCTLocationCapturer::ShowActor(AActor* AxisActor)
{
//创建显示的场景
GetCaptureComponent2D()->ShowOnlyActorComponents(AxisActor);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JiBu/UE4-RenderTargetTexture.git
git@gitee.com:JiBu/UE4-RenderTargetTexture.git
JiBu
UE4-RenderTargetTexture
UE4 RenderTargetTexture
master

搜索帮助