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