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 // Shorthand helpers for specifying wiring more quickly
19 final Cube.Wiring WFL = Cube.Wiring.FRONT_LEFT;
20 final Cube.Wiring WFR = Cube.Wiring.FRONT_RIGHT;
21 final Cube.Wiring WRL = Cube.Wiring.REAR_LEFT;
22 final Cube.Wiring WRR = Cube.Wiring.REAR_RIGHT;
24 // Utility value if you need the height of a cube shorthand
25 final float CH = Cube.EDGE_HEIGHT;
26 final float CW = Cube.EDGE_WIDTH ;
28 // Positions for the bass box
29 final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH;
33 // The model is represented as an array of towers. The cubes in the tower
34 // are represenented relatively. Each tower has an x, y, z reference position,
35 // which is typically the base cube's bottom left corner.
37 // Following that is an array of floats. A 2-d array contains an x-offset
38 // and a z-offset from the previous reference position. Typically the first cube
39 // will just be {0, 0}. Each successive cube uses the position of the previous
40 // cube as its reference.
42 // A 3-d array contains an x-offset, a z-offset, and a rotation about the
45 // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
47 // To-Do: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list.
48 // "raw object index" is serialized by running through towermapping and then individual cube mapping below.
49 // We can do better than this. The raw object index should be obvious from the code-- looking through the
50 // rendered simulation and counting through cubes in mapping mode is grossly inefficient.
52 // Single cubes can be constructed directly here if you need them
53 Cube[] singleCubes = new Cube[] {
54 // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL), // Back left channel behind speaker
55 // new Cube(x, y, z, rx, ry, rz, wiring),
56 // new Cube(0,0,0,0,225,0, WRR),
60 BassBox bassBox = BassBox.noBassBox(); // no bass box at all
63 List<Speaker> speakers = Arrays.asList(new Speaker[] {
64 // Each speaker parameter is x, y, z, rotation, the left speaker comes first
65 // new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15)
69 List<StaggeredTower> scubes = new ArrayList<StaggeredTower>();
71 float[] pos = new float[3];
74 scubes.add(new StaggeredTower(//tower 1
78 0, 4, new Cube.Wiring[] {
79 WRR, WRR, WRR, WRR, WRR, WRR
86 scubes.add(new StaggeredTower(// tower 2
90 0, 4, new Cube.Wiring[] {
91 WRR, WRR, WRR, WRR, WRR, WRR
97 scubes.add(new StaggeredTower(//tower 3
101 0, 5, new Cube.Wiring[] {
102 WRR, WRR, WRR, WRR, WRR, WRR
108 scubes.add(new StaggeredTower(//tower 4
112 0, 6, new Cube.Wiring[] {
113 WRR, WRR, WRR, WRR, WRR, WRR
119 scubes.add(new StaggeredTower(//tower 5
123 0, 6, new Cube.Wiring[] {
124 WRR, WRR, WRR, WRR, WRR, WRR
130 scubes.add(new StaggeredTower(//tower 6
134 0, 6, new Cube.Wiring[] {
135 WRR, WRR, WRR, WRR, WRR, WRR
141 scubes.add(new StaggeredTower(// tower 7
145 0, 4, new Cube.Wiring[] {
146 WRR, WRR, WRR, WRR, WRR, WRR
152 scubes.add(new StaggeredTower(//tower 8
156 0, 5, new Cube.Wiring[] {
157 WRR, WRR, WRR, WRR, WRR, WRR
163 scubes.add(new StaggeredTower(//tower 9
167 0, 5, new Cube.Wiring[] {
168 WRR, WRR, WRR, WRR, WRR, WRR
173 //////////////////////////////////////////////////////////////////////
174 // BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! //
175 //////////////////////////////////////////////////////////////////////
177 // These guts just convert the shorthand mappings into usable objects
178 List<Tower> towerList = new ArrayList<Tower>();
180 Cube[] cubes = new Cube[200];
183 for (Cube cube : singleCubes) {
184 cubes[cubeIndex++] = cube;
186 for (StaggeredTower st : scubes) {
187 tower = new ArrayList<Cube>();
188 for (int i = 0; i < st.n; i++) {
189 Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR;
190 tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w));
192 towerList.add(new Tower(tower));
195 return new Model(towerList, cubes, bassBox, speakers);
198 class StaggeredTower {
199 public final float x, y, z, r;
201 public final Cube.Wiring[] wiring;
202 StaggeredTower(float _x, float _y, float _z, float _r, int _n) {
203 this(_x, _y, _z, _r, _n, new Cube.Wiring[] {
207 StaggeredTower(float _x, float _y, float _z, float _r, int _n, Cube.Wiring[] _wiring) {