Added debug draw for animation system
This commit is contained in:
parent
354d9434f6
commit
80a7fe701b
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
Name: BoneIKTest4
|
||||
ID: 81814706
|
||||
Type: 4
|
||||
Sub Assets:
|
||||
Name: Cube
|
||||
ID: 137599708
|
||||
Type: 8
|
Binary file not shown.
|
@ -23,6 +23,7 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Graphics/SHVkUtil.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "Tools/SHDebugDraw.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -113,7 +114,7 @@ namespace SHADE
|
|||
return;
|
||||
|
||||
// Update time on the playback
|
||||
currPlaybackTime += dt;
|
||||
currPlaybackTime += dt * 0.01f;
|
||||
if (currPlaybackTime > currClip->GetTotalTime())
|
||||
{
|
||||
currPlaybackTime = currPlaybackTime - currClip->GetTotalTime();
|
||||
|
@ -139,7 +140,7 @@ namespace SHADE
|
|||
updatePoseWithClip(CLOSEST_FRAME_IDX, poseTime, rig->GetRootNode(), SHMatrix::Identity);
|
||||
}
|
||||
|
||||
void SHAnimatorComponent::updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix)
|
||||
void SHAnimatorComponent::updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix, std::optional<SHVec3> worldPos)
|
||||
{
|
||||
// Check if there is a channel for this node
|
||||
const std::string& BONE_NAME = rig->GetName(node);
|
||||
|
@ -160,15 +161,20 @@ namespace SHADE
|
|||
|
||||
// Apply transformations to this node
|
||||
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
|
||||
std::optional<SHVec3> position;
|
||||
if (BONE_MTX_IDX >= 0)
|
||||
{
|
||||
boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix * rig->GetGlobalInverseMatrix();
|
||||
boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix;
|
||||
position = SHVec3(boneMatrices[BONE_MTX_IDX]._41, boneMatrices[BONE_MTX_IDX]._42, boneMatrices[BONE_MTX_IDX]._43);
|
||||
SHDebugDraw::Cube(position.value(), SHQuaternion{}, SHVec3(0.01f, 0.01f, 0.01f), SHColour::ORANGE);
|
||||
if (worldPos.has_value())
|
||||
SHDebugDraw::Line(position.value(), worldPos.value(), SHColour::ORANGE);
|
||||
}
|
||||
|
||||
// Apply pose to children
|
||||
for (auto& child : node->Children)
|
||||
{
|
||||
updatePoseWithClip(closestFrameIndex, poseTime, child, transformMatrix);
|
||||
updatePoseWithClip(closestFrameIndex, poseTime, child, transformMatrix, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace SHADE
|
|||
/* Helper Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
void updatePoseWithClip(float poseTime);
|
||||
void updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix);
|
||||
void updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix, std::optional<SHVec3> worldPos = {});
|
||||
template<typename T>
|
||||
T getInterpolatedValue(const std::vector<SHAnimationKeyFrame<T>>& keyframes, int closestFrameIndex, float poseTime);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace SHADE
|
|||
rootNode = recurseCreateNode(asset, asset.root);
|
||||
if (rootNode)
|
||||
{
|
||||
globalInverseMatrix = rootNode->OffsetMatrix;
|
||||
globalInverseMatrix = SHMatrix::Inverse(rootNode->TransformMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue