Animation WIP merge #321

Merged
XiaoQiDigipen merged 76 commits from SP3-17-animation-system into main 2023-01-30 17:35:57 +08:00
3 changed files with 9 additions and 8 deletions
Showing only changes of commit 354d9434f6 - Show all commits

View File

@ -143,7 +143,7 @@ namespace SHADE
{
// Check if there is a channel for this node
const std::string& BONE_NAME = rig->GetName(node);
SHMatrix transformMatrix = SHMatrix::Identity;
SHMatrix transformMatrix = node->TransformMatrix;
if (channelMap.contains(BONE_NAME))
{
const auto CHANNEL = channelMap[BONE_NAME];
@ -154,19 +154,15 @@ namespace SHADE
getInterpolatedValue(CHANNEL->ScaleKeyFrames, closestFrameIndex, poseTime)
);
}
else
{
transformMatrix = SHMatrix::Inverse(node->OffsetMatrix); // TODO: Use TransformMatrix for the bone
}
// Apply parent's transformation
transformMatrix = parentMatrix * transformMatrix;
transformMatrix = transformMatrix * parentMatrix;
// Apply transformations to this node
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
if (BONE_MTX_IDX >= 0)
{
boneMatrices[BONE_MTX_IDX] = rig->GetGlobalInverseMatrix() * transformMatrix * node->OffsetMatrix;
boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix * rig->GetGlobalInverseMatrix();
}
// Apply pose to children

View File

@ -86,7 +86,8 @@ namespace SHADE
// Fill the node with data
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
newNode->OffsetMatrix = SHMatrix::Inverse(NODE_DATA.transform);
newNode->OffsetMatrix = SHMatrix::Transpose(NODE_DATA.offset);
newNode->TransformMatrix = SHMatrix::Transpose(NODE_DATA.transform);
// Populate maps
if (!NODE_DATA.name.empty())

View File

@ -43,6 +43,10 @@ namespace SHADE
/// </summary>
SHMatrix OffsetMatrix;
/// <summary>
/// Matrix that performs a transformation from bone (node) space to local space.
/// </summary>
SHMatrix TransformMatrix;
/// <summary>
/// Child nodes of this node.
/// </summary>
std::vector<Handle<SHRigNode>> Children;