一、目的
1、想:在UE4中打开Falsh
二、参考
1、用Kinect2人物画面抠图显示在UE4中
https://blog.csdn.net/qq_40544338/article/details/105487067
- 总结:自己写的,也是参考的内容
1、GuShi的三防知识介绍
三、操作
1、运行结果
直接显示flash
1、工程是在:用Kinect2人物画面抠图显示在UE4中:后面编写的,自己也可以新建工程进行编写
https://blog.csdn.net/qq_40544338/article/details/105487067
1、版本
UE4 :4.21
FLASH :Adobe Flash Professional CS6
1、文件夹设置
1、RSXB.h :导入头文件
#include "../../ThirdParty/Fast/include/Fast_Flash.h"
1、RSXB.Build.cs :编写flash静态库位置
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.IO;
public class RSXB : ModuleRules
{
private string ModulePath
{
get { return ModuleDirectory; }
}
public RSXB(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
PublicIncludePaths.Add(Path.Combine(ModulePath, "../../ThirdParty/Fast/include"));
PublicAdditionalLibraries.Add(Path.Combine(ModulePath, "../../ThirdParty/Fast/lib/Fast_Config.lib"));
PublicAdditionalLibraries.Add(Path.Combine(ModulePath, "../../ThirdParty/Fast/lib/Fast_Flash.lib"));
PublicAdditionalLibraries.Add(Path.Combine(ModulePath, "../../ThirdParty/Fast/lib/FastFaceDetect.lib"));
//TKinect2.0
PublicIncludePaths.Add(Path.Combine(ModulePath, "../../ThirdParty/Kinect2"));
PublicAdditionalLibraries.Add(Path.Combine(ModulePath, "../../ThirdParty/Kinect2/K2.lib"));
}
}
1、MyHUD.h
UTexture2D* MyTex;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "XZY")
UTexture2D* MyTex;
1、MyHUD.cpp
AMyHUD
MyTex = nullptr;
BeginPlay
if (MyTex == nullptr)
{
MyTex = UTexture2D::CreateTransient(1920, 1080, PF_B8G8R8A8);
}
全局变量+flash回调函数
//Flash
void* pFlash = nullptr;
char fPath[255] = { 0 };
void __stdcall CallBackFun(void* pExample, const char* command, const char* args)
{
AMyHUD* pClass = (AMyHUD*)pExample;
if (pClass != nullptr)
{
if (strcmp(command, "cmd") == 0)
{
if (strcmp(args, "game_select") == 0)
{
}
}
}
}
BeginPlay
//运行Flash
if (pFlash == nullptr)
{
sprintf(fPath, "F:\\Project\\yinTang\\renShiXiBao\\Scripts\\Flash\\RSXB100\\RSXB.swf");
pFlash = FastFlashOpen(fPath, nullptr, 1);
if (pFlash != nullptr)
{
FastFlashRegeditFSCommand(pFlash, CallBackFun, this);
FastFlashStop(pFlash);
}
else
{
//FastOutputLog("log", 6, "FastFlashOpen failed!");
}
}
EndPlay
if (pFlash != nullptr)
{
FastFlashClose(pFlash);
pFlash = nullptr;
}
DrawHUD
void AMyHUD::DrawHUD()
{
if (pFlash != nullptr)
{
void* pData = FastFlashRenderTo(pFlash);
if (pData != nullptr && MyTex != nullptr)
{
FTexture2DMipMap& Mip = MyTex->PlatformData->Mips[0];
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
if (Data != nullptr)
{
FMemory::Memcpy(Data, pData, 1080 * 1920 * 4);
Mip.BulkData.Unlock();
MyTex->UpdateResource();
}
}
}
Super::DrawHUD();
}
1、蓝图:BP_myHUD:创建基于C++MyHUD的蓝图类
1、运行结果