-
Notifications
You must be signed in to change notification settings - Fork 7
/
Camera.h
63 lines (42 loc) · 1.45 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
52
53
54
55
56
57
58
59
60
61
62
63
/****************************************************************************
Copyright (C) 2012 Adrian Blumer ([email protected])
Copyright (C) 2012 Pascal Spörri ([email protected])
Copyright (C) 2012 Sabina Schellenberg ([email protected])
All Rights Reserved.
You may use, distribute and modify this code under the terms of the
MIT license (http://opensource.org/licenses/MIT).
*****************************************************************************/
#ifndef CAMERA_H
#define CAMERA_H
#include "platform_includes.h"
#include <glm/gtc/quaternion.hpp>
// Backwards compatibility
#define GLM_FORCE_RADIANS
using namespace glm;
class Camera
{
public:
Camera();
void SetProjection(float angle=45.0f, float aspect=800.0f/600.0f, float near=0.1f, float far=100.0f);
void SetAspectRatio(float aspect);
/// Matrix access
const glm::mat4x4& ProjMatrix();
const glm::mat4x4& ViewMatrix();
// Transform
void TranslateGlobal(const glm::vec3& delta);
void TranslateLocal(const glm::vec3& delta);
void LocalRotate(const glm::vec3& axis, float angle);
void GlobalRotate(const glm::vec3& axis, float angle);
protected:
void recomputeViewMatrix();
protected:
glm::vec3 _position;
glm::fquat _forward;
glm::fquat _upward;
glm::mat4x4 _viewMatrix;
glm::mat4x4 _projMatrix;
float _angle;
float _near, _far;
float _aspect;
};
#endif // CAMERA_H