-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOctahedron.pde
77 lines (66 loc) · 1.51 KB
/
Octahedron.pde
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
public class Octahedron {
OctaSquare[] squares;
float xLat;
float yLat;
float zLat;
float xRot;
float yRot;
float zRot;
int order;
public Octahedron(boolean hasLeds1, boolean hasLeds2, boolean hasLeds3, float xLat, float yLat, float zLat, float xRot, float yRot, float zRot, int order) {
squares = new OctaSquare[3];
squares[0] = new OctaSquare(hasLeds1);
squares[1] = new OctaSquare(hasLeds2);
squares[2] = new OctaSquare(hasLeds3);
this.xLat = xLat;
this.yLat = yLat;
this.zLat = zLat;
this.xRot = xRot;
this.yRot = yRot;
this.zRot = zRot;
this.order = order;
}
void draw() {
pushMatrix();
translate(xLat,yLat,zLat);
if (order == 0) {
rotateX(xRot);
rotateY(yRot);
rotateZ(zRot);
}
else if (order == 1) {
rotateY(yRot);
rotateZ(zRot);
rotateX(xRot);
}
else {
rotateZ(zRot);
rotateX(xRot);
rotateY(yRot);
}
pushMatrix();
squares[0].draw();
rotateX(PI/4);
popMatrix();
pushMatrix();
rotateX(PI/4);
rotateZ(PI/2);
rotateX(PI/4);
squares[1].draw();
popMatrix();
pushMatrix();
rotateX(PI/4);
rotateZ(PI/2);
rotateY(PI/2);
rotateX(PI/4);
squares[2].draw();
popMatrix();
popMatrix();
}
public int appendJSON(JSONArray top, int id) {
id = squares[0].appendJSON(top, id);
id = squares[1].appendJSON(top, id);
id = squares[2].appendJSON(top, id);
return id;
}
}