2 * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND
5 * ///\\\ ///\\\ ///\\\ ///\\\
6 * \\\/// \\\/// \\\/// \\\///
9 * EXPERTS ONLY!! EXPERTS ONLY!!
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.
16 public Model buildModel() {
18 final float BASS_FLOOR = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH;
20 // Shorthand helpers for specifying wiring more quickly
21 final Cube.Wiring WFL = Cube.Wiring.FRONT_LEFT;
22 final Cube.Wiring WFR = Cube.Wiring.FRONT_RIGHT;
23 final Cube.Wiring WRL = Cube.Wiring.REAR_LEFT;
24 final Cube.Wiring WRR = Cube.Wiring.REAR_RIGHT;
26 // The model is represented as an array of towers. The cubes in the tower
27 // are represenented relatively. Each tower has an x, y, z reference position,
28 // which is typically the base cube's bottom left corner.
30 // Following that is an array of floats. A 2-d array contains an x-offset
31 // and a z-offset from the previous reference position. Typically the first cube
32 // will just be {0, 0}. Each successive cube uses the position of the previous
33 // cube as its reference.
35 // A 3-d array contains an x-offset, a z-offset, and a rotation about the
38 // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
39 TowerMapping[] towerCubes = new TowerMapping[] {
41 new TowerMapping(50, 0, 80, new CubeMapping[] {
42 new CubeMapping(0, 0, WFL),
47 // Single cubes can be constructed directly here if you need them
48 Cube[] singleCubes = new Cube[] {
49 // new Cube(x, y, z, rx, ry, rz, wiring),
53 BassBox bassBox = new BassBox(56, 0, 2);
56 List<Speaker> speakers = Arrays.asList(new Speaker[] {
57 new Speaker(-12, 6, 0, 15),
58 new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH, 6, 6, -15)
61 // These guts just convert the shorthand mappings into usable objects
62 ArrayList<Tower> towerList = new ArrayList<Tower>();
63 ArrayList<Cube> tower;
64 Cube[] cubes = new Cube[80];
67 for (TowerMapping tm : towerCubes) {
71 tower = new ArrayList<Cube>();
72 for (CubeMapping cm : tm.cubeMappings) {
73 tower.add(cubes[cubeIndex++] = new Cube(px = px + cm.dx, ny, pz = pz + cm.dz, 0, cm.ry, 0, cm.wiring));
74 ny += Cube.EDGE_HEIGHT;
76 towerList.add(new Tower(tower));
78 for (Cube cube : singleCubes) {
79 cubes[cubeIndex++] = cube;
82 return new Model(towerList, cubes, bassBox, speakers);
85 public PandaMapping[] buildPandaList() {
86 return new PandaMapping[] {
88 "10.200.1.28", new ChannelMapping[] {
89 new ChannelMapping(ChannelMapping.MODE_BASS),
90 new ChannelMapping(ChannelMapping.MODE_FLOOR),
91 new ChannelMapping(ChannelMapping.MODE_SPEAKER, 0),
92 new ChannelMapping(ChannelMapping.MODE_SPEAKER, 1),
93 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1 }),
94 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
95 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
96 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
97 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
98 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
99 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
100 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
101 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
105 "10.200.1.29", new ChannelMapping[] {
106 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
107 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
108 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
109 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
110 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
111 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
112 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
113 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
114 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
115 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
116 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
117 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
118 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
124 public final float x, y, z;
125 public final CubeMapping[] cubeMappings;
127 TowerMapping(float x, float y, float z, CubeMapping[] cubeMappings) {
131 this.cubeMappings = cubeMappings;
136 public final float dx, dz, ry;
137 public final Cube.Wiring wiring;
139 CubeMapping(float dx, float dz, Cube.Wiring wiring) {
140 this(dx, dz, 0, wiring);
143 CubeMapping(float dx, float dz, float ry) {
144 this(dz, dz, ry, Cube.Wiring.FRONT_LEFT);
147 CubeMapping(float dx, float dz, float ry, Cube.Wiring wiring) {
151 this.wiring = wiring;
156 * Each panda board has an IP address and a fixed number of channels. The channels
157 * each have a fixed number of pixels on them. Whether or not that many physical
158 * pixels are connected to the channel, we still send it that much data.
162 // How many channels are on the panda board
163 public final static int CHANNELS_PER_BOARD = 13;
165 // How many total pixels on the whole board
166 public final static int PIXELS_PER_BOARD = ChannelMapping.PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD;
169 final ChannelMapping[] channelList = new ChannelMapping[CHANNELS_PER_BOARD];
171 PandaMapping(String ip, ChannelMapping[] rawChannelList) {
174 // Ensure our array is the right length and has all valid items in it
175 for (int i = 0; i < channelList.length; ++i) {
176 channelList[i] = (i < rawChannelList.length) ? rawChannelList[i] : new ChannelMapping();
177 if (channelList[i] == null) {
178 channelList[i] = new ChannelMapping();
185 * Each channel on a pandaboard can be mapped in a number of modes. The typial is
186 * to a series of connected cubes, but we also have special mappings for the bass box,
187 * the speaker enclosures, and the DJ booth floor.
189 * This class is just the mapping meta-data. It sanitizes the input to make sure
190 * that the cubes and objects being referenced actually exist in the model.
192 * The logic for how to encode the pixels is contained in the PandaDriver.
194 class ChannelMapping {
196 // How many cubes per channel xc_PB is configured for
197 public final static int CUBES_PER_CHANNEL = 4;
199 // How many total pixels on each channel
200 public final static int PIXELS_PER_CHANNEL = Cube.POINTS_PER_CUBE * CUBES_PER_CHANNEL;
202 public static final int MODE_NULL = 0;
203 public static final int MODE_CUBES = 1;
204 public static final int MODE_BASS = 2;
205 public static final int MODE_SPEAKER = 3;
206 public static final int MODE_FLOOR = 4;
207 public static final int MODE_INVALID = 5;
209 public static final int NO_OBJECT = -1;
212 final int[] objectIndices = new int[CUBES_PER_CHANNEL];
218 ChannelMapping(int mode) {
219 this(mode, new int[]{});
222 ChannelMapping(int mode, int rawObjectIndex) {
223 this(mode, new int[]{ rawObjectIndex });
226 ChannelMapping(int mode, int[] rawObjectIndices) {
227 if (mode < 0 || mode >= MODE_INVALID) {
228 throw new RuntimeException("Invalid channel mapping mode: " + mode);
230 if (mode == MODE_SPEAKER) {
231 if (rawObjectIndices.length != 1) {
232 throw new RuntimeException("Speaker channel mapping mode must specify one speaker index");
234 int speakerIndex = rawObjectIndices[0];
235 if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) {
236 throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
238 } else if ((mode == MODE_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
239 if (rawObjectIndices.length > 0) {
240 throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
242 } else if (mode == MODE_CUBES) {
243 for (int rawCubeIndex : rawObjectIndices) {
244 if (glucose.model.getCubeByRawIndex(rawCubeIndex) == null) {
245 throw new RuntimeException("Non-existing cube specified in cube mapping: " + rawCubeIndex);
251 for (int i = 0; i < objectIndices.length; ++i) {
252 objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT;