Class Camera¶
Defined in File camera.hpp
Class Documentation¶
-
class Camera¶
Warning
Not thread safe!
Public Functions
-
Camera(const glm::vec3 &position, float yaw, float pitch, float window_width, float window_height)¶
Default constructor.
- Parameters
position – The camera’s position.
yaw – The camera’s yaw angle in degrees.
pitch – The camera’s pitch angle in degrees.
window_width – The width of the window.
window_height – The height of the window.
-
void set_type(CameraType type)¶
Set the camera type.
Note
We will implement more camera types in the future.
- Parameters
type – The camera type.
-
inline const CameraType &type() const¶
-
void set_movement_state(CameraMovement key, bool pressed)¶
Notify the camera if a certain key is pressed or released.
- Parameters
key – The key which was pressed or released.
pressed –
true
if the key is pressed.
-
void set_position(glm::vec3 position)¶
Set the position of the camera.
- Parameters
position – The position of the camera.
-
inline const glm::vec3 &position() const¶
-
void set_aspect_ratio(float width, float height)¶
Set the aspect ratio (window width divided by window height) of the camera view matrix.
- Parameters
width – The width of the window.
height – The height of the window.
-
inline float aspect_ratio() const¶
-
inline float fov() const¶
-
void set_movement_speed(float speed)¶
Set the movement speed of the camera.
- Parameters
speed – The movement speed of the camera.
-
inline float movement_speed() const¶
-
void set_rotation_speed(float speed)¶
Set the rotation speed of the camera.
- Parameters
speed – The rotation speed of the camera.
-
inline float rotation_speed() const¶
-
void rotate(float delta_yaw, float delta_pitch, float delta_roll = 0.0f)¶
Rotates the camera around x, y, and z axis.
- Parameters
delta_yaw – The yaw angle.
delta_pitch – The pitch angle.
delta_roll – The roll angle.
-
void set_rotation(float yaw, float pitch, float roll)¶
Set the camera’s rotation.
- Parameters
yaw – The yaw angle.
pitch – The pitch angle.
roll – The roll angle.
-
inline const glm::vec3 &rotation() const¶
-
inline float yaw() const¶
-
inline float pitch() const¶
-
inline float roll() const¶
-
inline const glm::vec3 &front() const¶
-
inline const glm::vec3 &up() const¶
-
inline const glm::vec3 &right() const¶
-
void set_near_plane(float near_plane)¶
Set the near plane distance of the camera.
- Parameters
near_plane – The near plane distance.
-
inline float near_plane() const¶
-
void set_far_plane(float far_plane)¶
Set the far plane distance of the camera.
- Parameters
far_plane – The far plane distance.
-
inline float far_plane() const¶
-
void change_zoom(float offset)¶
Change the zoom of the camera.
- Parameters
offset – The mouse wheel offset change.
-
void update(float delta_time)¶
Update the camera (recalculate vectors and matrices).
- Parameters
delta_time – The change in time since the last frame.
-
inline const glm::mat4 &view_matrix()¶
-
inline const glm::mat4 &perspective_matrix()¶
Private Members
-
CameraType m_type = {CameraType::LOOK_AT}¶
The type of the camera. Currently only one type is implemented.
-
glm::vec3 m_position = {0.0f, 0.0f, 0.0f}¶
The start position of the camera.
-
glm::vec3 m_front = {directions::DEFAULT_FRONT}¶
The vector of direction in which the camera is looking.
-
glm::vec3 m_right = {directions::DEFAULT_RIGHT}¶
The vector of direction which points to the right.
-
glm::vec3 m_up = {directions::DEFAULT_UP}¶
The vector which indicates “upwards”.
-
glm::vec3 m_world_up = {directions::DEFAULT_UP}¶
The world vector which indicates “upwards”.
-
glm::mat4 m_view_matrix = {}¶
-
glm::mat4 m_perspective_matrix = {}¶
-
float m_yaw = {0.0f}¶
The camera’s yaw angle.
-
float m_roll = {0.0f}¶
The camera’s roll angle.
-
float m_pitch = {0.0f}¶
The camera’s pitch angle.
-
float m_pitch_min = {-89.0f}¶
The camera’s minimum pitch angle. Looking straight downwards is the maximum pitch angle.
-
float m_pitch_max = {+89.0f}¶
The camera’s maximum pitch angle. Looking straight upwards is the maximum pitch angle.
-
float m_fov = {90.0f}¶
The camera’s horizontal field of view.
-
float m_fov_max = {90.0f}¶
The camera’s maximum field of view.
-
float m_fov_min = {20.0f}¶
The camera’s minimum field of view.
-
float m_zoom_step = {10.0f}¶
The zoom step when zooming in or out.
-
float m_rotation_speed = {1.0f}¶
The camera’s rotation speed.
-
float m_movement_speed = {2.0f}¶
The camera’s movement speed.
-
float m_aspect_ratio = {1920.0f / 1080.0f}¶
The camera’s aspect ratio (width divided by height).
-
float m_mouse_sensitivity = {0.005f}¶
The sensitivity of the mouse.
-
float m_near_plane = {0.001f}¶
The camera’s near plane.
-
float m_far_plane = {1000.0f}¶
The camera’s far plane.
-
std::array<bool, 4> m_keys = {false, false, false, false}¶
The keys for the movement FORWARD, BACKWARD, LEFT, RIGHT.
-
float m_vertical_fov = {0.0f}¶
-
bool m_update_vertical_fov = {false}¶
-
bool m_update_view_matrix = {false}¶
-
bool m_update_perspective_matrix = {false}¶
-
Camera(const glm::vec3 &position, float yaw, float pitch, float window_width, float window_height)¶