This repository has been archived by the owner on Apr 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.h
96 lines (74 loc) · 2.3 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// This camera stuff mostly by ehsu
#ifndef CAMERA_H
#define CAMERA_H
#include "vec.h"
//
#include "mat.h"
//==========[ class Camera ]===================================================
typedef enum {
kActionNone,
kActionTranslate,
kActionRotate,
kActionZoom,
kActionTwist,
} MouseAction_t;
class Camera {
protected:
float mElevation;
float mAzimuth;
float mDolly;
float mTwist; // Not implemented yet
Vec3f mLookAt;
Vec3f mPosition;
Vec3f mUpVector;
bool mDirtyTransform;
void calculateViewingTransformParameters();
Vec3f mLastMousePosition;
MouseAction_t mCurrentMouseAction;
public:
//---[ Constructors ]----------------------------------
// defaults to (0,0,0) facing down negative z axis
Camera();
//---[ Settings ]--------------------------------------
inline void setElevation(float elevation) {
// don't want elevation to be negative
if (elevation < 0)
elevation += 6.28318530717f;
mElevation = elevation;
mDirtyTransform = true;
}
inline float getElevation() const { return mElevation; }
inline void setAzimuth(float azimuth) {
mAzimuth = azimuth;
mDirtyTransform = true;
}
inline float getAzimuth() const { return mAzimuth; }
inline void setDolly(float dolly) {
mDolly = dolly;
mDirtyTransform = true;
}
inline float getDolly() const { return mDolly; }
inline void setTwist(float twist) {
mTwist = twist;
mDirtyTransform = true;
}
inline float getTwist() const { return mTwist; }
inline void setLookAt(const Vec3f &lookAt) {
mLookAt = lookAt;
mDirtyTransform = true;
}
inline Vec3f getLookAt() const { return mLookAt; }
//---[ Interactive Adjustment ]------------------------
// these should be used from a mouse event handling routine that calls
// the startX method on a mouse down, updateX on mouse move and finally
// endX on mouse up.
//-----------------------------------------------------
void clickMouse(MouseAction_t action, int x, int y);
void dragMouse(int x, int y);
void releaseMouse(int x, int y);
//---[ Viewing Transform ]--------------------------------
void applyViewingTransform();
// gluLookAt equivalent
void lookAt(Vec3f eye, Vec3f at, Vec3f up);
};
#endif