/
Model.pde
187 lines (152 loc) · 5.62 KB
/
Model.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// This file defines the structural model of where lights
// are placed. It can be extended and tacked onto, and each
// light point can exist anywhere in 3-D space. The model
// can be iterated over to visit all the points, and each
// point has an index into the underlying color buffer.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
static class Model extends LXModel {
public static final int NUM_STRIPS = 34; // Actual number of strips per side
public static final int STRIP_SPACING = 9*INCHES;
public final List<LXModel> strips;
Model() {
super(new Fixture());
Fixture f = (Fixture) fixtures.get(0);
this.strips = Collections.unmodifiableList(f.strips);
}
private static class Fixture extends LXAbstractFixture {
public static final int NUM_PORT_SIDE_STRIPS = 24;
public static final int NUM_PORT_BACK_STRIPS = 12;
public static final int NUM_PORT_STRIP_LOCATIONS = NUM_PORT_SIDE_STRIPS + NUM_PORT_BACK_STRIPS;
public static final int NUM_STARBOARD_SIDE_STRIPS = 20;
public static final int NUM_STARBOARD_STRIP_LOCATIONS = NUM_STARBOARD_SIDE_STRIPS;
private final List<LXModel> strips = new ArrayList<LXModel>();
private static boolean portGap(int i) {
return false;
}
private static boolean starboardGap(int i) {
return false;
}
Fixture() {
// Build an array of strips, from left to right, some will be skipped to make a gap
LXModel strip;
// Starboard side
for (int i = 0; i < NUM_STARBOARD_STRIP_LOCATIONS; ++i) {
if (!starboardGap(i)) {
strip = new VerticalStrip(0, (4 + NUM_PORT_BACK_STRIPS + i)*STRIP_SPACING);
strips.add(strip);
addPoints(strip);
}
}
for (int i = 0; i < 4; i++) {
strip = new VerticalHalfStrip(0, (NUM_PORT_BACK_STRIPS + 4 + NUM_STARBOARD_STRIP_LOCATIONS + i)*STRIP_SPACING);
strips.add(strip);
addPoints(strip);
}
// Front of the car
for (int i = 0; i < 2; i++) {
strip = new HorizontalStrip((NUM_PORT_BACK_STRIPS + 4 + NUM_STARBOARD_STRIP_LOCATIONS + 4)*STRIP_SPACING, (11 - i)*STRIP_SPACING, 0);
strips.add(strip);
addPoints(strip);
}
for (int i = 0; i < 4; i++) {
strip = new HorizontalStrip((NUM_PORT_BACK_STRIPS + 4 + NUM_STARBOARD_STRIP_LOCATIONS + 4)*STRIP_SPACING, (5 - i / 2.)*STRIP_SPACING, 0);
strips.add(strip);
addPoints(strip);
}
for (int i = 0; i < 4; i++) {
strip = new HorizontalStrip((NUM_PORT_BACK_STRIPS + 4 + NUM_STARBOARD_STRIP_LOCATIONS + 4)*STRIP_SPACING, (3 - i)*STRIP_SPACING, 0);
strips.add(strip);
addPoints(strip);
}
// Port & rear side
for (int i = 0; i < NUM_PORT_STRIP_LOCATIONS; ++i) {
if (!portGap(i)) {
strip = new VerticalStrip(9*FEET, (NUM_PORT_STRIP_LOCATIONS - i)*STRIP_SPACING);
strips.add(strip);
addPoints(strip);
}
}
}
}
}
static class VerticalStrip extends LXModel {
public static final int NUM_POINTS = 100;
public static final int NUM_POINTS_PER_PART = NUM_POINTS / 2;
public static final float POINT_SPACING = METER / 30.;
public final float x;
public final float z;
VerticalStrip(float z, float x) {
super(new Fixture(z, x));
this.z = z;
this.x = x;
}
private static class Fixture extends LXAbstractFixture {
Fixture(float z, float x) {
/**
* Points in each strip are mapped in two sections:
* - the first half are added middle to top
* - the second half are added middle to bottom
*/
for (int i = 0; i < NUM_POINTS_PER_PART; ++i) {
addPoint(new LXPoint(x, (NUM_POINTS_PER_PART + i)*POINT_SPACING, z));
}
for (int i = 0; i < NUM_POINTS_PER_PART; ++i) {
addPoint(new LXPoint(x, (NUM_POINTS_PER_PART - 1 - i)*POINT_SPACING, z));
}
}
}
}
static class VerticalHalfStrip extends LXModel {
public static final int NUM_POINTS = 50;
public static final int NUM_POINTS_PER_PART = NUM_POINTS;
public static final float POINT_SPACING = METER / 30.;
public final float x;
public final float z;
VerticalHalfStrip(float z, float x) {
super(new Fixture(z, x));
this.z = z;
this.x = x;
}
private static class Fixture extends LXAbstractFixture {
Fixture(float z, float x) {
/**
* Points in each strip are mapped from top to bottom
*/
for (int i = 0; i < NUM_POINTS_PER_PART; ++i) {
addPoint(new LXPoint(x, (NUM_POINTS_PER_PART - 1 - i)*POINT_SPACING, z));
}
}
}
}
static class HorizontalStrip extends LXModel {
public static final int NUM_POINTS = 100;
public static final int NUM_POINTS_PER_PART = NUM_POINTS / 2;
public static final float POINT_SPACING = METER / 30.;
public final float x;
public final float y;
public final float z;
HorizontalStrip(float x, float y, float z) {
super(new Fixture(x, y, z));
this.x = x;
this.y = y;
this.z = z;
}
private static class Fixture extends LXAbstractFixture {
Fixture(float x, float y, float z) {
/**
* Points in each strip are mapped in two sections:
* - the first half are added middle to left
* - the second half are added middle to right
* NOTE: depending on the strips, this may need to be flipped
*/
for (int i = 0; i < NUM_POINTS_PER_PART; ++i) {
addPoint(new LXPoint(x + (NUM_POINTS_PER_PART + i)*POINT_SPACING, y, z));
}
for (int i = 0; i < NUM_POINTS_PER_PART; ++i) {
addPoint(new LXPoint(x + (NUM_POINTS_PER_PART - 1 - i)*POINT_SPACING, y, z));
}
}
}
}