-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.hpp
More file actions
47 lines (33 loc) · 1.17 KB
/
camera.hpp
File metadata and controls
47 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// https://github.com/TheCherno/RayTracing/blob/master/RayTracing/src/Camera.h
#pragma once
#include "framework.h"
class Camera
{
public:
Camera(int width, int height, float fov = glm::radians(70.0),
float nearPlane = 0.01, float farPlane = 100);
//float left = -1.0f, float right = 1.0f, float bottom = -1.0f, float top = 1.0f);
std::vector<glm::vec3>& getOrthographicRayOrigins();
glm::vec3& getRayOrigin() { return position; }
std::vector<glm::vec3>& getRayDirections();
void onResize(int width, int height);
void onUpdate(int key, float deltaTime);
void onMouseUpdate(glm::vec2 offset, float deltaTime);
glm::vec3 position;
void calculateRayDirections();
private:
float speed, rotationSpeed;
glm::vec3 forwardDirection, rightDirection, upDirection;
const glm::vec3 worldUpDirection = glm::vec3(0.0f, 1.0f, 0.0f);
float fov, nearPlane, farPlane;
//float left, right, bottom, top;
int viewportWidth, viewportHeight;
void calculateProjMatrix();
void calculateViewMatrix();
glm::mat4 projMatrix;
glm::mat4 viewMatrix;
glm::mat4 inverseProjMatrix;
glm::mat4 inverseViewMatrix;
std::vector<glm::vec3> rayOrigins;
std::vector<glm::vec3> rayDirections;
};