Enhanced functionality of animation clip container creation #432
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -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:
|
||||
|
|
|
@ -26,19 +26,22 @@ 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);
|
||||
for (auto root : asset.roots)
|
||||
{
|
||||
auto rootNode = recurseCreateNode(asset, root, nodeStore);
|
||||
if (rootNode)
|
||||
{
|
||||
rootNodes.emplace_back(rootNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SHRig::SHRig(SHRig&& rhs)
|
||||
: rootNodes { std::move(rhs.rootNodes) }
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace SHADE
|
|||
{
|
||||
SHRigAsset::~SHRigAsset()
|
||||
{
|
||||
if (root != nullptr)
|
||||
delete[] root;
|
||||
if(!roots.empty())
|
||||
delete[] *roots.begin();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue