| 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 | class TowerMapping { |
| 17 | public final float x, y, z; |
| 18 | public final float[][] cubePositions; |
| 19 | |
| 20 | TowerMapping(float x, float y, float z, float[][] cubePositions) { |
| 21 | this.x = x; |
| 22 | this.y = y; |
| 23 | this.z = z; |
| 24 | this.cubePositions = cubePositions; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public Model buildModel() { |
| 29 | // The model is represented as an array of towers. The cubes in the tower |
| 30 | // are represenented relatively. Each tower has an x, y, z reference position, |
| 31 | // which is typically the base cube's bottom left corner. |
| 32 | // |
| 33 | // Following that is an array of floats. A 2-d array contains an x-offset |
| 34 | // and a z-offset from the reference position. Typically the first cube |
| 35 | // will just be {0, 0}. |
| 36 | // |
| 37 | // A 3-d array contains an x-offset, a z-offset, and a rotation about the |
| 38 | // y-axis. |
| 39 | // |
| 40 | // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT. |
| 41 | TowerMapping[] mapping = new TowerMapping[] { |
| 42 | |
| 43 | new TowerMapping(0, 0, 0, new float[][] { |
| 44 | {0, 0}, |
| 45 | {5, -10, 20}, |
| 46 | {0, -6}, |
| 47 | {-5, -2, -20}, |
| 48 | }), |
| 49 | |
| 50 | new TowerMapping(Cube.EDGE_WIDTH + 2, 0, 0, new float[][] { |
| 51 | {0, 0}, |
| 52 | {0, 5, 10}, |
| 53 | {0, 2, 20}, |
| 54 | {0, 0, 30}, |
| 55 | }), |
| 56 | |
| 57 | // Back Cubes behind DJ platform (in order of increasing x) |
| 58 | new TowerMapping(50, 5, BASS_DEPTH, new float[][] { |
| 59 | {0, 0}, |
| 60 | {2, 0, 20}, |
| 61 | {-2, 10}, |
| 62 | {-5, 15, -20}, |
| 63 | {-2, 13}, |
| 64 | }), |
| 65 | |
| 66 | new TowerMapping(79, 5, BASS_DEPTH, new float[][] { |
| 67 | {0, 0}, |
| 68 | {2, 0, 20}, |
| 69 | {4, 10}, |
| 70 | {2, 15, -20}, |
| 71 | {0, 13}, |
| 72 | }), |
| 73 | |
| 74 | new TowerMapping(107, 5, BASS_DEPTH, new float[][] { |
| 75 | {0, 0}, |
| 76 | {4, 0, 20}, |
| 77 | {6, 10}, |
| 78 | {3, 15, -20}, |
| 79 | // {8, 13}, |
| 80 | }), |
| 81 | |
| 82 | new TowerMapping(133, 5, BASS_DEPTH, new float[][] { |
| 83 | {0, 0}, |
| 84 | {-2, 0, 20}, |
| 85 | {0, 10}, |
| 86 | {2, 15, -20}, |
| 87 | // {4, 13} |
| 88 | }), |
| 89 | |
| 90 | new TowerMapping(165, 5, BASS_DEPTH, new float[][] { |
| 91 | {0, 0}, |
| 92 | {-1, 20}, |
| 93 | {2, 10}, |
| 94 | {-2, 15, -20}, |
| 95 | {3, 13}, |
| 96 | }), |
| 97 | |
| 98 | // front DJ cubes |
| 99 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2, BASS_HEIGHT, 10, new float[][] { |
| 100 | {0, 0}, |
| 101 | {0, -10, 20}, |
| 102 | }), |
| 103 | |
| 104 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + Cube.EDGE_HEIGHT, BASS_HEIGHT, 10, new float[][] { |
| 105 | {3, 0}, |
| 106 | {2, -10, 20}, |
| 107 | }), |
| 108 | |
| 109 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + 2*Cube.EDGE_HEIGHT + 5, BASS_HEIGHT, 10, new float[][] { |
| 110 | {0, 0}, |
| 111 | {1, 0, 10}, |
| 112 | }), |
| 113 | |
| 114 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + 3*Cube.EDGE_HEIGHT + 9, BASS_HEIGHT, 10, new float[][] { |
| 115 | {0, 0}, |
| 116 | {-1, 0}, |
| 117 | }), |
| 118 | |
| 119 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BASS_HEIGHT, 10, new float[][] { |
| 120 | {0, 0}, |
| 121 | {-1, 0}, |
| 122 | }), |
| 123 | |
| 124 | // left dj cubes |
| 125 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2, BASS_HEIGHT, Cube.EDGE_HEIGHT + 2, new float[][] { |
| 126 | {0, 0}, |
| 127 | {0, 2, 20}, |
| 128 | }), |
| 129 | |
| 130 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2, BASS_HEIGHT, 2*Cube.EDGE_HEIGHT + 4, new float[][] { |
| 131 | {0, 0}, |
| 132 | {0, 2, 20}, |
| 133 | }), |
| 134 | |
| 135 | // right dj cubes |
| 136 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BASS_HEIGHT, Cube.EDGE_HEIGHT + 2, new float[][] { |
| 137 | {0, 0}, |
| 138 | {0, 2, 20}, |
| 139 | }), |
| 140 | |
| 141 | new TowerMapping((TRAILER_WIDTH - BASS_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BASS_HEIGHT, 2*Cube.EDGE_HEIGHT + 4, new float[][] { |
| 142 | {0, 0}, |
| 143 | {0, 2, 20}, |
| 144 | }), |
| 145 | |
| 146 | new TowerMapping(200, 0, 0, new float[][] { |
| 147 | {0, 10}, |
| 148 | {5, 0, 20}, |
| 149 | {0, 4}, |
| 150 | {-5, 8, -20}, |
| 151 | {0, 3}, |
| 152 | }), |
| 153 | |
| 154 | new TowerMapping(0, 0, Cube.EDGE_HEIGHT + 10, new float[][] { |
| 155 | {10, 0, 40}, |
| 156 | {3, -2, 20}, |
| 157 | {0, 0, 40}, |
| 158 | {0, 0, 60}, |
| 159 | {0, 0, 40}, |
| 160 | }), |
| 161 | |
| 162 | new TowerMapping(20, 0, 2*Cube.EDGE_HEIGHT + 18, new float[][] { |
| 163 | {0, 0, 40}, |
| 164 | {10, 0, 20}, |
| 165 | {5, 0, 40}, |
| 166 | {10, 0, 60}, |
| 167 | {12, 0, 40}, |
| 168 | }), |
| 169 | |
| 170 | new TowerMapping(210, 0, Cube.EDGE_HEIGHT + 15, new float[][] { |
| 171 | {0, 0, 40}, |
| 172 | {5, 0, 20}, |
| 173 | {8, 0, 40}, |
| 174 | {3, 0, 60}, |
| 175 | {0, 0, 40}, |
| 176 | }), |
| 177 | |
| 178 | new TowerMapping(210, 0, 2*Cube.EDGE_HEIGHT + 25, new float[][] { |
| 179 | {0, 0, 40}, |
| 180 | {5, 0, 20}, |
| 181 | {2, 0, 40}, |
| 182 | {5, 0, 60}, |
| 183 | {0, 0, 40}, |
| 184 | }), |
| 185 | |
| 186 | }; |
| 187 | |
| 188 | ArrayList<Tower> towerList = new ArrayList<Tower>(); |
| 189 | ArrayList<Cube> tower; |
| 190 | Cube[] cubes = new Cube[79]; |
| 191 | int cubeIndex = 1; |
| 192 | float x, y, z, ry; |
| 193 | for (TowerMapping tm : mapping) { |
| 194 | tower = new ArrayList<Cube>(); |
| 195 | x = tm.x; |
| 196 | y = tm.y; |
| 197 | z = tm.z; |
| 198 | for (float[] cp : tm.cubePositions) { |
| 199 | ry = (cp.length >= 3) ? cp[2] : 0; |
| 200 | tower.add(cubes[cubeIndex++] = new Cube(x + cp[0], y, z + cp[1], 0, ry, 0)); |
| 201 | y += Cube.EDGE_HEIGHT; |
| 202 | } |
| 203 | towerList.add(new Tower(tower)); |
| 204 | } |
| 205 | |
| 206 | return new Model(towerList, cubes); |
| 207 | } |
| 208 | |
| 209 | public PandaMapping[] buildPandaList() { |
| 210 | return new PandaMapping[] { |
| 211 | new PandaMapping( |
| 212 | "10.200.1.28", new int[][] { |
| 213 | { 1, 2, 3, 4 }, // ch1 |
| 214 | { 5, 6, 7, 8 }, // ch2 |
| 215 | { 9, 10, 11, 12 }, // ch3 |
| 216 | { 13, 14, 15, 16 }, // ch4 |
| 217 | { 17, 18, 19, 20 }, // ch5 |
| 218 | { 21, 22, 23, 24 }, // ch6 |
| 219 | { 25, 26, 27, 28 }, // ch7 |
| 220 | { 29, 30, 31, 32 }, // ch8 |
| 221 | }), |
| 222 | |
| 223 | new PandaMapping( |
| 224 | "10.200.1.29", new int[][] { |
| 225 | { 33, 34, 35, 36 }, // ch9 |
| 226 | { 37, 38, 39, 40 }, // ch10 |
| 227 | { 41, 42, 43, 44 }, // ch11 |
| 228 | { 45, 46, 47, 48 }, // ch12 |
| 229 | { 49, 50, 51, 52 }, // ch13 |
| 230 | { 53, 54, 55, 56 }, // ch14 |
| 231 | { 57, 58, 59, 60 }, // ch15 |
| 232 | { 61, 62, 63, 64 }, // ch16 |
| 233 | }), |
| 234 | |
| 235 | }; |
| 236 | } |
| 237 | |
| 238 | class PandaMapping { |
| 239 | |
| 240 | // How many channels are on the panda board |
| 241 | public final static int CHANNELS_PER_BOARD = 8; |
| 242 | |
| 243 | // How many cubes per channel xc_PB is configured for |
| 244 | public final static int CUBES_PER_CHANNEL = 4; |
| 245 | |
| 246 | // How many total pixels on each channel |
| 247 | public final static int PIXELS_PER_CHANNEL = Cube.POINTS_PER_CUBE * CUBES_PER_CHANNEL; |
| 248 | |
| 249 | // How many total pixels on the whole board |
| 250 | public final static int PIXELS_PER_BOARD = PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD; |
| 251 | |
| 252 | final String ip; |
| 253 | final int[][] channelList = new int[CHANNELS_PER_BOARD][CUBES_PER_CHANNEL]; |
| 254 | |
| 255 | PandaMapping(String ip, int[][] rawChannelList) { |
| 256 | this.ip = ip; |
| 257 | for (int chi = 0; chi < CHANNELS_PER_BOARD; ++chi) { |
| 258 | int[] cubes = (chi < rawChannelList.length) ? rawChannelList[chi] : new int[]{}; |
| 259 | for (int cui = 0; cui < CUBES_PER_CHANNEL; ++cui) { |
| 260 | channelList[chi][cui] = (cui < cubes.length) ? cubes[cui] : 0; |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | |