1 |
def7cee2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 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_OCTAHEDRON;
|
13 |
621a672c
|
Leszek Koltunski
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE;
|
14 |
def7cee2
|
Leszek Koltunski
|
|
15 |
|
|
import org.distorted.library.type.Static3D;
|
16 |
|
|
import org.distorted.library.type.Static4D;
|
17 |
|
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
18 |
|
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
19 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
20 |
ae9d9227
|
leszek
|
import org.distorted.objectlib.metadata.Metadata;
|
21 |
def7cee2
|
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 |
def7cee2
|
Leszek Koltunski
|
import org.distorted.objectlib.shape.ShapeOctahedron;
|
25 |
|
|
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
|
26 |
|
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
|
|
public class TwistyPyraminxDiamond extends ShapeOctahedron
|
30 |
|
|
{
|
31 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
32 |
|
|
{
|
33 |
|
|
new Static3D(SQ2/2, 0, SQ2/2),
|
34 |
|
|
new Static3D( 0, 1, 0),
|
35 |
|
|
new Static3D(SQ2/2, 0,-SQ2/2)
|
36 |
|
|
};
|
37 |
|
|
|
38 |
|
|
private static final float D = 0.3f; // Size of the small cubit in relation to the face of the octahedron.
|
39 |
|
|
// Keep below 1/3.
|
40 |
|
|
|
41 |
9ba7f3f6
|
Leszek Koltunski
|
private int[][] mEdges;
|
42 |
def7cee2
|
Leszek Koltunski
|
private int[][] mBasicAngle;
|
43 |
|
|
private float[][] mCuts;
|
44 |
|
|
private float[][] mPositions;
|
45 |
|
|
private int[] mQuatIndex;
|
46 |
|
|
|
47 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48 |
|
|
|
49 |
ae9d9227
|
leszek
|
public TwistyPyraminxDiamond(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
50 |
def7cee2
|
Leszek Koltunski
|
{
|
51 |
ae9d9227
|
leszek
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
52 |
def7cee2
|
Leszek Koltunski
|
}
|
53 |
|
|
|
54 |
8f5116ec
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
|
|
@Override
|
57 |
|
|
protected float[][][] getStickerRadii()
|
58 |
|
|
{
|
59 |
|
|
float R1 = 0.13f;
|
60 |
|
|
float R2 = 0.00f;
|
61 |
|
|
float R3 = 0.13f;
|
62 |
|
|
return new float[][][] { {{ R3,R3,R3,R2,R3,R3 }} , {{ R1,R1,R1 }} };
|
63 |
|
|
}
|
64 |
|
|
|
65 |
a70b1e96
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66 |
|
|
|
67 |
|
|
@Override
|
68 |
|
|
public float[][] returnRotationFactor()
|
69 |
|
|
{
|
70 |
|
|
float C = 1.5f;
|
71 |
|
|
float[] f = new float[] {C,C,C};
|
72 |
|
|
return new float[][] { f,f,f };
|
73 |
|
|
}
|
74 |
|
|
|
75 |
def7cee2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76 |
5abb9a18
|
Leszek Koltunski
|
// single edge; middle layers don't move
|
77 |
def7cee2
|
Leszek Koltunski
|
|
78 |
9ba7f3f6
|
Leszek Koltunski
|
public int[][] getScrambleEdges()
|
79 |
def7cee2
|
Leszek Koltunski
|
{
|
80 |
5abb9a18
|
Leszek Koltunski
|
if( mEdges==null )
|
81 |
|
|
{
|
82 |
|
|
mEdges = new int[][]
|
83 |
|
|
{
|
84 |
|
|
{0,0,1,0,2,0,6,0,7,0,8,0, 9,0,10,0,11,0,15,0,16,0,17,0, 18,0,19,0,20,0,24,0,25,0,26,0}
|
85 |
|
|
};
|
86 |
|
|
}
|
87 |
9ba7f3f6
|
Leszek Koltunski
|
return mEdges;
|
88 |
def7cee2
|
Leszek Koltunski
|
}
|
89 |
|
|
|
90 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
|
|
public float[][] getCuts(int[] numLayers)
|
93 |
|
|
{
|
94 |
|
|
if( mCuts==null )
|
95 |
|
|
{
|
96 |
|
|
float C = 0.5f*SQ2;
|
97 |
|
|
float[] cut = { -C,C};
|
98 |
|
|
mCuts = new float[][] { cut,cut,cut };
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
return mCuts;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105 |
|
|
|
106 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
107 |
|
|
{
|
108 |
|
|
boolean[] tmp = {true,false,true};
|
109 |
|
|
return new boolean[][] { tmp,tmp,tmp };
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113 |
|
|
|
114 |
|
|
public int getTouchControlType()
|
115 |
|
|
{
|
116 |
|
|
return TC_OCTAHEDRON;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120 |
|
|
|
121 |
|
|
public int getTouchControlSplit()
|
122 |
|
|
{
|
123 |
621a672c
|
Leszek Koltunski
|
return TYPE_SPLIT_EDGE;
|
124 |
def7cee2
|
Leszek Koltunski
|
}
|
125 |
|
|
|
126 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127 |
|
|
|
128 |
|
|
public int[][][] getEnabled()
|
129 |
|
|
{
|
130 |
621a672c
|
Leszek Koltunski
|
int[][] e0 = {{1},{2},{0}};
|
131 |
|
|
int[][] e1 = {{1},{0},{2}};
|
132 |
|
|
return new int[][][] { e0,e0,e0,e0,e1,e1,e1,e1 };
|
133 |
def7cee2
|
Leszek Koltunski
|
}
|
134 |
|
|
|
135 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136 |
|
|
|
137 |
|
|
public float[] getDist3D(int[] numLayers)
|
138 |
|
|
{
|
139 |
|
|
return TouchControlOctahedron.D3D;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143 |
|
|
|
144 |
|
|
public Static3D[] getFaceAxis()
|
145 |
|
|
{
|
146 |
|
|
return TouchControlOctahedron.FACE_AXIS;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
150 |
|
|
|
151 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
152 |
|
|
{
|
153 |
|
|
if( mPositions==null )
|
154 |
|
|
{
|
155 |
|
|
float B0 = 1.5f*SQ2;
|
156 |
|
|
float C0 = 1.5f;
|
157 |
|
|
float A = 1.03f; // move the centers 3% out - otherwise they look hidden.
|
158 |
|
|
float B1 = 0.5f*SQ2*A;
|
159 |
|
|
float C1 = A;
|
160 |
|
|
|
161 |
|
|
mPositions = new float[][]
|
162 |
|
|
{
|
163 |
|
|
{ 0, B0, 0 },
|
164 |
|
|
{ 0,-B0, 0 },
|
165 |
|
|
{ C0, 0, C0 },
|
166 |
|
|
{ C0, 0,-C0 },
|
167 |
|
|
{-C0, 0, C0 },
|
168 |
|
|
{-C0, 0,-C0 },
|
169 |
|
|
|
170 |
|
|
{ 0, B1, C1 },
|
171 |
|
|
{ 0, B1,-C1 },
|
172 |
|
|
{ 0,-B1, C1 },
|
173 |
|
|
{ 0,-B1,-C1 },
|
174 |
|
|
{ C1, B1, 0 },
|
175 |
|
|
{ C1,-B1, 0 },
|
176 |
|
|
{-C1, B1, 0 },
|
177 |
|
|
{-C1,-B1, 0 },
|
178 |
|
|
};
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
return mPositions;
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
185 |
|
|
|
186 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
187 |
|
|
{
|
188 |
|
|
if( mQuatIndex==null )
|
189 |
|
|
{
|
190 |
|
|
mQuatIndex = new int[] { 0,2,9,1,3,7, 0,5,3,11,1,2,4,8 };
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
return mObjectQuats[mQuatIndex[cubit]];
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197 |
|
|
|
198 |
|
|
private float[][] getVertices(int variant)
|
199 |
|
|
{
|
200 |
|
|
if( variant==0 )
|
201 |
|
|
{
|
202 |
|
|
final float A0 = 1-D;
|
203 |
|
|
final float H0 = -SQ2*(1-D);
|
204 |
|
|
final float A1 = 0.75f;
|
205 |
|
|
final float H1 = -0.75f*SQ2;
|
206 |
|
|
final float H2 = -SQ2 + 0.25f*SQ2*D;
|
207 |
|
|
final float A2 = 0.0f + 0.75f*D;
|
208 |
|
|
final float B2 = 1.0f - 0.25f*D;
|
209 |
|
|
final float A3 = 0.25f + 0.5f*D;
|
210 |
|
|
final float H3 = (-1.25f + 0.5f*D)*SQ2;
|
211 |
|
|
|
212 |
|
|
return new float[][]
|
213 |
|
|
{
|
214 |
|
|
{ 0, 0, 0 }, //0
|
215 |
|
|
|
216 |
|
|
{ 0, H0, A0 },
|
217 |
|
|
{ A0, H0, 0 },
|
218 |
|
|
{ 0, H0,-A0 },
|
219 |
|
|
{-A0, H0, 0 }, //4
|
220 |
|
|
|
221 |
|
|
{ 0, H0, 0 },
|
222 |
|
|
|
223 |
|
|
{ A1, H1, A1 },
|
224 |
|
|
{ A1, H1,-A1 },
|
225 |
|
|
{-A1, H1,-A1 },
|
226 |
|
|
{-A1, H1, A1 }, //9
|
227 |
|
|
|
228 |
|
|
{ A2, H2, B2 },
|
229 |
|
|
{ B2, H2,-A2 },
|
230 |
|
|
{-A2, H2,-B2 },
|
231 |
|
|
{-B2, H2, A2 },
|
232 |
|
|
|
233 |
|
|
{ B2, H2, A2 }, //14
|
234 |
|
|
{ A2, H2,-B2 },
|
235 |
|
|
{-B2, H2,-A2 },
|
236 |
|
|
{-A2, H2, B2 },
|
237 |
|
|
|
238 |
|
|
{ A3, H3, A3 },
|
239 |
|
|
{ A3, H3,-A3 }, //19
|
240 |
|
|
{-A3, H3,-A3 },
|
241 |
|
|
{-A3, H3, A3 }
|
242 |
|
|
};
|
243 |
|
|
}
|
244 |
|
|
else
|
245 |
|
|
{
|
246 |
|
|
return new float[][]
|
247 |
|
|
{
|
248 |
|
|
{-1.5f*D, -0.5f*SQ2*D, 0.5f*D},
|
249 |
|
|
{ 1.5f*D, -0.5f*SQ2*D, 0.5f*D},
|
250 |
|
|
{ 0.0f , SQ2*D, -D},
|
251 |
|
|
{ 0.0f , -0.5f*SQ2 ,-1.0f }
|
252 |
|
|
};
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
257 |
|
|
|
258 |
|
|
public ObjectShape getObjectShape(int variant)
|
259 |
|
|
{
|
260 |
|
|
if( variant==0 )
|
261 |
|
|
{
|
262 |
|
|
int[][] indices =
|
263 |
|
|
{
|
264 |
|
|
{0,9,17,1,10,6},
|
265 |
|
|
{0,6,14,2,11,7},
|
266 |
|
|
{0,7,15,3,12,8},
|
267 |
|
|
{0,8,16,4,13,9},
|
268 |
|
|
{6,10,18,14},
|
269 |
|
|
{7,11,19,15},
|
270 |
|
|
{8,12,20,16},
|
271 |
|
|
{9,13,21,17},
|
272 |
|
|
|
273 |
|
|
{5,18,10,1},
|
274 |
|
|
{5,1,17,21},
|
275 |
|
|
{5,21,13,4},
|
276 |
|
|
{5,4,16,20},
|
277 |
|
|
{5,20,12,3},
|
278 |
|
|
{5,3,15,19},
|
279 |
|
|
{5,19,11,2},
|
280 |
|
|
{5,2,14,18}
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
};
|
284 |
|
|
|
285 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
286 |
|
|
}
|
287 |
|
|
else
|
288 |
|
|
{
|
289 |
|
|
int[][] indices = { {0,1,2},{3,1,0},{3,2,1},{3,0,2} };
|
290 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
291 |
|
|
}
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
295 |
|
|
|
296 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
297 |
|
|
{
|
298 |
347f6cc1
|
Leszek Koltunski
|
int angle = 20;
|
299 |
|
|
float R = 0.7f;
|
300 |
|
|
float S = 0.5f;
|
301 |
|
|
|
302 |
def7cee2
|
Leszek Koltunski
|
if( variant==0 )
|
303 |
|
|
{
|
304 |
|
|
float height = isInIconMode() ? 0.001f : 0.03f;
|
305 |
347f6cc1
|
Leszek Koltunski
|
float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
|
306 |
def7cee2
|
Leszek Koltunski
|
int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
|
307 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
308 |
|
|
}
|
309 |
|
|
else
|
310 |
|
|
{
|
311 |
|
|
float height = isInIconMode() ? 0.001f : 0.03f;
|
312 |
347f6cc1
|
Leszek Koltunski
|
float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
|
313 |
def7cee2
|
Leszek Koltunski
|
int[] indices = { 0,1,1,1 };
|
314 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
315 |
|
|
}
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
319 |
|
|
|
320 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
321 |
|
|
{
|
322 |
|
|
if( variant==0 )
|
323 |
|
|
{
|
324 |
|
|
float[][] corners = { {0.03f,0.20f},{0.03f,0.15f} };
|
325 |
|
|
int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
326 |
|
|
float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
|
327 |
|
|
int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
328 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
329 |
|
|
}
|
330 |
|
|
else
|
331 |
|
|
{
|
332 |
|
|
float[][] corners = { {0.02f,0.10f} };
|
333 |
|
|
int[] indices = { 0,0,0,-1 };
|
334 |
|
|
float[][] centers = { {0,-SQ2/2,-1.0f} };
|
335 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
336 |
|
|
}
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
340 |
|
|
|
341 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
342 |
|
|
{
|
343 |
|
|
return 2;
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
347 |
|
|
|
348 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
349 |
|
|
{
|
350 |
|
|
return cubit<6 ? 0:1;
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
354 |
8f5116ec
|
leszek
|
// overriding getStickerRadii()
|
355 |
def7cee2
|
Leszek Koltunski
|
|
356 |
|
|
public float getStickerRadius()
|
357 |
|
|
{
|
358 |
8f5116ec
|
leszek
|
return 0.0f;
|
359 |
def7cee2
|
Leszek Koltunski
|
}
|
360 |
|
|
|
361 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
362 |
|
|
|
363 |
|
|
public float getStickerStroke()
|
364 |
|
|
{
|
365 |
8f5116ec
|
leszek
|
return isInIconMode() ? 0.20f : 0.11f;
|
366 |
def7cee2
|
Leszek Koltunski
|
}
|
367 |
|
|
|
368 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
369 |
|
|
|
370 |
ebe8c08e
|
leszek
|
public float[][][] getStickerAngles()
|
371 |
def7cee2
|
Leszek Koltunski
|
{
|
372 |
|
|
return null;
|
373 |
|
|
}
|
374 |
|
|
|
375 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
376 |
|
|
// PUBLIC API
|
377 |
|
|
|
378 |
|
|
public Static3D[] getRotationAxis()
|
379 |
|
|
{
|
380 |
|
|
return ROT_AXIS;
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
384 |
|
|
|
385 |
|
|
public int[][] getBasicAngles()
|
386 |
|
|
{
|
387 |
|
|
if( mBasicAngle ==null )
|
388 |
|
|
{
|
389 |
|
|
int[] tmp = {4,4,4};
|
390 |
|
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
return mBasicAngle;
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
397 |
|
|
|
398 |
|
|
public String getShortName()
|
399 |
|
|
{
|
400 |
361fd0de
|
leszek
|
return ListObjects.PDIA_3.name();
|
401 |
def7cee2
|
Leszek Koltunski
|
}
|
402 |
|
|
|
403 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404 |
|
|
|
405 |
|
|
public String[][] getTutorials()
|
406 |
|
|
{
|
407 |
|
|
return new String[][] {
|
408 |
|
|
{"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
|
409 |
|
|
{"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
|
410 |
|
|
{"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
|
411 |
|
|
{"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
|
412 |
2318a72a
|
leszek
|
{"tw","76M-RMl70w0","Pyraminx Diamond","不正常魔術方塊研究中心"},
|
413 |
def7cee2
|
Leszek Koltunski
|
};
|
414 |
|
|
}
|
415 |
|
|
}
|