08ada8c2
David Mayerich
updated image to ...
|
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
|
void render_scene();
void draw_colorcube() {
glBegin(GL_LINES); //start a line series
glColor3f(0, 0, 0);
glVertex3f(-0.5, -0.5, -0.5);
glColor3f(1, 0, 0);
glVertex3f(0.5, -0.5, -0.5);
glColor3f(0, 0, 0);
glVertex3f(-0.5, -0.5, -0.5);
glColor3f(0, 1, 0);
glVertex3f(-0.5, 0.5, -0.5);
glColor3f(0, 0, 0);
glVertex3f(-0.5, -0.5, -0.5);
glColor3f(0, 0, 1);
glVertex3f(-0.5, -0.5, 0.5);
glColor3f(1, 1, 1);
glVertex3f(0.5, 0.5, 0.5);
glColor3f(1, 1, 0);
glVertex3f(0.5, 0.5, -0.5);
glColor3f(1, 1, 1);
glVertex3f(0.5, 0.5, 0.5);
glColor3f(1, 0, 1);
glVertex3f(0.5, -0.5, 0.5);
glColor3f(1, 1, 1);
glVertex3f(0.5, 0.5, 0.5);
glColor3f(0, 1, 1);
glVertex3f(-0.5, 0.5, 0.5);
glColor3f(1, 0, 0);
glVertex3f(0.5, -0.5, -0.5);
glColor3f(1, 1, 0);
glVertex3f(0.5, 0.5, -0.5);
glColor3f(1, 0, 0);
glVertex3f(0.5, -0.5, -0.5);
glColor3f(1, 0, 1);
glVertex3f(0.5, -0.5, 0.5);
glColor3f(0, 1, 0);
glVertex3f(-0.5, 0.5, -0.5);
glColor3f(1, 1, 0);
glVertex3f(0.5, 0.5, -0.5);
glColor3f(0, 1, 0);
glVertex3f(-0.5, 0.5, -0.5);
glColor3f(0, 1, 1);
glVertex3f(-0.5, 0.5, 0.5);
glColor3f(0, 0, 1);
glVertex3f(-0.5, -0.5, 0.5);
glColor3f(1, 0, 1);
glVertex3f(0.5, -0.5, 0.5);
glColor3f(0, 0, 1);
glVertex3f(-0.5, -0.5, 0.5);
glColor3f(0, 1, 1);
glVertex3f(-0.5, 0.5, 0.5);
glEnd();
}}
|
4d80c1dd
David Mayerich
added a GLUT temp...
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
struct glut_template_struct {
float theta_scale = 0.01f;
float phi_scale = 0.01f;
float zoom_scale = 0.1f;
stim::camera cam; //create a camera object
int mx, my; //mouse coordinates in the window space
float d = 1.5; //initial distance between the camera and the sphere
bool rotate_zoom = true; //sets the current camera mode (rotation = true, zoom = false)
bool axis = false; //render the z-axis (set via a command line flag)
} gt;
//render the XYZ axes
void render_axes() {
glDisable(GL_TEXTURE_2D); //turn off texture mapping
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f); //set the color to RED and render X
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(100.0, 0.0, 0.0);
glColor3f(0.0f, 1.0f, 0.0f); //set the color to RED and render X
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 100.0, 0.0);
glColor3f(0.0f, 0.0f, 1.0f); //set the color to RED and render X
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 100.0);
glEnd();
}
//display function executed to update every frame
void glut_display() {
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); //clear the screen
glMatrixMode(GL_PROJECTION); //put the projection matrix on the stack
glLoadIdentity(); //set it to the identity matrix
gluPerspective(gt.cam.getFOV(), 1, 0.001, 1000000); //set up a perspective projection
glMatrixMode(GL_MODELVIEW); //load the model view matrix to the stack
glLoadIdentity(); //set it to the identity matrix
stim::vec3<float> p = gt.cam.getPosition(); //get the camera parameters
stim::vec3<float> u = gt.cam.getUp();
|