Better 3D navigator (#5620)

* Initial working impl of face labels

* Improve color

* Remove background
This commit is contained in:
Noisyfox 2024-06-15 12:17:57 +08:00 committed by GitHub
parent aa692b815e
commit dbac0f2919
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 80 additions and 4 deletions

View file

@ -5662,9 +5662,17 @@ void GLCanvas3D::_render_3d_navigator()
style.Colors[ImGuizmo::COLOR::DIRECTION_X] = ImGuiWrapper::to_ImVec4(ColorRGBA::Y());
style.Colors[ImGuizmo::COLOR::DIRECTION_Y] = ImGuiWrapper::to_ImVec4(ColorRGBA::Z());
style.Colors[ImGuizmo::COLOR::DIRECTION_Z] = ImGuiWrapper::to_ImVec4(ColorRGBA::X());
style.Colors[ImGuizmo::COLOR::TEXT] = m_is_dark ? ImVec4(224 / 255.f, 224 / 255.f, 224 / 255.f, 1.f) : ImVec4(.2f, .2f, .2f, 1.0f);
style.Colors[ImGuizmo::COLOR::FACE] = m_is_dark ? ImVec4(45 / 255.f, 45 / 255.f, 49 / 255.f, 1.f) : ImVec4(1, 1, 1, 1);
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_X], "y");
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Y], "z");
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Z], "x");
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_FRONT], _utf8("Front").c_str());
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BACK], _utf8("Back").c_str());
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_TOP], _utf8("Top").c_str());
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BOTTOM], _utf8("Bottom").c_str());
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_LEFT], _utf8("Left").c_str());
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_RIGHT], _utf8("Right").c_str());
float sc = get_scale();
#ifdef WIN32
@ -5694,7 +5702,7 @@ void GLCanvas3D::_render_3d_navigator()
const float size = 128 * sc;
const bool dirty = ImGuizmo::ViewManipulate(cameraView, cameraProjection, ImGuizmo::OPERATION::ROTATE, ImGuizmo::MODE::WORLD,
identityMatrix, camDistance, ImVec2(viewManipulateLeft, viewManipulateTop - size),
ImVec2(size, size), 0x10101010);
ImVec2(size, size), 0x00101010);
if (dirty) {
for (unsigned int c = 0; c < 4; ++c) {