-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcamera.cpp
More file actions
87 lines (75 loc) · 1.25 KB
/
camera.cpp
File metadata and controls
87 lines (75 loc) · 1.25 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
/* camera.cpp
*
* Omkar H. Ramachandran
* omkar.ramachandran@colorado.edu
*
* Simple rotating triangle
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include <cstdio>
#include "camera.h"
// Amount by which the camera will move in any direction - in degrees
const int move_amt = 7.0f;
Camera::Camera(){
th = 90.0f;
ph = 320.0f;
r = 10.0f;
beta_x = 0.6;
}
float Camera::Getr(){
return r;
}
void Camera::Move(int dir){
switch(dir){
case 1: // +th
th += move_amt;
if(th>360.0f){
th-=360.0f;
}
break;
case -1: // -th
th -= move_amt;
if(th<=0.0f){
th+=360.0f;
}
break;
case 2: // ph
ph += move_amt;
if(ph>=360.0f){
ph-=360.0f;
}
break;
case -2: // -ph
ph -= move_amt;
if(ph<=0.0f){
ph+=360.0f;
}
break;
default:
break;
}
}
void Camera::Zoom(float dr){
r += dr;
}
void Camera::Changebeta(float dr){
if((beta_x>=0.0 && beta_x+dr <= 1.0) ||
(beta_x<=0.0 && beta_x+dr >= -1.0)){
beta_x += dr;
fprintf(stderr,"Beta = %f\n",beta_x);
}else
fprintf(stderr,"Beta approaching 1!\n");
}
void Camera::print(){
fprintf(stderr,"Theta = %f ; Phi = %f\n",th,ph);
}
float Camera::Getth(){
return th;
}
float Camera::Getph(){
return ph;
}
double Camera::Getbeta(){
return beta_x;
}