-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxis4d.cpp
More file actions
50 lines (44 loc) · 1.43 KB
/
axis4d.cpp
File metadata and controls
50 lines (44 loc) · 1.43 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
#include <iostream>
using namespace std;
#include <glm/glm.hpp>
void outputAxis(int axis, glm::ivec4 cs, glm::ivec4 ce, int step)
{
double d = 1.0/step;
glm::vec4 v(0,0,0,0);
v[axis] = 1;
for (int i=-step; i<=step; i++) {
glm::vec4 w = ((float) d*i)*v;
glm::ivec4 c = (cs*(step-i) + ce*(i+step))/(2*step);
cout << w[0] << " " << w[1] << " " << w[2] << " " << w[3] << " "
<< c[0] << " " << c[1] << " " << c[2] << " " << c[3] << endl;
}
}
int main()
{
int c[4][2][4] =
{ { { 255, 0, 0 } , { 255, 255, 0} },
{ { 0, 255, 0 }, { 0, 255, 255} },
{ { 0, 0, 255 }, {255, 0, 255} },
{ { 128, 128, 0}, {0, 128, 128} } };
int step=50;
cout << "ply" << endl
<< "format ascii 1.0" << endl
<< "element vertex " << (2*step+1)*4 << endl
<< "property float x" << endl
<< "property float y" << endl
<< "property float z" << endl
<< "property float w" << endl
<< "property uchar red" << endl
<< "property uchar green" << endl
<< "property uchar blue" << endl
<< "property uchar alpha" << endl
<< "element face 0" << endl
<< "property list uchar int vertex_indices" << endl
<< "end_header" << endl;
glm::ivec4 cs, ce;
for (int i=0; i<4; i++) {
cs = glm::ivec4(c[i][0][0], c[i][0][1], c[i][0][2], c[i][0][3]);
ce = glm::ivec4(c[i][1][0], c[i][1][1], c[i][1][2], c[i][1][3]);
outputAxis(i, cs, ce, step);
}
}