Model is now in processing, not glucose
[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
e18b4cb7
MS
16static final float SPACING = 27;
17static final float RISER = 13.5;
18static final float FLOOR = 0;
e037f60f 19
e18b4cb7
MS
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 */
26static final float[][] TOWER_CONFIG = new float[][] {
27 // x, z, y, #
28 new float[] { 0, 0, RISER, 4 },
29 new float[] { 25, -10, RISER, 4 },
30 new float[] { 50, -22.5, FLOOR, 5 },
31 new float[] { 17.25, -35.5, FLOOR, 6 },
32 new float[] { 43.25, -51.5, RISER, 6 },
33 new float[] { 69.25, -56, FLOOR, 6 },
34 new float[] { 12.75, -62.5, RISER, 4 },
35 new float[] { 38.75, -78.5, FLOOR, 5 },
36 new float[] { 65.75, -83, RISER, 5 },
37
38};
ae579223 39
e18b4cb7 40public Model buildModel() {
e27a8652 41
e18b4cb7 42 // TODO: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list.
73687629 43 // "raw object index" is serialized by running through towermapping and then individual cube mapping below.
44 // We can do better than this. The raw object index should be obvious from the code-- looking through the
45 // rendered simulation and counting through cubes in mapping mode is grossly inefficient.
b9b7b3d4 46
e18b4cb7 47 List<Tower> towers = new ArrayList<Tower>();
3fa45e9e 48 Cube[] cubes = new Cube[200];
e18b4cb7
MS
49 int cubeIndex = 1;
50
51 float rt2 = sqrt(2);
52 float x, y, z, xd, zd, num;
53 for (float[] tc : TOWER_CONFIG) {
54 x = -tc[1];
55 z = tc[0];
56 y = tc[2];
57 num = tc[3];
58 if (z < x) {
59 zd = -(x-z)/rt2;
60 xd = z*rt2 - zd;
61 } else {
62 zd = (z-x)/rt2;
63 xd = z*rt2 - zd;
bf1fe2d4 64 }
e18b4cb7
MS
65 List<Cube> tower = new ArrayList<Cube>();
66 for (int n = 0; n < num; ++n) {
67 Cube cube = new Cube(xd + 24, y, zd + 84, 0, -45, 0);
68 tower.add(cube);
69 cubes[cubeIndex++] = cube;
70 y += SPACING;
045b432d 71 }
e18b4cb7 72 towers.add(new Tower(tower));
84086fa3 73 }
e18b4cb7 74
b9b7b3d4 75 return new Model(towers, cubes);
2bb56822 76}