Datasmith Asset Mesh Writer

Datasmith Asset

FBufferArchive

Archive for storing arbitrary data to the specified memory location.

1

UdsMesh

Datasmith Mesh资源文件的写入。
2

/**
 * @param MeshName		The path and name of the udsmesh file to save
 * @param RawMesh	    The FRawMesh object to save
 */
void FUdsAsset::SaveToUdsMeshFile(FString & MeshName, FRawMesh & RawMesh)
{
	uint32 Zero4Bytes =0;//Placeholder
	uint32 One4Bytes = 1;//Placeholder
	uint32 FileSize = 0;

	FBufferArchive RawMeshArchive;
	RawMeshArchive << One4Bytes;
	int64 FileSizePos = RawMeshArchive.Tell();
	RawMeshArchive << One4Bytes;

	int64 FileStartPos = RawMeshArchive.Tell();
	RawMeshArchive << MeshName;

	uint8 Zero1Bytes = 0; //Placeholder
	RawMeshArchive << Zero1Bytes;
	RawMeshArchive << One4Bytes;

	RawMeshArchive << Source_Models;
	RawMeshArchive << Struct_Property;

	RawMeshArchive << Zero4Bytes<<Zero4Bytes;
	RawMeshArchive << Datasmith_Mesh_Source_Model;

	RawMeshArchive << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero1Bytes;

	int64 MeshSizePos = RawMeshArchive.Tell();
	RawMeshArchive << One4Bytes << One4Bytes;

	uint32 Placeholder125 = 125;//Placeholder
	RawMeshArchive << Placeholder125 << Zero4Bytes;

	int64 MeshStartPos = RawMeshArchive.Tell();
	RawMeshArchive << RawMesh;
	int64 MeshEndPos = RawMeshArchive.Tell();
	RawMeshArchive << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero4Bytes << Zero4Bytes;
	int64 FileEndPos = RawMeshArchive.Tell();

	uint32 MeshSize = MeshEndPos - MeshStartPos;
	RawMeshArchive.Seek(MeshSizePos);
	RawMeshArchive << MeshSize;
	RawMeshArchive << MeshSize;

	FileSize = FileEndPos - FileSizePos;
	RawMeshArchive.Seek(0);
	RawMeshArchive << One4Bytes<<FileSize;
	RawMeshArchive.Seek(FileEndPos);

	int64 TotalSize = FileSize + 8;
	TArray<uint8>RawBinaryData;
	RawBinaryData.SetNum(TotalSize);
	FMemory::Memcpy(RawBinaryData.GetData(), RawMeshArchive.GetData(),TotalSize);

	FString UdsMeshFileName = FString::Printf(TEXT("%s.udsmesh"), *MeshName);
	FFileHelper::SaveArrayToFile(RawBinaryData, *(UdsAssetPath+ UdsMeshFileName));
}

Texture

/**
 * @param TexName		The path and name of the png file to save
 * @param RawData	    The TArray Data to save
 */
 
 void FUdsAsset::SaveToPngFile(const FString & TexName, const TArray<uint8>& RawData)
{
	FString FileName = FString::Printf(TEXT("%s.png"), *TexName);
	FFileHelper::SaveArrayToFile(RawData, *(UdsAssetPath + FileName));
}

参考

  1. UE4 Datasmith UdsMesh 格式解析
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值