add basic camera controls
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "td/Maths.h"
|
||||
#include <td/render/Camera.h>
|
||||
|
||||
#include <cmath>
|
||||
@@ -24,5 +25,9 @@ void Camera::SetCamPos(const Vec3f& a_NewPos) {
|
||||
OnViewChange();
|
||||
}
|
||||
|
||||
const Vec3f& Camera::GetCamPos() const {
|
||||
return m_CamPos;
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
} // namespace td
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <td/Maths.h>
|
||||
#include <td/render/renderer/WorldRenderer.h>
|
||||
|
||||
#include <td/render/loader/WorldLoader.h>
|
||||
@@ -13,7 +14,17 @@ WorldRenderer::WorldRenderer(Camera& a_Camera, const game::WorldPtr& a_World) :
|
||||
|
||||
WorldRenderer::~WorldRenderer() {}
|
||||
|
||||
void WorldRenderer::UpdateControls() {
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
||||
constexpr float sensitivity = 1.0f;
|
||||
float delta = ImGui::GetIO().DeltaTime;
|
||||
auto mouseDelta = ImGui::GetIO().MouseDelta;
|
||||
m_Camera.SetCamPos(m_Camera.GetCamPos() + Vec3f{-mouseDelta.x * delta * sensitivity, 0, -mouseDelta.y * delta * sensitivity});
|
||||
}
|
||||
}
|
||||
|
||||
void WorldRenderer::Render(float a_Lerp) {
|
||||
UpdateControls();
|
||||
m_Shader->Start();
|
||||
Renderer::Render(*m_WorldVao);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user