1#include "../Util/GLProgramHandle.h"
2#include "DrawableSkinnedMeshComponent.h"
5#define MeshComponent DrawableSkinnedMeshComponent
10 m_classType =
"DrawableSkinnedMeshComponent";
13MeshComponent::~MeshComponent() =
default;
15void MeshComponent::SetRootJoint(
SGameObject* joint_object,
int joint_size) {
17 m_jointSize = joint_size;
19 m_jointRoot->calcInverseBindTransform(mat4::Identity());
28std::vector<mat4> DrawableSkinnedMeshComponent::GetJointMatrix()
const {
29 std::vector<mat4> jointMatrices;
31 if (m_jointRoot ==
nullptr)
return jointMatrices;
33 jointMatrices.resize(m_jointSize);
34 addJointsToVector(m_jointRoot, jointMatrices);
39void DrawableSkinnedMeshComponent::addJointsToVector(
JointComponent* headJoint, std::vector<mat4>& matrix)
const {
40 int index = headJoint->GetID();
41 matrix[index] = headJoint->GetAnimationMatrix();
43 const auto& children = headJoint->GetGameObject()->GetChildren();
44 for (
const auto& childJoint : children) {
47 if (joint ==
nullptr)
continue;
48 addJointsToVector(joint, matrix);
52void DrawableSkinnedMeshComponent::SetJointSize(
SGameObject* joint_object) {
53 if (joint_object->GetComponent<
JointComponent>() ==
nullptr)
return;
55 auto children = joint_object->GetChildren();
56 for (
const auto& childJoint : children) {
57 SetJointSize(childJoint);
61bool DrawableSkinnedMeshComponent::SetMesh(
const SISurface& meshSurface) {
62 return DrawableStaticMeshComponent::SetMesh(meshSurface);
68 clone->m_meshId = m_meshId;
69 clone->m_jointSize = m_jointSize;
74void DrawableSkinnedMeshComponent::CopyReference(
SComponent* src, std::map<SGameObject*, SGameObject*> lists_obj,
75 std::map<SComponent*, SComponent*> lists_comp) {
76 if (src ==
nullptr)
return;