UE4中显示Flash

48 篇文章 1 订阅

 

一、目的

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、运行结果

 

1、扩展:先绘制体感抠图,在绘制flash,这样就有了层级关系

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值