1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 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 java.io.InputStream;
|
13
|
|
14
|
import org.distorted.library.type.Static3D;
|
15
|
import org.distorted.library.type.Static4D;
|
16
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
17
|
import org.distorted.objectlib.helpers.ObjectShape;
|
18
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
19
|
import org.distorted.objectlib.main.InitData;
|
20
|
import org.distorted.objectlib.main.ObjectType;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
|
24
|
public class TwistyCrystal extends TwistyMinx
|
25
|
{
|
26
|
private static final float A = (SQ5+5)/10;
|
27
|
|
28
|
private float[][] mCuts;
|
29
|
private float[][] mPosition;
|
30
|
private int[] mQuatIndex;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public TwistyCrystal(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
35
|
{
|
36
|
super(data, meshState, iconMode, quat, move, scale, stream);
|
37
|
}
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public float[][] getCubitPositions(int[] numLayers)
|
42
|
{
|
43
|
if( mPosition==null )
|
44
|
{
|
45
|
if( mEdgeMap==null ) initializeEdgeMap();
|
46
|
if( mCenterCoords==null ) initializeCenterCoords();
|
47
|
|
48
|
mPosition = new float[NUM_EDGES+NUM_CORNERS][3];
|
49
|
|
50
|
for(int edge=0; edge<NUM_EDGES; edge++)
|
51
|
{
|
52
|
float[] c1 = mCorners[ mEdgeMap[edge][0] ];
|
53
|
float[] c2 = mCorners[ mEdgeMap[edge][1] ];
|
54
|
|
55
|
mPosition[edge][0] = (c1[0]+c2[0])/2;
|
56
|
mPosition[edge][1] = (c1[1]+c2[1])/2;
|
57
|
mPosition[edge][2] = (c1[2]+c2[2])/2;
|
58
|
}
|
59
|
|
60
|
System.arraycopy(mCorners, 0, mPosition, NUM_EDGES, NUM_CORNERS);
|
61
|
}
|
62
|
|
63
|
return mPosition;
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
|
68
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
69
|
{
|
70
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,17,12,13,20, 4,25, 5,24,16,
|
71
|
9,21, 1,34, 8,11,30,43,26,14,
|
72
|
15,45,33,28,10, 2,29, 6, 7, 3,
|
73
|
|
74
|
0, 2,20,42,13,41,16,33, 8,51,
|
75
|
1,25,12,27, 4, 3,21,28, 5, 6 };
|
76
|
return mObjectQuats[mQuatIndex[cubit]];
|
77
|
}
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
|
81
|
public ObjectShape getObjectShape(int variant)
|
82
|
{
|
83
|
float[] blueCenter = mCenterCoords[0];
|
84
|
float[] greeCenter = mCenterCoords[1];
|
85
|
float[] pinkCenter = mCenterCoords[2];
|
86
|
|
87
|
if( variant==0 )
|
88
|
{
|
89
|
float B = greeCenter[2]-mCorners[0][2];
|
90
|
float C = A*mCorners[0][1]+(1.0f-A)*mCorners[2][1];
|
91
|
float D = greeCenter[0];
|
92
|
|
93
|
float[][] vertices =
|
94
|
{
|
95
|
{ 0.0f, C, 0,0f },
|
96
|
{ 0.0f,-C, 0,0f },
|
97
|
{ -D,0.0f, B },
|
98
|
{ +D,0.0f, B },
|
99
|
};
|
100
|
int[][] indices =
|
101
|
{
|
102
|
{1,0,2},
|
103
|
{0,1,3},
|
104
|
{2,3,1},
|
105
|
{3,2,0}
|
106
|
};
|
107
|
|
108
|
return new ObjectShape(vertices, indices);
|
109
|
}
|
110
|
else
|
111
|
{
|
112
|
float X = mCorners[0][0];
|
113
|
float Y = mCorners[0][1];
|
114
|
float Z = mCorners[0][2];
|
115
|
|
116
|
float X1 = A*mCorners[0][0]+(1.0f-A)*mCorners[16][0];
|
117
|
float Y1 = A*mCorners[0][1]+(1.0f-A)*mCorners[16][1];
|
118
|
float Z1 = A*mCorners[0][2]+(1.0f-A)*mCorners[16][2];
|
119
|
float X2 = A*mCorners[0][0]+(1.0f-A)*mCorners[12][0];
|
120
|
float Y2 = A*mCorners[0][1]+(1.0f-A)*mCorners[12][1];
|
121
|
float Z2 = A*mCorners[0][2]+(1.0f-A)*mCorners[12][2];
|
122
|
float X3 = A*mCorners[0][0]+(1.0f-A)*mCorners[ 2][0];
|
123
|
float Y3 = A*mCorners[0][1]+(1.0f-A)*mCorners[ 2][1];
|
124
|
float Z3 = A*mCorners[0][2]+(1.0f-A)*mCorners[ 2][2];
|
125
|
|
126
|
float[][] vertices =
|
127
|
{
|
128
|
{0.0f, 0.0f, 0.0f},
|
129
|
{X1-X, Y1-Y, Z1-Z},
|
130
|
{X2-X, Y2-Y, Z2-Z},
|
131
|
{X3-X, Y3-Y, Z3-Z},
|
132
|
{ greeCenter[0]-X, greeCenter[1]-Y, greeCenter[2]-Z },
|
133
|
{ pinkCenter[0]-X, pinkCenter[1]-Y, pinkCenter[2]-Z },
|
134
|
{ blueCenter[0]-X, blueCenter[1]-Y, blueCenter[2]-Z }
|
135
|
};
|
136
|
int[][] indices =
|
137
|
{
|
138
|
{ 5,3,0,1 },
|
139
|
{ 4,2,0,3 },
|
140
|
{ 6,1,0,2 },
|
141
|
{ 5,4,3 },
|
142
|
{ 4,6,2 },
|
143
|
{ 6,5,1 },
|
144
|
{ 6,4,5 }
|
145
|
};
|
146
|
|
147
|
return new ObjectShape(vertices, indices);
|
148
|
}
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
154
|
{
|
155
|
if( variant==0 )
|
156
|
{
|
157
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
158
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
159
|
float[][] bands = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
|
160
|
int[] bandIndices = { 0,0,1,1 };
|
161
|
float[][] corners = { { 0.015f, 0.20f } };
|
162
|
int[] cornerIndices = { 0,0,0,0 };
|
163
|
float[][] centers = { { 0.0f,0.0f,-mCorners[0][2] } };
|
164
|
int[] centerIndices = { 0,0,0,0 };
|
165
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
166
|
}
|
167
|
else
|
168
|
{
|
169
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
170
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
171
|
float[][] bands = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,3,0,0} };
|
172
|
int[] bandIndices = { 0,0,0,1,1,1,2 };
|
173
|
float[][] corners = { { 0.01f, 0.20f } };
|
174
|
int[] cornerIndices = { 0,0,0,0,0,0,0 };
|
175
|
float[][] centers = { { 0.0f,-1.5f,-mCorners[0][2] } };
|
176
|
int[] centerIndices = { 0,0,0,0,0,0,0 };
|
177
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
178
|
}
|
179
|
}
|
180
|
|
181
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
182
|
|
183
|
public int getNumCubitVariants(int[] numLayers)
|
184
|
{
|
185
|
return 2;
|
186
|
}
|
187
|
|
188
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
189
|
|
190
|
public int getCubitVariant(int cubit, int[] numLayers)
|
191
|
{
|
192
|
return cubit<NUM_EDGES ? 0:1;
|
193
|
}
|
194
|
|
195
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
196
|
|
197
|
public float[][] getCuts(int[] numLayers)
|
198
|
{
|
199
|
if( mCuts==null )
|
200
|
{
|
201
|
float CUT = 1.5f; // TODO
|
202
|
float[] cut = new float[] { -CUT,+CUT };
|
203
|
mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
|
204
|
}
|
205
|
|
206
|
return mCuts;
|
207
|
}
|
208
|
|
209
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
210
|
|
211
|
public float getStickerRadius()
|
212
|
{
|
213
|
return 0.18f;
|
214
|
}
|
215
|
|
216
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
217
|
|
218
|
public float getStickerStroke()
|
219
|
{
|
220
|
return isInIconMode() ? 0.22f : 0.15f;
|
221
|
}
|
222
|
|
223
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
224
|
|
225
|
public float[][] getStickerAngles()
|
226
|
{
|
227
|
return null;
|
228
|
}
|
229
|
|
230
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
231
|
// PUBLIC API
|
232
|
|
233
|
public String getShortName()
|
234
|
{
|
235
|
return ObjectType.CRYS_3.name();
|
236
|
}
|
237
|
|
238
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
239
|
|
240
|
public ObjectSignature getSignature()
|
241
|
{
|
242
|
return new ObjectSignature(ObjectType.CRYS_3);
|
243
|
}
|
244
|
|
245
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
|
247
|
public String getObjectName()
|
248
|
{
|
249
|
return "Pyraminx Crystal";
|
250
|
}
|
251
|
|
252
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
253
|
|
254
|
public String getInventor()
|
255
|
{
|
256
|
return "Aleh Hladzilin";
|
257
|
}
|
258
|
|
259
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
260
|
|
261
|
public int getYearOfInvention()
|
262
|
{
|
263
|
return 2006;
|
264
|
}
|
265
|
|
266
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
267
|
|
268
|
public int getComplexity()
|
269
|
{
|
270
|
return 3;
|
271
|
}
|
272
|
|
273
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
274
|
|
275
|
public String[][] getTutorials()
|
276
|
{
|
277
|
return new String[][]{
|
278
|
{"gb","tFSGC9esay0","Pyraminx Crystal Tutorial","twistypuzzling"},
|
279
|
{"es","AmrIwSICFB8","Como resolver Pyraminx Crystal","Tutoriales Rubik"},
|
280
|
{"ru","3AKeT8JIU0E","Как собрать Crystal Pyraminx","RBcuber"},
|
281
|
{"fr","SPsrHhQzmVg","Résolution du Pyraminx Crystal","asthalis"},
|
282
|
{"de","EH4sw7_21eA","Crystal Pyraminx Tutorial","GerCubing"},
|
283
|
{"pl","AmrIwSICFB8","Crystal Pyraminx TUTORIAL PL","MrUK"},
|
284
|
{"br","13pz0cNBVow","Como resolver o Pyraminx Crystal 1/3","RafaelCinoto"},
|
285
|
{"br","eT654oZsBg0","Como resolver o Pyraminx Crystal 2/3","RafaelCinoto"},
|
286
|
{"br","MnooQbVFbfU","Como resolver o Pyraminx Crystal 3/3","RafaelCinoto"},
|
287
|
{"kr","o-w_ZzDrfFU","피라밍크스 크리스탈 해법 1/2","SlowCuberToumai"},
|
288
|
{"kr","ExMg8SAge4Q","피라밍크스 크리스탈 해법 2/2","SlowCuberToumai"},
|
289
|
{"vn","MxF4bKlnIMU","Tutorial N.28 - Pyraminx Crystal","Duy Thích Rubik"},
|
290
|
};
|
291
|
}
|
292
|
}
|