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