7UVcyDd (1).gif

y4mcVoT.gif

ImGuizmo란 무엇인가?

ImGuizmoDear ImGui 위에서 동작하는 간단한 변환 도구(Transform Gizmo)입니다. 개발자들이 3D 모델링 도구(예: Blender, Unity)에서 볼 수 있는 이동(Translate), 회전(Rotate), 크기 조정(Scale) 기능을 게임 엔진이나 편집기에 통합할 수 있도록 도와줍니다. 주요 기능은 다음과 같습니다:

  1. Translate, Rotate, Scale 기능 지원
  2. 세계 좌표계(World)와 로컬 좌표계(Local) 모드 지원
  3. 스냅(Snap) 기능으로 정밀한 변환 지원
  4. Orthographic(직교) 및 Perspective(투시) 카메라 지원

코드 분석

1. 기본 설정

ImGuizmo::SetOrthographic(false);
ImGuizmo::SetDrawlist();
ImGuizmo::SetRect(mViewportBounds[0].x, mViewportBounds[0].y
    , mViewportBounds[1].x - mViewportBounds[0].x, mViewportBounds[1].y - mViewportBounds[0].y);

2. 카메라와 대상 객체 설정

const ya::math::Matrix& viewMatrix = ya::renderer::mainCamera->GetViewMatrix();
const ya::math::Matrix& projectionMatrix = ya::renderer::mainCamera->GetProjectionMatrix();

ya::Transform* transform = selectedObject->GetComponent<ya::Transform>();
ya::math::Matrix worldMatrix = transform->GetWorldMatrix();