-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCamera.h
79 lines (55 loc) · 1.92 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// -----------------------------------------------------------------------------
// libDDG -- Camera.h
// -----------------------------------------------------------------------------
//
// Camera is used by Viewer to keep track of the view state; it also
// handles mouse input related to camera manipulation.
//
#ifndef DDG_CAMERA_H
#define DDG_CAMERA_H
#include "Quaternion.h"
#include "glm/mat4x4.hpp"
namespace DDG
{
class Camera
{
public:
Camera(float x, float y, float z, float w);
// constructor
void setHorizontalLock(bool newLock);
Quaternion clickToSphere( float x, float y, float w, float h );
// projects a mouse click onto the unit sphere
glm::mat4 getView( bool reverse = false) const;
glm::mat4 setView( ) const;
// applies the camera transformation to the OpenGL modelview stack
void mouse( int state, float x, float y, float w, float h );
// handles mouse clicks
void motion( float x, float y, float w, float h );
// handles mouse drags
void idle( void );
// handles camera momentum
void zoomIn( void );
// moves viewer toward object
void zoomOut( void );
// moves viewer away from object
Quaternion currentRotation( void ) const;
// returns the rotation corresponding to the current mouse state
Quaternion pClick;
// mouse coordinates of current click
Quaternion pDrag;
// mouse coordinates of current drag
Quaternion pLast;
// mouse coordinates of previous drag
Quaternion rLast;
// previous camera rotation
Quaternion momentum;
// camera momentum
int tLast;
// time of previous drag
double zoom, vZoom;
bool lock;
enum { BOTH_AXES, X_AXIS, Y_AXIS} axis;
// zoom and zoom velocity
};
}
#endif