Remove OSC references
[SugarCubes.git] / _Mappings.pde
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 static final float SPACING = 27;
17 static final float RISER = 13.5;
18 static final float FLOOR = 0;
19
20 /**
21 * Definitions of tower positions. This is all that should need
22 * to be modified. Distances are measured from the left-most cube.
23 * The first value is the offset moving NE (towards back-right).
24 * The second value is the offset moving NW (negative comes forward-right).
25 */
26 static final float[][] TOWER_CONFIG = new float[][] {
27 new float[] { 0, 0, RISER, 4 },
28 new float[] { 25, -10, RISER, 4 },
29 new float[] { 50, -22.5, FLOOR, 5 },
30 new float[] { 17.25, -35.5, FLOOR, 6 },
31 new float[] { 43.25, -51.5, RISER, 6 },
32 new float[] { 69.25, -56, FLOOR, 6 },
33 new float[] { 12.75, -62.5, RISER, 4 },
34 new float[] { 38.75, -78.5, FLOOR, 5 },
35 new float[] { 65.75, -83, RISER, 5 },
36
37 };
38
39 public Model buildModel() {
40
41 List<Tower> towers = new ArrayList<Tower>();
42 Cube[] cubes = new Cube[200];
43 int cubeIndex = 1;
44
45 float rt2 = sqrt(2);
46 float x, y, z, xd, zd, num;
47 for (float[] tc : TOWER_CONFIG) {
48 x = -tc[1];
49 z = tc[0];
50 y = tc[2];
51 num = tc[3];
52 if (z < x) {
53 zd = -(x-z)/rt2;
54 xd = z*rt2 - zd;
55 } else {
56 zd = (z-x)/rt2;
57 xd = z*rt2 - zd;
58 }
59 List<Cube> tower = new ArrayList<Cube>();
60 for (int n = 0; n < num; ++n) {
61 Cube cube = new Cube(xd + 24, y, zd + 84, 0, -45, 0);
62 tower.add(cube);
63 cubes[cubeIndex++] = cube;
64 y += SPACING;
65 }
66 towers.add(new Tower(tower));
67 }
68
69 return new Model(towers, cubes);
70 }