1#include "DAEConvertSGameObject.h"
2#include "../../../../Component/Animation/JointComponent.h"
3#include "../../../../Component/Animation/AnimatorComponent.h"
4#include "../../../../Manager/EngineCore.h"
5#include "../../../../Object/SGameObjectFromSPrefab.h"
9DAEConvertSGameObject::DAEConvertSGameObject() =
default;
11DAEConvertSGameObject::~DAEConvertSGameObject() =
default;
15 if (parent ==
nullptr)
return nullptr;
19 joint->SetID(data->GetIndex());
20 int jointIndex = CORE->GetCore(
ResMgr)->GetStringHash(data->GetName());
21 joint->SetAnimationJointId(jointIndex);
22 joint->SetBindLocalMatrix(data->GetBindLocalTransform());
24 auto children = data->GetChildren();
25 for (
const auto& child : children) {
26 CreateJoints(jointObject, child);
29 parent->AddChild(jointObject);
36 const std::string& name,
Animation* animation) {
37 if (parent ==
nullptr)
return nullptr;
42 std::list<KeyFrame*> frames;
43 unsigned int length = animationData->keyFrames.size();
45 for (
int i = 0; i < length; i++) {
46 frames.push_back(CreateKeyFrame(animationData->keyFrames[i]));
49 if (animation ==
nullptr)
51 animation->LinkResource(name +
".prefab?animation");
52 animation->SetKeyframe(animationData->lengthSeconds, frames);
54 animator->PlayAnimation(animation);
55 animator->SetRootJoint(rootJoint);
57 parent->AddChild(animationObject);
59 return animationObject;
63 std::vector<JointTransform*> resultData;
64 const auto& jointTransforms = data->jointTransforms;
65 resultData.reserve(jointTransforms.size());
67 for (
const auto& jointData : jointTransforms) {
69 resultData.push_back(jointTransform);
71 return new KeyFrame(data->time, std::move(resultData));
75 mat4 mat = data->jointLocalTransform;
76 vec3 translation =
vec3(mat.w.x, mat.w.y, mat.w.z);
77 Quaternion rotation = Quaternion::ToQuaternion(mat);