Implement picture-in-picture mode.

Adds a new window that allows the user to display one or more renders from
the different cameras in the scene.

PiperOrigin-RevId: 856607089
Change-Id: I7268ffd3ef62b9b4d62ce8d004fdbbec92b42af4
This commit is contained in:
Haroon Qureshi
2026-01-15 04:41:34 -08:00
committed by Copybara-Service
parent d816b38f4c
commit c92746641d
8 changed files with 209 additions and 7 deletions
+14 -1
View File
@@ -36,6 +36,7 @@
#include "experimental/platform/helpers.h"
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/interaction.h"
#include "experimental/platform/picture_gui.h"
#include "experimental/platform/renderer.h"
#include "experimental/platform/step_control.h"
#include "experimental/platform/window.h"
@@ -788,6 +789,13 @@ void App::BuildGui() {
ImGui::End();
}
if (tmp_.picture_in_picture) {
if (ImGui::Begin("Picture-in-Picture", &tmp_.picture_in_picture)) {
PipGui(model_, data_, window_.get(), renderer_.get(), &tmp_.pips);
}
ImGui::End();
}
if (tmp_.help) {
platform::ScopedStyle style;
style.Var(ImGuiStyleVar_Alpha, 0.6f);
@@ -1258,7 +1266,7 @@ void App::ToolBarGui() {
if (ImGui::BeginCombo("##Camera", cameras[camera_idx], combo_flags)) {
for (int n = 0; n < cameras.size(); n++) {
if (ImGui::Selectable(cameras[n], (camera_idx == n))) {
ui_.camera_idx = ::mujoco::platform::SetCamera(
ui_.camera_idx = platform::SetCamera(
model_, &camera_, camera_idx + platform::kTumbleCameraIdx);
}
}
@@ -1505,6 +1513,11 @@ void App::MainMenuGui() {
if (ImGui::MenuItem("Full Screen", "F11")) {
tmp_.full_screen = !tmp_.full_screen;
}
ImGui::Separator();
if (ImGui::MenuItem("Picture-in-Picture")) {
tmp_.picture_in_picture = !tmp_.picture_in_picture;
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Charts")) {
+5
View File
@@ -25,6 +25,7 @@
#include "experimental/platform/gui.h"
#include "experimental/platform/helpers.h"
#include "experimental/platform/interaction.h"
#include "experimental/platform/picture_gui.h"
#include "experimental/platform/renderer.h"
#include "experimental/platform/sim_history.h"
#include "experimental/platform/sim_profiler.h"
@@ -84,6 +85,7 @@ class App {
bool stats = false;
bool chart_solver = false;
bool chart_performance = false;
bool picture_in_picture = false;
bool options_panel = true;
bool inspector_panel = true;
bool full_screen = false;
@@ -111,6 +113,9 @@ class App {
int state_sig = 0;
std::vector<mjtNum> state;
// Picture-in-Picture.
std::vector<platform::PipState> pips;
// File dialogs.
char filename[1000] = "";
std::string last_load_file;