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