Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
This commit is contained in:
+32
-26
@@ -8,30 +8,30 @@ Camera::Camera(float yFOV, float aspectRatio, float nearClip, float farClip)
|
||||
m_FarClip = farClip;
|
||||
|
||||
m_Position = glm::vec3(0.0);
|
||||
m_Pitch = 0.f;
|
||||
m_Yaw = 0.f;
|
||||
/*m_Pitch = 0.f;
|
||||
m_Yaw = 0.f;*/
|
||||
|
||||
UpdateProjectionMatrix();
|
||||
UpdateViewMatrix();
|
||||
}
|
||||
|
||||
glm::vec3 Camera::Forward()
|
||||
{
|
||||
return glm::rotate(glm::vec3(0.f, 0.f, -1.f), -m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
}
|
||||
//glm::vec3 Camera::Forward()
|
||||
//{
|
||||
// return glm::rotate(glm::vec3(0.f, 0.f, -1.f), -m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
//}
|
||||
//
|
||||
//glm::vec3 Camera::Right()
|
||||
//{
|
||||
// return glm::rotate(glm::vec3(1.f, 0.f, 0.f), -m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
//}
|
||||
|
||||
glm::vec3 Camera::Right()
|
||||
{
|
||||
return glm::rotate(glm::vec3(1.f, 0.f, 0.f), -m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
}
|
||||
|
||||
glm::mat4 Camera::Orientation()
|
||||
{
|
||||
glm::mat4 orientation(1.f);
|
||||
orientation = glm::rotate(orientation, m_Pitch, glm::vec3(1.f, 0.f, 0.f));
|
||||
orientation = glm::rotate(orientation, m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
return orientation;
|
||||
}
|
||||
//glm::mat4 Camera::Orientation()
|
||||
//{
|
||||
// glm::mat4 orientation(1.f);
|
||||
// orientation = glm::rotate(orientation, m_Pitch, glm::vec3(1.f, 0.f, 0.f));
|
||||
// orientation = glm::rotate(orientation, m_Yaw, glm::vec3(0.f, 1.f, 0.f));
|
||||
// return orientation;
|
||||
//}
|
||||
|
||||
void Camera::AspectRatio(float val)
|
||||
{
|
||||
@@ -46,17 +46,23 @@ void Camera::Position(glm::vec3 val)
|
||||
}
|
||||
|
||||
|
||||
void Camera::Pitch(float val)
|
||||
void Camera::Orientation(glm::quat val)
|
||||
{
|
||||
m_Pitch = val;
|
||||
m_Orientation = val;
|
||||
UpdateViewMatrix();
|
||||
}
|
||||
|
||||
void Camera::Yaw(float val)
|
||||
{
|
||||
m_Yaw = val;
|
||||
UpdateViewMatrix();
|
||||
}
|
||||
//void Camera::Pitch(float val)
|
||||
//{
|
||||
// m_Pitch = val;
|
||||
// UpdateViewMatrix();
|
||||
//}
|
||||
//
|
||||
//void Camera::Yaw(float val)
|
||||
//{
|
||||
// m_Yaw = val;
|
||||
// UpdateViewMatrix();
|
||||
//}
|
||||
|
||||
void Camera::UpdateProjectionMatrix()
|
||||
{
|
||||
@@ -70,5 +76,5 @@ void Camera::UpdateProjectionMatrix()
|
||||
|
||||
void Camera::UpdateViewMatrix()
|
||||
{
|
||||
m_ViewMatrix = glm::translate(Orientation(), -m_Position);
|
||||
m_ViewMatrix = glm::translate(glm::toMat4(m_Orientation), -m_Position);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtx/rotate_vector.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
class Camera
|
||||
{
|
||||
@@ -14,7 +16,7 @@ public:
|
||||
|
||||
glm::vec3 Forward();
|
||||
glm::vec3 Right();
|
||||
glm::mat4 Orientation();
|
||||
glm::quat Orientation();
|
||||
|
||||
float AspectRatio() const { return m_AspectRatio; }
|
||||
void AspectRatio(float val);
|
||||
@@ -22,10 +24,13 @@ public:
|
||||
glm::vec3 Position() const { return m_Position; }
|
||||
void Position(glm::vec3 val);
|
||||
|
||||
float Pitch() const { return m_Pitch; }
|
||||
glm::quat Orientation() const { return m_Orientation; }
|
||||
void Orientation(glm::quat val);
|
||||
|
||||
/*float Pitch() const { return m_Pitch; }
|
||||
void Pitch(float val);
|
||||
float Yaw() const { return m_Yaw; }
|
||||
void Yaw(float val);
|
||||
void Yaw(float val);*/
|
||||
|
||||
glm::mat4 ProjectionMatrix() const { return m_ProjectionMatrix; }
|
||||
void ProjectionMatrix(glm::mat4 val) { m_ProjectionMatrix = val; }
|
||||
@@ -43,8 +48,9 @@ private:
|
||||
float m_FarClip;
|
||||
|
||||
glm::vec3 m_Position;
|
||||
float m_Pitch;
|
||||
float m_Yaw;
|
||||
glm::quat m_Orientation;
|
||||
//float m_Pitch;
|
||||
//float m_Yaw;
|
||||
|
||||
glm::mat4 m_ProjectionMatrix;
|
||||
glm::mat4 m_ViewMatrix;
|
||||
|
||||
Reference in New Issue
Block a user