everything

This commit is contained in:
Tarion 2026-07-02 04:02:29 +02:00
parent 79fa59c3aa
commit 8998bc3936
No known key found for this signature in database
19 changed files with 855 additions and 7504 deletions

View file

@ -11,13 +11,14 @@ enum Camera_Movement {
FORWARD,
BACKWARD,
LEFT,
RIGHT
RIGHT,
SPRINT
};
// Default camera values
const float YAW = -90.0f;
const float PITCH = 0.0f;
const float SPEED = 2.5f;
const float SPEED = 5.5f;
const float SENSITIVITY = 0.1f;
const float ZOOM = 45.0f;
@ -27,6 +28,7 @@ public:
glm::vec3 position, front, up, right, worldUp;
float yaw, pitch;
float movementSpeed, mouseSensitivity, zoom;
bool sprinting = false;
// constructor with vectors
Camera(glm::vec3 newPosition = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f), float newYaw = YAW, float newPitch = PITCH) : front(glm::vec3(0.0f, 0.0f, -1.0f)), movementSpeed(SPEED), mouseSensitivity(SENSITIVITY), zoom(ZOOM)
@ -57,6 +59,9 @@ public:
void processKeyboard(Camera_Movement direction, float deltaTime)
{
float velocity = movementSpeed * deltaTime;
if (sprinting)
velocity *= 8;
if (direction == FORWARD)
position += front * velocity;
if (direction == BACKWARD)
@ -65,6 +70,8 @@ public:
position -= right * velocity;
if (direction == RIGHT)
position += right * velocity;
if (direction == SPRINT)
sprinting = !sprinting;
}
// processes input received from a mouse input system. Expects the offset value in both the x and y direction.
@ -100,6 +107,14 @@ public:
zoom = 45.0f;
}
void Update(Shader shader, int screenWidth, int screenHeight)
{
glm::mat4 projection = glm::perspective(glm::radians(zoom), (float)screenWidth / (float)screenHeight, 0.1f, 100.0f);
shader.setMat4("projection", projection);
shader.setMat4("view", GetViewMatrix());
shader.setVec3("viewPos", position);
}
private:
// calculates the front vector from the Camera's (updated) Euler Angles