1#include "JointComponent.h"
2#include "../TransformComponent.h"
3#include "../../Object/SResource.h"
7COMPONENT_CONSTRUCTOR(
JointComponent), m_id(-1), m_animatedMatrix(mat4::Identity()), m_inverseTransformMatrix(mat4::Identity()) {
12 m_animatedMatrix = src.m_animatedMatrix;
14 m_inverseTransformMatrix = src.m_inverseTransformMatrix;
17JointComponent::~JointComponent() =
default;
19void JointComponent::Exterminate() {
23void JointComponent::Init() {
27void JointComponent::Tick(
float elapsedTime) {
32void JointComponent::SetAnimationMatrix(
mat4&& animation) {
33 m_animatedMatrix = animation;
36void JointComponent::calcInverseBindTransform(
const mat4& parentTransform) {
37 mat4 bindTransform = m_localBindMatrix * parentTransform;
38 m_inverseTransformMatrix = mat4::Invert(bindTransform);
40 auto children = gameObject->GetChildren();
41 for (
const auto& child : children) {
44 if(child_comp ==
nullptr)
continue;
46 child_comp->calcInverseBindTransform(bindTransform);
53 clone->m_inverseTransformMatrix =
mat4(m_inverseTransformMatrix);
54 clone->m_animatedMatrix =
mat4(m_animatedMatrix);
55 clone->m_localBindMatrix =
mat4(m_localBindMatrix);
57 clone->m_animationJointId = m_animationJointId;
62void JointComponent::SetBindLocalMatrix(
const mat4& mat) {
63 m_localBindMatrix = mat;
66void JointComponent::SetValue(std::string name_str, VariableBinder::Arguments value) {
67 if(name_str ==
"m_inverseTransformMatrix") {
68 SET_MAT4(m_inverseTransformMatrix)
70 else if(name_str ==
"m_animatedMatrix") {
71 SET_MAT4(m_animatedMatrix)
73 else if(name_str ==
"m_localBindMatrix") {
74 SET_MAT4(m_localBindMatrix)
78std::string JointComponent::PrintValue()
const {
79 PRINT_START(
"component");
81 PRINT_VALUE_MAT4(m_inverseTransformMatrix);
82 PRINT_VALUE_MAT4(m_animatedMatrix);
83 PRINT_VALUE_MAT4(m_localBindMatrix);
85 PRINT_END(
"component");