Tfm gizmo wip

This commit is contained in:
Sri Sham Haran 2022-10-19 20:42:38 +08:00
parent 125ce7b564
commit 6051b7ded5
5 changed files with 29 additions and 48 deletions

View File

@ -1,48 +0,0 @@
[Window][MainStatusBar]
Pos=0,1389
Size=2547,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=2547,1341
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,172
Size=571,1217
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=2276,48
Size=271,1341
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=571,122
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=573,48
Size=1701,1341
Collapsed=0
DockId=0x00000002,0
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=8,79 Size=2547,1341 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1992,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=571,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1074,1036 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=271,1036 Selected=0xE7039252

View File

@ -4,6 +4,10 @@
#include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHComponentManager.h"
#include "ECS_Base/Managers/SHSystemManager.h" #include "ECS_Base/Managers/SHSystemManager.h"
#include "Editor/SHEditor.hpp" #include "Editor/SHEditor.hpp"
#include <imgui.h>
#include <ImGuizmo.h>
#include "Camera/SHCameraSystem.h"
namespace SHADE namespace SHADE
{ {
@ -18,7 +22,21 @@ namespace SHADE
selectedEntityTranformComponent = SHComponentManager::GetComponent_s<SHTransformComponent>(eid); selectedEntityTranformComponent = SHComponentManager::GetComponent_s<SHTransformComponent>(eid);
} }
if(!editorCamera)
{
auto const cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
editorCamera = cameraSystem->GetEditorCamera();
}
ImGuizmo::SetOrthographic(false);
SHMatrix view = editorCamera->GetViewMatrix();
SHMatrix proj = editorCamera->GetProjMatrix();
SHMatrix mat = selectedEntityTranformComponent->GetTRS();
ImGuizmo::DrawGrid(view.m[0], proj.m[0], mat.m[0], 10.f);
if(ImGuizmo::Manipulate(view.m[0], proj.m[0], ImGuizmo::OPERATION::UNIVERSAL, ImGuizmo::MODE::WORLD, mat.m[0]))
{
}
} }
} }

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "Camera/SHCameraComponent.h"
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
namespace SHADE namespace SHADE
@ -9,5 +10,6 @@ namespace SHADE
void Draw(); void Draw();
private: private:
SHTransformComponent* selectedEntityTranformComponent{nullptr}; SHTransformComponent* selectedEntityTranformComponent{nullptr};
SHCameraComponent* editorCamera{nullptr};
}; };
} }

View File

@ -36,6 +36,7 @@
#include <imgui.h> #include <imgui.h>
#include <SDL.h> #include <SDL.h>
#include <rttr/registration> #include <rttr/registration>
#include <ImGuizmo.h>
//#==============================================================# //#==============================================================#
//|| ImGui Backend Includes || //|| ImGui Backend Includes ||
@ -129,6 +130,9 @@ namespace SHADE
if(window->isOpen) if(window->isOpen)
window->Update(); window->Update();
} }
ImGuizmo::SetDrawlist(ImGui::GetForegroundDrawList());
transformGizmo.Draw();
if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z)) if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z))
{ {
@ -366,6 +370,7 @@ namespace SHADE
ImGui_ImplVulkan_NewFrame(); ImGui_ImplVulkan_NewFrame();
ImGui_ImplSDL2_NewFrame(); ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
ImGuizmo::BeginFrame();
} }

View File

@ -16,6 +16,8 @@
#include "Resource/Handle.h" #include "Resource/Handle.h"
#include "EditorWindow/SHEditorWindow.h" #include "EditorWindow/SHEditorWindow.h"
#include "Tools/SHLogger.h" #include "Tools/SHLogger.h"
#include "Gizmos/SHTransformGizmo.h"
//#==============================================================# //#==============================================================#
//|| Library Includes || //|| Library Includes ||
@ -200,5 +202,7 @@ namespace SHADE
SDL_Window* sdlWindow {nullptr}; SDL_Window* sdlWindow {nullptr};
ImGuiIO* io{nullptr}; ImGuiIO* io{nullptr};
SHTransformGizmo transformGizmo;
};//class SHEditor };//class SHEditor
}//namespace SHADE }//namespace SHADE