From 017b5a716e3248657087f8df092ed2de054a3330 Mon Sep 17 00:00:00 2001 From: T1ti <40864460+T1ti@users.noreply.github.com> Date: Sun, 28 Jul 2024 21:43:59 +0200 Subject: [PATCH] fix wmo doodads rotation --- src/noggit/ModelInstance.cpp | 24 ++++++++++++------------ src/noggit/TextureManager.h | 1 + src/noggit/ui/CurrentTexture.cpp | 1 + 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/noggit/ModelInstance.cpp b/src/noggit/ModelInstance.cpp index 98d5fab1..d31ad8b2 100755 --- a/src/noggit/ModelInstance.cpp +++ b/src/noggit/ModelInstance.cpp @@ -1,6 +1,7 @@ // This file is part of Noggit3, licensed under GNU General Public License (version 3). #include +#include #include #include #include @@ -278,8 +279,10 @@ wmo_doodad_instance::wmo_doodad_instance(BlizzardArchive::Listfile::FileKey cons pos = glm::vec3(ff[0], ff[2], -ff[1]); f->read(ff, 16); - doodad_orientation = glm::quat (-ff[0], -ff[2], ff[1], ff[3]); - dir = glm::eulerAngles(doodad_orientation); + // doodad_orientation = glm::quat (-ff[0], -ff[2], ff[1], ff[3]); + doodad_orientation = glm::quat(ff[3], -ff[0], -ff[2], ff[1]); // in GLM w is the first argument + doodad_orientation = glm::normalize(doodad_orientation); + dir = glm::degrees(glm::eulerAngles(doodad_orientation)); f->read(&scale, 4); @@ -307,18 +310,15 @@ void wmo_doodad_instance::update_transform_matrix_wmo(WMOInstance* wmo) // world_pos = wmo->transformMatrix() * glm::vec4(pos,0); world_pos = wmo->transformMatrix() * glm::vec4(pos, 1.0f); - auto m2_mat = glm::mat4x4(1); - m2_mat = glm::translate(m2_mat, pos); - m2_mat = m2_mat * glm::toMat4(doodad_orientation); + auto m2_mat = glm::mat4x4(1.0f); + + // m2_mat = glm::translate(m2_mat, pos); + m2_mat = m2_mat * glm::translate(glm::mat4(1.0f), pos); + m2_mat = m2_mat * glm::toMat4(glm::inverse(doodad_orientation)); m2_mat = glm::scale(m2_mat, glm::vec3(scale)); - glm::mat4x4 mat - ( - wmo->transformMatrix() * m2_mat - ); - - _transform_mat = mat; - _transform_mat_inverted = glm::inverse(mat); + _transform_mat = wmo->transformMatrix() * m2_mat; + _transform_mat_inverted = glm::inverse(_transform_mat); // to compute the size category (used in culling) // updateTransformMatrix() is overriden to do nothing diff --git a/src/noggit/TextureManager.h b/src/noggit/TextureManager.h index 7693f656..778090ef 100755 --- a/src/noggit/TextureManager.h +++ b/src/noggit/TextureManager.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/src/noggit/ui/CurrentTexture.cpp b/src/noggit/ui/CurrentTexture.cpp index 2f59233b..7feeb282 100755 --- a/src/noggit/ui/CurrentTexture.cpp +++ b/src/noggit/ui/CurrentTexture.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace Noggit