1 |
82bc272d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2021 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_TETRAHEDRON;
|
13 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
14 |
|
|
|
15 |
|
|
import org.distorted.library.type.Static3D;
|
16 |
|
|
import org.distorted.library.type.Static4D;
|
17 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
18 |
82bc272d
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
19 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
20 |
ae9d9227
|
leszek
|
import org.distorted.objectlib.metadata.Metadata;
|
21 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22 |
cf93ea4e
|
Leszek Koltunski
|
import org.distorted.objectlib.main.InitAssets;
|
23 |
361fd0de
|
leszek
|
import org.distorted.objectlib.metadata.ListObjects;
|
24 |
b31249d6
|
Leszek Koltunski
|
import org.distorted.objectlib.shape.ShapeTetrahedron;
|
25 |
82bc272d
|
Leszek Koltunski
|
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
|
26 |
|
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
|
|
public class TwistyPyraminxDuo extends ShapeTetrahedron
|
30 |
|
|
{
|
31 |
ccd8a6f2
|
Leszek Koltunski
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
32 |
82bc272d
|
Leszek Koltunski
|
{
|
33 |
|
|
new Static3D( 0,-SQ3/3,-SQ6/3),
|
34 |
1b197b82
|
Leszek Koltunski
|
new Static3D( 0,-SQ3/3, SQ6/3),
|
35 |
|
|
new Static3D( SQ6/3, SQ3/3, 0),
|
36 |
|
|
new Static3D(-SQ6/3, SQ3/3, 0),
|
37 |
82bc272d
|
Leszek Koltunski
|
};
|
38 |
|
|
|
39 |
f7f7ea8e
|
Leszek Koltunski
|
private static final float F = 0.60f; // let point A = corner of the tetrahedron; B - center of tetrahedron face;
|
40 |
|
|
// C - corner of the triangular face cubit. Then C = A + F(B-A)
|
41 |
|
|
private static final float G = 0.02f; // this defines the gap between two corner cubits. 0.0 -> no gap.
|
42 |
82bc272d
|
Leszek Koltunski
|
|
43 |
9ba7f3f6
|
Leszek Koltunski
|
private int[][] mEdges;
|
44 |
82bc272d
|
Leszek Koltunski
|
private int[][] mBasicAngle;
|
45 |
|
|
private int[] mQuatIndex;
|
46 |
|
|
private float[][] mCuts;
|
47 |
|
|
private float[][] mCenters;
|
48 |
|
|
|
49 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
|
51 |
ae9d9227
|
leszek
|
public TwistyPyraminxDuo(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
52 |
82bc272d
|
Leszek Koltunski
|
{
|
53 |
ae9d9227
|
leszek
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
54 |
82bc272d
|
Leszek Koltunski
|
}
|
55 |
|
|
|
56 |
8f5116ec
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57 |
|
|
|
58 |
|
|
@Override
|
59 |
|
|
protected float[][][] getStickerRadii()
|
60 |
|
|
{
|
61 |
|
|
float R1 = 0.10f;
|
62 |
|
|
float R2 = 0.02f;
|
63 |
|
|
float R3 = 0.10f;
|
64 |
|
|
return new float[][][] { {{ R3,R3,R3,R2,R3,R3 }} , {{ R1,R1,R1 }} };
|
65 |
|
|
}
|
66 |
|
|
|
67 |
a70b1e96
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68 |
|
|
|
69 |
|
|
@Override
|
70 |
|
|
public float[][] returnRotationFactor()
|
71 |
|
|
{
|
72 |
|
|
float[] f = new float[] {1.4f,1.8f};
|
73 |
|
|
return new float[][] { f,f,f,f };
|
74 |
|
|
}
|
75 |
|
|
|
76 |
82bc272d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
5abb9a18
|
Leszek Koltunski
|
// single edge; only the tip layers move
|
78 |
82bc272d
|
Leszek Koltunski
|
|
79 |
9ba7f3f6
|
Leszek Koltunski
|
public int[][] getScrambleEdges()
|
80 |
82bc272d
|
Leszek Koltunski
|
{
|
81 |
5abb9a18
|
Leszek Koltunski
|
if( mEdges==null ) mEdges = new int[][] { {2,0,3,0,6,0,7,0,10,0,11,0,14,0,15,0} };
|
82 |
9ba7f3f6
|
Leszek Koltunski
|
return mEdges;
|
83 |
82bc272d
|
Leszek Koltunski
|
}
|
84 |
|
|
|
85 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86 |
|
|
|
87 |
|
|
public float[][] getCuts(int[] numLayers)
|
88 |
|
|
{
|
89 |
|
|
if( mCuts==null )
|
90 |
|
|
{
|
91 |
|
|
float[] cut = { 0.0f };
|
92 |
|
|
mCuts = new float[][] { cut,cut,cut,cut };
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
return mCuts;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99 |
|
|
|
100 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
101 |
|
|
{
|
102 |
|
|
boolean[] tmp = {true,true};
|
103 |
|
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107 |
|
|
|
108 |
|
|
public int getTouchControlType()
|
109 |
|
|
{
|
110 |
|
|
return TC_TETRAHEDRON;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
|
|
|
115 |
|
|
public int getTouchControlSplit()
|
116 |
|
|
{
|
117 |
|
|
return TYPE_NOT_SPLIT;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121 |
|
|
|
122 |
|
|
public int[][][] getEnabled()
|
123 |
|
|
{
|
124 |
|
|
return new int[][][] { {{1,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,2}} };
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128 |
|
|
|
129 |
|
|
public float[] getDist3D(int[] numLayers)
|
130 |
|
|
{
|
131 |
|
|
return TouchControlTetrahedron.D3D;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135 |
|
|
|
136 |
|
|
public Static3D[] getFaceAxis()
|
137 |
|
|
{
|
138 |
|
|
return TouchControlTetrahedron.FACE_AXIS;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
144 |
|
|
{
|
145 |
|
|
if( mCenters==null )
|
146 |
|
|
{
|
147 |
|
|
mCenters = new float[][]
|
148 |
|
|
{
|
149 |
|
|
{ 0.000f, -SQ2/2, 1.000f },
|
150 |
|
|
{ 0.000f, -SQ2/2,-1.000f },
|
151 |
|
|
{-1.000f, SQ2/2, 0.000f },
|
152 |
|
|
{ 1.000f, SQ2/2, 0.000f },
|
153 |
|
|
|
154 |
|
|
{ 0.000f, SQ2/6, 1.0f/3 },
|
155 |
|
|
{ 0.000f, SQ2/6,-1.0f/3 },
|
156 |
|
|
{-1.0f/3, -SQ2/6, 0.000f },
|
157 |
|
|
{ 1.0f/3, -SQ2/6, 0.000f },
|
158 |
|
|
};
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
return mCenters;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
167 |
|
|
{
|
168 |
|
|
if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8, 0,10,7,3};
|
169 |
|
|
return mObjectQuats[mQuatIndex[cubit]];
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173 |
|
|
|
174 |
84a17011
|
Leszek Koltunski
|
private float[][] getVertices(int variant)
|
175 |
82bc272d
|
Leszek Koltunski
|
{
|
176 |
|
|
if( variant==0 )
|
177 |
|
|
{
|
178 |
f7f7ea8e
|
Leszek Koltunski
|
float v1x = G*(0.5f);
|
179 |
|
|
float v1y = G*(SQ2/2);
|
180 |
|
|
float v1z = G*(-0.5f);
|
181 |
|
|
float v2x = G*(-0.5f);
|
182 |
|
|
float v2y = G*(SQ2/2);
|
183 |
|
|
float v2z = G*(-0.5f);
|
184 |
|
|
float v3x = 0.0f;
|
185 |
|
|
float v3y = 0.0f;
|
186 |
|
|
float v3z = G*(-1.0f);
|
187 |
|
|
|
188 |
4efc17f0
|
leszek
|
float F1 = 1.05f*F;
|
189 |
|
|
|
190 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
191 |
82bc272d
|
Leszek Koltunski
|
{
|
192 |
|
|
{ 0.0f, 0.0f,0.0f},
|
193 |
f7f7ea8e
|
Leszek Koltunski
|
{ 0.5f -v1x, SQ2/2 -v1y,-0.5f -v1z},
|
194 |
|
|
{-0.5f -v2x, SQ2/2 -v2y,-0.5f -v2z},
|
195 |
|
|
{ 0.0f -v3x, 0.0f -v3y,-1.0f -v3z},
|
196 |
4efc17f0
|
leszek
|
{ 0.0f, (2*SQ2/3)*F1, -2*F1/3},
|
197 |
|
|
{ F1/3, (SQ2/3)*F1, -F1},
|
198 |
|
|
{ -F1/3, (SQ2/3)*F1, -F1},
|
199 |
f7f7ea8e
|
Leszek Koltunski
|
{ (1-F)*0.5f -v1x, (1-F)*(SQ2/2)+(2*SQ2/3)*F -v1y, -(1-F)*0.5f-F*(2.0f/3) -v1z},
|
200 |
|
|
{-(1-F)*0.5f -v2x, (1-F)*(SQ2/2)+(2*SQ2/3)*F -v2y, -(1-F)*0.5f-F*(2.0f/3) -v2z},
|
201 |
|
|
{ F/3 -v3x, (SQ2/3)*F -v3x, -1.0f -v3z},
|
202 |
|
|
{ (1-F)*0.5f+F/3 -v1x, (1-F)*(SQ2/2)+F*(SQ2/3) -v1y, -(1-F)*0.5f-F -v1z},
|
203 |
|
|
{-(1-F)*0.5f-F/3 -v2x, (1-F)*(SQ2/2)+F*(SQ2/3) -v2y, -(1-F)*0.5f-F -v2z},
|
204 |
|
|
{-F/3 -v3x, (SQ2/3)*F -v3y, -1.0f -v3z},
|
205 |
|
|
{0.0f, (1-G)*SQ2/2, (1-G)*(-1.0f) }
|
206 |
82bc272d
|
Leszek Koltunski
|
};
|
207 |
84a17011
|
Leszek Koltunski
|
}
|
208 |
|
|
else
|
209 |
|
|
{
|
210 |
|
|
return new float[][]
|
211 |
|
|
{
|
212 |
|
|
{ 0.0f, (1-F)*(-2*SQ2/3), (1-F)*(2.0f/3) },
|
213 |
|
|
{ (1-F), (1-F)*(SQ2/3), (1-F)*(-1.0f/3) },
|
214 |
|
|
{ (F-1), (1-F)*(SQ2/3), (1-F)*(-1.0f/3) },
|
215 |
|
|
{0,-SQ2/3,-1.0f/3}
|
216 |
|
|
};
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221 |
|
|
|
222 |
|
|
public ObjectShape getObjectShape(int variant)
|
223 |
|
|
{
|
224 |
|
|
if( variant==0 )
|
225 |
|
|
{
|
226 |
82bc272d
|
Leszek Koltunski
|
int[][] indices =
|
227 |
|
|
{
|
228 |
|
|
{0,1,7,4,8,2},
|
229 |
|
|
{0,3,9,5,10,1},
|
230 |
|
|
{0,2,11,6,12,3},
|
231 |
|
|
{1,10,13,7},
|
232 |
|
|
{3,12,13,9},
|
233 |
|
|
{2,8,13,11},
|
234 |
|
|
{4,7,13},
|
235 |
|
|
{4,13,8},
|
236 |
|
|
{5,9,13},
|
237 |
|
|
{5,13,10},
|
238 |
|
|
{6,11,13},
|
239 |
|
|
{6,13,12}
|
240 |
|
|
};
|
241 |
|
|
|
242 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
243 |
82bc272d
|
Leszek Koltunski
|
}
|
244 |
|
|
else
|
245 |
|
|
{
|
246 |
|
|
int[][] indices =
|
247 |
|
|
{
|
248 |
|
|
{0,1,2},
|
249 |
|
|
{3,1,0},
|
250 |
|
|
{3,2,1},
|
251 |
|
|
{3,0,2}
|
252 |
|
|
};
|
253 |
|
|
|
254 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
255 |
82bc272d
|
Leszek Koltunski
|
}
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
259 |
|
|
|
260 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
261 |
|
|
{
|
262 |
|
|
if( variant==0 )
|
263 |
|
|
{
|
264 |
|
|
float height = isInIconMode() ? 0.001f : 0.015f;
|
265 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {height,35,0.25f,0.5f,5,1,1},{0.001f,35,0.25f,0.5f,5,0,0} };
|
266 |
|
|
int[] indices = { 0,0,0,1,1,1,1,1,1,1,1,1 };
|
267 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
268 |
82bc272d
|
Leszek Koltunski
|
}
|
269 |
|
|
else
|
270 |
|
|
{
|
271 |
|
|
float height = isInIconMode() ? 0.001f : 0.020f;
|
272 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {height,35,0.20f,0.6f,5,0,0}, {0.001f,35,0.20f,0.6f,3,0,0} };
|
273 |
|
|
int[] indices = { 0,1,1,1 };
|
274 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
275 |
|
|
}
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
279 |
|
|
|
280 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
281 |
|
|
{
|
282 |
|
|
if( variant==0 )
|
283 |
|
|
{
|
284 |
|
|
float[][] corners = { {0.04f,0.10f} };
|
285 |
|
|
int[] indices = { 0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
286 |
|
|
float[][] centers = { {0.0f, SQ2/2, -1.0f} };
|
287 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
288 |
|
|
}
|
289 |
|
|
else
|
290 |
|
|
{
|
291 |
|
|
float[][] corners = { {0.02f,0.10f} };
|
292 |
|
|
int[] indices = { 0,0,0,-1 };
|
293 |
|
|
float[][] centers = { {0,-SQ2/3,-1.0f/3} };
|
294 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
295 |
82bc272d
|
Leszek Koltunski
|
}
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
299 |
|
|
|
300 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
301 |
|
|
{
|
302 |
|
|
return 2;
|
303 |
|
|
}
|
304 |
|
|
|
305 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
306 |
|
|
|
307 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
308 |
|
|
{
|
309 |
|
|
return cubit<4 ? 0:1;
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
313 |
8f5116ec
|
leszek
|
// doesn't matter, we override getStickerRadii()
|
314 |
82bc272d
|
Leszek Koltunski
|
|
315 |
|
|
public float getStickerRadius()
|
316 |
|
|
{
|
317 |
8f5116ec
|
leszek
|
return 0.0f;
|
318 |
82bc272d
|
Leszek Koltunski
|
}
|
319 |
|
|
|
320 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321 |
|
|
|
322 |
|
|
public float getStickerStroke()
|
323 |
|
|
{
|
324 |
f7f7ea8e
|
Leszek Koltunski
|
return isInIconMode() ? 0.07f : 0.06f;
|
325 |
82bc272d
|
Leszek Koltunski
|
}
|
326 |
|
|
|
327 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328 |
|
|
|
329 |
ebe8c08e
|
leszek
|
public float[][][] getStickerAngles()
|
330 |
82bc272d
|
Leszek Koltunski
|
{
|
331 |
|
|
return null;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335 |
|
|
// PUBLIC API
|
336 |
|
|
|
337 |
|
|
public Static3D[] getRotationAxis()
|
338 |
|
|
{
|
339 |
|
|
return ROT_AXIS;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
|
|
|
344 |
|
|
public int[][] getBasicAngles()
|
345 |
|
|
{
|
346 |
|
|
if( mBasicAngle==null )
|
347 |
|
|
{
|
348 |
|
|
int[] tmp = {3,3};
|
349 |
|
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
return mBasicAngle;
|
353 |
|
|
}
|
354 |
|
|
|
355 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
356 |
|
|
|
357 |
|
|
public String getShortName()
|
358 |
|
|
{
|
359 |
361fd0de
|
leszek
|
return ListObjects.PDUO_2.name();
|
360 |
82bc272d
|
Leszek Koltunski
|
}
|
361 |
|
|
|
362 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
363 |
|
|
|
364 |
|
|
public String[][] getTutorials()
|
365 |
|
|
{
|
366 |
|
|
return new String[][]{
|
367 |
|
|
{"gb","xB9OFNyi-Uk","Pyraminx Duo: Beginner","Z3"},
|
368 |
|
|
{"gb","P-Zt7GEyYuE","Pyraminx Duo: Optimal","Z3"},
|
369 |
|
|
{"es","ojDwj9Ld3t8","Tutorial: Pyraminx Duo","RubikArt"},
|
370 |
|
|
{"ru","pTaHQOqp4L8","Как собрать Pyraminx Duo","GCubing"},
|
371 |
|
|
{"pl","r9pW0933vz4","Poradnik mini - Pyraminx Duo","Speedcubing Nation"},
|
372 |
|
|
{"vn","F2XahC2fYuk","Hướng dẫn giải Pyraminx Duo","Rubik For Everyone"},
|
373 |
2318a72a
|
leszek
|
{"tw","xNn5bnYOGjA","金字塔二重奏 \"最少步法\" 教學","不正常魔術方塊研究中心"},
|
374 |
82bc272d
|
Leszek Koltunski
|
};
|
375 |
|
|
}
|
376 |
|
|
}
|