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 final float CH = Cube.EDGE_HEIGHT;
28 // The model is represented as an array of towers. The cubes in the tower
29 // are represenented relatively. Each tower has an x, y, z reference position,
30 // which is typically the base cube's bottom left corner.
32 // Following that is an array of floats. A 2-d array contains an x-offset
33 // and a z-offset from the previous reference position. Typically the first cube
34 // will just be {0, 0}. Each successive cube uses the position of the previous
35 // cube as its reference.
37 // A 3-d array contains an x-offset, a z-offset, and a rotation about the
40 // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
41 TowerMapping[] towerCubes = new TowerMapping[] {
43 new TowerMapping(50, 0, 80, new CubeMapping[] {
44 new CubeMapping(0, 0, WFL),
49 // Single cubes can be constructed directly here if you need them
50 Cube[] singleCubes = new Cube[] {
51 // new Cube(x, y, z, rx, ry, rz, wiring),
55 BassBox bassBox = new BassBox(56, 0, 2);
58 List<Speaker> speakers = Arrays.asList(new Speaker[] {
59 new Speaker(-12, 6, 0, 15),
60 new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH, 6, 6, -15)
63 // These guts just convert the shorthand mappings into usable objects
64 ArrayList<Tower> towerList = new ArrayList<Tower>();
65 ArrayList<Cube> tower;
66 Cube[] cubes = new Cube[80];
69 for (TowerMapping tm : towerCubes) {
73 tower = new ArrayList<Cube>();
74 for (CubeMapping cm : tm.cubeMappings) {
75 tower.add(cubes[cubeIndex++] = new Cube(px = px + cm.dx, ny, pz = pz + cm.dz, 0, cm.ry, 0, cm.wiring));
76 ny += Cube.EDGE_HEIGHT;
78 towerList.add(new Tower(tower));
80 for (Cube cube : singleCubes) {
81 cubes[cubeIndex++] = cube;
84 return new Model(towerList, cubes, bassBox, speakers);
87 public PandaMapping[] buildPandaList() {
88 return new PandaMapping[] {
90 "10.200.1.28", new ChannelMapping[] {
91 new ChannelMapping(ChannelMapping.MODE_BASS),
92 new ChannelMapping(ChannelMapping.MODE_FLOOR),
93 new ChannelMapping(ChannelMapping.MODE_SPEAKER, 0),
94 new ChannelMapping(ChannelMapping.MODE_SPEAKER, 1),
95 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1 }),
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[] { }),
102 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
103 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
107 "10.200.1.29", new ChannelMapping[] {
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[] { }),
119 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
120 new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
126 public final float x, y, z;
127 public final CubeMapping[] cubeMappings;
129 TowerMapping(float x, float y, float z, CubeMapping[] cubeMappings) {
133 this.cubeMappings = cubeMappings;
138 public final float dx, dz, ry;
139 public final Cube.Wiring wiring;
141 CubeMapping(float dx, float dz, Cube.Wiring wiring) {
142 this(dx, dz, 0, wiring);
145 CubeMapping(float dx, float dz, float ry) {
146 this(dz, dz, ry, Cube.Wiring.FRONT_LEFT);
149 CubeMapping(float dx, float dz, float ry, Cube.Wiring wiring) {
153 this.wiring = wiring;
158 * Each panda board has an IP address and a fixed number of channels. The channels
159 * each have a fixed number of pixels on them. Whether or not that many physical
160 * pixels are connected to the channel, we still send it that much data.
164 // How many channels are on the panda board
165 public final static int CHANNELS_PER_BOARD = 13;
167 // How many total pixels on the whole board
168 public final static int PIXELS_PER_BOARD = ChannelMapping.PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD;
171 final ChannelMapping[] channelList = new ChannelMapping[CHANNELS_PER_BOARD];
173 PandaMapping(String ip, ChannelMapping[] rawChannelList) {
176 // Ensure our array is the right length and has all valid items in it
177 for (int i = 0; i < channelList.length; ++i) {
178 channelList[i] = (i < rawChannelList.length) ? rawChannelList[i] : new ChannelMapping();
179 if (channelList[i] == null) {
180 channelList[i] = new ChannelMapping();
187 * Each channel on a pandaboard can be mapped in a number of modes. The typial is
188 * to a series of connected cubes, but we also have special mappings for the bass box,
189 * the speaker enclosures, and the DJ booth floor.
191 * This class is just the mapping meta-data. It sanitizes the input to make sure
192 * that the cubes and objects being referenced actually exist in the model.
194 * The logic for how to encode the pixels is contained in the PandaDriver.
196 class ChannelMapping {
198 // How many cubes per channel xc_PB is configured for
199 public final static int CUBES_PER_CHANNEL = 4;
201 // How many total pixels on each channel
202 public final static int PIXELS_PER_CHANNEL = Cube.POINTS_PER_CUBE * CUBES_PER_CHANNEL;
204 public static final int MODE_NULL = 0;
205 public static final int MODE_CUBES = 1;
206 public static final int MODE_BASS = 2;
207 public static final int MODE_SPEAKER = 3;
208 public static final int MODE_FLOOR = 4;
209 public static final int MODE_INVALID = 5;
211 public static final int NO_OBJECT = -1;
214 final int[] objectIndices = new int[CUBES_PER_CHANNEL];
220 ChannelMapping(int mode) {
221 this(mode, new int[]{});
224 ChannelMapping(int mode, int rawObjectIndex) {
225 this(mode, new int[]{ rawObjectIndex });
228 ChannelMapping(int mode, int[] rawObjectIndices) {
229 if (mode < 0 || mode >= MODE_INVALID) {
230 throw new RuntimeException("Invalid channel mapping mode: " + mode);
232 if (mode == MODE_SPEAKER) {
233 if (rawObjectIndices.length != 1) {
234 throw new RuntimeException("Speaker channel mapping mode must specify one speaker index");
236 int speakerIndex = rawObjectIndices[0];
237 if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) {
238 throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
240 } else if ((mode == MODE_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
241 if (rawObjectIndices.length > 0) {
242 throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
244 } else if (mode == MODE_CUBES) {
245 for (int rawCubeIndex : rawObjectIndices) {
246 if (glucose.model.getCubeByRawIndex(rawCubeIndex) == null) {
247 throw new RuntimeException("Non-existing cube specified in cube mapping: " + rawCubeIndex);
253 for (int i = 0; i < objectIndices.length; ++i) {
254 objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT;