Revision 1d581993
Added by Leszek Koltunski about 2 years ago
src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java | ||
---|---|---|
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.helpers; |
|
21 |
|
|
22 |
import org.distorted.objectlib.main.ObjectType; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
|
|
26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
27 |
|
|
28 |
public class ObjectSignature |
|
29 |
{ |
|
30 |
private long mSignature1, mSignature2, mSignature3; |
|
31 |
private int[] mLayer; |
|
32 |
private float[][][] mAllCycles; |
|
33 |
private float[][] mCubitTouch; |
|
34 |
private int mNumCubitTouches, mNumCycles; |
|
35 |
|
|
36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
37 |
// built-in objects |
|
38 |
|
|
39 |
public ObjectSignature(ObjectType type) |
|
40 |
{ |
|
41 |
mSignature1 = 0; |
|
42 |
mSignature2 = 0; |
|
43 |
mSignature3 = type.ordinal(); |
|
44 |
} |
|
45 |
|
|
46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
|
48 |
public ObjectSignature(ObjectSignature sig) |
|
49 |
{ |
|
50 |
mSignature1 = sig.mSignature1; |
|
51 |
mSignature2 = sig.mSignature2; |
|
52 |
mSignature3 = sig.mSignature3; |
|
53 |
|
|
54 |
mLayer = sig.mLayer; |
|
55 |
mAllCycles = sig.mAllCycles; |
|
56 |
mCubitTouch = sig.mCubitTouch; |
|
57 |
|
|
58 |
mNumCycles = sig.mNumCycles; |
|
59 |
mNumCubitTouches = sig.mNumCubitTouches; |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
// built-in bandaged 3x3s; objects created from JSON (version1) |
|
64 |
|
|
65 |
public ObjectSignature(long signature) |
|
66 |
{ |
|
67 |
mSignature1 = 0; |
|
68 |
mSignature2 = 0; |
|
69 |
mSignature3 = signature; |
|
70 |
} |
|
71 |
|
|
72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
73 |
// objects created from JSON (version2) |
|
74 |
|
|
75 |
public ObjectSignature(long signature1, long signature2, long signature3) |
|
76 |
{ |
|
77 |
mSignature1 = signature1; |
|
78 |
mSignature2 = signature2; |
|
79 |
mSignature3 = signature3; |
|
80 |
} |
|
81 |
|
|
82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
83 |
// Locally created bandaged cuboids 1<=N,M,K<=5 |
|
84 |
// This is the 'Andreas signature' of a bandaged cube. |
|
85 |
// https://twistypuzzles.com/forum/viewtopic.php?p=415466#p415466 |
|
86 |
|
|
87 |
public ObjectSignature(int lenx, int leny, int lenz, float[][] position) |
|
88 |
{ |
|
89 |
mLayer = new int[] {lenx,leny,lenz}; |
|
90 |
|
|
91 |
prepareCubitTouch(); |
|
92 |
prepareAllCycles(); |
|
93 |
|
|
94 |
for(float[] pos : position) |
|
95 |
{ |
|
96 |
int numCenters = pos.length/3; |
|
97 |
|
|
98 |
for(int i=0; i<numCenters; i++) |
|
99 |
for(int j=i+1; j<numCenters; j++) |
|
100 |
{ |
|
101 |
float x1 = pos[3*i ]; |
|
102 |
float y1 = pos[3*i+1]; |
|
103 |
float z1 = pos[3*i+2]; |
|
104 |
float x2 = pos[3*i ]; |
|
105 |
float y2 = pos[3*i+1]; |
|
106 |
float z2 = pos[3*i+2]; |
|
107 |
|
|
108 |
if(areNeighbours(x1-x2,y1-y2,z1-z2)) |
|
109 |
{ |
|
110 |
float xc = (x1+y1)/2; |
|
111 |
float yc = (y1+y2)/2; |
|
112 |
float zc = (z1+z2)/2; |
|
113 |
|
|
114 |
int bitIndex = getIndexOfCubitTouch(xc,yc,zc); |
|
115 |
setBit(bitIndex,1); |
|
116 |
} |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 |
|
|
123 |
public void setSignature(ObjectSignature sig) |
|
124 |
{ |
|
125 |
mSignature1 = sig.mSignature1; |
|
126 |
mSignature2 = sig.mSignature2; |
|
127 |
mSignature3 = sig.mSignature3; |
|
128 |
} |
|
129 |
|
|
130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
131 |
|
|
132 |
public void setSignature(int sig) |
|
133 |
{ |
|
134 |
mSignature1 = 0; |
|
135 |
mSignature2 = 0; |
|
136 |
mSignature3 = sig; |
|
137 |
} |
|
138 |
|
|
139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
140 |
|
|
141 |
public boolean isEqual(ObjectSignature sig) |
|
142 |
{ |
|
143 |
return mSignature1==sig.mSignature1 && mSignature2==sig.mSignature2 && mSignature3==sig.mSignature3; |
|
144 |
} |
|
145 |
|
|
146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
147 |
|
|
148 |
public long getLong1() |
|
149 |
{ |
|
150 |
return mSignature1; |
|
151 |
} |
|
152 |
|
|
153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
154 |
|
|
155 |
public long getLong2() |
|
156 |
{ |
|
157 |
return mSignature2; |
|
158 |
} |
|
159 |
|
|
160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
161 |
|
|
162 |
public long getLong3() |
|
163 |
{ |
|
164 |
return mSignature3; |
|
165 |
} |
|
166 |
|
|
167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
168 |
|
|
169 |
public String getString() |
|
170 |
{ |
|
171 |
return mSignature1+"_"+mSignature2+"_"+mSignature3; |
|
172 |
} |
|
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
|
|
176 |
public boolean isUnblockedFromLeft(int axis, int layer) |
|
177 |
{ |
|
178 |
if(layer>0) |
|
179 |
for(int index=0; index<mNumCubitTouches; index++) |
|
180 |
if( getBit(index)!=0 ) |
|
181 |
{ |
|
182 |
float[] touch = getCubitTouchOfIndex(index); |
|
183 |
if( belongsToTheLeft(touch,axis,layer) ) return false; |
|
184 |
} |
|
185 |
|
|
186 |
return true; |
|
187 |
} |
|
188 |
|
|
189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
190 |
|
|
191 |
public ObjectSignature turn(int axis, int layer, int turn) |
|
192 |
{ |
|
193 |
ObjectSignature ret = new ObjectSignature(this); |
|
194 |
|
|
195 |
for(int i=0; i<mNumCycles; i++) |
|
196 |
{ |
|
197 |
float[][] cyc = mAllCycles[i]; |
|
198 |
float[] p0 = cyc[0]; |
|
199 |
float[] p1 = cyc[1]; |
|
200 |
|
|
201 |
if( (belongsToTheLeft(p0,axis,layer) && belongsToTheLeft(p1,axis,layer)) || |
|
202 |
(belongsToTheCent(p0,axis,layer) && belongsToTheCent(p1,axis,layer)) ) |
|
203 |
{ |
|
204 |
ret.cycle(turn,cyc); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
return ret; |
|
209 |
} |
|
210 |
|
|
211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
212 |
|
|
213 |
private void cycle(int turn, float[][] cyc) |
|
214 |
{ |
|
215 |
int numPoints = cyc.length; |
|
216 |
|
|
217 |
if( numPoints==2 ) |
|
218 |
{ |
|
219 |
float[] p0 = cyc[0]; |
|
220 |
float[] p1 = cyc[1]; |
|
221 |
|
|
222 |
int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]); |
|
223 |
int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]); |
|
224 |
|
|
225 |
long b0 = getBit(index0); |
|
226 |
long b1 = getBit(index1); |
|
227 |
|
|
228 |
setBit(index1,b0); |
|
229 |
setBit(index0,b1); |
|
230 |
} |
|
231 |
else if( numPoints==4 ) |
|
232 |
{ |
|
233 |
float[] p0 = cyc[0]; |
|
234 |
float[] p1 = cyc[1]; |
|
235 |
float[] p2 = cyc[2]; |
|
236 |
float[] p3 = cyc[3]; |
|
237 |
|
|
238 |
int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]); |
|
239 |
int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]); |
|
240 |
int index2 = getIndexOfCubitTouch(p2[0],p2[1],p2[2]); |
|
241 |
int index3 = getIndexOfCubitTouch(p3[0],p3[1],p3[2]); |
|
242 |
|
|
243 |
long b0 = getBit(index0); |
|
244 |
long b1 = getBit(index1); |
|
245 |
long b2 = getBit(index2); |
|
246 |
long b3 = getBit(index3); |
|
247 |
|
|
248 |
switch(turn) |
|
249 |
{ |
|
250 |
case 1: setBit(index0,b3); |
|
251 |
setBit(index1,b0); |
|
252 |
setBit(index2,b1); |
|
253 |
setBit(index3,b2); |
|
254 |
break; |
|
255 |
case 2: setBit(index0,b2); |
|
256 |
setBit(index1,b3); |
|
257 |
setBit(index2,b0); |
|
258 |
setBit(index3,b1); |
|
259 |
break; |
|
260 |
case 3: setBit(index0,b1); |
|
261 |
setBit(index1,b2); |
|
262 |
setBit(index2,b3); |
|
263 |
setBit(index3,b0); |
|
264 |
break; |
|
265 |
} |
|
266 |
} |
|
267 |
else |
|
268 |
{ |
|
269 |
android.util.Log.e("D", "error in cycle, numPoints="+numPoints); |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
274 |
|
|
275 |
private void prepareCubitTouch() |
|
276 |
{ |
|
277 |
int numCenters = mLayer[0]*mLayer[1]*mLayer[2]; |
|
278 |
if( mLayer[0]>1 && mLayer[1]>1 && mLayer[2]>1 ) numCenters -= (mLayer[0]-2)*(mLayer[1]-2)*(mLayer[2]-2); |
|
279 |
|
|
280 |
float[][] centers = new float[numCenters][]; |
|
281 |
int index = 0; |
|
282 |
|
|
283 |
for(int i = 0; i<mLayer[0]; i++) |
|
284 |
for(int j = 0; j<mLayer[1]; j++) |
|
285 |
for(int k = 0; k<mLayer[2]; k++) |
|
286 |
if( (i==0) || (i==mLayer[0]-1) || (j==0) || (j==mLayer[1]-1) || (k==0) || (k==mLayer[2]-1) ) |
|
287 |
{ |
|
288 |
centers[index++] = new float[] { i+0.5f*(1-mLayer[0]), j+0.5f*(1-mLayer[1]), k+0.5f*(1-mLayer[2]) }; |
|
289 |
} |
|
290 |
|
|
291 |
ArrayList<float[]> mTouch = new ArrayList<>(); |
|
292 |
|
|
293 |
for(int i=0; i<numCenters; i++) |
|
294 |
for(int j=i+1; j<numCenters; j++) |
|
295 |
{ |
|
296 |
float[] c0 = centers[i]; |
|
297 |
float[] c1 = centers[j]; |
|
298 |
|
|
299 |
float x1 = c0[0]; |
|
300 |
float y1 = c0[1]; |
|
301 |
float z1 = c0[2]; |
|
302 |
float x2 = c1[0]; |
|
303 |
float y2 = c1[1]; |
|
304 |
float z2 = c1[2]; |
|
305 |
|
|
306 |
if( areNeighbours(x1-x2,y1-y2,z1-z2) ) |
|
307 |
{ |
|
308 |
float xc = (x1+y1)/2; |
|
309 |
float yc = (y1+y2)/2; |
|
310 |
float zc = (z1+z2)/2; |
|
311 |
|
|
312 |
float[] touch = new float[] {xc,yc,zc}; |
|
313 |
mTouch.add(touch); |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
mNumCubitTouches = mTouch.size(); |
|
318 |
mCubitTouch = new float[mNumCubitTouches][]; |
|
319 |
for(int i=0; i<mNumCubitTouches; i++) mCubitTouch[i] = mTouch.remove(0); |
|
320 |
} |
|
321 |
|
|
322 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
323 |
|
|
324 |
private void prepareAllCycles() |
|
325 |
{ |
|
326 |
ArrayList<float[][]> cycles = new ArrayList<>(); |
|
327 |
|
|
328 |
boolean[] longTurn = new boolean[] { mLayer[1]==mLayer[2], mLayer[0]==mLayer[2], mLayer[0]==mLayer[1] }; |
|
329 |
|
|
330 |
for(int i=0; i<mNumCubitTouches; i++) |
|
331 |
for(int axis=0; axis<3; axis++) |
|
332 |
{ |
|
333 |
if( longTurn[axis] ) |
|
334 |
{ |
|
335 |
int i0 = rotateIndex(axis,i); |
|
336 |
if( i0<i ) continue; |
|
337 |
int i1 = rotateIndex(axis,i0); |
|
338 |
if( i1<i ) continue; |
|
339 |
int i2 = rotateIndex(axis,i1); |
|
340 |
if( i2<i ) continue; |
|
341 |
|
|
342 |
float[] f0 = getCubitTouchOfIndex(i); |
|
343 |
float[] f1 = getCubitTouchOfIndex(i0); |
|
344 |
float[] f2 = getCubitTouchOfIndex(i1); |
|
345 |
float[] f3 = getCubitTouchOfIndex(i2); |
|
346 |
|
|
347 |
float[][] cycle = new float[][] { f0,f1,f2,f3 }; |
|
348 |
cycles.add(cycle); |
|
349 |
} |
|
350 |
else |
|
351 |
{ |
|
352 |
int i0 = rotateIndex2(axis,i); |
|
353 |
if( i0<i ) continue; |
|
354 |
|
|
355 |
float[] f0 = getCubitTouchOfIndex(i); |
|
356 |
float[] f1 = getCubitTouchOfIndex(i0); |
|
357 |
|
|
358 |
float[][] cycle = new float[][] { f0,f1 }; |
|
359 |
cycles.add(cycle); |
|
360 |
} |
|
361 |
} |
|
362 |
|
|
363 |
mNumCycles = cycles.size(); |
|
364 |
mAllCycles = new float[mNumCycles][][]; |
|
365 |
for(int i=0; i<mNumCycles; i++) mAllCycles[i] = cycles.remove(0); |
|
366 |
} |
|
367 |
|
|
368 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
369 |
|
|
370 |
private int rotateIndex(int axis, int index) |
|
371 |
{ |
|
372 |
float[] touch = getCubitTouchOfIndex(index); |
|
373 |
|
|
374 |
switch(axis) |
|
375 |
{ |
|
376 |
case 0: return getIndexOfCubitTouch(+touch[0],+touch[2],-touch[1]); |
|
377 |
case 1: return getIndexOfCubitTouch(-touch[2],+touch[1],+touch[0]); |
|
378 |
case 2: return getIndexOfCubitTouch(+touch[1],-touch[0],+touch[2]); |
|
379 |
} |
|
380 |
|
|
381 |
return -1; |
|
382 |
} |
|
383 |
|
|
384 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
385 |
|
|
386 |
private int rotateIndex2(int axis, int index) |
|
387 |
{ |
|
388 |
float[] touch = getCubitTouchOfIndex(index); |
|
389 |
|
|
390 |
switch(axis) |
|
391 |
{ |
|
392 |
case 0: return getIndexOfCubitTouch(+touch[0],-touch[1],-touch[2]); |
|
393 |
case 1: return getIndexOfCubitTouch(-touch[0],+touch[1],-touch[2]); |
|
394 |
case 2: return getIndexOfCubitTouch(-touch[0],-touch[1],+touch[2]); |
|
395 |
} |
|
396 |
|
|
397 |
return -1; |
|
398 |
} |
|
399 |
|
|
400 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
401 |
|
|
402 |
private boolean belongsToTheLeft(float[] point, int axis, int layer) |
|
403 |
{ |
|
404 |
return 2*point[axis]+mLayer[axis] == 2*layer; |
|
405 |
} |
|
406 |
|
|
407 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
408 |
|
|
409 |
private boolean belongsToTheCent(float[] point, int axis, int layer) |
|
410 |
{ |
|
411 |
return 2*point[axis]+mLayer[axis] == 2*layer+1; |
|
412 |
} |
|
413 |
|
|
414 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
415 |
|
|
416 |
private int getIndexOfCubitTouch(float x, float y, float z) |
|
417 |
{ |
|
418 |
for(int i=0; i<mNumCubitTouches; i++) |
|
419 |
{ |
|
420 |
float[] touch = mCubitTouch[i]; |
|
421 |
if( touch[0]==x && touch[1]==y && touch[2]==z ) return i; |
|
422 |
} |
|
423 |
|
|
424 |
return -1; |
|
425 |
} |
|
426 |
|
|
427 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
428 |
|
|
429 |
private float[] getCubitTouchOfIndex(int index) |
|
430 |
{ |
|
431 |
return mCubitTouch[index]; |
|
432 |
} |
|
433 |
|
|
434 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
435 |
|
|
436 |
private boolean areNeighbours(float dx, float dy, float dz) |
|
437 |
{ |
|
438 |
return dx*dx+dy*dy+dz*dz<1.1f; |
|
439 |
} |
|
440 |
|
|
441 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
442 |
|
|
443 |
private long getBit(int index) |
|
444 |
{ |
|
445 |
switch(index/64) |
|
446 |
{ |
|
447 |
case 0: return (mSignature3>>(index%64))&0x1; |
|
448 |
case 1: return (mSignature2>>(index%64))&0x1; |
|
449 |
case 2: return (mSignature1>>(index%64))&0x1; |
|
450 |
default: android.util.Log.e("D", "error in getBit, index="+index); |
|
451 |
} |
|
452 |
|
|
453 |
return 0L; |
|
454 |
} |
|
455 |
|
|
456 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
457 |
|
|
458 |
private void setBit(int index, long bit) |
|
459 |
{ |
|
460 |
long diff = (1L<<(index%64)); |
|
461 |
|
|
462 |
switch(index/64) |
|
463 |
{ |
|
464 |
case 0: if( bit!=0 ) mSignature3 |= diff; |
|
465 |
else mSignature3 &=~diff; |
|
466 |
break; |
|
467 |
case 1: if( bit!=0 ) mSignature2 |= diff; |
|
468 |
else mSignature2 &=~diff; |
|
469 |
break; |
|
470 |
case 2: if( bit!=0 ) mSignature1 |= diff; |
|
471 |
else mSignature1 &=~diff; |
|
472 |
break; |
|
473 |
default: android.util.Log.e("D", "error in setBit, index="+index); |
|
474 |
} |
|
475 |
} |
|
476 |
} |
src/main/java/org/distorted/objectlib/json/JsonReader.java | ||
---|---|---|
31 | 31 |
import android.content.Context; |
32 | 32 |
|
33 | 33 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
34 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
34 | 35 |
import org.json.JSONArray; |
35 | 36 |
import org.json.JSONException; |
36 | 37 |
import org.json.JSONObject; |
... | ... | |
78 | 79 |
private boolean mResetMaps; |
79 | 80 |
private String mTutorialObject; |
80 | 81 |
private String[][] mTutorials; |
81 |
private long mSignature;
|
|
82 |
private ObjectSignature mSignature;
|
|
82 | 83 |
|
83 | 84 |
private static JsonReader mThis; |
84 | 85 |
|
... | ... | |
98 | 99 |
|
99 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 101 |
|
101 |
private void parseMetadata(JSONObject object) throws JSONException |
|
102 |
private void parseMetadata1(JSONObject object) throws JSONException
|
|
102 | 103 |
{ |
103 | 104 |
mLongName = object.getString("longname"); |
104 | 105 |
mShortName = object.getString("shortname"); |
... | ... | |
112 | 113 |
|
113 | 114 |
try |
114 | 115 |
{ |
115 |
mSignature = object.getLong("signature"); |
|
116 |
long signature = object.getLong("signature"); |
|
117 |
mSignature = new ObjectSignature(signature); |
|
116 | 118 |
} |
117 | 119 |
catch(JSONException ex) |
118 | 120 |
{ |
119 | 121 |
// objects older than Feb 2022 do not have the 'signature' field. They all use the ObjectType.ordinal |
120 | 122 |
// as their signature. |
121 |
mSignature = ObjectType.getOrdinal(mShortName); |
|
123 |
long signature = ObjectType.getOrdinal(mShortName); |
|
124 |
mSignature = new ObjectSignature(signature); |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
129 |
|
|
130 |
private void parseMetadata2(JSONObject object) throws JSONException |
|
131 |
{ |
|
132 |
mLongName = object.getString("longname"); |
|
133 |
mShortName = object.getString("shortname"); |
|
134 |
mInventor = object.getString("inventor"); |
|
135 |
mYearOfInvention = object.getInt("year"); |
|
136 |
mComplexity = object.getInt("complexity"); |
|
137 |
mSize = (float)object.getDouble("size"); |
|
138 |
mNumScrambles = object.getInt("scrambles"); |
|
139 |
mResetMaps = object.getBoolean("resetmaps"); |
|
140 |
mNumFaces = object.getInt("num_faces"); |
|
141 |
|
|
142 |
try |
|
143 |
{ |
|
144 |
long signature1 = object.getLong("signature1"); |
|
145 |
long signature2 = object.getLong("signature2"); |
|
146 |
long signature3 = object.getLong("signature3"); |
|
147 |
mSignature = new ObjectSignature(signature1,signature2,signature3); |
|
148 |
} |
|
149 |
catch(JSONException ex) |
|
150 |
{ |
|
151 |
long signature = object.getLong("signature"); |
|
152 |
mSignature = new ObjectSignature(signature); |
|
122 | 153 |
} |
123 | 154 |
} |
124 | 155 |
|
... | ... | |
554 | 585 |
private void parseVersion1(JSONObject object) throws JSONException |
555 | 586 |
{ |
556 | 587 |
JSONObject metadata = object.getJSONObject("metadata"); |
557 |
parseMetadata(metadata); |
|
588 |
parseMetadata1(metadata);
|
|
558 | 589 |
JSONObject mesh = object.getJSONObject("mesh"); |
559 | 590 |
parseMesh(mesh); |
560 | 591 |
JSONArray axis = object.getJSONArray("axis"); |
... | ... | |
576 | 607 |
private void parseVersion2(JSONObject object) throws JSONException |
577 | 608 |
{ |
578 | 609 |
JSONObject metadata = object.getJSONObject("metadata"); |
579 |
parseMetadata(metadata); |
|
610 |
parseMetadata2(metadata);
|
|
580 | 611 |
JSONObject mesh = object.getJSONObject("mesh"); |
581 | 612 |
parseMesh(mesh); |
582 | 613 |
JSONArray axis = object.getJSONArray("axis"); |
... | ... | |
615 | 646 |
|
616 | 647 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
617 | 648 |
|
618 |
private void parseVersion1or2Metadata(JSONObject object) throws JSONException |
|
649 |
private void parseVersion1Metadata(JSONObject object) throws JSONException |
|
650 |
{ |
|
651 |
JSONObject metadata = object.getJSONObject("metadata"); |
|
652 |
parseMetadata1(metadata); |
|
653 |
} |
|
654 |
|
|
655 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
656 |
|
|
657 |
private void parseVersion2Metadata(JSONObject object) throws JSONException |
|
619 | 658 |
{ |
620 | 659 |
JSONObject metadata = object.getJSONObject("metadata"); |
621 |
parseMetadata(metadata); |
|
660 |
parseMetadata2(metadata);
|
|
622 | 661 |
} |
623 | 662 |
|
624 | 663 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
678 | 717 |
JSONObject object = new JSONObject(contents.toString()); |
679 | 718 |
int major = object.getInt("major"); |
680 | 719 |
|
681 |
if( major==1 || major==2 ) |
|
720 |
if( major==1 ) |
|
721 |
{ |
|
722 |
parseVersion1Metadata(object); |
|
723 |
} |
|
724 |
else if( major==2 ) |
|
682 | 725 |
{ |
683 |
parseVersion1or2Metadata(object);
|
|
726 |
parseVersion2Metadata(object); |
|
684 | 727 |
} |
685 | 728 |
else |
686 | 729 |
{ |
... | ... | |
951 | 994 |
|
952 | 995 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
953 | 996 |
|
954 |
public long getSignature()
|
|
997 |
public ObjectSignature getSignature()
|
|
955 | 998 |
{ |
956 | 999 |
return mSignature; |
957 | 1000 |
} |
src/main/java/org/distorted/objectlib/json/JsonWriter.java | ||
---|---|---|
26 | 26 |
import java.nio.charset.StandardCharsets; |
27 | 27 |
|
28 | 28 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
29 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
29 | 30 |
import org.json.JSONArray; |
30 | 31 |
import org.json.JSONException; |
31 | 32 |
import org.json.JSONObject; |
... | ... | |
362 | 363 |
metadata.put("shortname" , object.getShortName() ); |
363 | 364 |
metadata.put("resetmaps" , object.shouldResetTextureMaps() ); |
364 | 365 |
metadata.put("num_faces" , object.getNumFaces() ); |
365 |
metadata.put("signature" , object.getSignature() ); |
|
366 |
|
|
367 |
ObjectSignature signature = object.getSignature(); |
|
368 |
|
|
369 |
metadata.put("signature1" , signature.getLong1() ); |
|
370 |
metadata.put("signature2" , signature.getLong2() ); |
|
371 |
metadata.put("signature3" , signature.getLong3() ); |
|
366 | 372 |
|
367 | 373 |
return metadata; |
368 | 374 |
} |
src/main/java/org/distorted/objectlib/main/TwistyJson.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
27 | 27 |
import org.distorted.objectlib.helpers.ObjectShape; |
28 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
28 | 29 |
import org.distorted.objectlib.helpers.ObjectSticker; |
29 | 30 |
import org.distorted.objectlib.scrambling.ScrambleState; |
30 | 31 |
import org.distorted.objectlib.json.JsonReader; |
... | ... | |
284 | 285 |
|
285 | 286 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
286 | 287 |
|
287 |
public long getSignature()
|
|
288 |
public ObjectSignature getSignature()
|
|
288 | 289 |
{ |
289 | 290 |
return mReader.getSignature(); |
290 | 291 |
} |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
54 | 54 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
55 | 55 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
56 | 56 |
import org.distorted.objectlib.helpers.ObjectShape; |
57 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
57 | 58 |
import org.distorted.objectlib.helpers.ObjectSticker; |
58 | 59 |
import org.distorted.objectlib.helpers.QuatGroupGenerator; |
59 | 60 |
import org.distorted.objectlib.scrambling.ScrambleState; |
... | ... | |
1749 | 1750 |
public abstract float getScreenRatio(); |
1750 | 1751 |
public abstract int getColor(int face); |
1751 | 1752 |
public abstract String getShortName(); |
1752 |
public abstract long getSignature();
|
|
1753 |
public abstract ObjectSignature getSignature();
|
|
1753 | 1754 |
|
1754 | 1755 |
// not only for JSON |
1755 | 1756 |
public abstract Static3D[] getRotationAxis(); |
src/main/java/org/distorted/objectlib/objects/TwistyAxis.java | ||
---|---|---|
23 | 23 |
import org.distorted.library.type.Static4D; |
24 | 24 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
25 | 25 |
import org.distorted.objectlib.helpers.ObjectShape; |
26 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
26 | 27 |
import org.distorted.objectlib.scrambling.ScrambleState; |
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
import org.distorted.objectlib.main.ShapeHexahedron; |
... | ... | |
490 | 491 |
|
491 | 492 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
492 | 493 |
|
493 |
public long getSignature()
|
|
494 |
public ObjectSignature getSignature()
|
|
494 | 495 |
{ |
495 |
return ObjectType.AXIS_3.ordinal();
|
|
496 |
return new ObjectSignature(ObjectType.AXIS_3);
|
|
496 | 497 |
} |
497 | 498 |
|
498 | 499 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyBandaged2Bar.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
|
29 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
79 | 80 |
return ObjectType.BAN2_3.name(); |
80 | 81 |
} |
81 | 82 |
|
83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
84 |
|
|
85 |
public ObjectSignature getSignature() |
|
86 |
{ |
|
87 |
return new ObjectSignature(ObjectType.BAN2_3); |
|
88 |
} |
|
89 |
|
|
82 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
83 | 91 |
|
84 | 92 |
public String getObjectName() |
src/main/java/org/distorted/objectlib/objects/TwistyBandaged3Plate.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
|
29 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
73 | 74 |
return ObjectType.BAN3_3.name(); |
74 | 75 |
} |
75 | 76 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
public ObjectSignature getSignature() |
|
80 |
{ |
|
81 |
return new ObjectSignature(ObjectType.BAN3_3); |
|
82 |
} |
|
83 |
|
|
76 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 85 |
|
78 | 86 |
public String getObjectName() |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedAbstract.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import org.distorted.objectlib.helpers.FactoryBandagedCubit; |
32 | 32 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
33 |
import org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid; |
|
33 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
34 |
import org.distorted.objectlib.scrambling.ScrambleStateBandaged3x3; |
|
34 | 35 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
35 | 36 |
import org.distorted.objectlib.helpers.ObjectShape; |
36 | 37 |
import org.distorted.objectlib.scrambling.ScrambleState; |
... | ... | |
191 | 192 |
return mSolvedQuatsAbstract; |
192 | 193 |
} |
193 | 194 |
|
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
196 |
|
|
197 |
public ObjectSignature getSignature() |
|
198 |
{ |
|
199 |
long signature = 0; |
|
200 |
float[][] positions = getPositions(); |
|
201 |
for(float[] pos : positions ) signature = markConnections(signature,pos); |
|
202 |
|
|
203 |
return new ObjectSignature(signature); |
|
204 |
} |
|
205 |
|
|
194 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
195 | 207 |
|
196 | 208 |
public ScrambleState[] getScrambleStates() |
197 | 209 |
{ |
198 | 210 |
if( mStates==null && !isInIconMode() ) |
199 | 211 |
{ |
200 |
long signature = getSignature();
|
|
201 |
mStates = ScrambleStateBandagedCuboid.computeGraph(signature);
|
|
212 |
ObjectSignature signature = getSignature();
|
|
213 |
mStates = ScrambleStateBandaged3x3.computeGraph(signature.getLong3());
|
|
202 | 214 |
} |
203 | 215 |
|
204 | 216 |
return mStates; |
... | ... | |
382 | 394 |
return signature; |
383 | 395 |
} |
384 | 396 |
|
385 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
386 |
|
|
387 |
public long getSignature() |
|
388 |
{ |
|
389 |
long signature = 0; |
|
390 |
float[][] positions = getPositions(); |
|
391 |
for(float[] pos : positions ) signature = markConnections(signature,pos); |
|
392 |
return signature; |
|
393 |
} |
|
394 |
|
|
395 | 397 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
396 | 398 |
|
397 | 399 |
public ObjectShape getObjectShape(int variant) |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedBiCube.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
|
29 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
69 | 70 |
return ObjectType.BAN4_3.name(); |
70 | 71 |
} |
71 | 72 |
|
73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
74 |
|
|
75 |
public ObjectSignature getSignature() |
|
76 |
{ |
|
77 |
return new ObjectSignature(ObjectType.BAN4_3); |
|
78 |
} |
|
79 |
|
|
72 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
73 | 81 |
|
74 | 82 |
public String getObjectName() |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedFused.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
|
29 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
83 | 84 |
return ObjectType.BAN1_3.name(); |
84 | 85 |
} |
85 | 86 |
|
87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
88 |
|
|
89 |
public ObjectSignature getSignature() |
|
90 |
{ |
|
91 |
return new ObjectSignature(ObjectType.BAN1_3); |
|
92 |
} |
|
93 |
|
|
86 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 95 |
|
88 | 96 |
public String getObjectName() |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedGeneric.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import org.distorted.library.type.Static3D; |
23 | 23 |
import org.distorted.library.type.Static4D; |
24 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
24 | 25 |
import org.distorted.objectlib.scrambling.ScrambleState; |
25 | 26 |
|
26 | 27 |
import java.io.InputStream; |
... | ... | |
30 | 31 |
public class TwistyBandagedGeneric extends TwistyBandagedAbstract |
31 | 32 |
{ |
32 | 33 |
private static float[][] POS; |
33 |
private static long mSignature;
|
|
34 |
private static ObjectSignature mSignature;
|
|
34 | 35 |
|
35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 37 |
|
... | ... | |
62 | 63 |
public static void setPositions(float[][] positions) |
63 | 64 |
{ |
64 | 65 |
POS = positions; |
65 |
mSignature = -1;
|
|
66 |
mSignature = null;
|
|
66 | 67 |
} |
67 | 68 |
|
68 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
110 | 111 |
|
111 | 112 |
public String getShortName() |
112 | 113 |
{ |
113 |
if( mSignature<0 ) mSignature = getSignature(); |
|
114 |
return ""+mSignature; |
|
114 |
if( mSignature==null ) mSignature = getSignature(); |
|
115 |
int[] numLayers = getNumLayers(); |
|
116 |
int number = 100*numLayers[0]+10*numLayers[1]+numLayers[0]; |
|
117 |
|
|
118 |
return number+"_"+mSignature.getString(); |
|
115 | 119 |
} |
116 | 120 |
|
117 | 121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
118 | 122 |
|
119 |
public long getSignature()
|
|
123 |
public ObjectSignature getSignature()
|
|
120 | 124 |
{ |
121 |
if( mSignature<0 )
|
|
125 |
if( mSignature==null )
|
|
122 | 126 |
{ |
123 |
mSignature = 0;
|
|
124 |
for(float[] pos : POS ) mSignature = markConnections(mSignature,pos);
|
|
127 |
int[] numLayers = getNumLayers();
|
|
128 |
mSignature = new ObjectSignature(numLayers[0],numLayers[1],numLayers[2],POS);
|
|
125 | 129 |
} |
126 |
|
|
127 | 130 |
return mSignature; |
128 | 131 |
} |
129 | 132 |
|
src/main/java/org/distorted/objectlib/objects/TwistyContainer.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
27 | 27 |
import org.distorted.objectlib.helpers.ObjectShape; |
28 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
28 | 29 |
import org.distorted.objectlib.scrambling.ScrambleState; |
29 | 30 |
import org.distorted.objectlib.main.ObjectType; |
30 | 31 |
import org.distorted.objectlib.main.ShapeHexahedron; |
... | ... | |
344 | 345 |
|
345 | 346 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
346 | 347 |
|
347 |
public long getSignature()
|
|
348 |
public ObjectSignature getSignature()
|
|
348 | 349 |
{ |
349 |
return ObjectType.CONT_2.ordinal();
|
|
350 |
return new ObjectSignature(ObjectType.CONT_2);
|
|
350 | 351 |
} |
351 | 352 |
|
352 | 353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyCrystal.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
27 | 27 |
import org.distorted.objectlib.helpers.ObjectShape; |
28 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
28 | 29 |
import org.distorted.objectlib.main.ObjectType; |
29 | 30 |
|
30 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
245 | 246 |
|
246 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
247 | 248 |
|
248 |
public long getSignature()
|
|
249 |
public ObjectSignature getSignature()
|
|
249 | 250 |
{ |
250 |
return ObjectType.CRYS_3.ordinal();
|
|
251 |
return new ObjectSignature(ObjectType.CRYS_3);
|
|
251 | 252 |
} |
252 | 253 |
|
253 | 254 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlCuboids; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
679 | 680 |
|
680 | 681 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
681 | 682 |
|
682 |
public long getSignature()
|
|
683 |
public ObjectSignature getSignature()
|
|
683 | 684 |
{ |
684 | 685 |
int[] numLayers = getNumLayers(); |
685 | 686 |
|
... | ... | |
690 | 691 |
{ |
691 | 692 |
case 2: switch(y) |
692 | 693 |
{ |
693 |
case 2: return ObjectType.CUBE_2.ordinal();
|
|
694 |
case 3: return ObjectType.CU_232.ordinal();
|
|
694 |
case 2: return new ObjectSignature(ObjectType.CUBE_2);
|
|
695 |
case 3: return new ObjectSignature(ObjectType.CU_232);
|
|
695 | 696 |
} |
696 | 697 |
case 3: switch(y) |
697 | 698 |
{ |
698 |
case 2: return ObjectType.CU_323.ordinal();
|
|
699 |
case 3: return ObjectType.CUBE_3.ordinal();
|
|
700 |
case 4: return ObjectType.CU_343.ordinal();
|
|
699 |
case 2: return new ObjectSignature(ObjectType.CU_323);
|
|
700 |
case 3: return new ObjectSignature(ObjectType.CUBE_3);
|
|
701 |
case 4: return new ObjectSignature(ObjectType.CU_343);
|
|
701 | 702 |
} |
702 |
case 4: return ObjectType.CUBE_4.ordinal();
|
|
703 |
case 5: return ObjectType.CUBE_5.ordinal();
|
|
704 |
case 6: return ObjectType.CUBE_6.ordinal();
|
|
705 |
case 7: return ObjectType.CUBE_7.ordinal();
|
|
703 |
case 4: return new ObjectSignature(ObjectType.CUBE_4);
|
|
704 |
case 5: return new ObjectSignature(ObjectType.CUBE_5);
|
|
705 |
case 6: return new ObjectSignature(ObjectType.CUBE_6);
|
|
706 |
case 7: return new ObjectSignature(ObjectType.CUBE_7);
|
|
706 | 707 |
} |
707 | 708 |
|
708 |
return ObjectType.CUBE_3.ordinal();
|
|
709 |
return null;
|
|
709 | 710 |
} |
710 | 711 |
|
711 | 712 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyDiamond.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
504 | 505 |
|
505 | 506 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
506 | 507 |
|
507 |
public long getSignature()
|
|
508 |
public ObjectSignature getSignature()
|
|
508 | 509 |
{ |
509 | 510 |
switch(getNumLayers()[0]) |
510 | 511 |
{ |
511 |
case 2: return ObjectType.DIAM_2.ordinal();
|
|
512 |
case 3: return ObjectType.DIAM_3.ordinal();
|
|
513 |
case 4: return ObjectType.DIAM_4.ordinal();
|
|
512 |
case 2: return new ObjectSignature(ObjectType.DIAM_2);
|
|
513 |
case 3: return new ObjectSignature(ObjectType.DIAM_3);
|
|
514 |
case 4: return new ObjectSignature(ObjectType.DIAM_4);
|
|
514 | 515 |
} |
515 | 516 |
|
516 |
return ObjectType.DIAM_2.ordinal();
|
|
517 |
return null;
|
|
517 | 518 |
} |
518 | 519 |
|
519 | 520 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyDino4.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
import org.distorted.objectlib.scrambling.ScrambleState; |
29 | 30 |
|
... | ... | |
105 | 106 |
|
106 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 108 |
|
108 |
public long getSignature()
|
|
109 |
public ObjectSignature getSignature()
|
|
109 | 110 |
{ |
110 |
return ObjectType.DIN4_3.ordinal();
|
|
111 |
return new ObjectSignature(ObjectType.DIN4_3);
|
|
111 | 112 |
} |
112 | 113 |
|
113 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyDino6.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Static3D; |
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
import org.distorted.objectlib.scrambling.ScrambleState; |
29 | 30 |
|
... | ... | |
81 | 82 |
|
82 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
83 | 84 |
|
84 |
public long getSignature()
|
|
85 |
public ObjectSignature getSignature()
|
|
85 | 86 |
{ |
86 |
return ObjectType.DINO_3.ordinal();
|
|
87 |
return new ObjectSignature(ObjectType.DINO_3);
|
|
87 | 88 |
} |
88 | 89 |
|
89 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyFisher.java | ||
---|---|---|
23 | 23 |
import org.distorted.library.type.Static4D; |
24 | 24 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
25 | 25 |
import org.distorted.objectlib.helpers.ObjectShape; |
26 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
26 | 27 |
import org.distorted.objectlib.scrambling.ScrambleState; |
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
import org.distorted.objectlib.main.ShapeHexahedron; |
... | ... | |
412 | 413 |
|
413 | 414 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
414 | 415 |
|
415 |
public long getSignature()
|
|
416 |
public ObjectSignature getSignature()
|
|
416 | 417 |
{ |
417 |
return ObjectType.FISH_3.ordinal();
|
|
418 |
return new ObjectSignature(ObjectType.FISH_3);
|
|
418 | 419 |
} |
419 | 420 |
|
420 | 421 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
332 | 333 |
|
333 | 334 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
334 | 335 |
|
335 |
public long getSignature()
|
|
336 |
public ObjectSignature getSignature()
|
|
336 | 337 |
{ |
337 |
return ObjectType.HELI_3.ordinal();
|
|
338 |
return new ObjectSignature(ObjectType.HELI_3);
|
|
338 | 339 |
} |
339 | 340 |
|
340 | 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyIvy.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
448 | 449 |
|
449 | 450 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
450 | 451 |
|
451 |
public long getSignature()
|
|
452 |
public ObjectSignature getSignature()
|
|
452 | 453 |
{ |
453 |
return ObjectType.IVY_2.ordinal();
|
|
454 |
return new ObjectSignature(ObjectType.IVY_2);
|
|
454 | 455 |
} |
455 | 456 |
|
456 | 457 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyJing.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
374 | 375 |
|
375 | 376 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
376 | 377 |
|
377 |
public long getSignature()
|
|
378 |
public ObjectSignature getSignature()
|
|
378 | 379 |
{ |
379 |
return ObjectType.JING_2.ordinal();
|
|
380 |
return new ObjectSignature(ObjectType.JING_2);
|
|
380 | 381 |
} |
381 | 382 |
|
382 | 383 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyKilominx.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.main.QuatHelper; |
30 | 30 |
|
31 | 31 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
32 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
34 | 35 |
|
... | ... | |
571 | 572 |
|
572 | 573 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
573 | 574 |
|
574 |
public long getSignature()
|
|
575 |
public ObjectSignature getSignature()
|
|
575 | 576 |
{ |
576 | 577 |
switch(getNumLayers()[0]) |
577 | 578 |
{ |
578 |
case 3: return ObjectType.KILO_3.ordinal();
|
|
579 |
case 5: return ObjectType.KILO_5.ordinal();
|
|
579 |
case 3: return new ObjectSignature(ObjectType.KILO_3);
|
|
580 |
case 5: return new ObjectSignature(ObjectType.KILO_5);
|
|
580 | 581 |
} |
581 | 582 |
|
582 |
return ObjectType.KILO_3.ordinal();
|
|
583 |
return null;
|
|
583 | 584 |
} |
584 | 585 |
|
585 | 586 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
591 | 592 |
case 3: return "Kilominx"; |
592 | 593 |
case 5: return "Master Kilominx"; |
593 | 594 |
} |
594 |
return "Kilominx";
|
|
595 |
return null;
|
|
595 | 596 |
} |
596 | 597 |
|
597 | 598 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyMegaminx.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.main.QuatHelper; |
30 | 30 |
|
31 | 31 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
32 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
34 | 35 |
|
... | ... | |
492 | 493 |
|
493 | 494 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
494 | 495 |
|
495 |
public long getSignature()
|
|
496 |
public ObjectSignature getSignature()
|
|
496 | 497 |
{ |
497 | 498 |
switch(getNumLayers()[0]) |
498 | 499 |
{ |
499 |
case 3: return ObjectType.MEGA_3.ordinal();
|
|
500 |
case 5: return ObjectType.MEGA_5.ordinal();
|
|
500 |
case 3: return new ObjectSignature(ObjectType.MEGA_3);
|
|
501 |
case 5: return new ObjectSignature(ObjectType.MEGA_5);
|
|
501 | 502 |
} |
502 | 503 |
|
503 |
return ObjectType.MEGA_3.ordinal();
|
|
504 |
return null;
|
|
504 | 505 |
} |
505 | 506 |
|
506 | 507 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyMirror.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.main.ObjectType; |
32 | 33 |
import org.distorted.objectlib.helpers.ObjectShape; |
33 | 34 |
import org.distorted.objectlib.scrambling.ScrambleState; |
... | ... | |
397 | 398 |
|
398 | 399 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
399 | 400 |
|
400 |
public long getSignature()
|
|
401 |
public ObjectSignature getSignature()
|
|
401 | 402 |
{ |
402 | 403 |
switch(getNumLayers()[0]) |
403 | 404 |
{ |
404 |
case 2: return ObjectType.MIRR_2.ordinal();
|
|
405 |
case 3: return ObjectType.MIRR_3.ordinal();
|
|
406 |
case 4: return ObjectType.MIRR_4.ordinal();
|
|
405 |
case 2: return new ObjectSignature(ObjectType.MIRR_2);
|
|
406 |
case 3: return new ObjectSignature(ObjectType.MIRR_3);
|
|
407 |
case 4: return new ObjectSignature(ObjectType.MIRR_4);
|
|
407 | 408 |
} |
408 | 409 |
|
409 |
return ObjectType.MIRR_2.ordinal();
|
|
410 |
return null;
|
|
410 | 411 |
} |
411 | 412 |
|
412 | 413 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
419 | 420 |
case 3: return "Mirror Cube"; |
420 | 421 |
case 4: return "Master Mirror Blocks"; |
421 | 422 |
} |
422 |
return "Pocket Mirror";
|
|
423 |
return null;
|
|
423 | 424 |
} |
424 | 425 |
|
425 | 426 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
432 | 433 |
case 3: return "Hidetoshi Takeji"; |
433 | 434 |
case 4: return "Traiphum Prungtaengkit"; |
434 | 435 |
} |
435 |
return "Hidetoshi Takeji";
|
|
436 |
return null;
|
|
436 | 437 |
} |
437 | 438 |
|
438 | 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java | ||
---|---|---|
23 | 23 |
import org.distorted.library.type.Static4D; |
24 | 24 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
25 | 25 |
import org.distorted.objectlib.helpers.ObjectShape; |
26 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
26 | 27 |
import org.distorted.objectlib.scrambling.ScrambleState; |
27 | 28 |
import org.distorted.objectlib.main.ObjectType; |
28 | 29 |
import org.distorted.objectlib.main.ShapeTetrahedron; |
... | ... | |
301 | 302 |
|
302 | 303 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
303 | 304 |
|
304 |
public long getSignature()
|
|
305 |
public ObjectSignature getSignature()
|
|
305 | 306 |
{ |
306 |
return ObjectType.MORP_2.ordinal();
|
|
307 |
return new ObjectSignature(ObjectType.MORP_2);
|
|
307 | 308 |
} |
308 | 309 |
|
309 | 310 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyPentultimate.java | ||
---|---|---|
23 | 23 |
import org.distorted.library.type.Static4D; |
24 | 24 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
25 | 25 |
import org.distorted.objectlib.helpers.ObjectShape; |
26 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
26 | 27 |
import org.distorted.objectlib.main.ObjectType; |
27 | 28 |
import org.distorted.objectlib.scrambling.ScrambleState; |
28 | 29 |
|
... | ... | |
363 | 364 |
|
364 | 365 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
365 | 366 |
|
366 |
public long getSignature()
|
|
367 |
public ObjectSignature getSignature()
|
|
367 | 368 |
{ |
368 |
return ObjectType.PENT_2.ordinal();
|
|
369 |
return new ObjectSignature(ObjectType.PENT_2);
|
|
369 | 370 |
} |
370 | 371 |
|
371 | 372 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyPyraminx.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
386 | 387 |
|
387 | 388 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
388 | 389 |
|
389 |
public long getSignature()
|
|
390 |
public ObjectSignature getSignature()
|
|
390 | 391 |
{ |
391 | 392 |
switch(getNumLayers()[0]) |
392 | 393 |
{ |
393 |
case 3: return ObjectType.PYRA_3.ordinal();
|
|
394 |
case 4: return ObjectType.PYRA_4.ordinal();
|
|
395 |
case 5: return ObjectType.PYRA_5.ordinal();
|
|
394 |
case 3: return new ObjectSignature(ObjectType.PYRA_3);
|
|
395 |
case 4: return new ObjectSignature(ObjectType.PYRA_4);
|
|
396 |
case 5: return new ObjectSignature(ObjectType.PYRA_5);
|
|
396 | 397 |
} |
397 | 398 |
|
398 |
return ObjectType.PYRA_3.ordinal();
|
|
399 |
return null;
|
|
399 | 400 |
} |
400 | 401 |
|
401 | 402 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
408 | 409 |
case 4: return "Master Pyraminx"; |
409 | 410 |
case 5: return "Professor's Pyraminx"; |
410 | 411 |
} |
411 |
return "Pyraminx";
|
|
412 |
return null;
|
|
412 | 413 |
} |
413 | 414 |
|
414 | 415 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
421 | 422 |
case 4: return "Katsuhiko Okamoto"; |
422 | 423 |
case 5: return "Timur Evbatyrov"; |
423 | 424 |
} |
424 |
return "Uwe Meffert";
|
|
425 |
return null;
|
|
425 | 426 |
} |
426 | 427 |
|
427 | 428 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyRedi.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
377 | 378 |
|
378 | 379 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
379 | 380 |
|
380 |
public long getSignature()
|
|
381 |
public ObjectSignature getSignature()
|
|
381 | 382 |
{ |
382 |
return ObjectType.REDI_3.ordinal();
|
|
383 |
return new ObjectSignature(ObjectType.REDI_3);
|
|
383 | 384 |
} |
384 | 385 |
|
385 | 386 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyRex.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
|
30 | 30 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
31 |
import org.distorted.objectlib.helpers.ObjectSignature; |
|
31 | 32 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
32 | 33 |
import org.distorted.objectlib.main.ObjectType; |
33 | 34 |
import org.distorted.objectlib.helpers.ObjectShape; |
... | ... | |
376 | 377 |
|
377 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
378 | 379 |
|
379 |
public long getSignature()
|
|
380 |
public ObjectSignature getSignature()
|
|
380 | 381 |
{ |
381 |
return ObjectType.REX_3.ordinal();
|
|
382 |
return new ObjectSignature(ObjectType.REX_3);
|
|
382 | 383 |
} |
383 | 384 |
|
384 | 385 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Introduce ObjectSignature that can incorporate 192-bit signatures (for 5x5x5 bandaged cubes).
ObjectScrambler does not fully work yet.