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