im dissapointed w how little i got done this weekend
This commit is contained in:
@@ -33,9 +33,9 @@ Camera::Camera(int w, int h) {
|
|||||||
void Camera::UpdateView() {
|
void Camera::UpdateView() {
|
||||||
|
|
||||||
// roll can be removed
|
// roll can be removed
|
||||||
glm::mat4 matRoll = glm::mat4(1.0f); //identity matrix;
|
glm::mat4 matRoll = glm::mat4(1.0f);
|
||||||
glm::mat4 matPitch = glm::mat4(1.0f);//identity matrix
|
glm::mat4 matPitch = glm::mat4(1.0f);
|
||||||
glm::mat4 matYaw = glm::mat4(1.0f); //identity matrix
|
glm::mat4 matYaw = glm::mat4(1.0f);
|
||||||
|
|
||||||
// roll, pitch and yaw
|
// roll, pitch and yaw
|
||||||
matRoll = glm::rotate(matRoll, roll, glm::vec3(0.0f, 0.0f, 1.0f));
|
matRoll = glm::rotate(matRoll, roll, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
@@ -70,6 +70,12 @@ glm::mat4 Camera::GetProjectionMatrix() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::mat4 Camera::GetFrustrumMatrix() {
|
||||||
|
|
||||||
|
return viewMatrix * projMatrix;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Camera::UpdateProjection(int width, int height) {
|
void Camera::UpdateProjection(int width, int height) {
|
||||||
|
|
||||||
projMatrix = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 1000.0f);
|
projMatrix = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 1000.0f);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public:
|
|||||||
|
|
||||||
glm::mat4 GetViewMatrix();
|
glm::mat4 GetViewMatrix();
|
||||||
glm::mat4 GetProjectionMatrix();
|
glm::mat4 GetProjectionMatrix();
|
||||||
|
glm::mat4 GetFrustrumMatrix();
|
||||||
|
|
||||||
void UpdateProjection(int width, int height);
|
void UpdateProjection(int width, int height);
|
||||||
|
|
||||||
@@ -22,7 +23,9 @@ public:
|
|||||||
float MouseSensitivity = 0.1f;
|
float MouseSensitivity = 0.1f;
|
||||||
float CameraSpeed = 2.0f;
|
float CameraSpeed = 2.0f;
|
||||||
|
|
||||||
|
// Influences the views update
|
||||||
glm::vec3 Position = {};
|
glm::vec3 Position = {};
|
||||||
|
// Only updated after the view is updated
|
||||||
glm::vec3 LookDirection = {};
|
glm::vec3 LookDirection = {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -13,7 +13,19 @@ Entity::Entity(glm::vec3 postion, glm::vec3 direction, std::shared_ptr<Camera> c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Player {
|
Player::Player(glm::vec3 position, glm::vec3 direction, std::shared_ptr<Camera> camera)
|
||||||
|
: Entity(position, direction, camera) {
|
||||||
|
|
||||||
|
camera->Position =
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player(glm::vec3 position, glm::vec3 direction = {0.0f, 0.0f, 0.0f});
|
||||||
|
|
||||||
|
void Move(Uint8* state);
|
||||||
|
void HandleMouse(SDL_Event e);
|
||||||
|
|
||||||
|
void UpdatePosition(glm::vec3 position);
|
||||||
|
void UpdateDirection(glm::vec3 direction);
|
||||||
|
|
||||||
|
void CameaUpdateProjection(int xres, int yres);
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ public:
|
|||||||
|
|
||||||
Entity(glm::vec3 position, glm::vec3 direction = { 0.0f, 0.0f, 0.0f }, std::shared_ptr<Camera> camera = std::make_shared<Camera>());
|
Entity(glm::vec3 position, glm::vec3 direction = { 0.0f, 0.0f, 0.0f }, std::shared_ptr<Camera> camera = std::make_shared<Camera>());
|
||||||
|
|
||||||
bool Player = false;
|
|
||||||
|
|
||||||
// World position, 1.7 units below the
|
// World position, 1.7 units below the
|
||||||
// camera position.
|
// camera position.
|
||||||
glm::vec3 Position;
|
glm::vec3 Position;
|
||||||
@@ -36,7 +34,7 @@ public:
|
|||||||
class Player : public Entity {
|
class Player : public Entity {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Player(glm::vec3 position, glm::vec3 direction = {0.0f, 0.0f, 0.0f});
|
Player(glm::vec3 position, glm::vec3 direction, std::shared_ptr<Camera> camera);
|
||||||
|
|
||||||
void Move(Uint8* state);
|
void Move(Uint8* state);
|
||||||
void HandleMouse(SDL_Event e);
|
void HandleMouse(SDL_Event e);
|
||||||
|
|||||||
Reference in New Issue
Block a user