Commit | Line | Data |
---|---|---|
1ecdb44a MS |
1 | /** |
2 | * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND | |
3 | * | |
4 | * //\\ //\\ //\\ //\\ | |
5 | * ///\\\ ///\\\ ///\\\ ///\\\ | |
6 | * \\\/// \\\/// \\\/// \\\/// | |
7 | * \\// \\// \\// \\// | |
8 | * | |
9 | * EXPERTS ONLY!! EXPERTS ONLY!! | |
10 | * | |
186bc4d3 | 11 | * This file implements the mapping functions needed to lay out the physical |
1ecdb44a MS |
12 | * cubes and the output ports on the panda board. It should only be modified |
13 | * when physical changes or tuning is being done to the structure. | |
14 | */ | |
45f43cc2 | 15 | |
31b2d042 | 16 | <<<<<<< HEAD |
270a8b44 MS |
17 | final int MaxCubeHeight = 6; |
18 | final int NumBackTowers = 16; | |
19 | ||
f0cc0ba5 MS |
20 | public Model buildModel() { |
21 | ||
f0cc0ba5 MS |
22 | // Shorthand helpers for specifying wiring more quickly |
23 | final Cube.Wiring WFL = Cube.Wiring.FRONT_LEFT; | |
24 | final Cube.Wiring WFR = Cube.Wiring.FRONT_RIGHT; | |
25 | final Cube.Wiring WRL = Cube.Wiring.REAR_LEFT; | |
26 | final Cube.Wiring WRR = Cube.Wiring.REAR_RIGHT; | |
95c50032 | 27 | |
a3ccf23a | 28 | // Utility value if you need the height of a cube shorthand |
95c50032 | 29 | final float CH = Cube.EDGE_HEIGHT; |
73687629 | 30 | final float CW = Cube.EDGE_WIDTH ; |
ae579223 | 31 | |
a3ccf23a | 32 | // Positions for the bass box |
ae579223 MS |
33 | final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH; |
34 | final float BBX = 56; | |
35 | final float BBZ = 2; | |
36 | ||
46fc29d4 MS |
37 | // The model is represented as an array of towers. The cubes in the tower |
38 | // are represenented relatively. Each tower has an x, y, z reference position, | |
39 | // which is typically the base cube's bottom left corner. | |
40 | // | |
41 | // Following that is an array of floats. A 2-d array contains an x-offset | |
f0cc0ba5 MS |
42 | // and a z-offset from the previous reference position. Typically the first cube |
43 | // will just be {0, 0}. Each successive cube uses the position of the previous | |
44 | // cube as its reference. | |
46fc29d4 MS |
45 | // |
46 | // A 3-d array contains an x-offset, a z-offset, and a rotation about the | |
47 | // y-axis. | |
48 | // | |
49 | // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT. | |
e27a8652 | 50 | |
73687629 | 51 | // To-Do: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list. |
52 | // "raw object index" is serialized by running through towermapping and then individual cube mapping below. | |
53 | // We can do better than this. The raw object index should be obvious from the code-- looking through the | |
54 | // rendered simulation and counting through cubes in mapping mode is grossly inefficient. | |
e28f168c | 55 | |
73687629 | 56 | TowerMapping[] towerCubes = new TowerMapping[] {}; |
f0cc0ba5 MS |
57 | |
58 | // Single cubes can be constructed directly here if you need them | |
59 | Cube[] singleCubes = new Cube[] { | |
bf1fe2d4 | 60 | // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL), // Back left channel behind speaker |
f1370a0b | 61 | //new Cube(x, y, z, rx, ry, rz, wiring), |
bf1fe2d4 | 62 | //new Cube(0,0,0,0,225,0, WRR), |
f0cc0ba5 MS |
63 | }; |
64 | ||
65 | // The bass box! | |
73687629 | 66 | // BassBox bassBox = BassBox.unlitBassBox(BBX, 0, BBZ); // frame exists, no lights |
67 | BassBox bassBox = BassBox.noBassBox(); // no bass box at all | |
e89eda9f | 68 | // BassBox bassBox = new BassBox(BBX, 0, BBZ); // bass box with lights |
e28f168c | 69 | |
f0cc0ba5 | 70 | // The speakers! |
3b2e0b4a MS |
71 | List<Speaker> speakers = Arrays.asList(new Speaker[] { |
72 | // Each speaker parameter is x, y, z, rotation, the left speaker comes first | |
73687629 | 73 | // new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15) |
3b2e0b4a | 74 | }); |
f0cc0ba5 | 75 | |
bf1fe2d4 MS |
76 | |
77 | //////////////////////////////////////////////////////////////////////// | |
78 | // dan's proposed lattice | |
79 | ArrayList<StaggeredTower> scubes = new ArrayList<StaggeredTower>(); | |
3fa45e9e AG |
80 | //if (NumBackTowers != 25) exit(); |
81 | for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower( | |
82 | (i+1)*CW, // x | |
83 | (i % 2 == 0) ? 0 : CH * 2./3. , // y | |
270a8b44 MS |
84 | - ((i % 2 == 0) ? 11 : 0) + 80 , // z |
85 | -45, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight) ); // num cubes | |
bf1fe2d4 | 86 | |
ab65d40b | 87 | for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower( |
88 | (i+1)*CW, // x | |
89 | (i % 2 == 0) ? 0 : CH * 2./3. , // y | |
90 | - ((i % 2 == 0) ? 0 : 11) + 80 - pow(CH*CH + CW*CW, .5), // z | |
91 | 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) ); | |
e0cfbe20 AG |
92 | |
93 | // for (int i=0; i<2 ; i++) scubes.add(new StaggeredTower( | |
94 | // (i+1)*CW, // x | |
95 | // 0 , // y | |
96 | // - 0 + 97 - 2*pow(CH*CH + CW*CW, .5), // z | |
97 | // 225, MaxCubeHeight ) ); | |
98 | ||
bf1fe2d4 MS |
99 | ArrayList<Cube> dcubes = new ArrayList<Cube>(); |
100 | // for (int i=1; i<6; i++) { | |
101 | // if (i>1) dcubes.add(new Cube(-6+CW*4/3*i , 0, 0, 0, 0, 0, WRR)); | |
102 | // dcubes.add(new Cube(-6+CW*4/3*i+CW*2/3., CH*.5, 0, 0, 0, 0, WRR)); | |
103 | // } | |
104 | ||
a981ea46 | 105 | float current_x_position = 0; |
3fa45e9e AG |
106 | // scubes.add(new StaggeredTower(//tower 1 |
107 | // current_x_position, // x | |
108 | // 15 , // y | |
109 | // 0 , // z | |
110 | // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) ); | |
111 | // current_x_position += 25.25; | |
112 | // scubes.add(new StaggeredTower(// tower 2 | |
113 | // current_x_position, // x | |
114 | // 0 , // y | |
115 | // -10.5 , // z | |
116 | // 45, 6, new Cube.Wiring[] { WFR, WFL, WRR, WRR, WFL, WRR}) ); | |
117 | // current_x_position += 25.25; | |
118 | // scubes.add(new StaggeredTower(//tower 3 | |
119 | // current_x_position, // x | |
120 | // 15 , // y | |
121 | // 0, // z | |
122 | // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WRR, WFL, WRR}) ); | |
123 | // current_x_position += 25.25; | |
124 | // scubes.add(new StaggeredTower(//tower 4 | |
125 | // current_x_position, // x | |
126 | // 0, // y | |
127 | // -10.5 , // z | |
128 | // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) ); | |
129 | // current_x_position += 28; | |
130 | // scubes.add(new StaggeredTower(//tower 5 | |
131 | // current_x_position, // x | |
132 | // 15 , // y | |
133 | // -4.5 , // z | |
134 | // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WFL, WRR, WFL}) ); | |
135 | // current_x_position += 28; | |
136 | // scubes.add(new StaggeredTower(//tower 6 | |
137 | // current_x_position, // x | |
138 | // 0 , // y | |
139 | // -10.5, // z | |
140 | // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) ); | |
141 | // current_x_position += 25.25; | |
142 | // scubes.add(new StaggeredTower(// tower 7 | |
143 | // current_x_position, // x | |
144 | // 15 , // y | |
145 | // 0, // z | |
146 | // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WFL, WRR, WFL}) ); | |
147 | // current_x_position += 25.25; | |
148 | // scubes.add(new StaggeredTower(//tower 8 | |
149 | // current_x_position, // x | |
150 | // 0 , // y | |
151 | // -10.5 , // z | |
152 | // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) ); | |
153 | // current_x_position += 25.25; | |
154 | // scubes.add(new StaggeredTower(//tower 9 | |
155 | // current_x_position, // x | |
156 | // 15 , // y | |
157 | // 0, // z | |
158 | // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) ); | |
159 | // current_x_position += 25.25; | |
160 | ||
161 | // //TOWERS ON DANCE FLOOR | |
162 | // scubes.add(new StaggeredTower(//tower 10 | |
163 | // 83.75+39+43-124.5, // x | |
164 | // 0, // y | |
165 | // -47.5-43, // z | |
166 | // 45, 4, new Cube.Wiring[]{ WRR, WFL, WFL, WRR}) ); | |
167 | // scubes.add(new StaggeredTower(//tower 11 | |
168 | // 83.75, // x | |
169 | // 0, // y | |
170 | // -47.5, // z | |
171 | // 45, 4, new Cube.Wiring[]{ WFL, WRR, WRR, WFL}) ); | |
172 | // scubes.add(new StaggeredTower(//tower 12 | |
173 | // 83.75+39, // x | |
174 | // 0, // y | |
175 | // -47.5, // z | |
176 | // 45, 4, new Cube.Wiring[]{ WRR, WFL, WFL, WRR}) ); | |
177 | // scubes.add(new StaggeredTower(//tower 13 | |
178 | // 83.75+39+43, // x | |
179 | // 0, // y | |
180 | // -47.5-43, // z | |
181 | // 45, 4, new Cube.Wiring[]{ WFL, WRR, WFL, WRR}) ); | |
d93dc84a | 182 | |
a981ea46 AK |
183 | // scubes.add(new StaggeredTower(// Single cube on top of tower 4 |
184 | // 42, // x | |
185 | // 112 , // y | |
186 | // 72, // z | |
187 | // -10, 1, new Cube.Wiring[]{ WRL}) ); | |
bf1fe2d4 MS |
188 | |
189 | ||
190 | ||
191 | ||
192 | ||
193 | ||
194 | ||
a3ccf23a MS |
195 | ////////////////////////////////////////////////////////////////////// |
196 | // BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! // | |
197 | ////////////////////////////////////////////////////////////////////// | |
198 | ||
f0cc0ba5 | 199 | // These guts just convert the shorthand mappings into usable objects |
46fc29d4 MS |
200 | ArrayList<Tower> towerList = new ArrayList<Tower>(); |
201 | ArrayList<Cube> tower; | |
3fa45e9e | 202 | Cube[] cubes = new Cube[200]; |
46fc29d4 | 203 | int cubeIndex = 1; |
f0cc0ba5 MS |
204 | float px, pz, ny; |
205 | for (TowerMapping tm : towerCubes) { | |
206 | px = tm.x; | |
207 | ny = tm.y; | |
208 | pz = tm.z; | |
46fc29d4 | 209 | tower = new ArrayList<Cube>(); |
f0cc0ba5 MS |
210 | for (CubeMapping cm : tm.cubeMappings) { |
211 | tower.add(cubes[cubeIndex++] = new Cube(px = px + cm.dx, ny, pz = pz + cm.dz, 0, cm.ry, 0, cm.wiring)); | |
212 | ny += Cube.EDGE_HEIGHT; | |
46fc29d4 MS |
213 | } |
214 | towerList.add(new Tower(tower)); | |
215 | } | |
73687629 | 216 | |
f1370a0b | 217 | |
cd1c3313 MS |
218 | for (Cube cube : singleCubes) { |
219 | cubes[cubeIndex++] = cube; | |
220 | } | |
221 | for (Cube cube : dcubes) { | |
222 | cubes[cubeIndex++] = cube; | |
223 | } | |
270a8b44 | 224 | for (StaggeredTower st : scubes) { |
73687629 | 225 | tower = new ArrayList<Cube>(); |
bf1fe2d4 MS |
226 | for (int i=0; i < st.n; i++) { |
227 | Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR; | |
228 | tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w)); | |
229 | } | |
73687629 | 230 | towerList.add(new Tower(tower)); |
2bb56822 | 231 | } |
e76480d4 | 232 | |
7dceead9 | 233 | return new Model(towerList, cubes, bassBox, speakers); |
186bc4d3 | 234 | } |
31b2d042 | 235 | ======= |
e18b4cb7 MS |
236 | static final float SPACING = 27; |
237 | static final float RISER = 13.5; | |
238 | static final float FLOOR = 0; | |
31b2d042 | 239 | >>>>>>> 21dffb1b77608cacc57382f3eb6eac3ed16054c3 |
e73ef85d | 240 | |
a3ccf23a | 241 | /** |
e18b4cb7 MS |
242 | * Definitions of tower positions. This is all that should need |
243 | * to be modified. Distances are measured from the left-most cube. | |
244 | * The first value is the offset moving NE (towards back-right). | |
245 | * The second value is the offset moving NW (negative comes forward-right). | |
a3ccf23a | 246 | */ |
e18b4cb7 | 247 | static final float[][] TOWER_CONFIG = new float[][] { |
e18b4cb7 MS |
248 | new float[] { 0, 0, RISER, 4 }, |
249 | new float[] { 25, -10, RISER, 4 }, | |
250 | new float[] { 50, -22.5, FLOOR, 5 }, | |
251 | new float[] { 17.25, -35.5, FLOOR, 6 }, | |
252 | new float[] { 43.25, -51.5, RISER, 6 }, | |
253 | new float[] { 69.25, -56, FLOOR, 6 }, | |
254 | new float[] { 12.75, -62.5, RISER, 4 }, | |
255 | new float[] { 38.75, -78.5, FLOOR, 5 }, | |
256 | new float[] { 65.75, -83, RISER, 5 }, | |
257 | ||
258 | }; | |
73687629 | 259 | |
e18b4cb7 | 260 | public Model buildModel() { |
45f43cc2 | 261 | |
e18b4cb7 | 262 | List<Tower> towers = new ArrayList<Tower>(); |
3fa45e9e | 263 | Cube[] cubes = new Cube[200]; |
e18b4cb7 MS |
264 | int cubeIndex = 1; |
265 | ||
266 | float rt2 = sqrt(2); | |
267 | float x, y, z, xd, zd, num; | |
268 | for (float[] tc : TOWER_CONFIG) { | |
269 | x = -tc[1]; | |
270 | z = tc[0]; | |
271 | y = tc[2]; | |
272 | num = tc[3]; | |
273 | if (z < x) { | |
274 | zd = -(x-z)/rt2; | |
275 | xd = z*rt2 - zd; | |
276 | } else { | |
277 | zd = (z-x)/rt2; | |
278 | xd = z*rt2 - zd; | |
84086fa3 | 279 | } |
e18b4cb7 MS |
280 | List<Cube> tower = new ArrayList<Cube>(); |
281 | for (int n = 0; n < num; ++n) { | |
282 | Cube cube = new Cube(xd + 24, y, zd + 84, 0, -45, 0); | |
283 | tower.add(cube); | |
284 | cubes[cubeIndex++] = cube; | |
285 | y += SPACING; | |
84086fa3 | 286 | } |
e18b4cb7 | 287 | towers.add(new Tower(tower)); |
84086fa3 | 288 | } |
e18b4cb7 | 289 | |
b9b7b3d4 | 290 | return new Model(towers, cubes); |
2bb56822 | 291 | } |