ThreeLab/Engine/Components/Camera.h

48 lines
1.2 KiB
C
Raw Normal View History

2025-04-01 16:53:23 +00:00
#ifndef CAMERA_H
#define CAMERA_H
#include "Component.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
// A simple Camera component that inherits from Component.
class Camera : public Component {
public:
Camera();
virtual ~Camera();
// Override update (if needed, e.g. for smoothing or input handling).
virtual void Update(float deltaTime) override;
// Set the camera's position.
void SetPosition(const glm::vec3& pos);
// Set the camera's rotation in degrees.
void SetRotation(float yaw, float pitch);
// Get the view matrix calculated from position and rotation.
glm::mat4 GetViewMatrix() const;
// Get the projection matrix.
glm::mat4 GetProjectionMatrix() const;
// Set perspective projection parameters.
void SetPerspective(float fov, float aspect, float nearPlane, float farPlane);
// Getters.
glm::vec3 GetPosition() const;
float GetYaw() const;
float GetPitch() const;
private:
glm::vec3 position;
float yaw;
float pitch;
// Perspective projection parameters.
float fov;
float aspect;
float nearPlane;
float farPlane;
};
#endif // CAMERA_H