Gizmo api now working with a simple quad in the world

This commit is contained in:
antopilo
2025-03-22 23:17:25 -04:00
parent 0243ef83cb
commit 85f0eb2c02
13 changed files with 350 additions and 82 deletions

View File

@@ -7,9 +7,11 @@
#include "Nuake/Rendering/Vulkan/VulkanRenderer.h"
#include "Nuake/Rendering/Vulkan/SceneViewport.h"
#include "Nuake/Rendering/Vulkan/DebugCmd.h"
#include <glm/gtc/type_ptr.hpp>
using namespace Nuake;
ViewportWidget::ViewportWidget(EditorContext& context) : IEditorWidget(context)
@@ -204,4 +206,17 @@ void ViewportWidget::OnSceneChanged(Ref<Nuake::Scene> scene)
vkRenderer.RegisterSceneViewport(scene, viewport->GetID());
sceneViewport = viewport;
}
sceneViewport->GetOnDebugDraw().AddRaw(this, &ViewportWidget::OnDebugDraw);
}
void ViewportWidget::OnDebugDraw(DebugCmd& debugCmd)
{
auto cam = debugCmd.GetScene()->GetCurrentCamera();
auto view = cam->GetTransform();
auto proj = cam->GetPerspective();
Matrix4 model = glm::translate(Matrix4(1.0f), Vector3(0, 3, 0));
debugCmd.DrawQuad(proj * view * model);
}

View File

@@ -9,6 +9,7 @@ class EditorContext;
namespace Nuake
{
class Viewport;
class DebugCmd;
}
class ViewportWidget : public IEditorWidget
@@ -30,4 +31,6 @@ public:
void Update(float ts) override;
void Draw() override;
void OnSceneChanged(Ref<Nuake::Scene> scene) override;
void OnDebugDraw(Nuake::DebugCmd& debugCmd);
};