Revision 169219a7
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
|---|---|---|
| 353 | 353 |
return cuts; |
| 354 | 354 |
} |
| 355 | 355 |
|
| 356 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 357 |
|
|
| 358 |
int getSolvedFunctionIndex() |
|
| 359 |
{
|
|
| 360 |
return 0; |
|
| 361 |
} |
|
| 362 |
|
|
| 356 | 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 357 | 364 |
|
| 358 | 365 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyCube.java | ||
|---|---|---|
| 263 | 263 |
return cuts; |
| 264 | 264 |
} |
| 265 | 265 |
|
| 266 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 267 |
|
|
| 268 |
int getSolvedFunctionIndex() |
|
| 269 |
{
|
|
| 270 |
return 0; |
|
| 271 |
} |
|
| 272 |
|
|
| 266 | 273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 267 | 274 |
|
| 268 | 275 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyDiamond.java | ||
|---|---|---|
| 179 | 179 |
return false; |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 183 |
|
|
| 184 |
int getSolvedFunctionIndex() |
|
| 185 |
{
|
|
| 186 |
return 0; |
|
| 187 |
} |
|
| 188 |
|
|
| 182 | 189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 183 | 190 |
|
| 184 | 191 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyDino4.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import android.content.res.Resources; |
| 23 | 23 |
|
| 24 |
import org.distorted.helpers.QuatHelper; |
|
| 25 | 24 |
import org.distorted.library.main.DistortedEffects; |
| 26 | 25 |
import org.distorted.library.main.DistortedTexture; |
| 27 | 26 |
import org.distorted.library.mesh.MeshSquare; |
| ... | ... | |
| 35 | 34 |
public class TwistyDino4 extends TwistyDino |
| 36 | 35 |
{
|
| 37 | 36 |
private static final int[] mFaceMap = { 4, 2, 2, 4, 0, 2, 1, 4, 0, 0, 1, 1 };
|
| 38 |
private static final int[][] mScramble; |
|
| 39 |
|
|
| 40 |
static |
|
| 41 |
{
|
|
| 42 |
int numQuats = QUATS.length; |
|
| 43 |
int numCenters = CENTERS.length; |
|
| 44 |
|
|
| 45 |
mScramble = new int[numQuats][numCenters]; |
|
| 46 |
|
|
| 47 |
for(int q=0; q<numQuats; q++) |
|
| 48 |
for(int c=0; c<numCenters; c++) mScramble[q][c] = computeScramble(q,c); |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
private final int[] mColors = new int[CENTERS.length]; |
|
| 52 |
|
|
| 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 54 |
|
|
| 55 |
private static int computeScramble(int quatNum, int centerNum) |
|
| 56 |
{
|
|
| 57 |
float MAXDIFF = 0.01f; |
|
| 58 |
float[] center= CENTERS[centerNum]; |
|
| 59 |
Static4D sc = new Static4D(center[0], center[1], center[2], 1.0f); |
|
| 60 |
Static4D result = QuatHelper.rotateVectorByQuat(sc,QUATS[quatNum]); |
|
| 61 |
int numCenters = CENTERS.length; |
|
| 62 |
|
|
| 63 |
float x = result.get0(); |
|
| 64 |
float y = result.get1(); |
|
| 65 |
float z = result.get2(); |
|
| 66 |
|
|
| 67 |
for(int c=0; c<numCenters; c++) |
|
| 68 |
{
|
|
| 69 |
float[] cent = CENTERS[c]; |
|
| 70 |
|
|
| 71 |
float qx = cent[0] - x; |
|
| 72 |
float qy = cent[1] - y; |
|
| 73 |
float qz = cent[2] - z; |
|
| 74 |
|
|
| 75 |
if( qx>-MAXDIFF && qx<MAXDIFF && |
|
| 76 |
qy>-MAXDIFF && qy<MAXDIFF && |
|
| 77 |
qz>-MAXDIFF && qz<MAXDIFF ) return c; |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
return -1; |
|
| 81 |
} |
|
| 82 | 37 |
|
| 83 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 84 | 39 |
|
| 85 |
TwistyDino4(int size, Static4D quat, DistortedTexture texture, |
|
| 86 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
|
| 40 |
TwistyDino4(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
|
| 41 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
|
| 87 | 42 |
{
|
| 88 | 43 |
super(size, quat, texture, mesh, effects, moves, ObjectList.DIN4, res, scrWidth); |
| 89 | 44 |
} |
| ... | ... | |
| 102 | 57 |
return (cubitface==0 || cubitface==1) ? mFaceMap[cubit] : NUM_TEXTURES; |
| 103 | 58 |
} |
| 104 | 59 |
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
int getSolvedFunctionIndex() |
|
| 63 |
{
|
|
| 64 |
return 1; |
|
| 65 |
} |
|
| 66 |
|
|
| 105 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 106 | 68 |
|
| 107 | 69 |
boolean shouldResetTextureMaps() |
| ... | ... | |
| 132 | 94 |
} |
| 133 | 95 |
} |
| 134 | 96 |
|
| 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 136 |
// Dino4 is solved if and only if groups of cubits |
|
| 137 |
// (0,3,7), (1,2,5), (4,8,9), (6,10,11) |
|
| 138 |
// or |
|
| 139 |
// (0,1,4), (2,3,6), (5,9,10), (7,8,11) |
|
| 140 |
// are all the same color. |
|
| 141 |
|
|
| 142 |
public boolean isSolved() |
|
| 143 |
{
|
|
| 144 |
int numCenters = CENTERS.length; |
|
| 145 |
|
|
| 146 |
for(int c=0; c<numCenters; c++) |
|
| 147 |
{
|
|
| 148 |
int index = mScramble[CUBITS[c].mQuatIndex][c]; |
|
| 149 |
mColors[index] = mFaceMap[c]; |
|
| 150 |
} |
|
| 151 |
|
|
| 152 |
if( mColors[0]==mColors[3] && mColors[0]==mColors[7] && |
|
| 153 |
mColors[1]==mColors[2] && mColors[1]==mColors[5] && |
|
| 154 |
mColors[4]==mColors[8] && mColors[4]==mColors[9] ) return true; |
|
| 155 |
|
|
| 156 |
if( mColors[0]==mColors[1] && mColors[0]==mColors[4] && |
|
| 157 |
mColors[2]==mColors[3] && mColors[2]==mColors[6] && |
|
| 158 |
mColors[5]==mColors[9] && mColors[5]==mColors[10] ) return true; |
|
| 159 |
|
|
| 160 |
return false; |
|
| 161 |
} |
|
| 162 |
|
|
| 163 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 98 |
|
| 165 | 99 |
public int getObjectName(int numLayers) |
| src/main/java/org/distorted/objects/TwistyDino6.java | ||
|---|---|---|
| 39 | 39 |
|
| 40 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 41 | 41 |
|
| 42 |
TwistyDino6(int size, Static4D quat, DistortedTexture texture, |
|
| 43 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
|
| 42 |
TwistyDino6(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
|
| 43 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
|
| 44 | 44 |
{
|
| 45 | 45 |
super(size, quat, texture, mesh, effects, moves, ObjectList.DINO, res, scrWidth); |
| 46 | 46 |
} |
| ... | ... | |
| 87 | 87 |
} |
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 91 |
|
|
| 92 |
int getSolvedFunctionIndex() |
|
| 93 |
{
|
|
| 94 |
return 0; |
|
| 95 |
} |
|
| 96 |
|
|
| 90 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 91 | 98 |
|
| 92 | 99 |
boolean shouldResetTextureMaps() |
| src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
|---|---|---|
| 279 | 279 |
return FACE_COLORS.length; |
| 280 | 280 |
} |
| 281 | 281 |
|
| 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 283 |
|
|
| 284 |
int getSolvedFunctionIndex() |
|
| 285 |
{
|
|
| 286 |
return 0; |
|
| 287 |
} |
|
| 288 |
|
|
| 282 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 283 | 290 |
|
| 284 | 291 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyIvy.java | ||
|---|---|---|
| 160 | 160 |
return false; |
| 161 | 161 |
} |
| 162 | 162 |
|
| 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 164 |
|
|
| 165 |
int getSolvedFunctionIndex() |
|
| 166 |
{
|
|
| 167 |
return 0; |
|
| 168 |
} |
|
| 169 |
|
|
| 163 | 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 171 |
|
| 165 | 172 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyJing.java | ||
|---|---|---|
| 252 | 252 |
return FACE_COLORS.length; |
| 253 | 253 |
} |
| 254 | 254 |
|
| 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 256 |
|
|
| 257 |
int getSolvedFunctionIndex() |
|
| 258 |
{
|
|
| 259 |
return 0; |
|
| 260 |
} |
|
| 261 |
|
|
| 255 | 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 256 | 263 |
|
| 257 | 264 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyMinx.java | ||
|---|---|---|
| 360 | 360 |
return FACE_COLORS.length; |
| 361 | 361 |
} |
| 362 | 362 |
|
| 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 364 |
|
|
| 365 |
int getSolvedFunctionIndex() |
|
| 366 |
{
|
|
| 367 |
return 0; |
|
| 368 |
} |
|
| 369 |
|
|
| 363 | 370 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 364 | 371 |
|
| 365 | 372 |
boolean shouldResetTextureMaps() |
| src/main/java/org/distorted/objects/TwistyObject.java | ||
|---|---|---|
| 115 | 115 |
private final Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal; |
| 116 | 116 |
private final DistortedTexture mTexture; |
| 117 | 117 |
private final float mInitScreenRatio; |
| 118 |
private final int mSolvedFunctionIndex; |
|
| 118 | 119 |
private float mObjectScreenRatio; |
| 119 | 120 |
private int[][] mSolvedQuats; |
| 120 | 121 |
private int[][] mQuatMult; |
| ... | ... | |
| 124 | 125 |
private int mRotAxis; |
| 125 | 126 |
private MeshBase mMesh; |
| 126 | 127 |
|
| 128 |
//////////////////// SOLVED1 //////////////////////// |
|
| 129 |
|
|
| 130 |
private static final int[] mFaceMap = { 4, 2, 2, 4, 0, 2, 1, 4, 0, 0, 1, 1 };
|
|
| 131 |
private static int[][] mScramble; |
|
| 132 |
private int[] mColors; |
|
| 133 |
|
|
| 127 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 128 | 135 |
|
| 129 | 136 |
TwistyObject(int numLayers, int realSize, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh, |
| ... | ... | |
| 143 | 150 |
mInitScreenRatio = getScreenRatio(); |
| 144 | 151 |
mObjectScreenRatio = 1.0f; |
| 145 | 152 |
mNumCubitFaces = getNumCubitFaces(); |
| 153 |
mSolvedFunctionIndex = getSolvedFunctionIndex(); |
|
| 146 | 154 |
|
| 147 | 155 |
mCuts = getCuts(mNumLayers); |
| 148 | 156 |
mNumCuts = new int[mAxis.length]; |
| ... | ... | |
| 428 | 436 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 429 | 437 |
|
| 430 | 438 |
public boolean isSolved() |
| 439 |
{
|
|
| 440 |
if( mSolvedFunctionIndex==0 ) return isSolved0(); |
|
| 441 |
if( mSolvedFunctionIndex==1 ) return isSolved1(); |
|
| 442 |
|
|
| 443 |
return false; |
|
| 444 |
} |
|
| 445 |
|
|
| 446 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 447 |
|
|
| 448 |
public boolean isSolved0() |
|
| 431 | 449 |
{
|
| 432 | 450 |
int len, q1,q = CUBITS[0].mQuatIndex; |
| 433 | 451 |
int[] solved; |
| ... | ... | |
| 458 | 476 |
return true; |
| 459 | 477 |
} |
| 460 | 478 |
|
| 479 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 480 |
|
|
| 481 |
private int computeScramble(int quatNum, int centerNum) |
|
| 482 |
{
|
|
| 483 |
float MAXDIFF = 0.01f; |
|
| 484 |
float[] center= mOrigPos[centerNum]; |
|
| 485 |
Static4D sc = new Static4D(center[0], center[1], center[2], 1.0f); |
|
| 486 |
Static4D result = QuatHelper.rotateVectorByQuat(sc,QUATS[quatNum]); |
|
| 487 |
|
|
| 488 |
float x = result.get0(); |
|
| 489 |
float y = result.get1(); |
|
| 490 |
float z = result.get2(); |
|
| 491 |
|
|
| 492 |
for(int c=0; c<NUM_CUBITS; c++) |
|
| 493 |
{
|
|
| 494 |
float[] cent = mOrigPos[c]; |
|
| 495 |
|
|
| 496 |
float qx = cent[0] - x; |
|
| 497 |
float qy = cent[1] - y; |
|
| 498 |
float qz = cent[2] - z; |
|
| 499 |
|
|
| 500 |
if( qx>-MAXDIFF && qx<MAXDIFF && |
|
| 501 |
qy>-MAXDIFF && qy<MAXDIFF && |
|
| 502 |
qz>-MAXDIFF && qz<MAXDIFF ) return c; |
|
| 503 |
} |
|
| 504 |
|
|
| 505 |
return -1; |
|
| 506 |
} |
|
| 507 |
|
|
| 508 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 509 |
// Dino4 uses this. It is solved if and only if groups of cubits |
|
| 510 |
// (0,3,7), (1,2,5), (4,8,9), (6,10,11) |
|
| 511 |
// or |
|
| 512 |
// (0,1,4), (2,3,6), (5,9,10), (7,8,11) |
|
| 513 |
// are all the same color. |
|
| 514 |
|
|
| 515 |
public boolean isSolved1() |
|
| 516 |
{
|
|
| 517 |
if( mScramble==null ) |
|
| 518 |
{
|
|
| 519 |
int numQuats = QUATS.length; |
|
| 520 |
mScramble = new int[numQuats][NUM_CUBITS]; |
|
| 521 |
mColors = new int[NUM_CUBITS]; |
|
| 522 |
|
|
| 523 |
for(int q=0; q<numQuats; q++) |
|
| 524 |
for(int c=0; c<NUM_CUBITS; c++) mScramble[q][c] = computeScramble(q,c); |
|
| 525 |
} |
|
| 526 |
|
|
| 527 |
for(int c=0; c<NUM_CUBITS; c++) |
|
| 528 |
{
|
|
| 529 |
int index = mScramble[CUBITS[c].mQuatIndex][c]; |
|
| 530 |
mColors[index] = mFaceMap[c]; |
|
| 531 |
} |
|
| 532 |
|
|
| 533 |
if( mColors[0]==mColors[3] && mColors[0]==mColors[7] && |
|
| 534 |
mColors[1]==mColors[2] && mColors[1]==mColors[5] && |
|
| 535 |
mColors[4]==mColors[8] && mColors[4]==mColors[9] ) return true; |
|
| 536 |
|
|
| 537 |
if( mColors[0]==mColors[1] && mColors[0]==mColors[4] && |
|
| 538 |
mColors[2]==mColors[3] && mColors[2]==mColors[6] && |
|
| 539 |
mColors[5]==mColors[9] && mColors[5]==mColors[10] ) return true; |
|
| 540 |
|
|
| 541 |
return false; |
|
| 542 |
} |
|
| 543 |
|
|
| 461 | 544 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 462 | 545 |
|
| 463 | 546 |
public void setObjectRatio(float sizeChange) |
| ... | ... | |
| 1089 | 1172 |
abstract Static4D getQuat(int cubit, int numLayers); |
| 1090 | 1173 |
abstract ObjectShape getObjectShape(int cubit, int numLayers); |
| 1091 | 1174 |
abstract int[] getSolvedQuats(int cubit, int numLayers); |
| 1175 |
abstract int getSolvedFunctionIndex(); |
|
| 1092 | 1176 |
|
| 1093 | 1177 |
public abstract Static3D[] getRotationAxis(); |
| 1094 | 1178 |
public abstract int[] getBasicAngle(); |
| src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
|---|---|---|
| 226 | 226 |
return FACE_COLORS.length; |
| 227 | 227 |
} |
| 228 | 228 |
|
| 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 230 |
|
|
| 231 |
int getSolvedFunctionIndex() |
|
| 232 |
{
|
|
| 233 |
return 0; |
|
| 234 |
} |
|
| 235 |
|
|
| 229 | 236 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 230 | 237 |
|
| 231 | 238 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistyRedi.java | ||
|---|---|---|
| 242 | 242 |
return FACE_COLORS.length; |
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 246 |
|
|
| 247 |
int getSolvedFunctionIndex() |
|
| 248 |
{
|
|
| 249 |
return 0; |
|
| 250 |
} |
|
| 251 |
|
|
| 245 | 252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 246 | 253 |
|
| 247 | 254 |
boolean shouldResetTextureMaps() |
| src/main/java/org/distorted/objects/TwistyRex.java | ||
|---|---|---|
| 196 | 196 |
return false; |
| 197 | 197 |
} |
| 198 | 198 |
|
| 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 200 |
|
|
| 201 |
int getSolvedFunctionIndex() |
|
| 202 |
{
|
|
| 203 |
return 0; |
|
| 204 |
} |
|
| 205 |
|
|
| 199 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 200 | 207 |
|
| 201 | 208 |
int getNumStickerTypes(int numLayers) |
| src/main/java/org/distorted/objects/TwistySkewb.java | ||
|---|---|---|
| 247 | 247 |
return FACE_COLORS.length; |
| 248 | 248 |
} |
| 249 | 249 |
|
| 250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 251 |
|
|
| 252 |
int getSolvedFunctionIndex() |
|
| 253 |
{
|
|
| 254 |
return 0; |
|
| 255 |
} |
|
| 256 |
|
|
| 250 | 257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 251 | 258 |
|
| 252 | 259 |
boolean shouldResetTextureMaps() |
| src/main/java/org/distorted/objects/TwistySquare.java | ||
|---|---|---|
| 220 | 220 |
return FACE_COLORS[face]; |
| 221 | 221 |
} |
| 222 | 222 |
|
| 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 224 |
|
|
| 225 |
int getSolvedFunctionIndex() |
|
| 226 |
{
|
|
| 227 |
return 0; |
|
| 228 |
} |
|
| 229 |
|
|
| 223 | 230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 224 | 231 |
// PUBLIC API |
| 225 | 232 |
|
| src/main/java/org/distorted/objects/TwistyUltimate.java | ||
|---|---|---|
| 349 | 349 |
return QUATS; |
| 350 | 350 |
} |
| 351 | 351 |
|
| 352 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 353 |
|
|
| 354 |
int getSolvedFunctionIndex() |
|
| 355 |
{
|
|
| 356 |
return 0; |
|
| 357 |
} |
|
| 358 |
|
|
| 352 | 359 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 353 | 360 |
|
| 354 | 361 |
boolean shouldResetTextureMaps() |
Also available in: Unified diff
Remove the last 'isSolved()' (from Dino4) and put it to the parent class as a special case.