mirror of https://github.com/AxioDL/metaforce.git
Add Player Transform tools
This commit is contained in:
parent
96680d2660
commit
e331c5d5c6
|
@ -5,10 +5,13 @@
|
||||||
#include "Runtime/CStateManager.hpp"
|
#include "Runtime/CStateManager.hpp"
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/World/CPlayer.hpp"
|
#include "Runtime/World/CPlayer.hpp"
|
||||||
|
#include "Runtime/ImGuiEntitySupport.hpp"
|
||||||
|
|
||||||
#include "ImGuiEngine.hpp"
|
#include "ImGuiEngine.hpp"
|
||||||
#include "magic_enum.hpp"
|
#include "magic_enum.hpp"
|
||||||
|
|
||||||
|
#include <zeus/CEulerAngles.hpp>
|
||||||
|
|
||||||
namespace ImGui {
|
namespace ImGui {
|
||||||
// Internal functions
|
// Internal functions
|
||||||
void ClearIniSettings();
|
void ClearIniSettings();
|
||||||
|
@ -1057,6 +1060,7 @@ void ImGuiConsole::ShowAppMainMenuBar(bool canInspect) {
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("Tools")) {
|
if (ImGui::BeginMenu("Tools")) {
|
||||||
|
ImGui::MenuItem("Player Transform", nullptr, &m_showPlayerTransformEditor, canInspect && m_developer);
|
||||||
ImGui::MenuItem("Inspect", nullptr, &m_showInspectWindow, canInspect && m_developer);
|
ImGui::MenuItem("Inspect", nullptr, &m_showInspectWindow, canInspect && m_developer);
|
||||||
ImGui::MenuItem("Items", nullptr, &m_showItemsWindow, canInspect && m_developer && m_cheats);
|
ImGui::MenuItem("Items", nullptr, &m_showItemsWindow, canInspect && m_developer && m_cheats);
|
||||||
ImGui::MenuItem("Layers", nullptr, &m_showLayersWindow, canInspect && m_developer);
|
ImGui::MenuItem("Layers", nullptr, &m_showLayersWindow, canInspect && m_developer);
|
||||||
|
@ -1196,6 +1200,7 @@ void ImGuiConsole::PreUpdate() {
|
||||||
}
|
}
|
||||||
ShowDebugOverlay();
|
ShowDebugOverlay();
|
||||||
ShowInputViewer();
|
ShowInputViewer();
|
||||||
|
ShowPlayerTransformEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiConsole::PostUpdate() {
|
void ImGuiConsole::PostUpdate() {
|
||||||
|
@ -1545,4 +1550,71 @@ void ImGuiConsole::ShowMenuHint() {
|
||||||
ImGui::PopStyleColor(2);
|
ImGui::PopStyleColor(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGuiConsole::ShowPlayerTransformEditor() {
|
||||||
|
if (!m_showPlayerTransformEditor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::Begin("Player Transform", &m_showPlayerTransformEditor, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
if (ImGui::CollapsingHeader("Position")) {
|
||||||
|
ImGui::PushID("player_position");
|
||||||
|
zeus::CVector3f vec = g_StateManager->GetPlayer().GetTranslation();
|
||||||
|
|
||||||
|
if (ImGuiVector3fInput("Position", vec)) {
|
||||||
|
g_StateManager->GetPlayer().SetTranslation(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::Button("Save")) {
|
||||||
|
m_savedLocation.emplace(vec);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Load") && m_savedLocation) {
|
||||||
|
g_StateManager->GetPlayer().SetTranslation(*m_savedLocation);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Clear") && m_savedLocation) {
|
||||||
|
m_savedLocation.reset();
|
||||||
|
}
|
||||||
|
if (m_savedLocation) {
|
||||||
|
ImGui::Text("Saved: %g, %g, %g", float(m_savedLocation->x()), float(m_savedLocation->y()),
|
||||||
|
float(m_savedLocation->z()));
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
if (ImGui::CollapsingHeader("Rotation")) {
|
||||||
|
ImGui::PushID("player_rotation");
|
||||||
|
zeus::CEulerAngles angles(g_StateManager->GetPlayer().GetTransform());
|
||||||
|
angles = zeus::CEulerAngles(angles * zeus::skRadToDegVec);
|
||||||
|
if (ImGuiVector3fInput("Rotation", angles)) {
|
||||||
|
angles.x() = zeus::clamp(-179.999f, float(angles.x()), 179.999f);
|
||||||
|
angles.y() = zeus::clamp(-89.999f, float(angles.y()), 89.999f);
|
||||||
|
angles.z() = zeus::clamp(-179.999f, float(angles.z()), 179.999f);
|
||||||
|
auto xf = g_StateManager->GetPlayer().GetTransform();
|
||||||
|
xf.setRotation(zeus::CQuaternion(angles * zeus::skDegToRadVec).toTransform().buildMatrix3f());
|
||||||
|
g_StateManager->GetPlayer().SetTransform(xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::Button("Save")) {
|
||||||
|
m_savedRotation.emplace(angles);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Load") && m_savedRotation) {
|
||||||
|
auto xf = g_StateManager->GetPlayer().GetTransform();
|
||||||
|
xf.setRotation(zeus::CQuaternion((*m_savedRotation) * zeus::skDegToRadVec).toTransform().buildMatrix3f());
|
||||||
|
g_StateManager->GetPlayer().SetTransform(xf);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Clear") && m_savedRotation) {
|
||||||
|
m_savedRotation.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_savedRotation) {
|
||||||
|
ImGui::Text("Saved: %g, %g, %g", float(m_savedRotation->x()), float(m_savedRotation->y()),
|
||||||
|
float(m_savedRotation->z()));
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "hecl/CVarCommons.hpp"
|
#include "hecl/CVarCommons.hpp"
|
||||||
#include "hecl/CVarManager.hpp"
|
#include "hecl/CVarManager.hpp"
|
||||||
|
|
||||||
|
#include <zeus/CEulerAngles.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
void ImGuiStringViewText(std::string_view text);
|
void ImGuiStringViewText(std::string_view text);
|
||||||
void ImGuiTextCenter(std::string_view text);
|
void ImGuiTextCenter(std::string_view text);
|
||||||
|
@ -57,6 +59,9 @@ private:
|
||||||
bool m_showItemsWindow = false;
|
bool m_showItemsWindow = false;
|
||||||
bool m_showLayersWindow = false;
|
bool m_showLayersWindow = false;
|
||||||
bool m_showConsoleVariablesWindow = false;
|
bool m_showConsoleVariablesWindow = false;
|
||||||
|
bool m_showPlayerTransformEditor = false;
|
||||||
|
std::optional<zeus::CVector3f> m_savedLocation;
|
||||||
|
std::optional<zeus::CEulerAngles> m_savedRotation;
|
||||||
|
|
||||||
bool m_paused = false;
|
bool m_paused = false;
|
||||||
bool m_stepFrame = false;
|
bool m_stepFrame = false;
|
||||||
|
@ -106,5 +111,6 @@ private:
|
||||||
void ShowInputViewer();
|
void ShowInputViewer();
|
||||||
void SetOverlayWindowLocation(int corner) const;
|
void SetOverlayWindowLocation(int corner) const;
|
||||||
void ShowCornerContextMenu(int& corner, int avoidCorner) const;
|
void ShowCornerContextMenu(int& corner, int avoidCorner) const;
|
||||||
|
void ShowPlayerTransformEditor();
|
||||||
};
|
};
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "Runtime/ImGuiEntitySupport.hpp"
|
||||||
|
|
||||||
#include "Runtime/World/CActor.hpp"
|
#include "Runtime/World/CActor.hpp"
|
||||||
#include "Runtime/World/CAi.hpp"
|
#include "Runtime/World/CAi.hpp"
|
||||||
#include "Runtime/World/CAmbientAI.hpp"
|
#include "Runtime/World/CAmbientAI.hpp"
|
||||||
|
@ -178,7 +180,9 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec) {
|
namespace metaforce {
|
||||||
|
|
||||||
|
bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec) {
|
||||||
std::array<float, 3> arr{vec.x(), vec.y(), vec.z()};
|
std::array<float, 3> arr{vec.x(), vec.y(), vec.z()};
|
||||||
if (ImGui::DragFloat3(label, arr.data(), 0.1f)) {
|
if (ImGui::DragFloat3(label, arr.data(), 0.1f)) {
|
||||||
vec.assign(arr[0], arr[1], arr[2]);
|
vec.assign(arr[0], arr[1], arr[2]);
|
||||||
|
@ -221,7 +225,6 @@ void ImGuiAnimRes(const char* label, metaforce::CAnimRes& res) {
|
||||||
// TODO: More
|
// TODO: More
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace metaforce {
|
|
||||||
void CDamageVulnerability::ImGuiEditWindow(const char* title, bool& open) {
|
void CDamageVulnerability::ImGuiEditWindow(const char* title, bool& open) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <zeus/CVector3f.hpp>
|
||||||
|
|
||||||
|
namespace metaforce {
|
||||||
|
bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec);
|
||||||
|
}
|
|
@ -1 +1 @@
|
||||||
Subproject commit bb9b4c83af12647df1db7978347bd297dda3277b
|
Subproject commit f3630be9dee64378e7bcf20b4602b64bd8c810c0
|
|
@ -35,15 +35,18 @@ extern "C" int rep_closefrom(int lower);
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <optional>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "logvisor/logvisor.hpp"
|
#include "FourCC.hpp"
|
||||||
#include "athena/Global.hpp"
|
#include "athena/Global.hpp"
|
||||||
|
#include "logvisor/logvisor.hpp"
|
||||||
#include "xxhash/xxhash.h"
|
#include "xxhash/xxhash.h"
|
||||||
#include "SystemChar.hpp"
|
#include "SystemChar.hpp"
|
||||||
#include "FourCC.hpp"
|
#include "FourCC.hpp"
|
||||||
|
|
||||||
|
|
||||||
#if defined(__has_feature)
|
#if defined(__has_feature)
|
||||||
#if __has_feature(thread_sanitizer)
|
#if __has_feature(thread_sanitizer)
|
||||||
#define HECL_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
|
#define HECL_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
|
||||||
|
|
Loading…
Reference in New Issue