Commit | Line | Data |
---|---|---|
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 | |
f0cc0ba5 MS |
16 | public Model buildModel() { |
17 | ||
f0cc0ba5 MS |
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; | |
e037f60f | 23 | |
a3ccf23a | 24 | // Utility value if you need the height of a cube shorthand |
95c50032 | 25 | final float CH = Cube.EDGE_HEIGHT; |
73687629 | 26 | final float CW = Cube.EDGE_WIDTH ; |
e037f60f | 27 | |
a3ccf23a | 28 | // Positions for the bass box |
ae579223 MS |
29 | final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH; |
30 | final float BBX = 56; | |
31 | final float BBZ = 2; | |
32 | ||
46fc29d4 MS |
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. | |
36 | // | |
37 | // Following that is an array of floats. A 2-d array contains an x-offset | |
f0cc0ba5 MS |
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. | |
46fc29d4 MS |
41 | // |
42 | // A 3-d array contains an x-offset, a z-offset, and a rotation about the | |
43 | // y-axis. | |
44 | // | |
45 | // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT. | |
e27a8652 | 46 | |
73687629 | 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. | |
e28f168c | 51 | |
f0cc0ba5 MS |
52 | // Single cubes can be constructed directly here if you need them |
53 | Cube[] singleCubes = new Cube[] { | |
bf1fe2d4 | 54 | // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL), // Back left channel behind speaker |
e037f60f MS |
55 | // new Cube(x, y, z, rx, ry, rz, wiring), |
56 | // new Cube(0,0,0,0,225,0, WRR), | |
f0cc0ba5 MS |
57 | }; |
58 | ||
59 | // The bass box! | |
e037f60f MS |
60 | BassBox bassBox = BassBox.noBassBox(); // no bass box at all |
61 | ||
f0cc0ba5 | 62 | // The speakers! |
3b2e0b4a | 63 | List<Speaker> speakers = Arrays.asList(new Speaker[] { |
e037f60f MS |
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) | |
66 | } | |
67 | ); | |
68 | ||
69 | List<StaggeredTower> scubes = new ArrayList<StaggeredTower>(); | |
70 | ||
71 | float[] pos = new float[3]; | |
72 | pos[0] = 50; | |
73 | pos[2] = 100; | |
74 | scubes.add(new StaggeredTower(//tower 1 | |
75 | pos[0], // x | |
76 | 0, // y | |
77 | pos[2], // z | |
78 | 0, 4, new Cube.Wiring[] { | |
79 | WRR, WRR, WRR, WRR, WRR, WRR | |
80 | } | |
81 | )); | |
bf1fe2d4 MS |
82 | |
83 | ||
e037f60f MS |
84 | pos[0] += 25; |
85 | pos[2] -= 10; | |
86 | scubes.add(new StaggeredTower(// tower 2 | |
87 | pos[0], // x | |
88 | 15, // y | |
89 | pos[2], // z | |
90 | 0, 4, new Cube.Wiring[] { | |
91 | WRR, WRR, WRR, WRR, WRR, WRR | |
92 | } | |
93 | )); | |
94 | ||
95 | pos[0] += 25; | |
96 | pos[2] += -12.5; | |
97 | scubes.add(new StaggeredTower(//tower 3 | |
98 | pos[0], // x | |
99 | 0, // y | |
100 | pos[2], // z | |
101 | 0, 5, new Cube.Wiring[] { | |
102 | WRR, WRR, WRR, WRR, WRR, WRR | |
103 | } | |
104 | )); | |
105 | ||
106 | pos[0] += -32.75; | |
107 | pos[2] += -13; | |
108 | scubes.add(new StaggeredTower(//tower 4 | |
109 | pos[0], // x | |
110 | 0, // y | |
111 | pos[2], // z | |
112 | 0, 6, new Cube.Wiring[] { | |
113 | WRR, WRR, WRR, WRR, WRR, WRR | |
114 | } | |
115 | )); | |
116 | ||
117 | pos[0] += 26; | |
118 | pos[2] += -16; | |
119 | scubes.add(new StaggeredTower(//tower 5 | |
120 | pos[0], // x | |
121 | 15, // y | |
122 | pos[2], // z | |
123 | 0, 6, new Cube.Wiring[] { | |
124 | WRR, WRR, WRR, WRR, WRR, WRR | |
125 | } | |
126 | )); | |
127 | ||
128 | pos[0] += 26; | |
129 | pos[2] += -4.5; | |
130 | scubes.add(new StaggeredTower(//tower 6 | |
131 | pos[0], // x | |
132 | 0, // y | |
133 | pos[2], // z | |
134 | 0, 6, new Cube.Wiring[] { | |
135 | WRR, WRR, WRR, WRR, WRR, WRR | |
136 | } | |
137 | )); | |
138 | ||
139 | pos[0] += -56.5; | |
140 | pos[2] += -6.5; | |
141 | scubes.add(new StaggeredTower(// tower 7 | |
142 | pos[0], // x | |
143 | 15, // y | |
144 | pos[2], // z | |
145 | 0, 4, new Cube.Wiring[] { | |
146 | WRR, WRR, WRR, WRR, WRR, WRR | |
147 | } | |
148 | )); | |
149 | ||
150 | pos[0] += 26; | |
151 | pos[2] += -16.5; | |
152 | scubes.add(new StaggeredTower(//tower 8 | |
153 | pos[0], // x | |
154 | 0, // y | |
155 | pos[2], // z | |
156 | 0, 5, new Cube.Wiring[] { | |
157 | WRR, WRR, WRR, WRR, WRR, WRR | |
158 | } | |
159 | )); | |
160 | ||
161 | pos[0] += 27; | |
162 | pos[2] += -4.5; | |
163 | scubes.add(new StaggeredTower(//tower 9 | |
164 | pos[0], // x | |
165 | 15, // y | |
166 | pos[2], // z | |
167 | 0, 5, new Cube.Wiring[] { | |
168 | WRR, WRR, WRR, WRR, WRR, WRR | |
169 | } | |
170 | )); | |
bf1fe2d4 MS |
171 | |
172 | ||
a3ccf23a MS |
173 | ////////////////////////////////////////////////////////////////////// |
174 | // BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! // | |
175 | ////////////////////////////////////////////////////////////////////// | |
176 | ||
f0cc0ba5 | 177 | // These guts just convert the shorthand mappings into usable objects |
e037f60f MS |
178 | List<Tower> towerList = new ArrayList<Tower>(); |
179 | List<Cube> tower; | |
3fa45e9e | 180 | Cube[] cubes = new Cube[200]; |
46fc29d4 | 181 | int cubeIndex = 1; |
73687629 | 182 | |
cd1c3313 MS |
183 | for (Cube cube : singleCubes) { |
184 | cubes[cubeIndex++] = cube; | |
185 | } | |
270a8b44 | 186 | for (StaggeredTower st : scubes) { |
73687629 | 187 | tower = new ArrayList<Cube>(); |
e037f60f | 188 | for (int i = 0; i < st.n; i++) { |
bf1fe2d4 MS |
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)); | |
191 | } | |
73687629 | 192 | towerList.add(new Tower(tower)); |
2bb56822 | 193 | } |
e76480d4 | 194 | |
7dceead9 | 195 | return new Model(towerList, cubes, bassBox, speakers); |
186bc4d3 | 196 | } |
e73ef85d | 197 | |
73687629 | 198 | class StaggeredTower { |
199 | public final float x, y, z, r; | |
200 | public final int n; | |
bf1fe2d4 | 201 | public final Cube.Wiring[] wiring; |
e037f60f MS |
202 | StaggeredTower(float _x, float _y, float _z, float _r, int _n) { |
203 | this(_x, _y, _z, _r, _n, new Cube.Wiring[] { | |
045b432d | 204 | } |
e037f60f | 205 | ); |
e73ef85d | 206 | } |
e037f60f MS |
207 | StaggeredTower(float _x, float _y, float _z, float _r, int _n, Cube.Wiring[] _wiring) { |
208 | x=_x; | |
209 | y=_y; | |
210 | z=_z; | |
211 | r=_r; | |
212 | n=_n; | |
213 | wiring=_wiring; | |
84086fa3 | 214 | } |
2bb56822 | 215 | } |
e037f60f | 216 |