Enhanced functionality of animation clip container creation #432

Merged
XiaoQiDigipen merged 6 commits from SP3-13-Assets-Manager into main 2023-03-21 14:31:16 +08:00
7 changed files with 982 additions and 1757 deletions
Showing only changes of commit 9fdfe17e9d - Show all commits

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -64,14 +64,14 @@
Transform Component:
Translate: {x: 0.332949668, y: 0, z: 0}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.0710000023, y: 0.0710000023, z: 0.0710000023}
Scale: {x: 0.173914507, y: 0.173914507, z: 0.173914507}
IsActive: true
Renderable Component:
Mesh: 141097368
Mesh: 148542784
Material: 128805346
IsActive: true
Animator Component:
Rig: 72178939
Rig: 76586906
AnimationController: 0
IsActive: true
Scripts:

View File

@ -26,17 +26,20 @@ namespace SHADE
SHRig::SHRig(const SHRigAsset& asset, SHResourceLibrary<SHRigNode>& nodeStore)
{
// Don't bother if empty
if (asset.root == nullptr)
if (asset.roots.empty() || *asset.roots.begin() == nullptr)
{
SHLOG_ERROR("[SHRig] Attempted to load an invalid rig with no root.");
return;
}
// Do a recursive depth first traversal to populate the rig
auto rootNode = recurseCreateNode(asset, asset.root, nodeStore);
if (rootNode)
for (auto root : asset.roots)
{
rootNodes.emplace_back(rootNode);
auto rootNode = recurseCreateNode(asset, root, nodeStore);
if (rootNode)
{
rootNodes.emplace_back(rootNode);
}
}
}

View File

@ -5,7 +5,7 @@ namespace SHADE
{
SHRigAsset::~SHRigAsset()
{
if (root != nullptr)
delete[] root;
if(!roots.empty())
delete[] *roots.begin();
}
}

View File

@ -102,14 +102,12 @@ namespace SHADE
{
ReadRigHeader(file, asset.rig.header);
ReadRigData(file, asset.rig.header, asset.rig.nodeDataCollection);
ReadRigTree(file, asset.rig.header, asset.rig.root);
ReadRigTree(file, asset.rig.header, asset.rig.roots);
for (auto& mesh : asset.meshes)
{
mesh->BoneCount = asset.rig.nodeDataCollection.size();
}
//BuildTransformMatrices(asset.rig);
}
}
@ -140,26 +138,6 @@ namespace SHADE
);
}
void SHModelLoader::BuildTransformMatrices(SHRigAsset& rig)
{
std::queue<SHRigNodeAsset const*> nodeQueue;
nodeQueue.push(rig.root);
while(!nodeQueue.empty())
{
auto& current = nodeQueue.front();
nodeQueue.pop();
auto& parentData {rig.nodeDataCollection[current->idRef]};
for (auto const& child: current->children)
{
nodeQueue.push(child);
auto& childData {rig.nodeDataCollection[child->idRef]};
childData.transform = childData.transform * parentData.transform;
}
}
}
void SHModelLoader::ReadRigHeader(FileReference file, SHRigDataHeader& header)
{
file.read(
@ -254,7 +232,7 @@ namespace SHADE
}
}
void SHModelLoader::ReadRigTree(FileReference file, SHRigDataHeader const& header, SHRigNodeAsset*& root)
void SHModelLoader::ReadRigTree(FileReference file, SHRigDataHeader const& header, std::vector<SHRigNodeAsset*>& roots)
{
// Read All nodes into one contiguous data block
struct NodeTemp
@ -271,7 +249,7 @@ namespace SHADE
// Build and populate tree
SHRigNodeAsset* nodePool = new SHRigNodeAsset[header.nodeCount];
root = nodePool;
roots.push_back(nodePool);
std::queue<std::pair<SHRigNodeAsset*, NodeTemp*>> nodeQueue;
nodeQueue.emplace(std::make_pair(nodePool, dst));
@ -292,9 +270,14 @@ namespace SHADE
nodeCount++;
if (currTemp->numChild == 0 && nodeCount < header.nodeCount)
if (
nodeQueue.empty() &&
currTemp->numChild == 0 &&
nodeCount < header.nodeCount
)
{
roots.push_back(depthPtr);
nodeQueue.emplace(depthPtr++, depthTempPtr++);
}
for (auto i{0}; i < currTemp->numChild; ++i)
@ -303,6 +286,8 @@ namespace SHADE
nodeQueue.emplace(depthPtr++, depthTempPtr++);
}
}
std::cout << "hi";
}
void SHModelLoader::ReadMeshData(FileReference file, std::vector<SHMeshDataHeader> const& headers,

View File

@ -23,14 +23,12 @@ namespace SHADE
void ReadRigHeader(FileReference file, SHRigDataHeader& header);
void ReadRigData(FileReference file, SHRigDataHeader const& header, std::vector<SHRigNodeData>& data);
void ReadRigTree(FileReference file, SHRigDataHeader const& header, SHRigNodeAsset*& root);
void ReadRigTree(FileReference file, SHRigDataHeader const& header, std::vector<SHRigNodeAsset*>& roots);
void ReadMeshData(FileReference file, std::vector<SHMeshDataHeader> const& headers, std::vector<SHMeshAsset*>& meshes);
void ReadAnimData(FileReference file, std::vector<SHAnimDataHeader> const& headers, std::vector<SHAnimAsset*>& anims);
void ReadAnimNode(FileReference file, uint32_t frameCount, SHAnimNode& data);
void BuildTransformMatrices(SHRigAsset& rig);
void ReadHeaders(FileReference file, SHModelAsset& asset);
void ReadData(FileReference file, SHModelAsset& asset);
public: