-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.h
More file actions
99 lines (80 loc) · 2.28 KB
/
Copy pathCamera.h
File metadata and controls
99 lines (80 loc) · 2.28 KB
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
97
98
99
/*
* Camera.h
* 3d Ink
*
* Based on code provided by Geng Sun, Durham University
*
*/
#include <GLUT/GLUT.h>
#include <cmath>
#include "Settings.h"
#include "Model.h"
#include "Controller.h"
#if !defined(CAMERA_H)
#define CAMERA_H
class Camera {
protected:
GLdouble zViewing; // viewing distance from viewer to the display
GLdouble eyeSeperation;
GLdouble distanceToVirtualDisplay;
GLdouble halfWidth;
GLdouble height;
GLdouble cameraSeperation;
GLdouble displayRatio;
GLdouble sceneZ;
GLdouble sceneWidth;
GLdouble sceneHeight;
GLdouble viewingAngle;
GLdouble theta;
public:
Camera(GLdouble zViewing, GLdouble displayWidth, GLdouble pHeight, GLdouble pWidth) {
this->zViewing = zViewing;
this->eyeSeperation = 65.0/2.0;
this->halfWidth=displayWidth/2.0;
this->displayRatio= (pHeight/pWidth);
this->height = halfWidth * displayRatio;
this->viewingAngle = atan(halfWidth/zViewing) * 180.0 / M_PI * 2;
this->theta = viewingAngle * (M_PI/180.0);
Settings::vAngle = theta;
}
~Camera() {
}
virtual void setupFrustum(GLdouble nearDisplayBoundary, GLdouble farDisplayBoundary, GLdouble nearSceneBoundary, GLdouble farSceneBoundary)=0;
};
/*
* Stereo Camera
*/
class StereoCamera: public Camera {
private:
GLdouble leftFrustum[6];
GLdouble rightFrustum[6];
GLdouble leftFrom;
GLdouble leftTo[3];
GLdouble rightFrom;
GLdouble rightTo[3];
public:
StereoCamera(GLdouble zViewing, GLdouble displayWidth, GLdouble pixelHeight, GLdouble pixelWidth): Camera(zViewing, displayWidth, pixelHeight, pixelWidth) {
}
void setupFrustum(GLdouble nearDisplayBoundary, GLdouble farDisplayBoundary, GLdouble nearSceneBoundary, GLdouble farSceneBoundary);
double* getLeftFrustum();
double* getRightFrustum();
double getLeftFrom();
double* getLeftTo();
double getRightFrom();
double* getRightTo();
};
/*
* Mono Camera
*/
class MonoCamera: public Camera {
private:
double monoFrustum[6];
double monoTo;
public:
MonoCamera(GLdouble zViewing, GLdouble displayWidth, GLdouble pixelHeight, GLdouble pixelWidth): Camera(zViewing, displayWidth, pixelHeight, pixelWidth) {
}
void setupFrustum(GLdouble nearDisplayBoundary, GLdouble farDisplayBoundary, GLdouble nearSceneBoundary, GLdouble farSceneBoundary);
double* getMonoFrustum();
double getMonoTo();
};
#endif