Last active
December 1, 2022 14:50
-
-
Save newpolaris/c2cc473d894cffff5f3b7a3933fb65c9 to your computer and use it in GitHub Desktop.
Quat / Euler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 오차가 계속 누적되는 듯 | |
| glm::vec3 angle = glm::eulerAngles(B.rotation); | |
| angle = glm::degrees(angle); | |
| ImGui::SliderFloat3("Rotation", (float*)&angle, -180.f, 180.f); | |
| angle.y = glm::clamp(angle.y, -91.f, 91.f); | |
| B.rotation = glm::radians(angle); | |
| y에 90을 넣어도, 다시 들어올때는 89.98 정도가 나옴 | |
| eulerAngles 함수는 -90 ~ 90 이 제한임 // https://gamedev.stackexchange.com/questions/183771/euler-angle-and-quaternion-conversion-become-weird-when-yaw-is-bigger-than-90-de | |
| 에디터로는 좋은 디자인이 아님; 각도를 슬라이드로 조잘하는 것은 | |
| ImGuizmo::DecomposeMatrixToComponents(matrix, matrixTranslation, matrixRotation, matrixScale); | |
| ImGui::InputFloat3("Tr", matrixTranslation); | |
| ImGui::InputFloat3("Rt", matrixRotation); | |
| ImGui::InputFloat3("Sc", matrixScale); | |
| ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, matrix); | |
| 와 guizmo로 조절하는게 적당한듯 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| glm::vec3 angle = glm::eulerAngles(B.rotation); | |
| angle = glm::degrees(angle); | |
| if (ImGui::InputFloat3("Rotation", (float*)&angle) { | |
| B.rotation = glm::normalize(glm::radians(angle)); | |
| } | |
| 90이 나오긴하는데, -0.0 에서 시작하고, 에디팅시 90도 일때 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://gamedev.stackexchange.com/questions/183771/euler-angle-and-quaternion-conversion-become-weird-when-yaw-is-bigger-than-90-de | |
| glm::vec3 angle = glm::eulerAngles(B.rotation); | |
| // https://stackoverflow.com/questions/2084970/how-to-get-rid-of-minus-sign-from-signed-zero/14015445#14015445 | |
| angle += glm::vec3(0.f); | |
| angle = glm::degrees(angle); | |
| if (ImGui::InputFloat3("Rt", (float*)&angle)) { | |
| angle.y = glm::clamp(angle.y, -90.f, 90.f); | |
| B.rotation = GetQuat(angle); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment