-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCamera.h
94 lines (76 loc) · 2.89 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
//
// Created by Jackson Hall on 4/27/2020.
//
#ifndef PART_2___GRAPHICS_ALTERNATE_CAMERA_H
#define PART_2___GRAPHICS_ALTERNATE_CAMERA_H
#include "utils.h"
#include <memory>
#include <vector>
class Camera {
public:
/** ---------- Enums ---------- */
enum CameraType {
Camera3D,
Camera4D
};
enum MovementMode {
// Move by a fixed distance left/right/up/etc
Fixed,
// Use acceleration and velocity to glide around
Fly
};
/** ---------- Static Const Vars ---------- */
// Distance in blocks the camera moves
static const double DEFAULT_MOVE_DISTANCE;
// Angle in degrees the camera rotates by default
static const double DEFAULT_ROTATION_ANGLE;
/** ---------- Constructors ---------- */
explicit Camera(double focalDistance, MovementMode movementMode);
/** ---------- Static Methods ---------- */
static double getFocalDistanceFromFOV(double fovDegrees,
double screenWidthBlocks);
/** ---------- Getters ---------- */
double getFocalDistance() const;
MovementMode getMovementMode();
/** ---------- Setters ---------- */
/* Utility */
void setFocalDistance(double newFocalDistance);
void toggleMovementMode();
virtual void setFocus() = 0;
/* Movement */
virtual void setLocation(std::vector<double> newLocation) = 0;
/* Rotation */
virtual void setNormal() = 0;
virtual void setSphericalDirection(std::vector<double> newAngles) = 0;
/** ---------- Other Methods ---------- */
/* Movement */
virtual void moveAbsolute(std::vector<double> dPosition) = 0;
virtual void moveAbsolute(const spatialVector& dPosition) = 0;
/**
* Take a vector of doubles <forward, right, up> and move in given
* directions relative to camera orientation. Ex. if 'forward'
* value negative, move backward, etc.
*/
virtual void moveRelative(const std::vector<double>& dPosition) = 0;
/**
* Take a spatialVector <forward, right, up> and move in given directions
* relative to camera orientation. Ex. if 'forward' value negative, move
* backward, etc.
* @param dPosition
*/
virtual void moveRelative(const spatialVector& dPosition) = 0;
/* Rotation */
virtual void rotate(std::vector<double> dAngles) = 0;
protected:
// Distance in the direction opposite the Camera's normal from its
// coordinate location to the focus. Used to set the focus point
double focalDistance{};
// Movement mode for this Camera.
// Fixed mode: Pressing movement keys moves Camera by a fixed distance
// each tick.
// Fly mode: Pressing movement keys sets directional acceleration that is
// used to update velocity fields, which decay to 0 over time when keys
// are released. See public static constants above.
MovementMode movementMode;
};
#endif //PART_2___GRAPHICS_ALTERNATE_CAMERA_H