-
Notifications
You must be signed in to change notification settings - Fork 3
/
CubePieceFace.pde
74 lines (67 loc) · 2.37 KB
/
CubePieceFace.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
class CubePieceFace {
private PVector orientation;
public PVector center;
public PVector[] corners = new PVector[4];
public CubePieceFace(PVector orientationIn, PVector centerIn) {
orientation = orientationIn;
center = centerIn;
if (orientation == PZ) {
corners[0] = new PVector(-R, -R, R);
corners[1] = new PVector(R, -R, R);
corners[2] = new PVector(R, R, R);
corners[3] = new PVector(-R, R, R);
} else if (orientation == NZ) {
corners[0] = new PVector(-R, -R, -R);
corners[1] = new PVector(R, -R, -R);
corners[2] = new PVector(R, R, -R);
corners[3] = new PVector(-R, R, -R);
} else if (orientation == PX) {
corners[0] = new PVector(R, -R, R);
corners[1] = new PVector(R, -R, -R);
corners[2] = new PVector(R, R, -R);
corners[3] = new PVector(R, R, R);
} else if (orientation == NX) {
corners[0] = new PVector(-R, -R, R);
corners[1] = new PVector(-R, -R, -R);
corners[2] = new PVector(-R, R, -R);
corners[3] = new PVector(-R, R, R);
} else if (orientation == PY) {
corners[0] = new PVector(-R, R, -R);
corners[1] = new PVector(R, R, -R);
corners[2] = new PVector(R, R, R);
corners[3] = new PVector(-R, R, R);
} else if (orientation == NY) {
corners[0] = new PVector(-R, -R, -R);
corners[1] = new PVector(R, -R, -R);
corners[2] = new PVector(R, -R, R);
corners[3] = new PVector(-R, -R, R);
}
}
public void show() {
pushMatrix();
if (orientation == PX) {
fill(BLUE);
} else if (orientation == PY) {
fill(WHITE);
} else if (orientation == PZ) {
fill(RED);
} else if (orientation == NX) {
fill(GREEN);
} else if (orientation == NY) {
fill(YELLOW);
} else if (orientation == NZ) {
fill(ORANGE);
}
stroke(0);
strokeWeight(5);
translate(center.x, center.y, center.z);
beginShape();
PVector v;
for (int i = 0; i < corners.length; i++) {
v = corners[i];
vertex(v.x, v.y, v.z);
}
endShape(CLOSE);
popMatrix();
}
}