-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.h
51 lines (33 loc) · 1.02 KB
/
Camera.h
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
48
49
50
51
#pragma once
#include "GLWindow.h"
class Camera
{
public:
Camera();
void LookAt(const vec3 &pos, const vec3 &t, const vec3 &up);
void UpdateProjection();
void FocalLength(const float &fovmm);
void FieldOfView(const float &fovy){ fov = fovy; };
float FieldOfViewH() const{ return fov * aspect; };
float FieldOfViewV() const{ return fov; };
void AspectRatio(const float &ar){ aspect = ar; };
void AspectRatio(const unsigned &w, const unsigned &h);
float AspectRatio() const{ return aspect; };
void NearP(const float &n){ nearp = n; };
void FarP(const float &f){ farp = f; };
float NearP() const{ return nearp; };
float FarP() const{ return farp; };
mat4 *MVP(){ return &mvpm; };
mat4 *MV(){ return &viewm; };
mat4 *P(){ return &projm; };
float TanHalfFOV() const{ return tanhalffov; };
vec3 Position() const{ return position; };
private:
vec3 position;
mat4 viewm, projm, mvpm, lastm;
float fov; // vertical fov
float tanhalffov;
float aspect; // aspect ratio
float nearp, farp;
float focallength;
};