New Grizzly code using LXOutput framework
[SugarCubes.git] / _Mappings.pde
CommitLineData
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
270a8b44
MS
16final int MaxCubeHeight = 6;
17final int NumBackTowers = 16;
18
f0cc0ba5
MS
19public Model buildModel() {
20
f0cc0ba5
MS
21 // Shorthand helpers for specifying wiring more quickly
22 final Cube.Wiring WFL = Cube.Wiring.FRONT_LEFT;
23 final Cube.Wiring WFR = Cube.Wiring.FRONT_RIGHT;
24 final Cube.Wiring WRL = Cube.Wiring.REAR_LEFT;
25 final Cube.Wiring WRR = Cube.Wiring.REAR_RIGHT;
95c50032 26
a3ccf23a 27 // Utility value if you need the height of a cube shorthand
95c50032 28 final float CH = Cube.EDGE_HEIGHT;
73687629 29 final float CW = Cube.EDGE_WIDTH ;
ae579223 30
a3ccf23a 31 // Positions for the bass box
ae579223
MS
32 final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH;
33 final float BBX = 56;
34 final float BBZ = 2;
35
46fc29d4
MS
36 // The model is represented as an array of towers. The cubes in the tower
37 // are represenented relatively. Each tower has an x, y, z reference position,
38 // which is typically the base cube's bottom left corner.
39 //
40 // Following that is an array of floats. A 2-d array contains an x-offset
f0cc0ba5
MS
41 // and a z-offset from the previous reference position. Typically the first cube
42 // will just be {0, 0}. Each successive cube uses the position of the previous
43 // cube as its reference.
46fc29d4
MS
44 //
45 // A 3-d array contains an x-offset, a z-offset, and a rotation about the
46 // y-axis.
47 //
48 // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
e27a8652 49
73687629 50 // To-Do: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list.
51 // "raw object index" is serialized by running through towermapping and then individual cube mapping below.
52 // We can do better than this. The raw object index should be obvious from the code-- looking through the
53 // rendered simulation and counting through cubes in mapping mode is grossly inefficient.
e28f168c 54
73687629 55 TowerMapping[] towerCubes = new TowerMapping[] {};
f0cc0ba5
MS
56
57 // Single cubes can be constructed directly here if you need them
58 Cube[] singleCubes = new Cube[] {
bf1fe2d4 59 // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL), // Back left channel behind speaker
f1370a0b 60 //new Cube(x, y, z, rx, ry, rz, wiring),
bf1fe2d4 61 //new Cube(0,0,0,0,225,0, WRR),
f0cc0ba5
MS
62 };
63
64 // The bass box!
73687629 65 // BassBox bassBox = BassBox.unlitBassBox(BBX, 0, BBZ); // frame exists, no lights
66 BassBox bassBox = BassBox.noBassBox(); // no bass box at all
e89eda9f 67 // BassBox bassBox = new BassBox(BBX, 0, BBZ); // bass box with lights
e28f168c 68
f0cc0ba5 69 // The speakers!
3b2e0b4a
MS
70 List<Speaker> speakers = Arrays.asList(new Speaker[] {
71 // Each speaker parameter is x, y, z, rotation, the left speaker comes first
73687629 72 // new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15)
3b2e0b4a 73 });
f0cc0ba5 74
bf1fe2d4
MS
75
76 ////////////////////////////////////////////////////////////////////////
77 // dan's proposed lattice
78 ArrayList<StaggeredTower> scubes = new ArrayList<StaggeredTower>();
3fa45e9e 79 //if (NumBackTowers != 25) exit();
882e2e3e 80 // for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
81 // (i+1)*CW, // x
82 // (i % 2 == 0) ? 0 : CH * 2./3. , // y
83 // - ((i % 2 == 0) ? 11 : 0) + 80 , // z
84 // -45, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight) ); // num cubes
bf1fe2d4 85
882e2e3e 86 // for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
87 // (i+1)*CW, // x
88 // (i % 2 == 0) ? 0 : CH * 2./3. , // y
89 // - ((i % 2 == 0) ? 0 : 11) + 80 - pow(CH*CH + CW*CW, .5), // z
90 // 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) );
e0cfbe20
AG
91
92 // for (int i=0; i<2 ; i++) scubes.add(new StaggeredTower(
93 // (i+1)*CW, // x
94 // 0 , // y
95 // - 0 + 97 - 2*pow(CH*CH + CW*CW, .5), // z
96 // 225, MaxCubeHeight ) );
97
bf1fe2d4
MS
98 ArrayList<Cube> dcubes = new ArrayList<Cube>();
99 // for (int i=1; i<6; i++) {
100 // if (i>1) dcubes.add(new Cube(-6+CW*4/3*i , 0, 0, 0, 0, 0, WRR));
101 // dcubes.add(new Cube(-6+CW*4/3*i+CW*2/3., CH*.5, 0, 0, 0, 0, WRR));
102 // }
103
882e2e3e 104float[] pos = new float[3];
105pos[0] = 50;
106pos[2] = 100;
107scubes.add(new StaggeredTower(//tower 1
108 pos[0], // x
109 0 , // y
110 pos[2], // z
111 0, 4, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
112
113
114pos[0] += 25;
115pos[2] -= 10;
116scubes.add(new StaggeredTower(// tower 2
117 pos[0], // x
118 15 , // y
119 pos[2], // z
120 0, 4, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
121
122pos[0] += 25;
123pos[2] += -12.5;
124scubes.add(new StaggeredTower(//tower 3
125 pos[0], // x
126 0 , // y
127 pos[2], // z
128 0, 5, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
129
130pos[0] += -32.75;
131pos[2] += -13;
132scubes.add(new StaggeredTower(//tower 4
133 pos[0], // x
134 0, // y
135 pos[2], // z
136 0, 6, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
137
138pos[0] += 26;
139pos[2] += -16;
140scubes.add(new StaggeredTower(//tower 5
141 pos[0], // x
142 15 , // y
143 pos[2], // z
144 0, 6, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
145
146pos[0] += 26;
147pos[2] += -4.5;
148scubes.add(new StaggeredTower(//tower 6
149 pos[0], // x
150 0 , // y
151 pos[2], // z
152 0, 6, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
153
154pos[0] += -56.5;
155pos[2] += -6.5;
156scubes.add(new StaggeredTower(// tower 7
157 pos[0], // x
158 15 , // y
159 pos[2], // z
160 0, 4, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
161
162pos[0] += 26;
163pos[2] += -16.5;
164scubes.add(new StaggeredTower(//tower 8
165 pos[0], // x
166 0 , // y
167 pos[2], // z
168 0, 5, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
169
170pos[0] += 27;
171pos[2] += -4.5;
172scubes.add(new StaggeredTower(//tower 9
173 pos[0], // x
174 15 , // y
175 pos[2], // z
176 0, 5, new Cube.Wiring[] { WRR, WRR, WRR, WRR, WRR, WRR}) );
3fa45e9e
AG
177
178// //TOWERS ON DANCE FLOOR
179// scubes.add(new StaggeredTower(//tower 10
180// 83.75+39+43-124.5, // x
181// 0, // y
182// -47.5-43, // z
882e2e3e 183// 45, 4, new Cube.Wiring[]{ WRR, WRR, WRR, WRR}) );
3fa45e9e
AG
184// scubes.add(new StaggeredTower(//tower 11
185// 83.75, // x
186// 0, // y
187// -47.5, // z
882e2e3e 188// 45, 4, new Cube.Wiring[]{ WRR, WRR, WRR, WRR}) );
3fa45e9e
AG
189// scubes.add(new StaggeredTower(//tower 12
190// 83.75+39, // x
191// 0, // y
192// -47.5, // z
882e2e3e 193// 45, 4, new Cube.Wiring[]{ WRR, WRR, WRR, WRR}) );
3fa45e9e
AG
194// scubes.add(new StaggeredTower(//tower 13
195// 83.75+39+43, // x
196// 0, // y
197// -47.5-43, // z
882e2e3e 198// 45, 4, new Cube.Wiring[]{ WRR, WRR, WRR, WRR}) );
d93dc84a 199
a981ea46
AK
200// scubes.add(new StaggeredTower(// Single cube on top of tower 4
201// 42, // x
202// 112 , // y
203// 72, // z
204// -10, 1, new Cube.Wiring[]{ WRL}) );
bf1fe2d4
MS
205
206
207
208
209
210
211
a3ccf23a
MS
212 //////////////////////////////////////////////////////////////////////
213 // BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! //
214 //////////////////////////////////////////////////////////////////////
215
f0cc0ba5 216 // These guts just convert the shorthand mappings into usable objects
46fc29d4
MS
217 ArrayList<Tower> towerList = new ArrayList<Tower>();
218 ArrayList<Cube> tower;
3fa45e9e 219 Cube[] cubes = new Cube[200];
46fc29d4 220 int cubeIndex = 1;
f0cc0ba5
MS
221 float px, pz, ny;
222 for (TowerMapping tm : towerCubes) {
223 px = tm.x;
224 ny = tm.y;
225 pz = tm.z;
46fc29d4 226 tower = new ArrayList<Cube>();
f0cc0ba5
MS
227 for (CubeMapping cm : tm.cubeMappings) {
228 tower.add(cubes[cubeIndex++] = new Cube(px = px + cm.dx, ny, pz = pz + cm.dz, 0, cm.ry, 0, cm.wiring));
229 ny += Cube.EDGE_HEIGHT;
46fc29d4
MS
230 }
231 towerList.add(new Tower(tower));
232 }
73687629 233
f1370a0b 234
cd1c3313
MS
235 for (Cube cube : singleCubes) {
236 cubes[cubeIndex++] = cube;
237 }
238 for (Cube cube : dcubes) {
239 cubes[cubeIndex++] = cube;
240 }
270a8b44 241 for (StaggeredTower st : scubes) {
73687629 242 tower = new ArrayList<Cube>();
bf1fe2d4
MS
243 for (int i=0; i < st.n; i++) {
244 Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR;
245 tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w));
246 }
73687629 247 towerList.add(new Tower(tower));
2bb56822 248 }
e76480d4 249
7dceead9 250 return new Model(towerList, cubes, bassBox, speakers);
186bc4d3 251}
e73ef85d 252
a3ccf23a
MS
253/**
254 * This function maps the panda boards. We have an array of them, each has
255 * an IP address and a list of channels.
256 */
186bc4d3 257public PandaMapping[] buildPandaList() {
1d75c8a9
MS
258 final int LEFT_SPEAKER = 0;
259 final int RIGHT_SPEAKER = 1;
260
3b2e0b4a 261 // 8 channels map to: 3, 4, 7, 8, 13, 14, 15, 16.
186bc4d3 262 return new PandaMapping[] {
bf1fe2d4 263 new PandaMapping(
882e2e3e 264 "192.168.88.100", new ChannelMapping[] { // G1
19ea62fd 265 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 6}),
19ea62fd
AK
266 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5}),
267 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 6}),
268 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7}),
19ea62fd
AK
269 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7}),
270 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 8}),
271 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
272 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 2}),
882e2e3e 273
19ea62fd 274 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 4}),
19ea62fd 275 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 3}),
882e2e3e 276 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 11}),
277 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 10}),
278 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 9}),
279 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 9}),
280 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 12}),
281 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13}),
19ea62fd 282 }),
882e2e3e 283
284 new PandaMapping(
285 "192.168.88.101", new ChannelMapping[] { //G4
286 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25}),
287 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 23}),
288 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 24}),
289 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43}),
290 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 45}),
291 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 44}),
292 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
293 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
294
295 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
296 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
297 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
298 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 41}),
299 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 42}),
300 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 21}),
301 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 20}),
302 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22}),
303 }),
304
df18145f 305 new PandaMapping(
882e2e3e 306 "192.168.88.104", new ChannelMapping[] { // G3
307 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 26}),
308 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28}),
309 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 27}),
310 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19}),
311 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 18}),
312 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 17}),
19ea62fd 313 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
19ea62fd 314 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
882e2e3e 315
316 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 18}),
317 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19}),
318 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 15}),
319 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16}),
320 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 14}),
321 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 29}),
322 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 30}),
323 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31}),
19ea62fd 324 }),
882e2e3e 325
19ea62fd 326 new PandaMapping(
882e2e3e 327 "192.168.88.105", new ChannelMapping[] { // G2
328 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
329 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
330 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
331 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 39}),
332 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 38}),
333 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40}),
334 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34}),
335 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 35}),
336
337 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 33}),
338 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 32}),
339 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37}),
340 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37}),
341 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
342 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
343 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
344 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1}),
19ea62fd 345 }),
3b2e0b4a 346 };
45f43cc2 347}
e73ef85d 348
f0cc0ba5
MS
349class TowerMapping {
350 public final float x, y, z;
351 public final CubeMapping[] cubeMappings;
352
353 TowerMapping(float x, float y, float z, CubeMapping[] cubeMappings) {
354 this.x = x;
355 this.y = y;
356 this.z = z;
357 this.cubeMappings = cubeMappings;
358 }
359}
360
361class CubeMapping {
362 public final float dx, dz, ry;
363 public final Cube.Wiring wiring;
364
365 CubeMapping(float dx, float dz, Cube.Wiring wiring) {
73687629 366 this(dx, dz, 0., wiring);
f0cc0ba5 367 }
f0cc0ba5
MS
368 CubeMapping(float dx, float dz, float ry) {
369 this(dz, dz, ry, Cube.Wiring.FRONT_LEFT);
370 }
371
372 CubeMapping(float dx, float dz, float ry, Cube.Wiring wiring) {
373 this.dx = dx;
374 this.dz = dz;
375 this.ry = ry;
376 this.wiring = wiring;
377 }
378}
379
73687629 380class StaggeredTower {
381 public final float x, y, z, r;
382 public final int n;
bf1fe2d4
MS
383 public final Cube.Wiring[] wiring;
384 StaggeredTower(float _x, float _y, float _z, float _r, int _n) { this(_x, _y, _z, _r, _n, new Cube.Wiring[]{}); }
385 StaggeredTower(float _x, float _y, float _z, float _r, int _n, Cube.Wiring[] _wiring) { x=_x; y=_y; z=_z; r=_r; n=_n; wiring=_wiring;}
73687629 386}
387
a922e963
MS
388/**
389 * Each panda board has an IP address and a fixed number of channels. The channels
390 * each have a fixed number of pixels on them. Whether or not that many physical
391 * pixels are connected to the channel, we still send it that much data.
392 */
45f43cc2
MS
393class PandaMapping {
394
045b432d 395 // How many channels are on the panda board
19ea62fd 396 public final static int CHANNELS_PER_BOARD = 16;
045b432d 397
44b8de9c 398 // How many total pixels on the whole board
84086fa3 399 public final static int PIXELS_PER_BOARD = ChannelMapping.PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD;
44b8de9c 400
45f43cc2 401 final String ip;
84086fa3 402 final ChannelMapping[] channelList = new ChannelMapping[CHANNELS_PER_BOARD];
45f43cc2 403
84086fa3 404 PandaMapping(String ip, ChannelMapping[] rawChannelList) {
45f43cc2 405 this.ip = ip;
a922e963
MS
406
407 // Ensure our array is the right length and has all valid items in it
84086fa3
MS
408 for (int i = 0; i < channelList.length; ++i) {
409 channelList[i] = (i < rawChannelList.length) ? rawChannelList[i] : new ChannelMapping();
a922e963
MS
410 if (channelList[i] == null) {
411 channelList[i] = new ChannelMapping();
412 }
045b432d 413 }
e73ef85d 414 }
1ecdb44a
MS
415}
416
a922e963 417/**
e27a8652 418 * Each channel on a pandaboard can be mapped in a number of modes. The typical is
a922e963
MS
419 * to a series of connected cubes, but we also have special mappings for the bass box,
420 * the speaker enclosures, and the DJ booth floor.
421 *
422 * This class is just the mapping meta-data. It sanitizes the input to make sure
423 * that the cubes and objects being referenced actually exist in the model.
424 *
425 * The logic for how to encode the pixels is contained in the PandaDriver.
426 */
84086fa3
MS
427class ChannelMapping {
428
429 // How many cubes per channel xc_PB is configured for
19ea62fd 430 public final static int CUBES_PER_CHANNEL = 1;
45f43cc2 431
84086fa3
MS
432 // How many total pixels on each channel
433 public final static int PIXELS_PER_CHANNEL = Cube.POINTS_PER_CUBE * CUBES_PER_CHANNEL;
434
435 public static final int MODE_NULL = 0;
436 public static final int MODE_CUBES = 1;
437 public static final int MODE_BASS = 2;
438 public static final int MODE_SPEAKER = 3;
1d75c8a9 439 public static final int MODE_STRUTS_AND_FLOOR = 4;
84086fa3
MS
440 public static final int MODE_INVALID = 5;
441
442 public static final int NO_OBJECT = -1;
443
444 final int mode;
445 final int[] objectIndices = new int[CUBES_PER_CHANNEL];
446
447 ChannelMapping() {
448 this(MODE_NULL);
449 }
450
451 ChannelMapping(int mode) {
452 this(mode, new int[]{});
453 }
454
455 ChannelMapping(int mode, int rawObjectIndex) {
456 this(mode, new int[]{ rawObjectIndex });
457 }
458
459 ChannelMapping(int mode, int[] rawObjectIndices) {
460 if (mode < 0 || mode >= MODE_INVALID) {
461 throw new RuntimeException("Invalid channel mapping mode: " + mode);
462 }
463 if (mode == MODE_SPEAKER) {
464 if (rawObjectIndices.length != 1) {
465 throw new RuntimeException("Speaker channel mapping mode must specify one speaker index");
466 }
467 int speakerIndex = rawObjectIndices[0];
468 if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) {
3b2e0b4a 469 throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
84086fa3 470 }
1d75c8a9 471 } else if ((mode == MODE_STRUTS_AND_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
84086fa3 472 if (rawObjectIndices.length > 0) {
3b2e0b4a 473 throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
84086fa3
MS
474 }
475 } else if (mode == MODE_CUBES) {
476 for (int rawCubeIndex : rawObjectIndices) {
477 if (glucose.model.getCubeByRawIndex(rawCubeIndex) == null) {
478 throw new RuntimeException("Non-existing cube specified in cube mapping: " + rawCubeIndex);
479 }
480 }
481 }
482
483 this.mode = mode;
484 for (int i = 0; i < objectIndices.length; ++i) {
485 objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT;
486 }
487 }
2bb56822 488}