camera yaw and pitch
This commit is contained in:
@@ -16,6 +16,9 @@ struct Camera {
|
|||||||
Mat4f InvProjectionMatrix;
|
Mat4f InvProjectionMatrix;
|
||||||
|
|
||||||
Vec3f CamPos;
|
Vec3f CamPos;
|
||||||
|
|
||||||
|
float m_Yaw = -3.141592653f / 2.0f;
|
||||||
|
constexpr static float m_Pitch = -3.141592653f / 2.0f + 0.0000001f;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
|
|||||||
@@ -97,8 +97,15 @@ void Renderer::SetCamMovement(const Vec2f& mov) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetCamPos(const Vec3f& newPos) {
|
void Renderer::SetCamPos(const Vec3f& newPos) {
|
||||||
|
|
||||||
|
Vec3f front = {
|
||||||
|
std::cos(m_Camera.m_Yaw) * std::cos(m_Camera.m_Pitch),
|
||||||
|
std::sin(m_Camera.m_Pitch),
|
||||||
|
std::sin(m_Camera.m_Yaw) * std::cos(m_Camera.m_Pitch)
|
||||||
|
};
|
||||||
|
|
||||||
m_Camera.CamPos = newPos;
|
m_Camera.CamPos = newPos;
|
||||||
m_Camera.viewMatrix = maths::Look(m_Camera.CamPos, {0, -1, -0.000000001}, {0, 1, 0});
|
m_Camera.viewMatrix = maths::Look(m_Camera.CamPos, front, {0, 1, 0});
|
||||||
m_Camera.InvViewMatrix = maths::Inverse(m_Camera.viewMatrix);
|
m_Camera.InvViewMatrix = maths::Inverse(m_Camera.viewMatrix);
|
||||||
m_WorldShader->Start();
|
m_WorldShader->Start();
|
||||||
m_WorldShader->SetViewMatrix(m_Camera.viewMatrix);
|
m_WorldShader->SetViewMatrix(m_Camera.viewMatrix);
|
||||||
|
|||||||
Reference in New Issue
Block a user