Skip to content

Commit 01edabd

Browse files
committed
draggable camera input
1 parent 89419ec commit 01edabd

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/saturn/imgui/saturn_imgui.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,24 @@ void saturn_imgui_update() {
815815
camera_savestate_mult = 0.f;
816816
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
817817
ImGui::BeginChild("###model_metadata", ImVec2(200, 90), true, ImGuiWindowFlags_NoScrollbar);
818-
ImGui::TextDisabled("pos %.f, %.f, %.f", gCamera->pos[0], gCamera->pos[1], gCamera->pos[2]);
819-
ImGui::TextDisabled("foc %.f, %.f, %.f", gCamera->focus[0], gCamera->focus[1], gCamera->focus[2]);
818+
float dist;
819+
s16 yaw, pitch;
820+
vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &dist, &pitch, &yaw);
821+
float rot[] = { (float)yaw, (float)pitch, (float)gLakituState.roll };
822+
ImGui::PushItemWidth(200);
823+
ImGui::DragFloat3("pos", gCamera->pos, 5.f);
824+
ImGui::DragFloat3("rot", rot, 128.f);
825+
ImGui::PopItemWidth();
826+
yaw = rot[0];
827+
pitch = rot[1];
828+
gLakituState.roll = rot[2];
829+
vec3f_set_dist_and_angle(gCamera->pos, gCamera->focus, dist, pitch, yaw);
830+
vec3f_copy(gLakituState.pos, gCamera->pos);
831+
vec3f_copy(gLakituState.focus, gCamera->focus);
832+
vec3f_copy(gLakituState.goalPos, gCamera->pos);
833+
vec3f_copy(gLakituState.goalFocus, gCamera->focus);
834+
gCamera->yaw = calculate_yaw(gCamera->focus, gCamera->pos);
835+
gLakituState.yaw = gCamera->yaw;
820836
if (ImGui::Button(ICON_FK_FILES_O " Copy###copy_camera")) {
821837
saturn_copy_camera(copy_relative);
822838
if (copy_relative) saturn_paste_camera();

0 commit comments

Comments
 (0)