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:
|
Transform Component:
|
||||||
Translate: {x: 0.332949668, y: 0, z: 0}
|
Translate: {x: 0.332949668, y: 0, z: 0}
|
||||||
Rotate: {x: -0, 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
|
IsActive: true
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 141097368
|
Mesh: 148542784
|
||||||
Material: 128805346
|
Material: 128805346
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Animator Component:
|
Animator Component:
|
||||||
Rig: 72178939
|
Rig: 76586906
|
||||||
AnimationController: 0
|
AnimationController: 0
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
|
|
|
@ -26,17 +26,20 @@ namespace SHADE
|
||||||
SHRig::SHRig(const SHRigAsset& asset, SHResourceLibrary<SHRigNode>& nodeStore)
|
SHRig::SHRig(const SHRigAsset& asset, SHResourceLibrary<SHRigNode>& nodeStore)
|
||||||
{
|
{
|
||||||
// Don't bother if empty
|
// 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.");
|
SHLOG_ERROR("[SHRig] Attempted to load an invalid rig with no root.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do a recursive depth first traversal to populate the rig
|
// Do a recursive depth first traversal to populate the rig
|
||||||
auto rootNode = recurseCreateNode(asset, asset.root, nodeStore);
|
for (auto root : asset.roots)
|
||||||
if (rootNode)
|
|
||||||
{
|
{
|
||||||
rootNodes.emplace_back(rootNode);
|
auto rootNode = recurseCreateNode(asset, root, nodeStore);
|
||||||
|
if (rootNode)
|
||||||
|
{
|
||||||
|
rootNodes.emplace_back(rootNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHRigAsset::~SHRigAsset()
|
SHRigAsset::~SHRigAsset()
|
||||||
{
|
{
|
||||||
if (root != nullptr)
|
if(!roots.empty())
|
||||||
delete[] root;
|
delete[] *roots.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,14 +102,12 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
ReadRigHeader(file, asset.rig.header);
|
ReadRigHeader(file, asset.rig.header);
|
||||||
ReadRigData(file, asset.rig.header, asset.rig.nodeDataCollection);
|
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)
|
for (auto& mesh : asset.meshes)
|
||||||
{
|
{
|
||||||
mesh->BoneCount = asset.rig.nodeDataCollection.size();
|
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)
|
void SHModelLoader::ReadRigHeader(FileReference file, SHRigDataHeader& header)
|
||||||
{
|
{
|
||||||
file.read(
|
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
|
// Read All nodes into one contiguous data block
|
||||||
struct NodeTemp
|
struct NodeTemp
|
||||||
|
@ -271,7 +249,7 @@ namespace SHADE
|
||||||
|
|
||||||
// Build and populate tree
|
// Build and populate tree
|
||||||
SHRigNodeAsset* nodePool = new SHRigNodeAsset[header.nodeCount];
|
SHRigNodeAsset* nodePool = new SHRigNodeAsset[header.nodeCount];
|
||||||
root = nodePool;
|
roots.push_back(nodePool);
|
||||||
|
|
||||||
std::queue<std::pair<SHRigNodeAsset*, NodeTemp*>> nodeQueue;
|
std::queue<std::pair<SHRigNodeAsset*, NodeTemp*>> nodeQueue;
|
||||||
nodeQueue.emplace(std::make_pair(nodePool, dst));
|
nodeQueue.emplace(std::make_pair(nodePool, dst));
|
||||||
|
@ -292,9 +270,14 @@ namespace SHADE
|
||||||
|
|
||||||
nodeCount++;
|
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)
|
for (auto i{0}; i < currTemp->numChild; ++i)
|
||||||
|
@ -303,6 +286,8 @@ namespace SHADE
|
||||||
nodeQueue.emplace(depthPtr++, depthTempPtr++);
|
nodeQueue.emplace(depthPtr++, depthTempPtr++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "hi";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHModelLoader::ReadMeshData(FileReference file, std::vector<SHMeshDataHeader> const& headers,
|
void SHModelLoader::ReadMeshData(FileReference file, std::vector<SHMeshDataHeader> const& headers,
|
||||||
|
|
|
@ -23,14 +23,12 @@ namespace SHADE
|
||||||
|
|
||||||
void ReadRigHeader(FileReference file, SHRigDataHeader& header);
|
void ReadRigHeader(FileReference file, SHRigDataHeader& header);
|
||||||
void ReadRigData(FileReference file, SHRigDataHeader const& header, std::vector<SHRigNodeData>& data);
|
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 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 ReadAnimData(FileReference file, std::vector<SHAnimDataHeader> const& headers, std::vector<SHAnimAsset*>& anims);
|
||||||
void ReadAnimNode(FileReference file, uint32_t frameCount, SHAnimNode& data);
|
void ReadAnimNode(FileReference file, uint32_t frameCount, SHAnimNode& data);
|
||||||
|
|
||||||
void BuildTransformMatrices(SHRigAsset& rig);
|
|
||||||
|
|
||||||
void ReadHeaders(FileReference file, SHModelAsset& asset);
|
void ReadHeaders(FileReference file, SHModelAsset& asset);
|
||||||
void ReadData(FileReference file, SHModelAsset& asset);
|
void ReadData(FileReference file, SHModelAsset& asset);
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue