UE5基于RumtimeFBXImport插件使用C++加载服务器上fbx文件方法
创始人
2025-01-20 09:05:27
0

        UE5的RumtimeFBXImport插件其实只能加载本机的fbx文件,要加载服务器上的fbx文件的话,需要先将该fbx文件下载到本地,然后再使用RumtimeFBXImport插件加载。

        示例文件如下:

#include "Loader/WebLoader.h" #include "Misc/FileHelper.h" #include "Misc/Paths.h" #include "HttpModule.h" #include "Http.h" #include "FBXImportManager.h"  AWebLoader::AWebLoader(){}  void AWebLoader::BeginPlay() { 	Super::BeginPlay();  	if (WebFbxPath.Len() > 0) 	{ 		LoadFileFromServer(WebFbxPath); 	} }  void AWebLoader::LoadFileFromServer(const FString& URL) { 	TSharedRef HttpRequest = FHttpModule::Get().CreateRequest(); 	HttpRequest->SetURL(URL); 	HttpRequest->SetVerb("GET"); 	HttpRequest->OnProcessRequestComplete().BindUObject(this, &AWebLoader::OnFileDownloadComplete); 	HttpRequest->ProcessRequest(); }  void AWebLoader::OnFileDownloadComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { 	if (bWasSuccessful && Response.IsValid() && Response->GetResponseCode() == EHttpResponseCodes::Ok) 	{ 		FString ProjectRoot = FPaths::Combine(FPaths::ProjectDir(), LocalRelatedPath); 		FString FileName = FPaths::GetCleanFilename(WebFbxPath); 		FString LocalFullPath = FPaths::Combine(ProjectRoot, FileName);  		if (!FFileHelper::SaveArrayToFile(Response->GetContent(), *LocalFullPath)) 		{ 			UE_LOG(LogTemp, Error, TEXT("File downloaded failed!")); 			return; 		} 		// 		LoadLocalFBX(LocalFullPath); 	} 	else 	{ 		UE_LOG(LogTemp, Error, TEXT("File download failed.")); 	} }  void AWebLoader::LoadLocalFBX(FString LocalFullPath) { 	if (!FBXImportManager) 	{ 		FBXImportManager = GetWorld()->SpawnActor(); 	}  	FBXImportManager->InitializeFBXLoad(); 	FBXImportManager->ImportFBXFile(LocalFullPath, FVector::UpVector, BaseMaterial, EFBXCollisionType::MeshCollision); }

相关内容

热门资讯

第三方技巧!hhpoker软件... 您好,hhpoker可以控制吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
最终!德普之星透视软件免费入口... 最终!德普之星透视软件免费入口官网,aapoker透视脚本,切实存在有挂(今日头条)1、下载好德普之...
日前!模拟器打开hhpoker... 日前!模拟器打开hhpoker,德普辅助软件,总是确实有挂(有挂解惑)1、进入到模拟器打开hhpok...
2026版总结!werplan... 2026版总结!werplan免费挂下载,德州圈脚本,好像真的有挂(有挂技巧)一、werplan免费...
反观!wpk真吗,hhpoke... 反观!wpk真吗,hhpoker破解工具,都是真的有挂(证实有挂)运hhpoker破解工具辅助工具,...
在玩家背景下!hhpoker透... 在玩家背景下!hhpoker透视脚本下载,hhpoker辅助挂,一直确实有挂(有挂详情)1、让任何用...
黑科技辅助挂!fishpoke... 黑科技辅助挂!fishpoker透视底牌,hhpoker有没有作弊挂,一直真的是有挂(真的有挂)1、...
今天上午!aapoker怎么选... 今天上午!aapoker怎么选牌,wepoker私人辅助器,都是是真的有挂(有挂实锤)1、不需要AI...
据目击者称!wpk德州局透视,... 据目击者称!wpk德州局透视,wpk是真的还是假的,真是存在有挂(有挂规律)1、玩家可以在wpk是真...
第三方技巧!xpoker辅助工... 第三方技巧!xpoker辅助工具,wpk俱乐部怎么作弊,一直是有挂(有挂透明挂)1、上手简单,内置详...