Completed rig node data and rig structure write
This commit is contained in:
parent
fc072a8967
commit
acbf67f2a8
|
@ -301,6 +301,7 @@ namespace SH_COMP
|
|||
//node.weights
|
||||
);
|
||||
}
|
||||
|
||||
for (auto const& skin : data.skins)
|
||||
{
|
||||
std::vector<SHMat4> inverseBindMatrices;
|
||||
|
@ -314,5 +315,6 @@ namespace SH_COMP
|
|||
nodes[joint].inverseBindMatrix = *(matrix++);
|
||||
}
|
||||
}
|
||||
asset.rig.header.startNode = data.skins[0].joints[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ namespace SH_COMP
|
|||
{
|
||||
WriteRigHeader(file, data.header);
|
||||
WriteRigNodeData(file, data);
|
||||
WriteRigStructure(file, data);
|
||||
}
|
||||
|
||||
void MeshWriter::WriteRigHeader(FileReference file, RigDataHeader const& header)
|
||||
|
@ -174,26 +175,63 @@ namespace SH_COMP
|
|||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(node.rotation.data()),
|
||||
sizeof(double) * NODE_COMPONENT_COUNT_ROTATION
|
||||
sizeof(double) * node.rotation.size()
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(node.scale.data()),
|
||||
sizeof(double) * NODE_COMPONENT_COUNT_SCALE
|
||||
sizeof(double) * node.scale.size()
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(node.translation.data()),
|
||||
sizeof(double) * NODE_COMPONENT_COUNT_TRANSLATION
|
||||
sizeof(double) * node.translation.size()
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(node.matrix.data()),
|
||||
sizeof(double) * NODE_COMPONENT_COUNT_MATRIX
|
||||
sizeof(double) * node.matrix.size()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshWriter::WriteRigStructure(FileReference file, RigData const& rig)
|
||||
{
|
||||
std::queue<std::pair<IndexType, NodeAsset const*>> nodeQueue;
|
||||
nodeQueue.push(
|
||||
std::make_pair(
|
||||
rig.header.startNode,
|
||||
rig.nodes.data() + rig.header.startNode
|
||||
)
|
||||
);
|
||||
|
||||
while (!nodeQueue.empty())
|
||||
{
|
||||
auto const currentPair = nodeQueue.front();
|
||||
auto const& node = *currentPair.second;
|
||||
nodeQueue.pop();
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(¤tPair.first),
|
||||
sizeof(IndexType)
|
||||
);
|
||||
|
||||
auto const childCount{ static_cast<uint32_t>(node.children.size()) };
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(&childCount),
|
||||
sizeof(uint32_t)
|
||||
);
|
||||
|
||||
for (auto const& child : node.children)
|
||||
{
|
||||
nodeQueue.push(std::make_pair(
|
||||
child,
|
||||
rig.nodes.data() + child
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeshWriter::WriteHeaders(FileReference file, ModelConstRef asset)
|
||||
{
|
||||
file.write(
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace SH_COMP
|
|||
static void WriteRig(FileReference file, RigData const& data);
|
||||
static void WriteRigHeader(FileReference file, RigDataHeader const& header);
|
||||
static void WriteRigNodeData(FileReference file, RigData const& rig);
|
||||
static void WriteRigStructure(FileReference file, RigData const& rig);
|
||||
|
||||
static void WriteHeaders(FileReference file, ModelConstRef asset);
|
||||
static void WriteData(FileReference file, ModelConstRef asset);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <array>
|
||||
|
||||
#include "PseudoMath.h"
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@ namespace SH_COMP
|
|||
{
|
||||
using NodeDataFlag = unsigned char;
|
||||
|
||||
constexpr NodeDataFlag NODE_DATA_ROTATION = 0b00001;
|
||||
constexpr NodeDataFlag NODE_DATA_SCALE = 0b00010;
|
||||
constexpr NodeDataFlag NODE_DATA_TRANSLATION = 0b00100;
|
||||
constexpr NodeDataFlag NODE_DATA_MATRIX = 0b01000;
|
||||
constexpr NodeDataFlag NODE_DATA_ROTATION = 0b0001;
|
||||
constexpr NodeDataFlag NODE_DATA_SCALE = 0b0010;
|
||||
constexpr NodeDataFlag NODE_DATA_TRANSLATION = 0b0100;
|
||||
constexpr NodeDataFlag NODE_DATA_MATRIX = 0b1000;
|
||||
//constexpr NodeDataFlag NODE_DATA_WEIGHTS = 0b10000;
|
||||
|
||||
constexpr size_t NODE_COMPONENT_COUNT_ROTATION{ 4 };
|
||||
constexpr size_t NODE_COMPONENT_COUNT_SCALE{ 3 };
|
||||
constexpr size_t NODE_COMPONENT_COUNT_TRANSLATION{ 3 };
|
||||
constexpr size_t NODE_COMPONENT_COUNT_MATRIX{ 16 };
|
||||
|
||||
struct RigDataHeader
|
||||
{
|
||||
uint32_t nodeCount;
|
||||
IndexType startNode;
|
||||
std::vector<uint32_t> charCounts;
|
||||
std::vector<uint32_t> childCount;
|
||||
std::vector<NodeDataFlag> dataFlags;
|
||||
|
|
Loading…
Reference in New Issue