Rudimentary implementation of the translate,Rotate,Scale tools
This commit is contained in:
@ -118,6 +118,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
ImGuizmo::OPERATION activeOperation = ImGuizmo::OPERATION::TRANSLATE;
|
||||
|
||||
void OnUI() override {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { ImGui::GetWindowWidth(), 7 });
|
||||
ImGui::BeginMainMenuBar();
|
||||
@ -280,6 +282,49 @@ public:
|
||||
|
||||
|
||||
ImGui::Begin("RuntimeControls");
|
||||
|
||||
ImGui::BeginGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(ICON_MD_TRANSFORM);
|
||||
|
||||
auto spacing = 10;
|
||||
float buttonWidth = 75.0f;
|
||||
float buttonHeight = 30;
|
||||
float ColorIntensity = 0.5f;
|
||||
float ColorIntensityHovered = 0.75;
|
||||
float ColorIntensityActive = 0.85;
|
||||
float yPadding = 6.f;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{0, yPadding });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.0f,ColorIntensity ,0.0f ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.0f,ColorIntensityHovered ,0.0f ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.0f,ColorIntensityActive ,0.0f ,1.0f });
|
||||
ImGui::SameLine(0, spacing);
|
||||
if (ImGui::Button("Translate", { buttonWidth,buttonHeight }))
|
||||
activeOperation = ImGuizmo::OPERATION::TRANSLATE;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 0, yPadding });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ ColorIntensity, 0.0f ,0.0f ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ ColorIntensityHovered, 0.0f ,0.0f ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ ColorIntensityActive, 0.0f ,0.0f ,1.0f });
|
||||
ImGui::SameLine(0, spacing);
|
||||
if (ImGui::Button("Rotate", { buttonWidth,buttonHeight }))
|
||||
activeOperation = ImGuizmo::OPERATION::ROTATE;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 0, yPadding });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.0f, 0.0f ,ColorIntensity ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.0f, 0.0f ,ColorIntensityHovered ,1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.0f, 0.0f ,ColorIntensityActive ,1.0f });
|
||||
ImGui::SameLine(0, spacing);
|
||||
if (ImGui::Button("Scale", { buttonWidth,buttonHeight }))
|
||||
activeOperation = ImGuizmo::OPERATION::SCALE;
|
||||
|
||||
ImGui::PopStyleColor(9);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - (90));
|
||||
auto color = ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001 * 69, 1.0f };
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
||||
@ -325,32 +370,40 @@ public:
|
||||
| ImGuiWindowFlags_NoCollapse;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 });
|
||||
ImGui::Begin("SceneView",nullptr,viewportWindowFlags);
|
||||
spdlog::info( "Editor Resolution {0}x{1}", (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight());
|
||||
|
||||
|
||||
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
||||
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
|
||||
|
||||
ImGuizmo::Enable(true);
|
||||
ImGuizmo::SetOrthographic(false);
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
||||
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetContentRegionMax().x, ImGui::GetContentRegionMax().y);
|
||||
/*
|
||||
const auto& projection = camera.projection;
|
||||
glm::mat4& view = glm::mat4(1.0f);
|
||||
ImGuizmo::DrawGrid();
|
||||
ImGuizmo::ViewManipulate();
|
||||
|
||||
|
||||
//ImGuizmo::ViewManipulate(glm::value_ptr(cameraView), 1, ImGui::GetWindowPos(), { 90,90 }, 0x22CCCCCCC);
|
||||
|
||||
|
||||
if(selected != nullptr && selected->isValid()){
|
||||
auto& tc = selected->GetComponent<YoggieEngine::TransformComponent>();
|
||||
glm::mat4 transform = tc.GetTransform();
|
||||
if(Selected.isValid()){
|
||||
|
||||
|
||||
ImGuizmo::SetOrthographic(false);
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
||||
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||
|
||||
const auto& ProjMatrix = camera->projection;
|
||||
glm::mat4& cameraView = glm::inverse(((EditorCamera*)camera)->view);
|
||||
glm::mat4 cameraDelta = glm::mat4(1.0f);
|
||||
|
||||
|
||||
|
||||
|
||||
auto& tc = Selected.GetComponent<YoggieEngine::TransformComponent>();
|
||||
glm::mat4& transform = tc.GetTransform();
|
||||
ImGuizmo::Manipulate(glm::value_ptr(cameraView), glm::value_ptr(ProjMatrix), activeOperation, ImGuizmo::WORLD, glm::value_ptr(transform), nullptr, nullptr);
|
||||
if(ImGuizmo::IsUsing())
|
||||
tc.Decompose(transform);
|
||||
|
||||
ImGuizmo::Manipulate();
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
|
Reference in New Issue
Block a user