1 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.objectlib.objects;
|
21 |
|
|
|
22 |
|
|
import static org.distorted.objectlib.main.Movement.TYPE_NOT_SPLIT;
|
23 |
|
|
|
24 |
|
|
import android.content.res.Resources;
|
25 |
|
|
|
26 |
|
|
import org.distorted.library.main.DistortedEffects;
|
27 |
|
|
import org.distorted.library.main.DistortedTexture;
|
28 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
29 |
|
|
import org.distorted.library.type.Static3D;
|
30 |
|
|
import org.distorted.library.type.Static4D;
|
31 |
|
|
|
32 |
|
|
import org.distorted.objectlib.R;
|
33 |
|
|
import org.distorted.objectlib.main.Movement;
|
34 |
|
|
import org.distorted.objectlib.main.Movement6;
|
35 |
8005e762
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectType;
|
36 |
29b82486
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectShape;
|
37 |
|
|
import org.distorted.objectlib.main.ObjectSticker;
|
38 |
|
|
import org.distorted.objectlib.main.ScrambleState;
|
39 |
|
|
import org.distorted.objectlib.main.Twisty6;
|
40 |
|
|
|
41 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42 |
|
|
|
43 |
|
|
public class TwistyMirror extends Twisty6
|
44 |
|
|
{
|
45 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
46 |
|
|
{
|
47 |
|
|
new Static3D(1,0,0),
|
48 |
|
|
new Static3D(0,1,0),
|
49 |
|
|
new Static3D(0,0,1)
|
50 |
|
|
};
|
51 |
|
|
|
52 |
|
|
private static final int[][][] ENABLED = new int[][][]
|
53 |
|
|
{
|
54 |
|
|
{{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}},
|
55 |
|
|
};
|
56 |
|
|
|
57 |
|
|
private static final int[] FACE_COLORS = new int[] { COLOR_WHITE };
|
58 |
|
|
private static final float DX = 0.10f;
|
59 |
|
|
private static final float DY = 0.25f;
|
60 |
|
|
private static final float DZ = 0.40f;
|
61 |
|
|
|
62 |
cc448c54
|
Leszek Koltunski
|
private static final float[][] SEQ2 = new float[][]
|
63 |
|
|
{
|
64 |
|
|
{1-DX,1-DY},{1+DX,1-DY},{1-DX,1+DY},{1+DX,1+DY},
|
65 |
|
|
{1-DX,1-DZ},{1+DX,1-DZ},{1-DX,1+DZ},{1+DX,1+DZ},
|
66 |
|
|
{1-DZ,1-DY},{1+DZ,1-DY},{1-DZ,1+DY},{1+DZ,1+DY},
|
67 |
|
|
};
|
68 |
|
|
|
69 |
|
|
private static final float[][] SEQ3 = new float[][]
|
70 |
|
|
{
|
71 |
|
|
{1 ,1 },{1-DX,1-DY},{1 ,1-DY},{1+DX,1-DY},{1-DX,1 },
|
72 |
|
|
{1+DX,1 },{1-DX,1+DY},{1 ,1+DY},{1+DX,1+DY},{1-DX,1-DZ},
|
73 |
|
|
{1 ,1-DZ},{1+DX,1-DZ},{1-DX,1 },{1+DX,1 },{1-DX,1+DZ},
|
74 |
|
|
{1 ,1+DZ},{1+DX,1+DZ},{1-DZ,1-DY},{1 ,1-DY},{1+DZ,1-DY},
|
75 |
|
|
{1-DZ,1 },{1+DZ,1 },{1-DZ,1+DY},{1 ,1+DY},{1+DZ,1+DY},
|
76 |
|
|
};
|
77 |
|
|
|
78 |
29b82486
|
Leszek Koltunski
|
private ScrambleState[] mStates;
|
79 |
|
|
private Static4D[] mQuats;
|
80 |
|
|
private float[][] mCuts;
|
81 |
|
|
private boolean[][] mLayerRotatable;
|
82 |
|
|
private int[] mBasicAngle;
|
83 |
|
|
private ObjectSticker[] mStickers;
|
84 |
|
|
private float[][] mPositions;
|
85 |
|
|
private Movement mMovement;
|
86 |
|
|
|
87 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
|
89 |
|
|
public TwistyMirror(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
90 |
|
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
91 |
|
|
{
|
92 |
61aa85e4
|
Leszek Koltunski
|
super(size, size, quat, texture, mesh, effects, moves, res, scrWidth);
|
93 |
29b82486
|
Leszek Koltunski
|
}
|
94 |
|
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
protected ScrambleState[] getScrambleStates()
|
98 |
|
|
{
|
99 |
|
|
if( mStates==null )
|
100 |
|
|
{
|
101 |
|
|
int size = getNumLayers();
|
102 |
|
|
int[][] m = new int[16][];
|
103 |
|
|
for(int i=1; i<16; i++) m[i] = createEdges(size,i);
|
104 |
|
|
|
105 |
|
|
mStates = new ScrambleState[]
|
106 |
|
|
{
|
107 |
|
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0
|
108 |
|
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // x
|
109 |
|
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // y
|
110 |
|
|
new ScrambleState( new int[][] { m[ 8], m[ 8], null } ), // z
|
111 |
|
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // xy
|
112 |
|
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // xz
|
113 |
|
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // yx
|
114 |
|
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // yz
|
115 |
|
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // zx
|
116 |
|
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // zy
|
117 |
|
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // xyx
|
118 |
|
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // xzx
|
119 |
|
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // yxy
|
120 |
|
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // yzy
|
121 |
|
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // zxz
|
122 |
|
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // zyz
|
123 |
|
|
};
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
return mStates;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
4e1dc313
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130 |
|
|
|
131 |
|
|
protected int getResource(int numLayers)
|
132 |
|
|
{
|
133 |
|
|
switch(numLayers)
|
134 |
|
|
{
|
135 |
|
|
case 2: return R.raw.mirr2;
|
136 |
|
|
case 3: return R.raw.mirr3;
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
return 0;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143 |
|
|
|
144 |
|
|
private int[] createEdges(int size, int vertex)
|
145 |
|
|
{
|
146 |
|
|
int[] ret = new int[9*size];
|
147 |
|
|
|
148 |
|
|
for(int l=0; l<size; l++)
|
149 |
|
|
{
|
150 |
|
|
ret[9*l ] = l;
|
151 |
|
|
ret[9*l+1] =-1;
|
152 |
|
|
ret[9*l+2] = vertex;
|
153 |
|
|
ret[9*l+3] = l;
|
154 |
|
|
ret[9*l+4] = 1;
|
155 |
|
|
ret[9*l+5] = vertex;
|
156 |
|
|
ret[9*l+6] = l;
|
157 |
|
|
ret[9*l+7] = 2;
|
158 |
|
|
ret[9*l+8] = vertex;
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
return ret;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
|
|
private void initializeQuats()
|
167 |
|
|
{
|
168 |
|
|
mQuats = new Static4D[]
|
169 |
|
|
{
|
170 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f),
|
171 |
|
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f),
|
172 |
|
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f),
|
173 |
|
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f),
|
174 |
|
|
|
175 |
|
|
new Static4D( SQ2/2, SQ2/2, 0.0f , 0.0f),
|
176 |
|
|
new Static4D( SQ2/2, -SQ2/2, 0.0f , 0.0f),
|
177 |
|
|
new Static4D( SQ2/2, 0.0f, SQ2/2, 0.0f),
|
178 |
|
|
new Static4D(-SQ2/2, 0.0f, SQ2/2, 0.0f),
|
179 |
|
|
new Static4D( SQ2/2, 0.0f, 0.0f, SQ2/2),
|
180 |
|
|
new Static4D( SQ2/2, 0.0f, 0.0f, -SQ2/2),
|
181 |
|
|
new Static4D( 0.0f, SQ2/2, SQ2/2, 0.0f),
|
182 |
|
|
new Static4D( 0.0f, SQ2/2, -SQ2/2, 0.0f),
|
183 |
|
|
new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2),
|
184 |
|
|
new Static4D( 0.0f, SQ2/2, 0.0f, -SQ2/2),
|
185 |
|
|
new Static4D( 0.0f, 0.0f, SQ2/2, SQ2/2),
|
186 |
|
|
new Static4D( 0.0f, 0.0f, SQ2/2, -SQ2/2),
|
187 |
|
|
|
188 |
|
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f),
|
189 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f),
|
190 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f),
|
191 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f),
|
192 |
|
|
new Static4D( -0.5f, -0.5f, -0.5f, 0.5f),
|
193 |
|
|
new Static4D( -0.5f, 0.5f, -0.5f, -0.5f),
|
194 |
|
|
new Static4D( -0.5f, 0.5f, 0.5f, -0.5f),
|
195 |
|
|
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f)
|
196 |
|
|
};
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
200 |
|
|
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
|
201 |
|
|
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
|
202 |
|
|
|
203 |
|
|
protected int[] getSolvedQuats(int cubit, int numLayers)
|
204 |
|
|
{
|
205 |
|
|
if( numLayers==3 )
|
206 |
|
|
{
|
207 |
|
|
switch(cubit)
|
208 |
|
|
{
|
209 |
|
|
case 4:
|
210 |
|
|
case 21: return new int[] {1,8,9};
|
211 |
|
|
case 10:
|
212 |
|
|
case 15: return new int[] {2,12,13};
|
213 |
|
|
case 12:
|
214 |
|
|
case 13: return new int[] {3,14,15};
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
return null;
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
222 |
|
|
|
223 |
|
|
protected int getFaceColor(int cubit, int cubitface, int numLayers)
|
224 |
|
|
{
|
225 |
|
|
if( numLayers==2 )
|
226 |
|
|
{
|
227 |
|
|
switch(cubitface)
|
228 |
|
|
{
|
229 |
|
|
case 0: if( cubit==4 ) return 11;
|
230 |
|
|
if( cubit==5 ) return 10;
|
231 |
|
|
if( cubit==6 ) return 9;
|
232 |
|
|
if( cubit==7 ) return 8;
|
233 |
|
|
return NUM_TEXTURES;
|
234 |
|
|
case 1: if( cubit==0 ) return 11;
|
235 |
|
|
if( cubit==1 ) return 10;
|
236 |
|
|
if( cubit==2 ) return 9;
|
237 |
|
|
if( cubit==3 ) return 8;
|
238 |
|
|
return NUM_TEXTURES;
|
239 |
|
|
case 2: if( cubit==3 ) return 4;
|
240 |
|
|
if( cubit==7 ) return 5;
|
241 |
|
|
if( cubit==2 ) return 6;
|
242 |
|
|
if( cubit==6 ) return 7;
|
243 |
|
|
return NUM_TEXTURES;
|
244 |
|
|
case 3: if( cubit==1 ) return 4;
|
245 |
|
|
if( cubit==5 ) return 5;
|
246 |
|
|
if( cubit==0 ) return 6;
|
247 |
|
|
if( cubit==4 ) return 7;
|
248 |
|
|
return NUM_TEXTURES;
|
249 |
|
|
case 4: if( cubit==3 ) return 0;
|
250 |
|
|
if( cubit==7 ) return 1;
|
251 |
|
|
if( cubit==1 ) return 2;
|
252 |
|
|
if( cubit==5 ) return 3;
|
253 |
|
|
return NUM_TEXTURES;
|
254 |
|
|
case 5: if( cubit==2 ) return 0;
|
255 |
|
|
if( cubit==6 ) return 1;
|
256 |
|
|
if( cubit==0 ) return 2;
|
257 |
|
|
if( cubit==4 ) return 3;
|
258 |
|
|
return NUM_TEXTURES;
|
259 |
|
|
}
|
260 |
|
|
}
|
261 |
|
|
if( numLayers==3 )
|
262 |
|
|
{
|
263 |
|
|
switch(cubitface)
|
264 |
|
|
{
|
265 |
|
|
case 0: if( cubit==17 ) return 24;
|
266 |
|
|
if( cubit==18 ) return 23;
|
267 |
|
|
if( cubit==19 ) return 22;
|
268 |
|
|
if( cubit==20 ) return 21;
|
269 |
|
|
if( cubit==21 ) return 0;
|
270 |
|
|
if( cubit==22 ) return 20;
|
271 |
|
|
if( cubit==23 ) return 19;
|
272 |
|
|
if( cubit==24 ) return 18;
|
273 |
|
|
if( cubit==25 ) return 17;
|
274 |
|
|
return NUM_TEXTURES;
|
275 |
|
|
case 1: if( cubit== 0 ) return 24;
|
276 |
|
|
if( cubit== 1 ) return 23;
|
277 |
|
|
if( cubit== 2 ) return 22;
|
278 |
|
|
if( cubit== 3 ) return 21;
|
279 |
|
|
if( cubit== 4 ) return 0;
|
280 |
|
|
if( cubit== 5 ) return 20;
|
281 |
|
|
if( cubit== 6 ) return 19;
|
282 |
|
|
if( cubit== 7 ) return 18;
|
283 |
|
|
if( cubit== 8 ) return 17;
|
284 |
|
|
return NUM_TEXTURES;
|
285 |
|
|
case 2: if( cubit== 6 ) return 14;
|
286 |
|
|
if( cubit==14 ) return 2; // theoretically should have been 15, but this must have gotten collapsed in the Factory
|
287 |
|
|
if( cubit==23 ) return 16;
|
288 |
|
|
if( cubit== 7 ) return 12;
|
289 |
|
|
if( cubit==15 ) return 0;
|
290 |
|
|
if( cubit==24 ) return 13;
|
291 |
|
|
if( cubit== 8 ) return 9;
|
292 |
|
|
if( cubit==16 ) return 20; // ditto, theoretically 10
|
293 |
|
|
if( cubit==25 ) return 11;
|
294 |
|
|
return NUM_TEXTURES;
|
295 |
|
|
case 3: if( cubit== 0 ) return 14;
|
296 |
|
|
if( cubit== 9 ) return 2; // ditto, theoretically 15
|
297 |
|
|
if( cubit==17 ) return 16;
|
298 |
|
|
if( cubit== 1 ) return 12;
|
299 |
|
|
if( cubit==10 ) return 0;
|
300 |
|
|
if( cubit==18 ) return 13;
|
301 |
|
|
if( cubit== 2 ) return 9;
|
302 |
|
|
if( cubit==11 ) return 20; // ditto, theoretically 10
|
303 |
|
|
if( cubit==19 ) return 11;
|
304 |
|
|
return NUM_TEXTURES;
|
305 |
|
|
case 4: if( cubit== 8 ) return 1;
|
306 |
|
|
if( cubit==16 ) return 2;
|
307 |
|
|
if( cubit==25 ) return 3;
|
308 |
|
|
if( cubit== 5 ) return 4;
|
309 |
|
|
if( cubit==13 ) return 0;
|
310 |
|
|
if( cubit==22 ) return 5;
|
311 |
|
|
if( cubit== 2 ) return 6;
|
312 |
|
|
if( cubit==11 ) return 7;
|
313 |
|
|
if( cubit==19 ) return 8;
|
314 |
|
|
return NUM_TEXTURES;
|
315 |
|
|
case 5: if( cubit== 6 ) return 1;
|
316 |
|
|
if( cubit==14 ) return 2;
|
317 |
|
|
if( cubit==23 ) return 3;
|
318 |
|
|
if( cubit== 3 ) return 4;
|
319 |
|
|
if( cubit==12 ) return 0;
|
320 |
|
|
if( cubit==20 ) return 5;
|
321 |
|
|
if( cubit== 0 ) return 6;
|
322 |
|
|
if( cubit== 9 ) return 7;
|
323 |
|
|
if( cubit==17 ) return 8;
|
324 |
|
|
return NUM_TEXTURES;
|
325 |
|
|
}
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
return 0;
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
332 |
|
|
|
333 |
|
|
private float returnStroke(float x, float y)
|
334 |
|
|
{
|
335 |
|
|
return 0.08f/(Math.max(x,y));
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
339 |
|
|
|
340 |
|
|
private float[] generateStrokes()
|
341 |
|
|
{
|
342 |
|
|
int num = getNumLayers();
|
343 |
|
|
|
344 |
|
|
if( num==2 )
|
345 |
|
|
{
|
346 |
cc448c54
|
Leszek Koltunski
|
int LEN = SEQ2.length;
|
347 |
|
|
float[] tmp = new float[LEN];
|
348 |
|
|
for(int i=0; i<LEN; i++) tmp[i] = returnStroke(SEQ2[i][0],SEQ2[i][1]);
|
349 |
|
|
return tmp;
|
350 |
29b82486
|
Leszek Koltunski
|
}
|
351 |
|
|
else
|
352 |
|
|
{
|
353 |
cc448c54
|
Leszek Koltunski
|
int LEN = SEQ3.length;
|
354 |
|
|
float[] tmp = new float[LEN];
|
355 |
|
|
for(int i=0; i<LEN; i++) tmp[i] = returnStroke(SEQ3[i][0],SEQ3[i][1]);
|
356 |
|
|
return tmp;
|
357 |
29b82486
|
Leszek Koltunski
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
361 |
|
|
|
362 |
|
|
private float[] returnSticker(float x, float y)
|
363 |
|
|
{
|
364 |
|
|
float H = 0.5f;
|
365 |
|
|
|
366 |
|
|
if( x<y ) { float D=H*x/y; return new float[] {-D,-H,+D,-H,+D,+H,-D,+H}; }
|
367 |
|
|
else { float D=H*y/x; return new float[] {-H,-D,+H,-D,+H,+D,-H,+D}; }
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371 |
|
|
|
372 |
|
|
private float[][] generateStickers()
|
373 |
|
|
{
|
374 |
|
|
int num = getNumLayers();
|
375 |
|
|
|
376 |
|
|
if( num==2 )
|
377 |
|
|
{
|
378 |
cc448c54
|
Leszek Koltunski
|
int LEN = SEQ2.length;
|
379 |
|
|
float[][] tmp = new float[LEN][];
|
380 |
|
|
for(int i=0; i<LEN; i++) tmp[i] = returnSticker(SEQ2[i][0],SEQ2[i][1]);
|
381 |
|
|
return tmp;
|
382 |
29b82486
|
Leszek Koltunski
|
}
|
383 |
|
|
else
|
384 |
|
|
{
|
385 |
cc448c54
|
Leszek Koltunski
|
int LEN = SEQ3.length;
|
386 |
|
|
float[][] tmp = new float[LEN][];
|
387 |
|
|
for(int i=0; i<LEN; i++) tmp[i] = returnSticker(SEQ3[i][0],SEQ3[i][1]);
|
388 |
|
|
return tmp;
|
389 |
29b82486
|
Leszek Koltunski
|
}
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393 |
|
|
|
394 |
|
|
protected ObjectSticker retSticker(int face)
|
395 |
|
|
{
|
396 |
|
|
if( mStickers==null )
|
397 |
|
|
{
|
398 |
|
|
final float[][] STICKERS = generateStickers();
|
399 |
|
|
final float[] STROKES = generateStrokes();
|
400 |
|
|
final int NUM_STICKERS = STICKERS.length;
|
401 |
|
|
final float radius = 0.10f;
|
402 |
|
|
final float[] radii = {radius,radius,radius,radius};
|
403 |
|
|
mStickers = new ObjectSticker[NUM_STICKERS];
|
404 |
|
|
|
405 |
|
|
for(int i=0; i<NUM_STICKERS; i++)
|
406 |
|
|
{
|
407 |
|
|
mStickers[i] = new ObjectSticker(STICKERS[i],null,radii,STROKES[i]);
|
408 |
|
|
}
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
return mStickers[face/NUM_FACE_COLORS];
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415 |
|
|
|
416 |
|
|
protected int getNumStickerTypes(int numLayers)
|
417 |
|
|
{
|
418 |
cc448c54
|
Leszek Koltunski
|
return numLayers==2 ? SEQ2.length : SEQ3.length;
|
419 |
29b82486
|
Leszek Koltunski
|
}
|
420 |
|
|
|
421 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
422 |
|
|
|
423 |
|
|
private int getRow(int cubit, int numLayers, int dim)
|
424 |
|
|
{
|
425 |
|
|
return (int)(mPositions[cubit][dim] + 0.5f*(numLayers-1));
|
426 |
|
|
}
|
427 |
|
|
|
428 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429 |
|
|
|
430 |
|
|
protected ObjectShape getObjectShape(int cubit, int numLayers)
|
431 |
|
|
{
|
432 |
|
|
int extraI, extraV, num;
|
433 |
|
|
float height;
|
434 |
|
|
|
435 |
|
|
switch(numLayers)
|
436 |
|
|
{
|
437 |
|
|
case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
|
438 |
|
|
case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
|
439 |
|
|
case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
|
440 |
|
|
default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
int xrow = getRow(cubit,numLayers,0);
|
444 |
|
|
int yrow = getRow(cubit,numLayers,1);
|
445 |
|
|
int zrow = getRow(cubit,numLayers,2);
|
446 |
|
|
|
447 |
|
|
float XL = -0.5f + (xrow== 0 ? DX : 0);
|
448 |
|
|
float XR = +0.5f + (xrow==numLayers-1 ? DX : 0);
|
449 |
|
|
float YL = -0.5f - (yrow== 0 ? DY : 0);
|
450 |
|
|
float YR = +0.5f - (yrow==numLayers-1 ? DY : 0);
|
451 |
|
|
float ZL = -0.5f - (zrow== 0 ? DZ : 0);
|
452 |
|
|
float ZR = +0.5f - (zrow==numLayers-1 ? DZ : 0);
|
453 |
|
|
|
454 |
|
|
double[][] vertices = new double[][]
|
455 |
|
|
{
|
456 |
|
|
{ XR, YR, ZR },
|
457 |
|
|
{ XR, YR, ZL },
|
458 |
|
|
{ XR, YL, ZR },
|
459 |
|
|
{ XR, YL, ZL },
|
460 |
|
|
{ XL, YR, ZR },
|
461 |
|
|
{ XL, YR, ZL },
|
462 |
|
|
{ XL, YL, ZR },
|
463 |
|
|
{ XL, YL, ZL },
|
464 |
|
|
};
|
465 |
|
|
|
466 |
|
|
int[][] vert_indices = new int[][]
|
467 |
|
|
{
|
468 |
|
|
{2,3,1,0},
|
469 |
|
|
{7,6,4,5},
|
470 |
|
|
{4,0,1,5},
|
471 |
|
|
{7,3,2,6},
|
472 |
|
|
{6,2,0,4},
|
473 |
|
|
{3,7,5,1}
|
474 |
|
|
};
|
475 |
|
|
|
476 |
|
|
float[][] bands = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
|
477 |
|
|
int[] bandIndices = new int[] { 0,0,0,0,0,0};
|
478 |
|
|
float[][] corners = new float[][] { {0.036f,0.12f} };
|
479 |
|
|
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
480 |
|
|
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
481 |
|
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
482 |
|
|
|
483 |
|
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
487 |
|
|
|
488 |
|
|
protected Static4D getQuat(int cubit, int numLayers)
|
489 |
|
|
{
|
490 |
|
|
if( mQuats ==null ) initializeQuats();
|
491 |
|
|
return mQuats[0];
|
492 |
|
|
}
|
493 |
|
|
|
494 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
495 |
|
|
|
496 |
|
|
protected int getNumCubitVariants(int numLayers)
|
497 |
|
|
{
|
498 |
|
|
return 6*numLayers*numLayers - 12*numLayers + 8;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
502 |
|
|
|
503 |
|
|
protected int getCubitVariant(int cubit, int numLayers)
|
504 |
|
|
{
|
505 |
|
|
return cubit;
|
506 |
|
|
}
|
507 |
|
|
|
508 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
509 |
|
|
|
510 |
0310ac32
|
Leszek Koltunski
|
protected int getColor(int face)
|
511 |
29b82486
|
Leszek Koltunski
|
{
|
512 |
|
|
return FACE_COLORS[face];
|
513 |
|
|
}
|
514 |
|
|
|
515 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
516 |
|
|
|
517 |
|
|
protected float[][] getCubitPositions(int numLayers)
|
518 |
|
|
{
|
519 |
|
|
if( mPositions==null )
|
520 |
|
|
{
|
521 |
|
|
int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
|
522 |
|
|
mPositions = new float[numCubits][];
|
523 |
|
|
|
524 |
|
|
float diff = 0.5f*(numLayers-1);
|
525 |
|
|
int currentPosition = 0;
|
526 |
|
|
|
527 |
|
|
for(int x = 0; x<numLayers; x++)
|
528 |
|
|
for(int y = 0; y<numLayers; y++)
|
529 |
|
|
for(int z = 0; z<numLayers; z++)
|
530 |
|
|
if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
|
531 |
|
|
{
|
532 |
|
|
mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
|
533 |
|
|
}
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
return mPositions;
|
537 |
|
|
}
|
538 |
|
|
|
539 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
540 |
|
|
|
541 |
|
|
protected Static4D[] getQuats()
|
542 |
|
|
{
|
543 |
|
|
if( mQuats ==null ) initializeQuats();
|
544 |
|
|
return mQuats;
|
545 |
|
|
}
|
546 |
|
|
|
547 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
548 |
|
|
|
549 |
0310ac32
|
Leszek Koltunski
|
protected int getNumFaceColors()
|
550 |
29b82486
|
Leszek Koltunski
|
{
|
551 |
|
|
return 1;
|
552 |
|
|
}
|
553 |
|
|
|
554 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
555 |
|
|
|
556 |
|
|
protected float[][] getCuts(int numLayers)
|
557 |
|
|
{
|
558 |
|
|
if( mCuts==null )
|
559 |
|
|
{
|
560 |
|
|
mCuts = new float[3][numLayers-1];
|
561 |
|
|
|
562 |
|
|
for(int i=0; i<numLayers-1; i++)
|
563 |
|
|
{
|
564 |
|
|
float cut = (2-numLayers)*0.5f + i;
|
565 |
|
|
mCuts[0][i] = cut;
|
566 |
|
|
mCuts[1][i] = cut;
|
567 |
|
|
mCuts[2][i] = cut;
|
568 |
|
|
}
|
569 |
|
|
}
|
570 |
|
|
|
571 |
|
|
return mCuts;
|
572 |
|
|
}
|
573 |
|
|
|
574 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
575 |
|
|
|
576 |
|
|
private void getLayerRotatable(int numLayers)
|
577 |
|
|
{
|
578 |
|
|
if( mLayerRotatable==null )
|
579 |
|
|
{
|
580 |
|
|
int numAxis = ROT_AXIS.length;
|
581 |
|
|
boolean[] tmp = new boolean[numLayers];
|
582 |
|
|
for(int i=0; i<numLayers; i++) tmp[i] = true;
|
583 |
|
|
mLayerRotatable = new boolean[numAxis][];
|
584 |
|
|
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
|
585 |
|
|
}
|
586 |
|
|
}
|
587 |
|
|
|
588 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
589 |
|
|
|
590 |
|
|
protected int getSolvedFunctionIndex()
|
591 |
|
|
{
|
592 |
|
|
return 0;
|
593 |
|
|
}
|
594 |
|
|
|
595 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
596 |
|
|
|
597 |
|
|
protected int getNumCubitFaces()
|
598 |
|
|
{
|
599 |
|
|
return 6;
|
600 |
|
|
}
|
601 |
|
|
|
602 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
603 |
|
|
// PUBLIC API
|
604 |
|
|
|
605 |
|
|
public Static3D[] getRotationAxis()
|
606 |
|
|
{
|
607 |
|
|
return ROT_AXIS;
|
608 |
|
|
}
|
609 |
|
|
|
610 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
611 |
|
|
|
612 |
|
|
public Movement getMovement()
|
613 |
|
|
{
|
614 |
|
|
if( mMovement==null )
|
615 |
|
|
{
|
616 |
|
|
int numLayers = getNumLayers();
|
617 |
|
|
if( mCuts==null ) getCuts(numLayers);
|
618 |
|
|
getLayerRotatable(numLayers);
|
619 |
|
|
mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED);
|
620 |
|
|
}
|
621 |
|
|
return mMovement;
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
625 |
|
|
|
626 |
|
|
public int[] getBasicAngle()
|
627 |
|
|
{
|
628 |
|
|
if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
|
629 |
|
|
return mBasicAngle;
|
630 |
|
|
}
|
631 |
|
|
|
632 |
61aa85e4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
633 |
|
|
|
634 |
8005e762
|
Leszek Koltunski
|
public ObjectType intGetObjectList(int numLayers)
|
635 |
61aa85e4
|
Leszek Koltunski
|
{
|
636 |
|
|
switch(numLayers)
|
637 |
|
|
{
|
638 |
8005e762
|
Leszek Koltunski
|
case 2: return ObjectType.MIRR_2;
|
639 |
|
|
case 3: return ObjectType.MIRR_3;
|
640 |
61aa85e4
|
Leszek Koltunski
|
}
|
641 |
|
|
|
642 |
8005e762
|
Leszek Koltunski
|
return ObjectType.MIRR_2;
|
643 |
61aa85e4
|
Leszek Koltunski
|
}
|
644 |
|
|
|
645 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
646 |
|
|
|
647 |
|
|
public int getObjectName(int numLayers)
|
648 |
|
|
{
|
649 |
|
|
switch(numLayers)
|
650 |
|
|
{
|
651 |
|
|
case 2: return R.string.mirr2;
|
652 |
|
|
case 3: return R.string.mirr3;
|
653 |
|
|
}
|
654 |
|
|
return R.string.mirr3;
|
655 |
|
|
}
|
656 |
|
|
|
657 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
658 |
|
|
|
659 |
|
|
public int getInventor(int numLayers)
|
660 |
|
|
{
|
661 |
|
|
switch(numLayers)
|
662 |
|
|
{
|
663 |
|
|
case 2: return R.string.mirr2_inventor;
|
664 |
|
|
case 3: return R.string.mirr3_inventor;
|
665 |
|
|
}
|
666 |
|
|
return R.string.mirr3_inventor;
|
667 |
|
|
}
|
668 |
|
|
|
669 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
670 |
|
|
|
671 |
|
|
public int getComplexity(int numLayers)
|
672 |
|
|
{
|
673 |
|
|
switch(numLayers)
|
674 |
|
|
{
|
675 |
|
|
case 2: return 5;
|
676 |
|
|
case 3: return 7;
|
677 |
|
|
}
|
678 |
|
|
return 7;
|
679 |
|
|
}
|
680 |
|
|
}
|