-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaxis.hpp
56 lines (43 loc) · 1.52 KB
/
axis.hpp
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
# ifndef AXIS_H
# define AXIS_H
# include "graphicsDefs.hpp"
point3 primaryColors[] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
point3 worldBasis[3] = {{ 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 }};
point3 worldOrigin = {0.0, 0.0, 0.0};
// draws an axis system at any frame given by
void drawAxis(point3 basis[3], point3 origin) {
int j, k;
point3 endPoints[3];
for (j = 0; j < 3; ++j)
for ( k = 0; k < 3; ++k)
endPoints[j][k] = basis[j][k] + origin[k];
glLineWidth(3);
glBegin(GL_LINES);
for (j = 0; j < 3; ++j)
{
glColor3fv(primaryColors[j]);
glVertex3fv(origin);
glVertex3fv(endPoints[j]);
}
glEnd();
}
void drawGrid(float left, float right, float back, float front, float interval) {
float j;
glColor3f(0.25, 0.25, 0.25);
glLineWidth(0.5);
glBegin(GL_LINES);
for (j = left; j <= right; j += interval)
{
glVertex3f(j, 0, back);
glVertex3f(j, 0, front);
}
for (j = back; j <= front; j += interval)
{
glVertex3f(left, 0, j);
glVertex3f(right, 0, j);
}
glEnd();
}
#endif