3 #include "imgui/imgui.h"
4 #include "imguizmo/ImGuizmo.h"
11 ImGuizmo::SetDrawlist(ImGui::GetForegroundDrawList());
17 ImGuizmo::BeginFrame();
22 std::optional<ImGuizmo::OPERATION>
25 bool a, ImGuizmo::OPERATION ao,
26 bool b, ImGuizmo::OPERATION bo,
27 bool c, ImGuizmo::OPERATION co
31 constexpr
const auto none =
static_cast<ImGuizmo::OPERATION
>(0);
55 const std::optional<vec3f>& snap,
56 const mat4f& camera_view,
57 const mat4f& camera_projection,
59 bool tx,
bool ty,
bool tz,
63 const auto current_gizmo_mode = is_local ? ImGuizmo::LOCAL : ImGuizmo::WORLD;
65 const auto operation = combine
67 tx, ImGuizmo::TRANSLATE_X,
68 ty, ImGuizmo::TRANSLATE_Y,
69 tz, ImGuizmo::TRANSLATE_Z
72 if (operation.has_value() ==
false)
78 ImGuiIO& io = ImGui::GetIO();
79 ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
82 auto model_to_modify = model;
84 const auto was_modified = ImGuizmo::Manipulate
90 model_to_modify.get_column_major(),
92 snap.has_value() ? &snap->x :
nullptr
97 float matrix_rotation[3];
98 float matrix_scale[3];
100 ImGuizmo::DecomposeMatrixToComponents
102 model_to_modify.get_column_major(),
103 new_position->
get_data_ptr(), matrix_rotation, matrix_scale
115 const std::optional<Angle>& snap,
116 const mat4f& camera_view,
117 const mat4f& camera_projection,
119 bool rx,
bool ry,
bool rz,
123 const auto current_gizmo_mode = is_local ? ImGuizmo::LOCAL : ImGuizmo::WORLD;
125 const auto operation = combine
127 rx, ImGuizmo::ROTATE_X,
128 ry, ImGuizmo::ROTATE_Y,
129 rz, ImGuizmo::ROTATE_Z
132 if (operation.has_value() ==
false)
138 ImGuiIO& io = ImGui::GetIO();
139 ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
142 auto model_to_modify = model;
144 const auto snap_degrees = snap.value_or(
no_rotation).as_degrees();
146 const auto was_modified = ImGuizmo::Manipulate
152 model_to_modify.get_column_major(),
154 snap.has_value() ? &snap_degrees :
nullptr
159 float matrix_position[3];
160 float matrix_rotation[3];
161 float matrix_scale[3];
163 ImGuizmo::DecomposeMatrixToComponents
165 model_to_modify.get_column_major(),
166 matrix_position, matrix_rotation, matrix_scale
bool translate(bool is_local, const std::optional< vec3f > &snap, const mat4f &camera_view, const mat4f &camera_projection, const mat4f &model, bool tx, bool ty, bool tz, vec3f *new_position)
bool rotate(bool is_local, const std::optional< Angle > &snap, const mat4f &camera_view, const mat4f &camera_projection, const mat4f &model, bool rx, bool ry, bool rz, quatf *new_rotation)
constexpr Angle no_rotation
constexpr static Angle from_degrees(float degrees)
float * get_column_major()
static quatf from_ypr(const Angle &yaw, const Angle &pitch, const Angle &roll)