Revision a57e6870
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistyDiamond.java | ||
---|---|---|
69 | 69 |
|
70 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 71 |
|
72 |
public TwistyDiamond(int size, Static4D quat, Static3D move, DistortedTexture texture,
|
|
72 |
public TwistyDiamond(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
|
|
73 | 73 |
MeshSquare mesh, DistortedEffects effects, Resources res, int scrWidth) |
74 | 74 |
{ |
75 |
super(size, size, quat, move, texture, mesh, effects, res, scrWidth);
|
|
75 |
super(numL, numL[0], quat, move, texture, mesh, effects, res, scrWidth);
|
|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
81 | 81 |
{ |
82 | 82 |
if( mStates==null ) |
83 | 83 |
{ |
84 |
int size = getNumLayers(); |
|
85 |
int[] tmp = new int[3*2*size]; |
|
84 |
int[] numLayers = getNumLayers(); |
|
85 |
int numL = numLayers[0]; |
|
86 |
int[] tmp = new int[3*2*numL]; |
|
86 | 87 |
|
87 |
for(int i=0; i<2*size; i++)
|
|
88 |
for(int i=0; i<2*numL; i++)
|
|
88 | 89 |
{ |
89 |
tmp[3*i ] = (i<size) ? i:i-size;
|
|
90 |
tmp[3*i ] = (i<numL) ? i:i-numL;
|
|
90 | 91 |
tmp[3*i+1] = (i%2==0) ? -1:1; |
91 | 92 |
tmp[3*i+2] = 0; |
92 | 93 |
} |
... | ... | |
102 | 103 |
|
103 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
104 | 105 |
|
105 |
protected int getResource(int numLayers) |
|
106 |
protected int getResource(int[] numLayers)
|
|
106 | 107 |
{ |
107 |
switch(numLayers) |
|
108 |
switch(numLayers[0])
|
|
108 | 109 |
{ |
109 | 110 |
case 2: return R.raw.diam2; |
110 | 111 |
case 3: return R.raw.diam3; |
... | ... | |
138 | 139 |
|
139 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
140 | 141 |
|
141 |
protected int[] getSolvedQuats(int cubit, int numLayers) |
|
142 |
protected int[] getSolvedQuats(int cubit, int[] numLayers)
|
|
142 | 143 |
{ |
143 | 144 |
if( mQuats==null ) initializeQuats(); |
144 | 145 |
if( mFaceMap==null ) mFaceMap = new int[] {4,0,6,2,7,3,5,1}; |
... | ... | |
163 | 164 |
|
164 | 165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
165 | 166 |
|
166 |
protected int getNumStickerTypes(int numLayers) |
|
167 |
protected int getNumStickerTypes(int[] numLayers)
|
|
167 | 168 |
{ |
168 | 169 |
return 1; |
169 | 170 |
} |
170 | 171 |
|
171 | 172 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
172 | 173 |
|
173 |
protected float[][] getCuts(int numLayers) |
|
174 |
protected float[][] getCuts(int[] numLayers)
|
|
174 | 175 |
{ |
175 |
if( numLayers<2 ) return null; |
|
176 |
int numL = numLayers[0]; |
|
177 |
if( numL<2 ) return null; |
|
176 | 178 |
|
177 | 179 |
if( mCuts==null ) |
178 | 180 |
{ |
179 |
mCuts = new float[4][numLayers-1];
|
|
180 |
float cut = (SQ6/6)*(2-numLayers);
|
|
181 |
mCuts = new float[4][numL-1]; |
|
182 |
float cut = (SQ6/6)*(2-numL); |
|
181 | 183 |
|
182 |
for(int i=0; i<numLayers-1; i++)
|
|
184 |
for(int i=0; i<numL-1; i++) |
|
183 | 185 |
{ |
184 | 186 |
mCuts[0][i] = cut; |
185 | 187 |
mCuts[1][i] = cut; |
... | ... | |
194 | 196 |
|
195 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
196 | 198 |
|
197 |
private void getLayerRotatable(int numLayers) |
|
199 |
private void getLayerRotatable(int[] numLayers)
|
|
198 | 200 |
{ |
199 | 201 |
if( mLayerRotatable==null ) |
200 | 202 |
{ |
201 | 203 |
int numAxis = ROT_AXIS.length; |
202 |
boolean[] tmp = new boolean[numLayers]; |
|
203 |
for(int i=0; i<numLayers; i++) tmp[i] = true; |
|
204 | 204 |
mLayerRotatable = new boolean[numAxis][]; |
205 |
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp; |
|
205 |
|
|
206 |
for(int i=0; i<numAxis; i++) |
|
207 |
{ |
|
208 |
mLayerRotatable[i] = new boolean[numLayers[i]]; |
|
209 |
for(int j=0; j<numLayers[i]; j++) mLayerRotatable[i][j] = true; |
|
210 |
} |
|
206 | 211 |
} |
207 | 212 |
} |
208 | 213 |
|
... | ... | |
322 | 327 |
|
323 | 328 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
324 | 329 |
|
325 |
protected float[][] getCubitPositions(int layers)
|
|
330 |
protected float[][] getCubitPositions(int[] numLayers)
|
|
326 | 331 |
{ |
332 |
int layers = numLayers[0]; |
|
327 | 333 |
int numO = getNumOctahedrons(layers); |
328 | 334 |
int numT = getNumTetrahedrons(layers); |
329 | 335 |
int index = 0; |
... | ... | |
369 | 375 |
|
370 | 376 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
371 | 377 |
|
372 |
protected ObjectShape getObjectShape(int cubit, int numLayers) |
|
378 |
protected ObjectShape getObjectShape(int cubit, int[] numLayers)
|
|
373 | 379 |
{ |
374 | 380 |
int variant = getCubitVariant(cubit,numLayers); |
375 |
int N = numLayers>3 ? 5:6; |
|
376 |
int E = numLayers>2 ? (numLayers>3 ? 0:1):2; |
|
381 |
int numL = numLayers[0]; |
|
382 |
int N = numL>3 ? 5:6; |
|
383 |
int E = numL>2 ? (numL>3 ? 0:1):2; |
|
377 | 384 |
|
378 | 385 |
if( variant==0 ) |
379 | 386 |
{ |
... | ... | |
423 | 430 |
|
424 | 431 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
425 | 432 |
|
426 |
protected Static4D getQuat(int cubit, int numLayers) |
|
433 |
protected Static4D getQuat(int cubit, int[] numLayers)
|
|
427 | 434 |
{ |
428 | 435 |
if( mQuats==null ) initializeQuats(); |
429 |
int numO = getNumOctahedrons(numLayers); |
|
436 |
|
|
437 |
int numL = numLayers[0]; |
|
438 |
int numO = getNumOctahedrons(numL); |
|
430 | 439 |
|
431 | 440 |
if( cubit<numO ) return mQuats[0]; |
432 | 441 |
|
433 |
switch( retFaceTetraBelongsTo(cubit-numO, numLayers) )
|
|
442 |
switch( retFaceTetraBelongsTo(cubit-numO, numL) ) |
|
434 | 443 |
{ |
435 | 444 |
case 0: return mQuats[0]; // unit quat |
436 | 445 |
case 1: return new Static4D(0,-SQ2/2,0,SQ2/2); // 90 along Y |
... | ... | |
447 | 456 |
|
448 | 457 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
449 | 458 |
|
450 |
protected int getNumCubitVariants(int numLayers) |
|
459 |
protected int getNumCubitVariants(int[] numLayers)
|
|
451 | 460 |
{ |
452 | 461 |
return 2; |
453 | 462 |
} |
454 | 463 |
|
455 | 464 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
456 | 465 |
|
457 |
protected int getCubitVariant(int cubit, int numLayers) |
|
466 |
protected int getCubitVariant(int cubit, int[] numLayers)
|
|
458 | 467 |
{ |
459 |
return cubit<getNumOctahedrons(numLayers) ? 0 : 1; |
|
468 |
return cubit<getNumOctahedrons(numLayers[0]) ? 0 : 1;
|
|
460 | 469 |
} |
461 | 470 |
|
462 | 471 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
463 | 472 |
|
464 |
protected int getFaceColor(int cubit, int cubitface, int size)
|
|
473 |
protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
|
|
465 | 474 |
{ |
466 |
int numO = getNumOctahedrons(size); |
|
475 |
int numL = numLayers[0]; |
|
476 |
int numO = getNumOctahedrons(numL); |
|
467 | 477 |
|
468 | 478 |
if( cubit<numO ) |
469 | 479 |
{ |
... | ... | |
473 | 483 |
switch(cubitface) |
474 | 484 |
{ |
475 | 485 |
case 0: axis = 2; layer = 1; break; |
476 |
case 1: axis = 0; layer = (1<<(size-1)); break;
|
|
486 |
case 1: axis = 0; layer = (1<<(numL-1)); break;
|
|
477 | 487 |
case 2: axis = 3; layer = 1; break; |
478 |
case 3: axis = 1; layer = (1<<(size-1)); break;
|
|
479 |
case 4: axis = 3; layer = (1<<(size-1)); break;
|
|
488 |
case 3: axis = 1; layer = (1<<(numL-1)); break;
|
|
489 |
case 4: axis = 3; layer = (1<<(numL-1)); break;
|
|
480 | 490 |
case 5: axis = 1; layer = 1; break; |
481 |
case 6: axis = 2; layer = (1<<(size-1)); break;
|
|
491 |
case 6: axis = 2; layer = (1<<(numL-1)); break;
|
|
482 | 492 |
case 7: axis = 0; layer = 1; break; |
483 | 493 |
} |
484 | 494 |
|
... | ... | |
486 | 496 |
} |
487 | 497 |
else |
488 | 498 |
{ |
489 |
return cubitface>0 ? NUM_TEXTURES : retFaceTetraBelongsTo(cubit-numO, size);
|
|
499 |
return cubitface>0 ? NUM_TEXTURES : retFaceTetraBelongsTo(cubit-numO, numL);
|
|
490 | 500 |
} |
491 | 501 |
} |
492 | 502 |
|
... | ... | |
503 | 513 |
|
504 | 514 |
if( ObjectControl.isInIconMode() ) |
505 | 515 |
{ |
506 |
switch(getNumLayers()) |
|
516 |
int[] numLayers = getNumLayers(); |
|
517 |
|
|
518 |
switch(numLayers[0]) |
|
507 | 519 |
{ |
508 | 520 |
case 2: stroke*=1.4f; break; |
509 | 521 |
case 3: stroke*=2.0f; break; |
... | ... | |
533 | 545 |
{ |
534 | 546 |
if( mMovement==null ) |
535 | 547 |
{ |
536 |
int numLayers = getNumLayers(); |
|
548 |
int[] numLayers = getNumLayers();
|
|
537 | 549 |
if( mCuts==null ) getCuts(numLayers); |
538 | 550 |
getLayerRotatable(numLayers); |
539 |
mMovement = new Movement8(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED); |
|
551 |
mMovement = new Movement8(ROT_AXIS,mCuts,mLayerRotatable,numLayers[0],TYPE_NOT_SPLIT,ENABLED);
|
|
540 | 552 |
} |
541 | 553 |
return mMovement; |
542 | 554 |
} |
... | ... | |
551 | 563 |
|
552 | 564 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
553 | 565 |
|
554 |
public ObjectType intGetObjectType(int numLayers) |
|
566 |
public ObjectType intGetObjectType(int[] numLayers)
|
|
555 | 567 |
{ |
556 |
switch(numLayers) |
|
568 |
switch(numLayers[0])
|
|
557 | 569 |
{ |
558 | 570 |
case 2: return ObjectType.DIAM_2; |
559 | 571 |
case 3: return ObjectType.DIAM_3; |
... | ... | |
565 | 577 |
|
566 | 578 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
567 | 579 |
|
568 |
public int getObjectName(int numLayers) |
|
580 |
public int getObjectName(int[] numLayers)
|
|
569 | 581 |
{ |
570 |
switch(numLayers) |
|
582 |
switch(numLayers[0])
|
|
571 | 583 |
{ |
572 | 584 |
case 2: return R.string.diam2; |
573 | 585 |
case 3: return R.string.diam3; |
... | ... | |
579 | 591 |
|
580 | 592 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
581 | 593 |
|
582 |
public int getInventor(int numLayers) |
|
594 |
public int getInventor(int[] numLayers)
|
|
583 | 595 |
{ |
584 |
switch(numLayers) |
|
596 |
switch(numLayers[0])
|
|
585 | 597 |
{ |
586 | 598 |
case 2: return R.string.diam2_inventor; |
587 | 599 |
case 3: return R.string.diam3_inventor; |
... | ... | |
593 | 605 |
|
594 | 606 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
595 | 607 |
|
596 |
public int getComplexity(int numLayers) |
|
608 |
public int getComplexity(int[] numLayers)
|
|
597 | 609 |
{ |
598 |
switch(numLayers) |
|
610 |
switch(numLayers[0])
|
|
599 | 611 |
{ |
600 | 612 |
case 2: return 4; |
601 | 613 |
case 3: return 6; |
Also available in: Unified diff
make numLayers into an int[] (preparation for Cuboids)
Caution: because of previous changes to cubit order in cube, the Solver is broken!