-
Notifications
You must be signed in to change notification settings - Fork 7
/
UI.pde
91 lines (76 loc) · 2.51 KB
/
UI.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND
*
* //\\ //\\ //\\ //\\
* ///\\\ ///\\\ ///\\\ ///\\\
* \\\/// \\\/// \\\/// \\\///
* \\// \\// \\// \\//
*
* EXPERTS ONLY!! EXPERTS ONLY!!
*
* This file contains code to draws the dome model and set up
* the UI for the simulation. Please do not change this file
* unless you know what you are doing.
*/
/**
* Here's a simple extension of a camera component. This will be
* rendered inside the camera view context. We just override the
* onDraw method and invoke Processing drawing methods directly.
*/
class UIDome extends UI3dComponent {
private boolean LABEL_FACES = false;
private boolean LABEL_EDGES = false;
@Override
protected void onDraw(UI ui, PGraphics pg) {
HE_Mesh geodome = model.getLEDomeMesh();
if (RENDER_3D) {
pg.stroke(5);
render = new WB_Render((PGraphics3D)pg);
render.drawEdges(geodome);
}
if (RENDER_3D && LABEL_FACES) {
pg.stroke(1);
labelFaces(geodome, pg);
}
if (RENDER_3D && LABEL_EDGES) {
pg.stroke(1);
labelEdges(pg);
}
}
@Override
protected void endDraw(UI ui, PGraphics pg) {
pg.noLights();
}
private void labelFaces(HE_Mesh geodome, PGraphics pg) {
int numFaces = geodome.getNumberOfFaces();
HE_Face currentFace;
WB_Point faceCenter;
PFont labelFont = createFont("SansSerif", 5, true);
pg.textFont(labelFont);
pg.textAlign(CENTER, CENTER);
pg.pushMatrix();
pg.scale(1, -1, 1);
for(int i = 0; i < numFaces; i++) {
currentFace = geodome.getFaceByIndex(i);
faceCenter = currentFace.getFaceCenter();
if (currentFace.getLabel() != -1) {
pg.text(currentFace.getLabel(), faceCenter.xf(), -1 * faceCenter.yf(), faceCenter.zf());
}
}
pg.popMatrix();
}
private void labelEdges(PGraphics pg) {
int numEdges = model.edges.size();
PFont labelFont = createFont("SansSerif", 7, true);
pg.textFont(labelFont);
pg.textAlign(CENTER, CENTER);
pg.pushMatrix();
pg.scale(1, -1);
for(int i = 0; i < numEdges; ++i) {
LEDomeEdge edge = model.edges.get(i);
LXPoint middlePoint = edge.points.get(1);
pg.text(i, middlePoint.x, -1 * middlePoint.y, middlePoint.z);
}
pg.popMatrix();
}
}