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