1 |
f8e0d6be
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 org.distorted.library.type.Static3D;
|
23 |
|
|
import org.distorted.library.type.Static4D;
|
24 |
|
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
25 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
26 |
1d581993
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
27 |
10b7e306
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
28 |
f8e0d6be
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectType;
|
29 |
|
|
import org.distorted.objectlib.main.ShapeTetrahedron;
|
30 |
|
|
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
|
31 |
|
|
|
32 |
|
|
import java.io.InputStream;
|
33 |
|
|
|
34 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
35 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
36 |
|
|
|
37 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
052e0362
|
Leszek Koltunski
|
public class TwistyMorphix extends ShapeTetrahedron
|
40 |
f8e0d6be
|
Leszek Koltunski
|
{
|
41 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42 |
|
|
{
|
43 |
|
|
new Static3D( SQ2/2, 0.0f, SQ2/2),
|
44 |
|
|
new Static3D( 0.0f, 1.0f, 0.0f),
|
45 |
|
|
new Static3D( SQ2/2, 0.0f,-SQ2/2),
|
46 |
|
|
};
|
47 |
|
|
|
48 |
|
|
private ScrambleState[] mStates;
|
49 |
beee90ab
|
Leszek Koltunski
|
private int[][] mBasicAngle;
|
50 |
f8e0d6be
|
Leszek Koltunski
|
private float[][] mCuts;
|
51 |
|
|
private float[][] mCenters;
|
52 |
|
|
private int[] mQuatIndex;
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
3bf19410
|
Leszek Koltunski
|
public TwistyMorphix(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
57 |
f8e0d6be
|
Leszek Koltunski
|
{
|
58 |
3bf19410
|
Leszek Koltunski
|
super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
|
59 |
f8e0d6be
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
// same as in a 2x2
|
63 |
|
|
|
64 |
|
|
public ScrambleState[] getScrambleStates()
|
65 |
|
|
{
|
66 |
|
|
if( mStates==null )
|
67 |
|
|
{
|
68 |
|
|
int[] tmp = { 0,-1,0,0,1,0,0,2,0, 1,-1,0,1,1,0,1,2,0 };
|
69 |
|
|
|
70 |
|
|
mStates = new ScrambleState[]
|
71 |
|
|
{
|
72 |
|
|
new ScrambleState( new int[][] { tmp,tmp,tmp } )
|
73 |
|
|
};
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
return mStates;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80 |
|
|
|
81 |
|
|
public float[][] getCuts(int[] numLayers)
|
82 |
|
|
{
|
83 |
|
|
if( mCuts==null )
|
84 |
|
|
{
|
85 |
|
|
float[] cut = new float[] {0};
|
86 |
|
|
mCuts = new float[][] { cut,cut,cut };
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
return mCuts;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93 |
|
|
|
94 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
95 |
|
|
{
|
96 |
|
|
boolean[] tmp = new boolean[] {true,true};
|
97 |
|
|
return new boolean[][] { tmp,tmp,tmp };
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101 |
|
|
|
102 |
|
|
public int getTouchControlType()
|
103 |
|
|
{
|
104 |
|
|
return TC_CHANGING_SHAPEMOD;
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108 |
|
|
|
109 |
|
|
public int getTouchControlSplit()
|
110 |
|
|
{
|
111 |
|
|
return TYPE_NOT_SPLIT;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115 |
|
|
|
116 |
|
|
public int[][][] getEnabled()
|
117 |
|
|
{
|
118 |
|
|
return null;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122 |
|
|
|
123 |
|
|
public float[] getDist3D(int[] numLayers)
|
124 |
|
|
{
|
125 |
|
|
return TouchControlTetrahedron.D3D;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129 |
|
|
|
130 |
|
|
public Static3D[] getFaceAxis()
|
131 |
|
|
{
|
132 |
|
|
return TouchControlTetrahedron.FACE_AXIS;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136 |
|
|
|
137 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
138 |
|
|
{
|
139 |
|
|
if( mCenters==null )
|
140 |
|
|
{
|
141 |
|
|
final float A = SQ2/6;
|
142 |
|
|
final float B = 1.0f/3;
|
143 |
|
|
|
144 |
|
|
mCenters = new float[][]
|
145 |
|
|
{
|
146 |
|
|
{0.0f, -A, +B},
|
147 |
|
|
{0.0f, -A, -B},
|
148 |
|
|
{ +B, A, 0.0f},
|
149 |
|
|
{ -B, A, 0.0f},
|
150 |
|
|
{0.0f, A, +B},
|
151 |
|
|
{0.0f, A, -B},
|
152 |
|
|
{ +B, -A, 0.0f},
|
153 |
|
|
{ -B, -A, 0.0f}
|
154 |
|
|
};
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
return mCenters;
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161 |
|
|
|
162 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
163 |
|
|
{
|
164 |
82e62580
|
Leszek Koltunski
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,5,2,8,0,5,2,8 };
|
165 |
f8e0d6be
|
Leszek Koltunski
|
return mObjectQuats[mQuatIndex[cubit]];
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
169 |
|
|
|
170 |
|
|
public ObjectShape getObjectShape(int variant)
|
171 |
|
|
{
|
172 |
|
|
if( variant==0 )
|
173 |
|
|
{
|
174 |
|
|
final float Y = SQ2/2;
|
175 |
|
|
final float Z = 1.0f;
|
176 |
|
|
|
177 |
|
|
float[][] vertices =
|
178 |
|
|
{
|
179 |
|
|
{0.0f,-2*Y/3, 2*Z/3 },
|
180 |
|
|
{0.0f,-2*Y/3, -Z/3 },
|
181 |
|
|
{ Z/2, Y/3, Z/6 },
|
182 |
|
|
{-Z/2, Y/3, Z/6 },
|
183 |
|
|
{0.0f, Y/3, -Z/3 }
|
184 |
|
|
};
|
185 |
|
|
|
186 |
|
|
int[][] indices = { {0,2,3},{0,1,2},{0,3,1},{4,2,1},{4,1,3},{4,3,2} };
|
187 |
|
|
|
188 |
|
|
return new ObjectShape(vertices, indices);
|
189 |
|
|
}
|
190 |
|
|
else
|
191 |
|
|
{
|
192 |
|
|
final float X = 1.0f;
|
193 |
|
|
final float Y = SQ2/2;
|
194 |
|
|
final float Z = 0.5f;
|
195 |
|
|
|
196 |
|
|
float[][] vertices =
|
197 |
|
|
{
|
198 |
|
|
{-X/2, -Y/3, Z/3 },
|
199 |
|
|
{ X/2, -Y/3, Z/3 },
|
200 |
|
|
{0.0f, 2*Y/3,-2*Z/3 },
|
201 |
|
|
{0.0f, -Y/3,-2*Z/3 }
|
202 |
|
|
};
|
203 |
|
|
|
204 |
|
|
int[][] indices = { {1,2,0},{3,1,0},{1,3,2},{3,0,2} };
|
205 |
|
|
|
206 |
|
|
return new ObjectShape(vertices, indices);
|
207 |
|
|
}
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
211 |
|
|
|
212 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
213 |
|
|
{
|
214 |
3bf19410
|
Leszek Koltunski
|
float height = isInIconMode() ? 0.001f : 0.03f;
|
215 |
|
|
|
216 |
f8e0d6be
|
Leszek Koltunski
|
if( variant==0 )
|
217 |
|
|
{
|
218 |
3bf19410
|
Leszek Koltunski
|
float[][] bands = { {height,30,0.15f,0.5f,5,1,2}, {0.001f,30,0.2f,0.4f,5,1,2} };
|
219 |
f8e0d6be
|
Leszek Koltunski
|
int[] bandIndices = { 0,0,0,1,1,1 };
|
220 |
|
|
float[][] corners = { {0.08f,0.13f} };
|
221 |
|
|
int[] indices = { 0,0,0,0,-1 };
|
222 |
|
|
float[][] centers = { { 0.0f,0.0f,0.0f } };
|
223 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
224 |
|
|
}
|
225 |
|
|
else
|
226 |
|
|
{
|
227 |
|
|
final float Y = SQ2/2;
|
228 |
|
|
final float Z = 0.5f;
|
229 |
3bf19410
|
Leszek Koltunski
|
float[][] bands = { {height,30,0.15f,0.5f,5,1,1}, {0.001f,30,0.25f,0.5f,5,1,1} };
|
230 |
f8e0d6be
|
Leszek Koltunski
|
int[] bandIndices = { 0,1,1,1 };
|
231 |
|
|
float[][] corners = { {0.08f,0.13f} };
|
232 |
|
|
int[] indices = { 0,0,0,-1 };
|
233 |
|
|
float[][] centers = { { 0.0f,-Y/3,-2*Z/3 } };
|
234 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
235 |
|
|
}
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
239 |
|
|
|
240 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
241 |
|
|
{
|
242 |
|
|
return 2;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246 |
|
|
|
247 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
248 |
|
|
{
|
249 |
|
|
return cubit<4 ? 0 : 1;
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
253 |
|
|
|
254 |
|
|
public float getStickerRadius()
|
255 |
|
|
{
|
256 |
|
|
return 0.10f;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
260 |
|
|
|
261 |
|
|
public float getStickerStroke()
|
262 |
|
|
{
|
263 |
3bf19410
|
Leszek Koltunski
|
return isInIconMode() ? 0.12f : 0.07f;
|
264 |
f8e0d6be
|
Leszek Koltunski
|
}
|
265 |
|
|
|
266 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
267 |
|
|
|
268 |
|
|
public float[][] getStickerAngles()
|
269 |
|
|
{
|
270 |
|
|
return null;
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
274 |
|
|
// PUBLIC API
|
275 |
|
|
|
276 |
|
|
public Static3D[] getRotationAxis()
|
277 |
|
|
{
|
278 |
|
|
return ROT_AXIS;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
282 |
|
|
|
283 |
beee90ab
|
Leszek Koltunski
|
public int[][] getBasicAngles()
|
284 |
f8e0d6be
|
Leszek Koltunski
|
{
|
285 |
beee90ab
|
Leszek Koltunski
|
if( mBasicAngle==null )
|
286 |
|
|
{
|
287 |
|
|
int num = getNumLayers()[0];
|
288 |
|
|
int[] tmp = new int[num];
|
289 |
|
|
for(int i=0; i<num; i++) tmp[i] = 4;
|
290 |
|
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
291 |
|
|
}
|
292 |
|
|
|
293 |
f8e0d6be
|
Leszek Koltunski
|
return mBasicAngle;
|
294 |
|
|
}
|
295 |
|
|
|
296 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297 |
|
|
|
298 |
5f54927b
|
Leszek Koltunski
|
public String getShortName()
|
299 |
f8e0d6be
|
Leszek Koltunski
|
{
|
300 |
5f54927b
|
Leszek Koltunski
|
return ObjectType.MORP_2.name();
|
301 |
|
|
}
|
302 |
|
|
|
303 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304 |
|
|
|
305 |
1d581993
|
Leszek Koltunski
|
public ObjectSignature getSignature()
|
306 |
5f54927b
|
Leszek Koltunski
|
{
|
307 |
1d581993
|
Leszek Koltunski
|
return new ObjectSignature(ObjectType.MORP_2);
|
308 |
f8e0d6be
|
Leszek Koltunski
|
}
|
309 |
|
|
|
310 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
311 |
|
|
|
312 |
|
|
public String getObjectName()
|
313 |
|
|
{
|
314 |
|
|
return "Pyramorphix";
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
318 |
|
|
|
319 |
|
|
public String getInventor()
|
320 |
|
|
{
|
321 |
|
|
return "Manfred Fritsche";
|
322 |
|
|
}
|
323 |
|
|
|
324 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
325 |
|
|
|
326 |
|
|
public int getYearOfInvention()
|
327 |
|
|
{
|
328 |
|
|
return 0;
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
332 |
|
|
|
333 |
|
|
public int getComplexity()
|
334 |
|
|
{
|
335 |
|
|
return 1;
|
336 |
|
|
}
|
337 |
052e0362
|
Leszek Koltunski
|
|
338 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
339 |
|
|
|
340 |
|
|
public String[][] getTutorials()
|
341 |
|
|
{
|
342 |
|
|
return new String[][] {
|
343 |
|
|
{"gb","dD67B3cRaFw","Pyramorphix Solve Tutorial","SpeedCubeReview"},
|
344 |
|
|
{"es","RA37LhYlEW8","Resolver Pyramorphix","Cuby"},
|
345 |
|
|
{"ru","fTNXLAAuGAI","Как собрать Пираморфикс 2х2","Алексей Ярыгин"},
|
346 |
|
|
{"fr","SfEqoud5KRc","Résolution du Pyramorphix","Asthalis"},
|
347 |
|
|
{"de","1VDGoVJZCug","Pyramorphix - Tutorial","GerCubing"},
|
348 |
f7049f3d
|
Leszek Koltunski
|
{"pl","b7VpuXloBNU","Mastermorphix 2x2 TUTORIAL PL","MrUK"},
|
349 |
052e0362
|
Leszek Koltunski
|
{"br","wByfDxTrbC8","Como resolver o Pyramorphix","Rafael Cinoto"},
|
350 |
|
|
{"kr","WIy5ZvTXsOY","피라몰픽스 쉽게 맞추기","큐브놀이터"},
|
351 |
a399e91b
|
Leszek Koltunski
|
{"vn","6CuTRLjKHho","Tutorial N.14 - Pyramorphix","Duy Thích Rubik"},
|
352 |
052e0362
|
Leszek Koltunski
|
};
|
353 |
|
|
}
|
354 |
f8e0d6be
|
Leszek Koltunski
|
}
|