group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Camera.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <glm/glm.hpp>
7
10{
11public:
13 NewCamera();
14
18 void setAspect(float width, float height);
19
22 void setFov(float fovyDegrees);
23
26 void setZNear(float zNear);
27
30 void setZFar(float zFar);
31
34 void setEye(glm::vec3 eye);
35
43 void setTarget(float pitch, float yaw, float roll);
44
47 void setUp(glm::vec3 up);
48
51
53 [[nodiscard]] glm::mat4 getViewProjectionMatrix() const { return view_projection_; }
54
56 [[nodiscard]] glm::mat4 getViewProjection() const { return view_projection_; }
57
58 [[nodiscard]] const glm::vec3& getEye() const { return eye_; }
59 [[nodiscard]] glm::vec3 getForward() const;
60 [[nodiscard]] glm::vec3 getRight() const;
61 [[nodiscard]] const glm::vec3& getUp() const { return up_; }
62
63private:
64 glm::vec3 eye_{0.0f, 0.0f, 3.0f};
65 glm::vec3 target_{0.0f, 0.0f, 0.0f};
66 glm::vec3 up_{0.0f, 1.0f, 0.0f};
67
68 // Near/far are sized for Quake units.
69 float fovy_ = glm::radians(60.0f);
70 float aspect_ = 1.0f;
71 float zNear_ = 5.0f;
72 float zFar_ = 15000.0f;
73
74 glm::mat4 view_projection_{1.0f};
75};
glm::mat4 view_projection_
Definition Camera.hpp:74
glm::vec3 up_
Definition Camera.hpp:66
float fovy_
Definition Camera.hpp:69
float zFar_
Far clip; covers the 4 000-unit play area with margin.
Definition Camera.hpp:72
void setEye(glm::vec3 eye)
Set the camera eye position in world space (modifies view matrix).
Definition Camera.cpp:35
float zNear_
Near clip (Quake units); 5 ≈ half a foot.
Definition Camera.hpp:71
const glm::vec3 & getUp() const
Definition Camera.hpp:61
void setZFar(float zFar)
Set the far clip plane distance.
Definition Camera.cpp:30
glm::vec3 target_
Definition Camera.hpp:65
void setUp(glm::vec3 up)
Explicitly set the camera up direction, overriding setTarget's up vector.
Definition Camera.cpp:57
void computeViewProjectionMatrix()
Recompute the combined view-projection matrix from current parameters.
Definition Camera.cpp:62
glm::mat4 getViewProjectionMatrix() const
Return the combined view-projection matrix.
Definition Camera.hpp:53
NewCamera()
Construct a NewCamera with default perspective and position.
Definition Camera.cpp:10
glm::vec3 eye_
Definition Camera.hpp:64
const glm::vec3 & getEye() const
Definition Camera.hpp:58
void setAspect(float width, float height)
Set the aspect ratio from pixel dimensions (modifies projection matrix).
Definition Camera.cpp:15
void setFov(float fovyDegrees)
Set the vertical field of view in degrees.
Definition Camera.cpp:20
glm::vec3 getRight() const
Definition Camera.cpp:74
void setZNear(float zNear)
Set the near clip plane distance.
Definition Camera.cpp:25
glm::mat4 getViewProjection() const
Alias for getViewProjectionMatrix() — kept short for callsite ergonomics.
Definition Camera.hpp:56
float aspect_
Definition Camera.hpp:70
glm::vec3 getForward() const
Definition Camera.cpp:69
void setTarget(float pitch, float yaw, float roll)
Set the view direction from pitch, yaw, and roll (all in radians).
Definition Camera.cpp:41