weird merge shit
[SugarCubes.git] / _Mappings.pde
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 <<<<<<< HEAD
17 final int MaxCubeHeight = 6;
18 final int NumBackTowers = 16;
19
20 public Model buildModel() {
21
22 // Shorthand helpers for specifying wiring more quickly
23 final Cube.Wiring WFL = Cube.Wiring.FRONT_LEFT;
24 final Cube.Wiring WFR = Cube.Wiring.FRONT_RIGHT;
25 final Cube.Wiring WRL = Cube.Wiring.REAR_LEFT;
26 final Cube.Wiring WRR = Cube.Wiring.REAR_RIGHT;
27
28 // Utility value if you need the height of a cube shorthand
29 final float CH = Cube.EDGE_HEIGHT;
30 final float CW = Cube.EDGE_WIDTH ;
31
32 // Positions for the bass box
33 final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH;
34 final float BBX = 56;
35 final float BBZ = 2;
36
37 // The model is represented as an array of towers. The cubes in the tower
38 // are represenented relatively. Each tower has an x, y, z reference position,
39 // which is typically the base cube's bottom left corner.
40 //
41 // Following that is an array of floats. A 2-d array contains an x-offset
42 // and a z-offset from the previous reference position. Typically the first cube
43 // will just be {0, 0}. Each successive cube uses the position of the previous
44 // cube as its reference.
45 //
46 // A 3-d array contains an x-offset, a z-offset, and a rotation about the
47 // y-axis.
48 //
49 // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
50
51 // To-Do: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list.
52 // "raw object index" is serialized by running through towermapping and then individual cube mapping below.
53 // We can do better than this. The raw object index should be obvious from the code-- looking through the
54 // rendered simulation and counting through cubes in mapping mode is grossly inefficient.
55
56 TowerMapping[] towerCubes = new TowerMapping[] {};
57
58 // Single cubes can be constructed directly here if you need them
59 Cube[] singleCubes = new Cube[] {
60 // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL), // Back left channel behind speaker
61 //new Cube(x, y, z, rx, ry, rz, wiring),
62 //new Cube(0,0,0,0,225,0, WRR),
63 };
64
65 // The bass box!
66 // BassBox bassBox = BassBox.unlitBassBox(BBX, 0, BBZ); // frame exists, no lights
67 BassBox bassBox = BassBox.noBassBox(); // no bass box at all
68 // BassBox bassBox = new BassBox(BBX, 0, BBZ); // bass box with lights
69
70 // The speakers!
71 List<Speaker> speakers = Arrays.asList(new Speaker[] {
72 // Each speaker parameter is x, y, z, rotation, the left speaker comes first
73 // new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15)
74 });
75
76
77 ////////////////////////////////////////////////////////////////////////
78 // dan's proposed lattice
79 ArrayList<StaggeredTower> scubes = new ArrayList<StaggeredTower>();
80 //if (NumBackTowers != 25) exit();
81 for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
82 (i+1)*CW, // x
83 (i % 2 == 0) ? 0 : CH * 2./3. , // y
84 - ((i % 2 == 0) ? 11 : 0) + 80 , // z
85 -45, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight) ); // num cubes
86
87 for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
88 (i+1)*CW, // x
89 (i % 2 == 0) ? 0 : CH * 2./3. , // y
90 - ((i % 2 == 0) ? 0 : 11) + 80 - pow(CH*CH + CW*CW, .5), // z
91 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) );
92
93 // for (int i=0; i<2 ; i++) scubes.add(new StaggeredTower(
94 // (i+1)*CW, // x
95 // 0 , // y
96 // - 0 + 97 - 2*pow(CH*CH + CW*CW, .5), // z
97 // 225, MaxCubeHeight ) );
98
99 ArrayList<Cube> dcubes = new ArrayList<Cube>();
100 // for (int i=1; i<6; i++) {
101 // if (i>1) dcubes.add(new Cube(-6+CW*4/3*i , 0, 0, 0, 0, 0, WRR));
102 // dcubes.add(new Cube(-6+CW*4/3*i+CW*2/3., CH*.5, 0, 0, 0, 0, WRR));
103 // }
104
105 float current_x_position = 0;
106 // scubes.add(new StaggeredTower(//tower 1
107 // current_x_position, // x
108 // 15 , // y
109 // 0 , // z
110 // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) );
111 // current_x_position += 25.25;
112 // scubes.add(new StaggeredTower(// tower 2
113 // current_x_position, // x
114 // 0 , // y
115 // -10.5 , // z
116 // 45, 6, new Cube.Wiring[] { WFR, WFL, WRR, WRR, WFL, WRR}) );
117 // current_x_position += 25.25;
118 // scubes.add(new StaggeredTower(//tower 3
119 // current_x_position, // x
120 // 15 , // y
121 // 0, // z
122 // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WRR, WFL, WRR}) );
123 // current_x_position += 25.25;
124 // scubes.add(new StaggeredTower(//tower 4
125 // current_x_position, // x
126 // 0, // y
127 // -10.5 , // z
128 // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) );
129 // current_x_position += 28;
130 // scubes.add(new StaggeredTower(//tower 5
131 // current_x_position, // x
132 // 15 , // y
133 // -4.5 , // z
134 // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WFL, WRR, WFL}) );
135 // current_x_position += 28;
136 // scubes.add(new StaggeredTower(//tower 6
137 // current_x_position, // x
138 // 0 , // y
139 // -10.5, // z
140 // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) );
141 // current_x_position += 25.25;
142 // scubes.add(new StaggeredTower(// tower 7
143 // current_x_position, // x
144 // 15 , // y
145 // 0, // z
146 // 45, 6, new Cube.Wiring[] { WRR, WFL, WRR, WFL, WRR, WFL}) );
147 // current_x_position += 25.25;
148 // scubes.add(new StaggeredTower(//tower 8
149 // current_x_position, // x
150 // 0 , // y
151 // -10.5 , // z
152 // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) );
153 // current_x_position += 25.25;
154 // scubes.add(new StaggeredTower(//tower 9
155 // current_x_position, // x
156 // 15 , // y
157 // 0, // z
158 // 45, 6, new Cube.Wiring[] { WFL, WRR, WFL, WRR, WFL, WRR}) );
159 // current_x_position += 25.25;
160
161 // //TOWERS ON DANCE FLOOR
162 // scubes.add(new StaggeredTower(//tower 10
163 // 83.75+39+43-124.5, // x
164 // 0, // y
165 // -47.5-43, // z
166 // 45, 4, new Cube.Wiring[]{ WRR, WFL, WFL, WRR}) );
167 // scubes.add(new StaggeredTower(//tower 11
168 // 83.75, // x
169 // 0, // y
170 // -47.5, // z
171 // 45, 4, new Cube.Wiring[]{ WFL, WRR, WRR, WFL}) );
172 // scubes.add(new StaggeredTower(//tower 12
173 // 83.75+39, // x
174 // 0, // y
175 // -47.5, // z
176 // 45, 4, new Cube.Wiring[]{ WRR, WFL, WFL, WRR}) );
177 // scubes.add(new StaggeredTower(//tower 13
178 // 83.75+39+43, // x
179 // 0, // y
180 // -47.5-43, // z
181 // 45, 4, new Cube.Wiring[]{ WFL, WRR, WFL, WRR}) );
182
183 // scubes.add(new StaggeredTower(// Single cube on top of tower 4
184 // 42, // x
185 // 112 , // y
186 // 72, // z
187 // -10, 1, new Cube.Wiring[]{ WRL}) );
188
189
190
191
192
193
194
195 //////////////////////////////////////////////////////////////////////
196 // BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! //
197 //////////////////////////////////////////////////////////////////////
198
199 // These guts just convert the shorthand mappings into usable objects
200 ArrayList<Tower> towerList = new ArrayList<Tower>();
201 ArrayList<Cube> tower;
202 Cube[] cubes = new Cube[200];
203 int cubeIndex = 1;
204 float px, pz, ny;
205 for (TowerMapping tm : towerCubes) {
206 px = tm.x;
207 ny = tm.y;
208 pz = tm.z;
209 tower = new ArrayList<Cube>();
210 for (CubeMapping cm : tm.cubeMappings) {
211 tower.add(cubes[cubeIndex++] = new Cube(px = px + cm.dx, ny, pz = pz + cm.dz, 0, cm.ry, 0, cm.wiring));
212 ny += Cube.EDGE_HEIGHT;
213 }
214 towerList.add(new Tower(tower));
215 }
216
217
218 for (Cube cube : singleCubes) {
219 cubes[cubeIndex++] = cube;
220 }
221 for (Cube cube : dcubes) {
222 cubes[cubeIndex++] = cube;
223 }
224 for (StaggeredTower st : scubes) {
225 tower = new ArrayList<Cube>();
226 for (int i=0; i < st.n; i++) {
227 Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR;
228 tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w));
229 }
230 towerList.add(new Tower(tower));
231 }
232
233 return new Model(towerList, cubes, bassBox, speakers);
234 }
235 =======
236 static final float SPACING = 27;
237 static final float RISER = 13.5;
238 static final float FLOOR = 0;
239 >>>>>>> 21dffb1b77608cacc57382f3eb6eac3ed16054c3
240
241 /**
242 * Definitions of tower positions. This is all that should need
243 * to be modified. Distances are measured from the left-most cube.
244 * The first value is the offset moving NE (towards back-right).
245 * The second value is the offset moving NW (negative comes forward-right).
246 */
247 static final float[][] TOWER_CONFIG = new float[][] {
248 new float[] { 0, 0, RISER, 4 },
249 new float[] { 25, -10, RISER, 4 },
250 new float[] { 50, -22.5, FLOOR, 5 },
251 new float[] { 17.25, -35.5, FLOOR, 6 },
252 new float[] { 43.25, -51.5, RISER, 6 },
253 new float[] { 69.25, -56, FLOOR, 6 },
254 new float[] { 12.75, -62.5, RISER, 4 },
255 new float[] { 38.75, -78.5, FLOOR, 5 },
256 new float[] { 65.75, -83, RISER, 5 },
257
258 };
259
260 public Model buildModel() {
261
262 List<Tower> towers = new ArrayList<Tower>();
263 Cube[] cubes = new Cube[200];
264 int cubeIndex = 1;
265
266 float rt2 = sqrt(2);
267 float x, y, z, xd, zd, num;
268 for (float[] tc : TOWER_CONFIG) {
269 x = -tc[1];
270 z = tc[0];
271 y = tc[2];
272 num = tc[3];
273 if (z < x) {
274 zd = -(x-z)/rt2;
275 xd = z*rt2 - zd;
276 } else {
277 zd = (z-x)/rt2;
278 xd = z*rt2 - zd;
279 }
280 List<Cube> tower = new ArrayList<Cube>();
281 for (int n = 0; n < num; ++n) {
282 Cube cube = new Cube(xd + 24, y, zd + 84, 0, -45, 0);
283 tower.add(cube);
284 cubes[cubeIndex++] = cube;
285 y += SPACING;
286 }
287 towers.add(new Tower(tower));
288 }
289
290 return new Model(towers, cubes);
291 }