1 |
03410dc1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.objects;
|
11 |
|
|
|
12 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
13 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE_COIN;
|
14 |
|
|
|
15 |
|
|
import org.distorted.library.helpers.QuatHelper;
|
16 |
|
|
import org.distorted.library.type.Static3D;
|
17 |
|
|
import org.distorted.library.type.Static4D;
|
18 |
|
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
19 |
|
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
20 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
21 |
ae9d9227
|
leszek
|
import org.distorted.objectlib.metadata.Metadata;
|
22 |
03410dc1
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
23 |
|
|
import org.distorted.objectlib.main.InitAssets;
|
24 |
361fd0de
|
leszek
|
import org.distorted.objectlib.metadata.ListObjects;
|
25 |
03410dc1
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
26 |
|
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
27 |
|
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
28 |
|
|
|
29 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30 |
|
|
|
31 |
|
|
public class TwistyCoinHexahedron extends ShapeHexahedron
|
32 |
|
|
{
|
33 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
34 |
|
|
{
|
35 |
|
|
new Static3D( SQ3/3, SQ3/3, SQ3/3),
|
36 |
|
|
new Static3D( SQ3/3, SQ3/3,-SQ3/3),
|
37 |
|
|
new Static3D( SQ3/3,-SQ3/3, SQ3/3),
|
38 |
|
|
new Static3D( SQ3/3,-SQ3/3,-SQ3/3),
|
39 |
|
|
new Static3D( 1, 0, 0),
|
40 |
|
|
new Static3D( 0, 1, 0),
|
41 |
|
|
new Static3D( 0, 0, 1),
|
42 |
|
|
};
|
43 |
|
|
|
44 |
|
|
private static final int N = 5;
|
45 |
|
|
private static final float C = 0.2f;
|
46 |
|
|
private static final float D = 0.85f;
|
47 |
|
|
|
48 |
|
|
private int[][] mEdges;
|
49 |
|
|
private int[][] mBasicAngle;
|
50 |
|
|
private float[][] mCuts;
|
51 |
|
|
private float[][] mPosition;
|
52 |
|
|
private int[] mQuatIndex;
|
53 |
acf2a9e1
|
Leszek Koltunski
|
private boolean[][] mRotatable;
|
54 |
03410dc1
|
Leszek Koltunski
|
|
55 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56 |
|
|
|
57 |
ae9d9227
|
leszek
|
public TwistyCoinHexahedron(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
58 |
03410dc1
|
Leszek Koltunski
|
{
|
59 |
ae9d9227
|
leszek
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
60 |
03410dc1
|
Leszek Koltunski
|
}
|
61 |
|
|
|
62 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63 |
|
|
|
64 |
|
|
public int[][] getScrambleEdges()
|
65 |
|
|
{
|
66 |
acf2a9e1
|
Leszek Koltunski
|
if( mEdges==null )
|
67 |
|
|
{
|
68 |
1c90a93d
|
Leszek Koltunski
|
mEdges = new int[][]
|
69 |
|
|
{
|
70 |
|
|
{0,1,1,1, 2,2,3,2, 4,3,5,3, 6,4,7,4, 8,5,9,5, 10,6,11,6, 12,7,13,7, 14,8,15,8},
|
71 |
|
|
{16, 9,17, 9,18, 9, 22,11,23,11,24,11, 28,13,29,13,30,13},
|
72 |
|
|
{19,10,20,10,21,10, 25,12,26,12,27,12, 31,14,32,14,33,14},
|
73 |
|
|
{16, 9,17, 9,18, 9, 22,11,23,11,24,11, 31,14,32,14,33,14},
|
74 |
|
|
{19,10,20,10,21,10, 25,12,26,12,27,12, 28,13,29,13,30,13},
|
75 |
|
|
{16, 9,17, 9,18, 9, 25,12,26,12,27,12, 28,13,29,13,30,13},
|
76 |
|
|
{19,10,20,10,21,10, 22,11,23,11,24,11, 31,14,32,14,33,14},
|
77 |
|
|
{16, 9,17, 9,18, 9, 25,12,26,12,27,12, 31,14,32,14,33,14},
|
78 |
|
|
{19,10,20,10,21,10, 22,11,23,11,24,11, 28,13,29,13,30,13},
|
79 |
|
|
{ 0, 1, 1, 1, 4, 3, 5, 3, 8, 5, 9, 5, 12, 7,13, 7},
|
80 |
|
|
{ 2, 2, 3, 2, 6, 4, 7, 4, 10, 6,11, 6, 14, 8,15, 8},
|
81 |
|
|
{ 0, 1, 1, 1, 4, 3, 5, 3, 10, 6,11, 6, 14, 8,15, 8},
|
82 |
|
|
{ 2, 2, 3, 2, 6, 4, 7, 4, 8, 5, 9, 5, 12, 7,13, 7},
|
83 |
|
|
{ 0, 1, 1, 1, 6, 4, 7, 4, 8, 5, 9, 5, 14, 8,15, 8},
|
84 |
|
|
{ 2, 2, 3, 2, 4, 3, 5, 3, 10, 6,11, 6, 12, 7,13, 7}
|
85 |
|
|
};
|
86 |
acf2a9e1
|
Leszek Koltunski
|
}
|
87 |
|
|
|
88 |
03410dc1
|
Leszek Koltunski
|
return mEdges;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
3a0990b1
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92 |
|
|
|
93 |
|
|
@Override
|
94 |
|
|
public void adjustStickerCoords()
|
95 |
|
|
{
|
96 |
|
|
float A = 0.38f;
|
97 |
|
|
float B = 0.24f;
|
98 |
|
|
float C = 0.50f;
|
99 |
|
|
float D = 0.00f;
|
100 |
|
|
|
101 |
|
|
mStickerCoords = new float[][][][]
|
102 |
|
|
{
|
103 |
|
|
{ { { A,-C}, { A, A}, {-C, A}, {-C, B}, {B,-C} } },
|
104 |
|
|
{ { { C, D}, { D, C}, {-C, D}, { D,-C} } },
|
105 |
|
|
{ { { C,-C}, {-C, C} } }
|
106 |
|
|
};
|
107 |
|
|
}
|
108 |
|
|
|
109 |
731a57a6
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110 |
|
|
|
111 |
|
|
@Override
|
112 |
|
|
protected float[][][] getStickerStrokes()
|
113 |
|
|
{
|
114 |
|
|
boolean icon = isInIconMode();
|
115 |
|
|
|
116 |
8f5116ec
|
leszek
|
float S1 = icon ? 0.21f : 0.12f;
|
117 |
|
|
float S2 = icon ? 0.21f : 0.07f;
|
118 |
|
|
float S3 = icon ? 0.21f : 0.12f;
|
119 |
731a57a6
|
leszek
|
|
120 |
8f5116ec
|
leszek
|
return new float[][][] { {{ S1,S1,S1,S1,S1 }} , {{S2,S2,S2,S2}} , {{S3,S3}} };
|
121 |
731a57a6
|
leszek
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
|
|
@Override
|
126 |
|
|
protected float[][][] getStickerRadii()
|
127 |
|
|
{
|
128 |
|
|
float R = 0.15f;
|
129 |
|
|
return new float[][][] { {{ 0,R,0,0,0 }} , {{0,0,0,0}} , {{0,0}} };
|
130 |
|
|
}
|
131 |
|
|
|
132 |
acf2a9e1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133 |
|
|
|
134 |
|
|
@Override
|
135 |
|
|
public int[][] getScrambleAlgorithms()
|
136 |
|
|
{
|
137 |
|
|
setUpRotatable();
|
138 |
|
|
return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle, mRotatable);
|
139 |
|
|
}
|
140 |
|
|
|
141 |
a70b1e96
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
|
|
@Override
|
144 |
|
|
public float[][] returnRotationFactor()
|
145 |
|
|
{
|
146 |
|
|
float C1 = 2.5f;
|
147 |
|
|
float C2 = 1.0f;
|
148 |
|
|
float[] f1 = new float[] { C1,C1,C1 };
|
149 |
|
|
float[] f2 = new float[] { C2,C2,C2 };
|
150 |
|
|
|
151 |
|
|
return new float[][] { f1,f1,f1,f1, f2,f2,f2 };
|
152 |
|
|
}
|
153 |
|
|
|
154 |
03410dc1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
|
156 |
|
|
public float[][] getCuts(int[] numLayers)
|
157 |
|
|
{
|
158 |
|
|
if( mCuts==null )
|
159 |
|
|
{
|
160 |
|
|
float C1 = 0.75f*SQ3;
|
161 |
|
|
float C2 = 1.49f;
|
162 |
|
|
float[] cut1 = new float[] { -C1,C1 };
|
163 |
|
|
float[] cut2 = new float[] { -C2,C2 };
|
164 |
|
|
mCuts = new float[][] { cut1,cut1,cut1,cut1,cut2,cut2,cut2 };
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
return mCuts;
|
168 |
|
|
}
|
169 |
|
|
|
170 |
acf2a9e1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
171 |
|
|
|
172 |
|
|
private void setUpRotatable()
|
173 |
|
|
{
|
174 |
|
|
if( mRotatable==null )
|
175 |
|
|
{
|
176 |
|
|
boolean[] tmp = new boolean[] {true,false,true};
|
177 |
|
|
mRotatable = new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp,tmp };
|
178 |
|
|
}
|
179 |
|
|
}
|
180 |
|
|
|
181 |
03410dc1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
182 |
|
|
|
183 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
184 |
|
|
{
|
185 |
acf2a9e1
|
Leszek Koltunski
|
setUpRotatable();
|
186 |
|
|
return mRotatable;
|
187 |
03410dc1
|
Leszek Koltunski
|
}
|
188 |
|
|
|
189 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
190 |
|
|
|
191 |
|
|
public int getTouchControlType()
|
192 |
|
|
{
|
193 |
|
|
return TC_HEXAHEDRON;
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197 |
|
|
|
198 |
|
|
public int getTouchControlSplit()
|
199 |
|
|
{
|
200 |
|
|
return TYPE_SPLIT_EDGE_COIN;
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204 |
|
|
|
205 |
|
|
public int[][][] getEnabled()
|
206 |
|
|
{
|
207 |
|
|
return new int[][][]
|
208 |
|
|
{
|
209 |
|
|
{{4},{4},{4},{4},{1},{3},{2},{0}},
|
210 |
|
|
{{4},{4},{4},{4},{3},{1},{0},{2}},
|
211 |
|
|
{{5},{5},{5},{5},{1},{0},{3},{2}},
|
212 |
|
|
{{5},{5},{5},{5},{2},{3},{0},{1}},
|
213 |
|
|
{{6},{6},{6},{6},{0},{2},{1},{3}},
|
214 |
|
|
{{6},{6},{6},{6},{2},{0},{3},{1}},
|
215 |
|
|
};
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
219 |
|
|
|
220 |
|
|
public float[] getDist3D(int[] numLayers)
|
221 |
|
|
{
|
222 |
|
|
return TouchControlHexahedron.D3D;
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
226 |
|
|
|
227 |
|
|
public Static3D[] getFaceAxis()
|
228 |
|
|
{
|
229 |
|
|
return TouchControlHexahedron.FACE_AXIS;
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
233 |
|
|
|
234 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
235 |
|
|
{
|
236 |
|
|
if( mPosition==null )
|
237 |
|
|
{
|
238 |
1a7dd366
|
Leszek Koltunski
|
final float A = 1.48f-C;
|
239 |
|
|
final float B = 1.52f;
|
240 |
561a346d
|
Leszek Koltunski
|
final float Z = 1.50f;
|
241 |
03410dc1
|
Leszek Koltunski
|
final float E = 0.75f*D;
|
242 |
|
|
|
243 |
|
|
mPosition = new float[][]
|
244 |
|
|
{
|
245 |
|
|
{ A, A, A},
|
246 |
|
|
{ A, A,-A},
|
247 |
|
|
{ A,-A, A},
|
248 |
|
|
{ A,-A,-A},
|
249 |
|
|
{-A, A, A},
|
250 |
|
|
{-A, A,-A},
|
251 |
|
|
{-A,-A, A},
|
252 |
|
|
{-A,-A,-A},
|
253 |
|
|
|
254 |
cadc79fe
|
Leszek Koltunski
|
{ 0, 0, B },
|
255 |
|
|
{ 0, 0,-B },
|
256 |
|
|
{ 0, B, 0 },
|
257 |
|
|
{ 0,-B, 0 },
|
258 |
|
|
{ B, 0, 0 },
|
259 |
|
|
{-B, 0, 0 },
|
260 |
|
|
|
261 |
347f6cc1
|
Leszek Koltunski
|
{ E, E, Z},
|
262 |
|
|
{ E,-E, Z},
|
263 |
|
|
{-E, E, Z},
|
264 |
|
|
{-E,-E, Z},
|
265 |
|
|
{ E, E,-Z},
|
266 |
|
|
{ E,-E,-Z},
|
267 |
|
|
{-E, E,-Z},
|
268 |
|
|
{-E,-E,-Z},
|
269 |
|
|
{ E, Z, E},
|
270 |
|
|
{ E, Z,-E},
|
271 |
|
|
{-E, Z, E},
|
272 |
|
|
{-E, Z,-E},
|
273 |
|
|
{ E,-Z, E},
|
274 |
|
|
{ E,-Z,-E},
|
275 |
|
|
{-E,-Z, E},
|
276 |
|
|
{-E,-Z,-E},
|
277 |
|
|
{ Z, E, E},
|
278 |
|
|
{ Z, E,-E},
|
279 |
|
|
{ Z,-E, E},
|
280 |
|
|
{ Z,-E,-E},
|
281 |
|
|
{-Z, E, E},
|
282 |
|
|
{-Z, E,-E},
|
283 |
|
|
{-Z,-E, E},
|
284 |
|
|
{-Z,-E,-E},
|
285 |
03410dc1
|
Leszek Koltunski
|
};
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
return mPosition;
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
292 |
|
|
|
293 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
294 |
|
|
{
|
295 |
|
|
if( mQuatIndex==null ) mQuatIndex = new int[] {0,9,11,4,12,3,6,21,
|
296 |
|
|
0,10,1,4,2,3,
|
297 |
|
|
0,15,17,16,19,10,13,23,1,9,20,7, 11,4,6,21,2,14,18,5,12,3,8,22 };
|
298 |
|
|
return mObjectQuats[mQuatIndex[cubit]];
|
299 |
|
|
}
|
300 |
|
|
|
301 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
302 |
|
|
|
303 |
|
|
private float[] rotateVertices(float angle, float[] vector, float[] center, float[] rotAxis)
|
304 |
|
|
{
|
305 |
|
|
float[] ret = new float[4];
|
306 |
|
|
float sin = (float)Math.sin(angle/2);
|
307 |
|
|
float cos = (float)Math.cos(angle/2);
|
308 |
|
|
float[] quat= new float[] { sin*rotAxis[0], sin*rotAxis[1], sin*rotAxis[2], cos};
|
309 |
|
|
QuatHelper.rotateVectorByQuat(ret,vector,quat);
|
310 |
|
|
|
311 |
|
|
ret[0] += center[0];
|
312 |
|
|
ret[1] += center[1];
|
313 |
|
|
ret[2] += center[2];
|
314 |
|
|
|
315 |
|
|
return ret;
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
319 |
|
|
|
320 |
|
|
private float[][] produceCorner()
|
321 |
|
|
{
|
322 |
|
|
final float angle = (float)Math.PI/(2*N);
|
323 |
|
|
final float A = 0.3f;
|
324 |
|
|
final int N1 = 4;
|
325 |
|
|
final int N2 = N1 + N + 1;
|
326 |
|
|
final int N3 = N2 + N + 1;
|
327 |
|
|
float[][] vertices= new float[3*N+8][3];
|
328 |
|
|
|
329 |
cadc79fe
|
Leszek Koltunski
|
vertices[3*N+7][0] = -A;
|
330 |
|
|
vertices[3*N+7][1] = -A;
|
331 |
|
|
vertices[3*N+7][2] = -A;
|
332 |
03410dc1
|
Leszek Koltunski
|
|
333 |
|
|
vertices[0][0] = 0;
|
334 |
|
|
vertices[0][1] = 0;
|
335 |
|
|
vertices[0][2] = 0;
|
336 |
|
|
vertices[1][0] =-2;
|
337 |
|
|
vertices[1][1] = 0;
|
338 |
|
|
vertices[1][2] = 0;
|
339 |
|
|
vertices[2][0] = 0;
|
340 |
|
|
vertices[2][1] =-2;
|
341 |
|
|
vertices[2][2] = 0;
|
342 |
|
|
vertices[3][0] = 0;
|
343 |
|
|
vertices[3][1] = 0;
|
344 |
|
|
vertices[3][2] =-2;
|
345 |
|
|
|
346 |
|
|
for(int i=0; i<=N; i++)
|
347 |
|
|
{
|
348 |
|
|
float cos1 = (float)Math.cos((N-i)*angle);
|
349 |
|
|
float sin1 = (float)Math.sin((N-i)*angle);
|
350 |
|
|
float cos2 = (float)Math.cos(( i)*angle);
|
351 |
|
|
float sin2 = (float)Math.sin(( i)*angle);
|
352 |
|
|
|
353 |
|
|
vertices[N1+i][0] = 2*D*cos1-2;
|
354 |
|
|
vertices[N1+i][1] = 2*D*sin1-2;
|
355 |
|
|
vertices[N1+i][2] = 0;
|
356 |
|
|
|
357 |
|
|
vertices[N2+i][0] = 0;
|
358 |
|
|
vertices[N2+i][1] = 2*D*sin2-2;
|
359 |
|
|
vertices[N2+i][2] = 2*D*cos2-2;
|
360 |
|
|
|
361 |
|
|
vertices[N3+i][0] = 2*D*cos2-2;
|
362 |
|
|
vertices[N3+i][1] = 0;
|
363 |
|
|
vertices[N3+i][2] = 2*D*sin2-2;
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
for(int i=0; i<3*N+8; i++)
|
367 |
|
|
{
|
368 |
|
|
vertices[i][0] = 0.75f*vertices[i][0] + C;
|
369 |
|
|
vertices[i][1] = 0.75f*vertices[i][1] + C;
|
370 |
|
|
vertices[i][2] = 0.75f*vertices[i][2] + C;
|
371 |
|
|
}
|
372 |
|
|
|
373 |
|
|
return vertices;
|
374 |
|
|
}
|
375 |
|
|
|
376 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
377 |
|
|
|
378 |
|
|
private float[][] produceCenter()
|
379 |
|
|
{
|
380 |
|
|
float[][] ret = new float[4*N+1][];
|
381 |
|
|
|
382 |
|
|
float[] rot = new float[] { 0,0,-1 };
|
383 |
|
|
|
384 |
|
|
float[] center1 = { 1.5f*D, 1.5f*D, 0 };
|
385 |
|
|
float[] center2 = { 1.5f*D,-1.5f*D, 0 };
|
386 |
|
|
float[] center3 = {-1.5f*D,-1.5f*D, 0 };
|
387 |
|
|
float[] center4 = {-1.5f*D, 1.5f*D, 0 };
|
388 |
|
|
|
389 |
|
|
float[] vect1 = { -1.5f*D,0,0,0 };
|
390 |
|
|
float[] vect2 = { 0, 1.5f*D,0,0 };
|
391 |
|
|
float[] vect3 = { 1.5f*D,0,0,0 };
|
392 |
|
|
float[] vect4 = { 0,-1.5f*D,0,0 };
|
393 |
|
|
|
394 |
|
|
for(int i=0; i<N; i++)
|
395 |
|
|
{
|
396 |
|
|
float angle = (float)(Math.PI/2)*i/N;
|
397 |
|
|
|
398 |
|
|
ret[i ] = rotateVertices(angle, vect1, center1, rot);
|
399 |
|
|
ret[i+ N] = rotateVertices(angle, vect2, center2, rot);
|
400 |
|
|
ret[i+2*N] = rotateVertices(angle, vect3, center3, rot);
|
401 |
|
|
ret[i+3*N] = rotateVertices(angle, vect4, center4, rot);
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
ret[4*N] = new float[] { 0, 0, -1.5f };
|
405 |
|
|
|
406 |
|
|
return ret;
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
410 |
|
|
|
411 |
|
|
private float[][] produceLeaf()
|
412 |
|
|
{
|
413 |
|
|
float[][] ret = new float[2*N+1][];
|
414 |
|
|
|
415 |
|
|
float[] rot = new float[] { 0,0,1 };
|
416 |
|
|
|
417 |
|
|
float[] center1 = {-0.75f*D,-0.75f*D, 0 };
|
418 |
|
|
float[] center2 = { 0.75f*D, 0.75f*D, 0 };
|
419 |
|
|
|
420 |
|
|
float[] vect1 = { 0, 1.5f*D, 0, 0 };
|
421 |
|
|
float[] vect2 = { 0,-1.5f*D, 0, 0 };
|
422 |
|
|
|
423 |
|
|
for(int i=0; i<N; i++)
|
424 |
|
|
{
|
425 |
|
|
float angle = (float)(Math.PI/2)*i/N;
|
426 |
|
|
|
427 |
|
|
ret[ N-1-i] = rotateVertices(angle, vect1, center1, rot);
|
428 |
|
|
ret[2*N-1-i] = rotateVertices(angle, vect2, center2, rot);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
ret[2*N] = new float[] { 0, 0, -1.5f/10 };
|
432 |
|
|
|
433 |
|
|
return ret;
|
434 |
|
|
}
|
435 |
|
|
|
436 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
437 |
|
|
|
438 |
|
|
private float[][] getVertices(int variant)
|
439 |
|
|
{
|
440 |
|
|
if( variant==0 ) return produceCorner();
|
441 |
|
|
else if( variant==1 ) return produceCenter();
|
442 |
|
|
else return produceLeaf();
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
446 |
|
|
|
447 |
|
|
private int[][] produceCornerShape()
|
448 |
|
|
{
|
449 |
cadc79fe
|
Leszek Koltunski
|
int[][] indices = new int[3*N+9][];
|
450 |
03410dc1
|
Leszek Koltunski
|
|
451 |
|
|
indices[0] = new int[N+4];
|
452 |
|
|
indices[1] = new int[N+4];
|
453 |
|
|
indices[2] = new int[N+4];
|
454 |
|
|
|
455 |
|
|
indices[0][0] = 2;
|
456 |
|
|
indices[0][1] = 0;
|
457 |
|
|
indices[0][2] = 1;
|
458 |
|
|
indices[1][0] = 3;
|
459 |
|
|
indices[1][1] = 0;
|
460 |
|
|
indices[1][2] = 2;
|
461 |
|
|
indices[2][0] = 1;
|
462 |
|
|
indices[2][1] = 0;
|
463 |
|
|
indices[2][2] = 3;
|
464 |
|
|
|
465 |
|
|
int N1 = 4;
|
466 |
|
|
int N2 = N1 + N + 1;
|
467 |
|
|
int N3 = N2 + N + 1;
|
468 |
|
|
|
469 |
|
|
for(int i=0; i<=N; i++)
|
470 |
|
|
{
|
471 |
|
|
indices[0][i+3] = N1 + i;
|
472 |
|
|
indices[1][i+3] = N2 + i;
|
473 |
|
|
indices[2][i+3] = N3 + i;
|
474 |
|
|
}
|
475 |
|
|
|
476 |
|
|
for(int i=0; i<N; i++)
|
477 |
|
|
{
|
478 |
cadc79fe
|
Leszek Koltunski
|
indices[3*i+3] = new int[] { N1+i+1, N1+i, 3*N+7 };
|
479 |
|
|
indices[3*i+4] = new int[] { N2+i+1, N2+i, 3*N+7 };
|
480 |
|
|
indices[3*i+5] = new int[] { N3+i+1, N3+i, 3*N+7 };
|
481 |
03410dc1
|
Leszek Koltunski
|
}
|
482 |
|
|
|
483 |
cadc79fe
|
Leszek Koltunski
|
indices[3*N+3] = new int[] { 2 , 4+ N, 3*N+7 };
|
484 |
|
|
indices[3*N+4] = new int[] { 5 +N, 2 , 3*N+7 };
|
485 |
|
|
indices[3*N+5] = new int[] { 5+2*N, 3 , 3*N+7 };
|
486 |
|
|
indices[3*N+6] = new int[] { 3 , 6+2*N, 3*N+7 };
|
487 |
|
|
indices[3*N+7] = new int[] { 1 , 6+3*N, 3*N+7 };
|
488 |
|
|
indices[3*N+8] = new int[] { 4 , 1 , 3*N+7 };
|
489 |
|
|
|
490 |
03410dc1
|
Leszek Koltunski
|
return indices;
|
491 |
|
|
}
|
492 |
|
|
|
493 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
494 |
|
|
|
495 |
|
|
private int[][] produceCenterShape()
|
496 |
|
|
{
|
497 |
|
|
int[][] ret = new int[1+4*N][];
|
498 |
|
|
|
499 |
|
|
ret[0] = new int[4*N];
|
500 |
1a7dd366
|
Leszek Koltunski
|
for(int i=0; i<4*N; i++) ret[0][i] = 4*N-1-i;
|
501 |
03410dc1
|
Leszek Koltunski
|
|
502 |
|
|
for(int i=0; i<N; i++)
|
503 |
|
|
{
|
504 |
|
|
ret[i+1] = new int[3];
|
505 |
|
|
ret[i+1][0] = i;
|
506 |
|
|
ret[i+1][1] = i+1;
|
507 |
|
|
ret[i+1][2] = 4*N;
|
508 |
|
|
|
509 |
|
|
ret[N+i+1] = new int[3];
|
510 |
|
|
ret[N+i+1][0] = N+i;
|
511 |
|
|
ret[N+i+1][1] = N+i+1;
|
512 |
|
|
ret[N+i+1][2] = 4*N;
|
513 |
|
|
|
514 |
|
|
ret[2*N+i+1] = new int[3];
|
515 |
|
|
ret[2*N+i+1][0] = 2*N+i;
|
516 |
|
|
ret[2*N+i+1][1] = 2*N+i+1;
|
517 |
|
|
ret[2*N+i+1][2] = 4*N;
|
518 |
|
|
|
519 |
|
|
ret[3*N+i+1] = new int[3];
|
520 |
|
|
ret[3*N+i+1][0] = 3*N+i;
|
521 |
|
|
ret[3*N+i+1][1] = i<N-1 ? 3*N+i+1 : 0;
|
522 |
|
|
ret[3*N+i+1][2] = 4*N;
|
523 |
|
|
}
|
524 |
|
|
|
525 |
|
|
return ret;
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
529 |
|
|
|
530 |
|
|
private int[][] produceLeafShape()
|
531 |
|
|
{
|
532 |
|
|
int[][] ret = new int[2*N+1][];
|
533 |
|
|
|
534 |
|
|
ret[0] = new int[2*N];
|
535 |
|
|
for(int i=0; i<2*N; i++) ret[0][i] = i;
|
536 |
|
|
|
537 |
|
|
for(int i=1; i<=N-1; i++)
|
538 |
|
|
{
|
539 |
|
|
ret[i] = new int[3];
|
540 |
|
|
ret[i][0] = i;
|
541 |
|
|
ret[i][1] = i-1;
|
542 |
|
|
ret[i][2] = 2*N;
|
543 |
|
|
|
544 |
|
|
ret[N-1+i] = new int[3];
|
545 |
|
|
ret[N-1+i][0] = N+i;
|
546 |
|
|
ret[N-1+i][1] = N+i-1;
|
547 |
|
|
ret[N-1+i][2] = 2*N;
|
548 |
|
|
}
|
549 |
|
|
|
550 |
|
|
ret[2*N-1] = new int[] { N, N-1, 2*N };
|
551 |
|
|
ret[2*N ] = new int[] { 0,2*N-1, 2*N };
|
552 |
|
|
|
553 |
|
|
return ret;
|
554 |
|
|
}
|
555 |
|
|
|
556 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
557 |
|
|
|
558 |
|
|
public ObjectShape getObjectShape(int variant)
|
559 |
|
|
{
|
560 |
|
|
if( variant==0 )
|
561 |
|
|
{
|
562 |
|
|
int[][] indices = produceCornerShape();
|
563 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
564 |
|
|
}
|
565 |
|
|
else if( variant==1 )
|
566 |
|
|
{
|
567 |
|
|
int[][] indices = produceCenterShape();
|
568 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
569 |
|
|
}
|
570 |
|
|
else
|
571 |
|
|
{
|
572 |
|
|
int[][] indices = produceLeafShape();
|
573 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
574 |
|
|
}
|
575 |
|
|
}
|
576 |
|
|
|
577 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
578 |
|
|
|
579 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
580 |
|
|
{
|
581 |
|
|
if( variant==0 )
|
582 |
|
|
{
|
583 |
|
|
float h1 = isInIconMode() ? 0.0001f : 0.03f;
|
584 |
|
|
float h2 = isInIconMode() ? 0.0001f : 0.01f;
|
585 |
|
|
float[][] bands = { {h1,35,0.2f,0.4f,5,2,1}, {h2,35,0.2f,0.4f,2,0,0} };
|
586 |
cadc79fe
|
Leszek Koltunski
|
int num = 3*N+9;
|
587 |
03410dc1
|
Leszek Koltunski
|
int[] indices = new int[num];
|
588 |
|
|
for(int i=3; i<num; i++) indices[i] = 1;
|
589 |
|
|
float S = 1-SQ2/2 - C;
|
590 |
|
|
float[] convexCenter = {-S,-S,-S };
|
591 |
|
|
return new ObjectFaceShape(bands,indices,convexCenter);
|
592 |
|
|
}
|
593 |
|
|
else if( variant==1 )
|
594 |
|
|
{
|
595 |
1a7dd366
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.0001f : 0.001f;
|
596 |
03410dc1
|
Leszek Koltunski
|
float h2 = 0.0001f;
|
597 |
1a7dd366
|
Leszek Koltunski
|
float[][] bands = { {h1,5,0.2f,0.4f,5,0,0}, {h2,5,0.05f,0.1f,2,0,0} };
|
598 |
03410dc1
|
Leszek Koltunski
|
int num = 1+4*N;
|
599 |
|
|
int[] indices = new int[num];
|
600 |
|
|
for(int i=1; i<num; i++) indices[i] = 1;
|
601 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
602 |
|
|
}
|
603 |
|
|
else
|
604 |
|
|
{
|
605 |
|
|
float h1 = isInIconMode() ? 0.0001f : 0.015f;
|
606 |
|
|
float h2 = isInIconMode() ? 0.0001f : 0.001f;
|
607 |
347f6cc1
|
Leszek Koltunski
|
float[][] bands = { {h1,25,0.250f,0.7f,5,0,0}, {h2,25,0.125f,0.2f,2,0,0} };
|
608 |
03410dc1
|
Leszek Koltunski
|
int num = 1+2*N;
|
609 |
|
|
int[] indices = new int[num];
|
610 |
|
|
for(int i=1; i<num; i++) indices[i] = 1;
|
611 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
612 |
|
|
}
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
616 |
|
|
|
617 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
618 |
|
|
{
|
619 |
|
|
if( variant==0 )
|
620 |
|
|
{
|
621 |
1a7dd366
|
Leszek Koltunski
|
float[][] corners = { {0.05f,0.15f} };
|
622 |
03410dc1
|
Leszek Koltunski
|
int num = 8+3*N;
|
623 |
|
|
int[] indices = new int[num];
|
624 |
|
|
for(int i=1; i<num; i++) indices[i] = -1;
|
625 |
|
|
float[][] centers = {{ 0,0,0 }};
|
626 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
627 |
|
|
}
|
628 |
|
|
else if( variant==1 )
|
629 |
|
|
{
|
630 |
|
|
float[][] corners = { {0.05f,0.20f} };
|
631 |
|
|
int num = 1+4*N;
|
632 |
|
|
int[] indices = new int[num];
|
633 |
|
|
for(int i=0; i<num; i++) indices[i] = -1;
|
634 |
|
|
float[][] centers = { { 0,0,0 } };
|
635 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
636 |
|
|
}
|
637 |
|
|
else
|
638 |
|
|
{
|
639 |
|
|
float[][] corners = { {0.05f,0.20f} };
|
640 |
|
|
int num = 1+2*N;
|
641 |
|
|
int[] indices = new int[num];
|
642 |
|
|
for(int i=0; i<num; i++) indices[i] = -1;
|
643 |
|
|
float[][] centers = { { 0,0,0 } };
|
644 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
|
648 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
649 |
|
|
|
650 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
651 |
|
|
{
|
652 |
|
|
return 3;
|
653 |
|
|
}
|
654 |
|
|
|
655 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
656 |
|
|
|
657 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
658 |
|
|
{
|
659 |
|
|
return cubit<8 ? 0 : (cubit<14 ? 1:2);
|
660 |
|
|
}
|
661 |
|
|
|
662 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
663 |
731a57a6
|
leszek
|
// doesn't matter, we are overriding getStickerRadii() anyway
|
664 |
03410dc1
|
Leszek Koltunski
|
|
665 |
|
|
public float getStickerRadius()
|
666 |
|
|
{
|
667 |
731a57a6
|
leszek
|
return 0.0f;
|
668 |
03410dc1
|
Leszek Koltunski
|
}
|
669 |
|
|
|
670 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
671 |
731a57a6
|
leszek
|
// doesn't matter, we are overriding getStickerStrokes() anyway
|
672 |
03410dc1
|
Leszek Koltunski
|
|
673 |
|
|
public float getStickerStroke()
|
674 |
|
|
{
|
675 |
731a57a6
|
leszek
|
return 0.0f;
|
676 |
03410dc1
|
Leszek Koltunski
|
}
|
677 |
|
|
|
678 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
679 |
|
|
|
680 |
ebe8c08e
|
leszek
|
public float[][][] getStickerAngles()
|
681 |
03410dc1
|
Leszek Koltunski
|
{
|
682 |
8f5116ec
|
leszek
|
float D = (float)(Math.PI/2);
|
683 |
ebe8c08e
|
leszek
|
return new float[][][] { {{ 0,0,0,-D,0 }} , {{-D,-D,-D,-D}} , {{D,D}} };
|
684 |
03410dc1
|
Leszek Koltunski
|
}
|
685 |
|
|
|
686 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
687 |
|
|
// PUBLIC API
|
688 |
|
|
|
689 |
|
|
public Static3D[] getRotationAxis()
|
690 |
|
|
{
|
691 |
|
|
return ROT_AXIS;
|
692 |
|
|
}
|
693 |
|
|
|
694 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
695 |
|
|
|
696 |
|
|
public int[][] getBasicAngles()
|
697 |
|
|
{
|
698 |
|
|
if( mBasicAngle ==null )
|
699 |
|
|
{
|
700 |
|
|
int[] tmp1 = {3,3,3};
|
701 |
|
|
int[] tmp2 = {4,4,4};
|
702 |
|
|
mBasicAngle = new int[][] { tmp1,tmp1,tmp1,tmp1,tmp2,tmp2,tmp2 };
|
703 |
|
|
}
|
704 |
|
|
|
705 |
|
|
return mBasicAngle;
|
706 |
|
|
}
|
707 |
|
|
|
708 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
709 |
|
|
|
710 |
|
|
public String getShortName()
|
711 |
|
|
{
|
712 |
361fd0de
|
leszek
|
return ListObjects.COIH_3.name();
|
713 |
03410dc1
|
Leszek Koltunski
|
}
|
714 |
|
|
|
715 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
716 |
|
|
|
717 |
|
|
public String[][] getTutorials()
|
718 |
|
|
{
|
719 |
|
|
return new String[][] {
|
720 |
|
|
{"gb","8hPxLbZDSLQ","Chinese Coin Cube","CanChrisSolve"},
|
721 |
|
|
{"es","rK0_IsjoZqM","Ancient Coin Cube","R de Rubik"},
|
722 |
|
|
{"ru","HVZj2vBxD5A","Как собрать Коин Куб","Алексей Ярыгин"},
|
723 |
|
|
{"pl","yaNeIw4C5Uk","Ancient coin cube TUTORIAL PL","MrUK"},
|
724 |
2318a72a
|
leszek
|
{"tw","B7oD3pAXBVY","銅幣魔方教學","不正常魔術方塊研究中心"},
|
725 |
03410dc1
|
Leszek Koltunski
|
};
|
726 |
|
|
}
|
727 |
|
|
}
|