-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.h
More file actions
40 lines (26 loc) · 733 Bytes
/
Camera.h
File metadata and controls
40 lines (26 loc) · 733 Bytes
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
#pragma once
#include <glm/ext.hpp>
#include <GLFW/glfw3.h>
#include <glfw3webgpu.h>
struct DragState {
bool dragging = false;
glm::vec2 startMousePos = glm::vec2(0.);
glm::vec2 startCameraAngles = glm::vec2(0.);
};
class Camera
{
public:
// interaction state
DragState dragState;
// camera state
//glm::vec2 angles = { 0.0f, 0.0f }; // in radians
//float zoom = -0.5f;
// for my model (TODO refactor)
glm::vec2 angles = { 3.14159 / 2, 0.1f }; // in radians
float zoom = -1.0f;
glm::mat4 projMatrix = glm::perspective(glm::radians(45.0f), 640.0f / 480.0f, 0.1f, 1000.0f);
public:
void getViewMatrix(glm::mat4& outViewMatrix);
void getProjMatrix(glm::mat4& outModelMatrix);
glm::vec3 getPosition();
};