45 lines
1.7 KiB
Markdown
45 lines
1.7 KiB
Markdown
---
|
|
title: Untitled
|
|
date: 2024-11-05 16:57:23
|
|
excerpt:
|
|
tags:
|
|
rating: ⭐
|
|
---
|
|
# 前言
|
|
- StaticMesh:https://zhuanlan.zhihu.com/p/702589732
|
|
- 其他代码
|
|
- [RuntimeStaticMeshImporter](https://github.com/RianeDev/RuntimeStaticMeshImporter)
|
|
- [RuntimeMeshLoader](https://github.com/Chrizey91/RuntimeMeshLoader)
|
|
|
|
## 相关函数
|
|
```text
|
|
bool FSceneImporter::ProcessMeshData(FAssetData& MeshData)
|
|
UStaticMesh::BuildFromMeshDescription
|
|
```
|
|
|
|
```c++
|
|
FDatasmithMeshElementPayload MeshPayload;
|
|
{
|
|
if (!Translator->LoadStaticMesh(MeshElement, MeshPayload))
|
|
{ // If mesh cannot be loaded, add scene's resource path if valid and retry
|
|
bool bSecondTrySucceeded = false;
|
|
|
|
if (FPaths::DirectoryExists(SceneElement->GetResourcePath()) && FPaths::IsRelative(MeshElement->GetFile()))
|
|
{ MeshElement->SetFile( *FPaths::Combine(SceneElement->GetResourcePath(), MeshElement->GetFile()) );
|
|
bSecondTrySucceeded = Translator->LoadStaticMesh(MeshElement, MeshPayload);
|
|
}
|
|
if (!bSecondTrySucceeded)
|
|
{ // #ueent_datasmithruntime: TODO : Update FAssetFactory
|
|
ActionCounter.Add(MeshData.Referencers.Num());
|
|
FAssetRegistry::UnregisteredAssetsData(StaticMesh, SceneKey, [](FAssetData& AssetData) -> void
|
|
{
|
|
AssetData.AddState(EAssetState::Completed);
|
|
AssetData.Object.Reset();
|
|
});
|
|
UE_LOG(LogDatasmithRuntime, Warning, TEXT("CreateStaticMesh: Loading file %s failed. Mesh element %s has not been imported"), MeshElement->GetFile(), MeshElement->GetLabel());
|
|
|
|
return true;
|
|
} }}
|
|
|
|
TArray< FMeshDescription >& MeshDescriptions = MeshPayload.LodMeshes;
|
|
``` |