added grid and angle buttons
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "TransformEditor.hpp"
|
||||
#include <imgui.h>
|
||||
#include <cmath>
|
||||
|
||||
bool TransformEditor::renderComponent(flecs::entity entity,
|
||||
TransformComponent &transform)
|
||||
@@ -41,6 +42,71 @@ bool TransformEditor::renderComponent(flecs::entity entity,
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Rotation buttons (Y axis)
|
||||
ImGui::Text("Rotate Y:");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("-90##rot")) {
|
||||
Ogre::Quaternion q(Ogre::Degree(-90.0f), Ogre::Vector3::UNIT_Y);
|
||||
transform.rotation = q * transform.rotation;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("-45##rot")) {
|
||||
Ogre::Quaternion q(Ogre::Degree(-45.0f), Ogre::Vector3::UNIT_Y);
|
||||
transform.rotation = q * transform.rotation;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("+45##rot")) {
|
||||
Ogre::Quaternion q(Ogre::Degree(45.0f), Ogre::Vector3::UNIT_Y);
|
||||
transform.rotation = q * transform.rotation;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("+90##rot")) {
|
||||
Ogre::Quaternion q(Ogre::Degree(90.0f), Ogre::Vector3::UNIT_Y);
|
||||
transform.rotation = q * transform.rotation;
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Grid snap buttons
|
||||
ImGui::Text("Snap to Grid:");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("0.25")) {
|
||||
transform.position.x = std::round(transform.position.x / 0.25f) * 0.25f;
|
||||
transform.position.y = std::round(transform.position.y / 0.25f) * 0.25f;
|
||||
transform.position.z = std::round(transform.position.z / 0.25f) * 0.25f;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("0.5")) {
|
||||
transform.position.x = std::round(transform.position.x / 0.5f) * 0.5f;
|
||||
transform.position.y = std::round(transform.position.y / 0.5f) * 0.5f;
|
||||
transform.position.z = std::round(transform.position.z / 0.5f) * 0.5f;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("1.0")) {
|
||||
transform.position.x = std::round(transform.position.x);
|
||||
transform.position.y = std::round(transform.position.y);
|
||||
transform.position.z = std::round(transform.position.z);
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("2.0")) {
|
||||
transform.position.x = std::round(transform.position.x / 2.0f) * 2.0f;
|
||||
transform.position.y = std::round(transform.position.y / 2.0f) * 2.0f;
|
||||
transform.position.z = std::round(transform.position.z / 2.0f) * 2.0f;
|
||||
modified = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("4.0")) {
|
||||
transform.position.x = std::round(transform.position.x / 4.0f) * 4.0f;
|
||||
transform.position.y = std::round(transform.position.y / 4.0f) * 4.0f;
|
||||
transform.position.z = std::round(transform.position.z / 4.0f) * 4.0f;
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Reset buttons
|
||||
if (ImGui::Button("Reset Position")) {
|
||||
transform.position = Ogre::Vector3::ZERO;
|
||||
|
||||
Reference in New Issue
Block a user