Add **skeleton retargeting** to play animations on different skeletons

This commit is contained in:
Wojtek Figat
2023-05-04 11:54:17 +02:00
parent b89d32ce2b
commit 05ffaf7cef
15 changed files with 775 additions and 104 deletions

View File

@@ -782,6 +782,9 @@ bool ModelData::Pack2SkinnedModelHeader(WriteStream* stream) const
return true;
}
// Version
stream->WriteByte(1);
// Min Screen Size
stream->WriteFloat(MinScreenSize);
@@ -792,7 +795,6 @@ bool ModelData::Pack2SkinnedModelHeader(WriteStream* stream) const
for (int32 materialSlotIndex = 0; materialSlotIndex < Materials.Count(); materialSlotIndex++)
{
auto& slot = Materials[materialSlotIndex];
stream->Write(slot.AssetID);
stream->WriteByte(static_cast<byte>(slot.ShadowsMode));
stream->WriteString(slot.Name, 11);
@@ -878,6 +880,11 @@ bool ModelData::Pack2SkinnedModelHeader(WriteStream* stream) const
}
}
// Retargeting
{
stream->WriteInt32(0);
}
return false;
}

View File

@@ -112,7 +112,7 @@ public:
Bones.Swap(other.Bones);
}
int32 FindNode(const StringView& name)
int32 FindNode(const StringView& name) const
{
for (int32 i = 0; i < Nodes.Count(); i++)
{
@@ -122,7 +122,7 @@ public:
return -1;
}
int32 FindBone(int32 nodeIndex)
int32 FindBone(int32 nodeIndex) const
{
for (int32 i = 0; i < Bones.Count(); i++)
{

View File

@@ -331,6 +331,7 @@ bool SkinnedMesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, i
MemoryReadStream stream(chunk->Get(), chunk->Size());
// Seek to find mesh location
byte version = stream.ReadByte();
for (int32 i = 0; i <= _index; i++)
{
// #MODEL_DATA_FORMAT_USAGE

View File

@@ -15,6 +15,7 @@ bool SkinnedModelLOD::HasAnyMeshInitialized() const
bool SkinnedModelLOD::Load(MemoryReadStream& stream)
{
// Load LOD for each mesh
byte version = stream.ReadByte();
for (int32 i = 0; i < Meshes.Count(); i++)
{
auto& mesh = Meshes[i];