-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5cell.cpp
More file actions
63 lines (53 loc) · 1.66 KB
/
5cell.cpp
File metadata and controls
63 lines (53 loc) · 1.66 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
#include <iostream>
using namespace std;
#include <glm/glm.hpp>
void outputEdge(glm::vec4 ps, glm::vec4 pe,
glm::ivec4 cs, glm::ivec4 ce, int step)
{
float d = 1.0/step;
for (int i=0; i<=step; i++) {
glm::vec4 w = (step-i)*d*ps + i*d*pe;
glm::ivec4 c = ((step-i)*cs + i*ce)/step;
cout << w[0] << " " << w[1] << " " << w[2] << " " << w[3] << " "
<< c[0] << " " << c[1] << " " << c[2] << " " << c[3] << endl;
}
}
int main()
{
const glm::ivec3 c[5] =
{ glm::ivec3(255, 0, 0), glm::ivec3(255, 255, 0),
glm::ivec3(0, 255, 0), glm::ivec3(0, 255, 255),
glm::ivec3(255, 0, 255) };
const float sq5 = sqrt(5.0), sq5inv = 1/sqrt(5.0);
const glm::vec4 p[5] =
{ glm::vec4(1, 1, 1, -sq5inv),
glm::vec4(1, -1, -1, -sq5inv),
glm::vec4(-1, 1, -1, -sq5inv),
glm::vec4(-1, -1, 1, -sq5inv),
glm::vec4(0, 0, 0, sq5-sq5inv) };
int step=50;
int numpoints = (step+1)*10;
cout << "ply" << endl
<< "format ascii 1.0" << endl
<< "element vertex "
<< numpoints << 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++) {
for (int j=i+1; j<5; j++) {
cs = glm::ivec4(c[i], 255);
ce = glm::ivec4(c[j], 255);
outputEdge(p[i], p[j], cs, ce, step);
}
}
}