BoneAttachments now working perfectly
This commit is contained in:
@@ -50,13 +50,16 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
glm::vec4 perspective;
|
glm::vec4 perspective;
|
||||||
glm::decompose(boneTransform, scale, rotation, translation, skew, perspective);
|
glm::decompose(boneTransform, scale, rotation, translation, skew, perspective);
|
||||||
|
|
||||||
glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation));
|
rotation = glm::quat((glm::vec3)entity["BoneAttachment"]["OrientationOffset"]) * rotation;
|
||||||
|
|
||||||
|
rotation.w = -rotation.w;
|
||||||
|
glm::vec3 angles = glm::eulerAngles(rotation);
|
||||||
|
|
||||||
if ((bool)entity["BoneAttachment"]["InheritPosition"]) {
|
if ((bool)entity["BoneAttachment"]["InheritPosition"]) {
|
||||||
(glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"];
|
(glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"];
|
||||||
}
|
}
|
||||||
if ((bool)entity["BoneAttachment"]["InheritOrientation"]) {
|
if ((bool)entity["BoneAttachment"]["InheritOrientation"]) {
|
||||||
(glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"];
|
(glm::vec3&)entity["Transform"]["Orientation"] = angles;
|
||||||
}
|
}
|
||||||
if ((bool)entity["BoneAttachment"]["InheritScale"]) {
|
if ((bool)entity["BoneAttachment"]["InheritScale"]) {
|
||||||
(glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"];
|
(glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"];
|
||||||
|
|||||||
Reference in New Issue
Block a user