Revision d99f3a48
Added by Leszek Koltunski about 5 years ago
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 391 | 391 |
{
|
| 392 | 392 |
TwistyObject oldObject = pre.getObject(); |
| 393 | 393 |
ObjectList oldList = oldObject.getObjectList(); |
| 394 |
int oldSize = oldObject.getSize();
|
|
| 394 |
int oldNum = oldObject.getNumLayers();
|
|
| 395 | 395 |
float fps = view.getRenderer().getFPS(); |
| 396 | 396 |
fps = (int)(fps+0.5f); |
| 397 | 397 |
StringBuilder name = new StringBuilder(); |
| 398 | 398 |
name.append(oldList.name()); |
| 399 | 399 |
name.append('_');
|
| 400 |
name.append(oldSize);
|
|
| 400 |
name.append(oldNum);
|
|
| 401 | 401 |
name.append(' ');
|
| 402 | 402 |
name.append(fps); |
| 403 | 403 |
name.append(" --> ");
|
| src/main/java/org/distorted/main/RubikPreRender.java | ||
|---|---|---|
| 255 | 255 |
{
|
| 256 | 256 |
mChangeObject = false; |
| 257 | 257 |
|
| 258 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize)
|
|
| 258 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
|
|
| 259 | 259 |
{
|
| 260 | 260 |
mCanRotate= false; |
| 261 | 261 |
mCanPlay = false; |
| ... | ... | |
| 270 | 270 |
{
|
| 271 | 271 |
mSetupObject = false; |
| 272 | 272 |
|
| 273 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize)
|
|
| 273 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
|
|
| 274 | 274 |
{
|
| 275 | 275 |
mCanRotate= false; |
| 276 | 276 |
mCanPlay = false; |
| src/main/java/org/distorted/main/RubikSurfaceView.java | ||
|---|---|---|
| 305 | 305 |
} |
| 306 | 306 |
else |
| 307 | 307 |
{
|
| 308 |
Static4D touchPoint1 = new Static4D(x, y, 0, 0);
|
|
| 309 |
Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuat);
|
|
| 308 |
Static4D touchPoint = new Static4D(x, y, 0, 0); |
|
| 309 |
Static4D rotatedTouchPoint= rotateVectorByInvertedQuat(touchPoint, mQuat);
|
|
| 310 | 310 |
Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuat); |
| 311 | 311 |
|
| 312 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
|
|
| 312 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) ) |
|
| 313 | 313 |
{
|
| 314 | 314 |
mDragging = false; |
| 315 | 315 |
mContinuingRotation = false; |
| ... | ... | |
| 331 | 331 |
TwistyObject object = mPreRender.getObject(); |
| 332 | 332 |
mLastCubit = object.getCubit(point); |
| 333 | 333 |
mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color ); |
| 334 |
mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getSize(), mLastCubit);
|
|
| 334 |
mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getNumLayers(), mLastCubit);
|
|
| 335 | 335 |
} |
| 336 | 336 |
} |
| 337 | 337 |
} |
| ... | ... | |
| 461 | 461 |
mStartRotY = y; |
| 462 | 462 |
|
| 463 | 463 |
TwistyObject object = mPreRender.getObject(); |
| 464 |
int size = object.getSize();
|
|
| 464 |
int numLayers = object.getNumLayers();
|
|
| 465 | 465 |
|
| 466 | 466 |
Static4D touchPoint2 = new Static4D(x, y, 0, 0); |
| 467 | 467 |
Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuat); |
| 468 |
Static2D res = mMovement.newRotation(size,rotatedTouchPoint2);
|
|
| 468 |
Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2);
|
|
| 469 | 469 |
|
| 470 | 470 |
mCurrentAxis = (int)res.get0(); |
| 471 | 471 |
mCurrentRow = (int)res.get1(); |
| 472 | 472 |
|
| 473 | 473 |
computeCurrentAxis( mMovement.getCastedRotAxis(mCurrentAxis) ); |
| 474 |
mRotationFactor = mMovement.returnRotationFactor(size,mCurrentRow);
|
|
| 474 |
mRotationFactor = mMovement.returnRotationFactor(numLayers,mCurrentRow);
|
|
| 475 | 475 |
|
| 476 | 476 |
object.beginNewRotation( mCurrentAxis, mCurrentRow ); |
| 477 | 477 |
|
| src/main/java/org/distorted/objects/TwistyCube.java | ||
|---|---|---|
| 98 | 98 |
TwistyCube(int size, Static4D quat, DistortedTexture texture, |
| 99 | 99 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 100 | 100 |
{
|
| 101 |
super(size, 60, quat, texture, mesh, effects, moves, ObjectList.CUBE, res, scrWidth); |
|
| 101 |
super(size, size, 60, quat, texture, mesh, effects, moves, ObjectList.CUBE, res, scrWidth);
|
|
| 102 | 102 |
} |
| 103 | 103 |
|
| 104 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 111 | 111 |
} |
| 112 | 112 |
|
| 113 | 113 |
int ordinal= ObjectList.CUBE.ordinal(); |
| 114 |
int index = ObjectList.getSizeIndex(ordinal,getSize());
|
|
| 114 |
int index = ObjectList.getSizeIndex(ordinal,getNumLayers());
|
|
| 115 | 115 |
|
| 116 | 116 |
if( mMeshes[index]==null ) |
| 117 | 117 |
{
|
| ... | ... | |
| 222 | 222 |
|
| 223 | 223 |
float returnMultiplier() |
| 224 | 224 |
{
|
| 225 |
return getSize();
|
|
| 225 |
return getNumLayers();
|
|
| 226 | 226 |
} |
| 227 | 227 |
|
| 228 | 228 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 229 | 229 |
|
| 230 | 230 |
float[] getRowChances() |
| 231 | 231 |
{
|
| 232 |
int size = getSize();
|
|
| 233 |
float[] chances = new float[size];
|
|
| 232 |
int numLayers = getNumLayers();
|
|
| 233 |
float[] chances = new float[numLayers];
|
|
| 234 | 234 |
|
| 235 |
for(int i=0; i<size; i++)
|
|
| 235 |
for(int i=0; i<numLayers; i++)
|
|
| 236 | 236 |
{
|
| 237 |
chances[i] = (i+1.0f) / size;
|
|
| 237 |
chances[i] = (i+1.0f) / numLayers;
|
|
| 238 | 238 |
} |
| 239 | 239 |
|
| 240 | 240 |
return chances; |
| ... | ... | |
| 315 | 315 |
if ( cubit.mQuatIndex == quatIndex ) return true; |
| 316 | 316 |
|
| 317 | 317 |
int belongsToHowManyFaces = 0; |
| 318 |
int size = getSize()-1;
|
|
| 318 |
int lastLayer = getNumLayers()-1;
|
|
| 319 | 319 |
float row; |
| 320 | 320 |
final float MAX_ERROR = 0.01f; |
| 321 | 321 |
|
| 322 | 322 |
for(int i=0; i<NUM_AXIS; i++) |
| 323 | 323 |
{
|
| 324 | 324 |
row = cubit.mRotationRow[i]; |
| 325 |
if( (row <MAX_ERROR && row >-MAX_ERROR) ||
|
|
| 326 |
(row-size<MAX_ERROR && row-size>-MAX_ERROR) ) belongsToHowManyFaces++;
|
|
| 325 |
if( (row <MAX_ERROR && row >-MAX_ERROR) ||
|
|
| 326 |
(row-lastLayer<MAX_ERROR && row-lastLayer>-MAX_ERROR) ) belongsToHowManyFaces++;
|
|
| 327 | 327 |
} |
| 328 | 328 |
|
| 329 | 329 |
switch(belongsToHowManyFaces) |
| ... | ... | |
| 351 | 351 |
row1 = computeRow(x1,y1,z1,i); |
| 352 | 352 |
row2 = computeRow(x2,y2,z2,i); |
| 353 | 353 |
|
| 354 |
if( (row1==0 && row2==0) || (row1==size || row2==size) ) return true;
|
|
| 354 |
if( (row1==0 && row2==0) || (row1==lastLayer || row2==lastLayer) ) return true;
|
|
| 355 | 355 |
} |
| 356 | 356 |
return false; |
| 357 | 357 |
|
| ... | ... | |
| 385 | 385 |
public String retObjectString() |
| 386 | 386 |
{
|
| 387 | 387 |
StringBuilder objectString = new StringBuilder(); |
| 388 |
int size = getSize();
|
|
| 389 |
int len = size*size;
|
|
| 388 |
int layers = getNumLayers();
|
|
| 389 |
int len = layers*layers;
|
|
| 390 | 390 |
int cubitIndex, row, col, color,face; |
| 391 | 391 |
|
| 392 | 392 |
final int RIGHT= 0; |
| ... | ... | |
| 403 | 403 |
|
| 404 | 404 |
for(int i=0; i<len; i++) |
| 405 | 405 |
{
|
| 406 |
row = i/size;
|
|
| 407 |
col = i%size;
|
|
| 406 |
row = i/layers;
|
|
| 407 |
col = i%layers;
|
|
| 408 | 408 |
|
| 409 |
cubitIndex = col<size-1 ? (size-1)*(size+4*col) + row : 6*size*size - 13*size + 8 + row;
|
|
| 409 |
cubitIndex = col<layers-1 ? (layers-1)*(layers+4*col) + row : 6*layers*layers - 13*layers + 8 + row;
|
|
| 410 | 410 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| 411 | 411 |
objectString.append(FACE_NAMES[color]); |
| 412 | 412 |
} |
| ... | ... | |
| 415 | 415 |
|
| 416 | 416 |
for(int i=0; i<len; i++) |
| 417 | 417 |
{
|
| 418 |
cubitIndex = 6*size*size - 12*size +7 - i;
|
|
| 418 |
cubitIndex = 6*layers*layers - 12*layers +7 - i;
|
|
| 419 | 419 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| 420 | 420 |
objectString.append(FACE_NAMES[color]); |
| 421 | 421 |
} |
| ... | ... | |
| 424 | 424 |
|
| 425 | 425 |
for(int i=0; i<len; i++) |
| 426 | 426 |
{
|
| 427 |
row = i/size;
|
|
| 428 |
col = i%size;
|
|
| 427 |
row = i/layers;
|
|
| 428 |
col = i%layers;
|
|
| 429 | 429 |
|
| 430 |
if( col==size-1 ) cubitIndex = 6*size*size - 11*size + 6 -i;
|
|
| 431 |
else if( col==0 ) cubitIndex = size*size - 1 - i;
|
|
| 430 |
if( col==layers-1 ) cubitIndex = 6*layers*layers - 11*layers + 6 -i;
|
|
| 431 |
else if( col==0 ) cubitIndex = layers*layers - 1 - i;
|
|
| 432 | 432 |
else |
| 433 | 433 |
{
|
| 434 |
if( row==0 ) cubitIndex = size*size + size-1 + 4*(col-1)*(size-1) + 2*(size-2) + size;
|
|
| 435 |
else cubitIndex = size*size + size-1 + 4*(col-1)*(size-1) + 2*(size-1-row);
|
|
| 434 |
if( row==0 ) cubitIndex = layers*layers + layers-1 + 4*(col-1)*(layers-1) + 2*(layers-2) + layers;
|
|
| 435 |
else cubitIndex = layers*layers + layers-1 + 4*(col-1)*(layers-1) + 2*(layers-1-row);
|
|
| 436 | 436 |
} |
| 437 | 437 |
|
| 438 | 438 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| ... | ... | |
| 443 | 443 |
|
| 444 | 444 |
for(int i=0; i<len; i++) |
| 445 | 445 |
{
|
| 446 |
row = i/size;
|
|
| 447 |
col = i%size;
|
|
| 446 |
row = i/layers;
|
|
| 447 |
col = i%layers;
|
|
| 448 | 448 |
|
| 449 |
cubitIndex = col==0 ? size-1-row : size*size + size-1 + 4*(col-1)*(size-1) - row;
|
|
| 449 |
cubitIndex = col==0 ? layers-1-row : layers*layers + layers-1 + 4*(col-1)*(layers-1) - row;
|
|
| 450 | 450 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| 451 | 451 |
objectString.append(FACE_NAMES[color]); |
| 452 | 452 |
} |
| ... | ... | |
| 455 | 455 |
|
| 456 | 456 |
for(int i=0; i<len; i++) |
| 457 | 457 |
{
|
| 458 |
row = i/size;
|
|
| 459 |
col = i%size;
|
|
| 458 |
row = i/layers;
|
|
| 459 |
col = i%layers;
|
|
| 460 | 460 |
|
| 461 |
cubitIndex = (size-1-row)*size + col;
|
|
| 461 |
cubitIndex = (layers-1-row)*layers + col;
|
|
| 462 | 462 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| 463 | 463 |
objectString.append(FACE_NAMES[color]); |
| 464 | 464 |
} |
| ... | ... | |
| 467 | 467 |
|
| 468 | 468 |
for(int i=0; i<len; i++) |
| 469 | 469 |
{
|
| 470 |
row = i/size;
|
|
| 471 |
col = i%size;
|
|
| 470 |
row = i/layers;
|
|
| 471 |
col = i%layers;
|
|
| 472 | 472 |
|
| 473 |
if( col==size-1 ) cubitIndex = size*(size-1-row);
|
|
| 474 |
else if( col==0 ) cubitIndex = 5*size*size - 12*size + 8 + (size-1-row)*size;
|
|
| 473 |
if( col==layers-1 ) cubitIndex = layers*(layers-1-row);
|
|
| 474 |
else if( col==0 ) cubitIndex = 5*layers*layers - 12*layers + 8 + (layers-1-row)*layers;
|
|
| 475 | 475 |
else |
| 476 | 476 |
{
|
| 477 |
if( row==size-1 ) cubitIndex = size*size + 4*(size-2-col)*(size-1);
|
|
| 478 |
else cubitIndex = size*size + 4*(size-2-col)*(size-1) + size + 2*(size-2-row);
|
|
| 477 |
if( row==layers-1 ) cubitIndex = layers*layers + 4*(layers-2-col)*(layers-1);
|
|
| 478 |
else cubitIndex = layers*layers + 4*(layers-2-col)*(layers-1) + layers + 2*(layers-2-row);
|
|
| 479 | 479 |
} |
| 480 | 480 |
|
| 481 | 481 |
color = getCubitFaceColorIndex(cubitIndex,face); |
| src/main/java/org/distorted/objects/TwistyDiamond.java | ||
|---|---|---|
| 126 | 126 |
TwistyDiamond(int size, Static4D quat, DistortedTexture texture, |
| 127 | 127 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 128 | 128 |
{
|
| 129 |
super(size, 60, quat, texture, mesh, effects, moves, ObjectList.DIAM, res, scrWidth); |
|
| 129 |
super(size, size, 60, quat, texture, mesh, effects, moves, ObjectList.DIAM, res, scrWidth);
|
|
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 | 132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/TwistyDino.java | ||
|---|---|---|
| 97 | 97 |
TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
| 98 | 98 |
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) |
| 99 | 99 |
{
|
| 100 |
super(size, 60, quat, texture, mesh, effects, moves, obj, res, scrWidth); |
|
| 100 |
super(size, size, 60, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
|
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
|---|---|---|
| 191 | 191 |
TwistyHelicopter(int size, Static4D quat, DistortedTexture texture, |
| 192 | 192 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 193 | 193 |
{
|
| 194 |
super(size, 60, quat, texture, mesh, effects, moves, ObjectList.HELI, res, scrWidth); |
|
| 194 |
super(size, size, 60, quat, texture, mesh, effects, moves, ObjectList.HELI, res, scrWidth);
|
|
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/TwistyObject.java | ||
|---|---|---|
| 99 | 99 |
private Static3D[] mOrigPos; |
| 100 | 100 |
private Static3D mNodeScale; |
| 101 | 101 |
private Static4D mQuat; |
| 102 |
private int mSize; |
|
| 102 |
private int mNumLayers, mRealSize;
|
|
| 103 | 103 |
private ObjectList mList; |
| 104 | 104 |
private MeshBase mMesh; |
| 105 | 105 |
private DistortedEffects mEffects; |
| ... | ... | |
| 116 | 116 |
|
| 117 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 118 | 118 |
|
| 119 |
TwistyObject(int size, int fov, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh,
|
|
| 119 |
TwistyObject(int numLayers, int realSize, int fov, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh,
|
|
| 120 | 120 |
DistortedEffects nodeEffects, int[][] moves, ObjectList list, Resources res, int screenWidth) |
| 121 | 121 |
{
|
| 122 | 122 |
super(nodeTexture,nodeEffects,nodeMesh); |
| ... | ... | |
| 125 | 125 |
|
| 126 | 126 |
resizeFBO(mNodeSize, (int)(NODE_RATIO*mNodeSize)); |
| 127 | 127 |
|
| 128 |
mSize = size; |
|
| 128 |
mNumLayers = numLayers; |
|
| 129 |
mRealSize = realSize; |
|
| 129 | 130 |
mList = list; |
| 130 |
mOrigPos = getCubitPositions(size);
|
|
| 131 |
mOrigPos = getCubitPositions(mNumLayers);
|
|
| 131 | 132 |
|
| 132 | 133 |
QUATS = getQuats(); |
| 133 | 134 |
NUM_CUBITS = mOrigPos.length; |
| ... | ... | |
| 137 | 138 |
NUM_FACES = getNumFaces(); |
| 138 | 139 |
NUM_CUBIT_FACES = getNumCubitFaces(); |
| 139 | 140 |
NUM_TEXTURES = getNumStickerTypes()*NUM_FACES; |
| 140 |
CUTS = getCuts(mSize);
|
|
| 141 |
CUTS = getCuts(mNumLayers);
|
|
| 141 | 142 |
NUM_CUTS = CUTS.length; |
| 142 | 143 |
|
| 143 | 144 |
if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE; |
| ... | ... | |
| 156 | 157 |
mRotationAngleMiddle = new Static1D(0); |
| 157 | 158 |
mRotationAngleFinal = new Static1D(0); |
| 158 | 159 |
|
| 159 |
float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mSize; |
|
| 160 |
float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
|
|
| 160 | 161 |
mObjectScale = new Static3D(scale,scale,scale); |
| 161 | 162 |
mScaleEffect = new MatrixEffectScale(mObjectScale); |
| 162 | 163 |
mQuatEffect = new MatrixEffectQuaternion(quat, CENTER); |
| ... | ... | |
| 199 | 200 |
{
|
| 200 | 201 |
if( mCreateFromDMesh ) |
| 201 | 202 |
{
|
| 202 |
int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mSize);
|
|
| 203 |
int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers);
|
|
| 203 | 204 |
int resourceID= list.getResourceIDs()[sizeIndex]; |
| 204 | 205 |
|
| 205 | 206 |
InputStream is = res.openRawResource(resourceID); |
| ... | ... | |
| 249 | 250 |
if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE; |
| 250 | 251 |
if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE; |
| 251 | 252 |
|
| 252 |
float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mSize; |
|
| 253 |
float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
|
|
| 253 | 254 |
mObjectScale.set(scale,scale,scale); |
| 254 | 255 |
} |
| 255 | 256 |
|
| ... | ... | |
| 504 | 505 |
|
| 505 | 506 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 506 | 507 |
|
| 507 |
public int getSize()
|
|
| 508 |
public int getNumLayers()
|
|
| 508 | 509 |
{
|
| 509 |
return mSize;
|
|
| 510 |
return mNumLayers;
|
|
| 510 | 511 |
} |
| 511 | 512 |
|
| 512 | 513 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 604 | 605 |
|
| 605 | 606 |
for(int cubitface=0; cubitface<NUM_CUBIT_FACES; cubitface++) |
| 606 | 607 |
{
|
| 607 |
color = getFaceColor(cubit,cubitface,mSize);
|
|
| 608 |
color = getFaceColor(cubit,cubitface,mNumLayers);
|
|
| 608 | 609 |
maps[cubitface] = new Static4D( color*ratio, 0.0f, ratio, 1.0f); |
| 609 | 610 |
} |
| 610 | 611 |
|
| ... | ... | |
| 632 | 633 |
android.util.Log.e("object", "invalid rotation axis: "+axis);
|
| 633 | 634 |
return; |
| 634 | 635 |
} |
| 635 |
if( row<0 || row>=mSize )
|
|
| 636 |
if( row<0 || row>=mNumLayers )
|
|
| 636 | 637 |
{
|
| 637 | 638 |
android.util.Log.e("object", "invalid rotation row: "+row);
|
| 638 | 639 |
return; |
| src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
|---|---|---|
| 77 | 77 |
TwistyPyraminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
| 78 | 78 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 79 | 79 |
{
|
| 80 |
super(size, 30, quat, texture, mesh, effects, moves, ObjectList.PYRA, res, scrWidth); |
|
| 80 |
super(size, size, 30, quat, texture, mesh, effects, moves, ObjectList.PYRA, res, scrWidth);
|
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 221 | 221 |
|
| 222 | 222 |
MeshBase createCubitMesh(int cubit) |
| 223 | 223 |
{
|
| 224 |
int size = getSize();
|
|
| 224 |
int numLayers = getNumLayers();
|
|
| 225 | 225 |
|
| 226 |
if( cubit< (size-1)*size*(size+1)/6 )
|
|
| 226 |
if( cubit< (numLayers-1)*numLayers*(numLayers+1)/6 )
|
|
| 227 | 227 |
{
|
| 228 | 228 |
if( mOctaMesh==null ) mOctaMesh = CubitFactory.getInstance().createOctaMesh(); |
| 229 | 229 |
return mOctaMesh.copy(true); |
| ... | ... | |
| 253 | 253 |
|
| 254 | 254 |
float returnMultiplier() |
| 255 | 255 |
{
|
| 256 |
return getSize()/(SQ6/3);
|
|
| 256 |
return getNumLayers()/(SQ6/3);
|
|
| 257 | 257 |
} |
| 258 | 258 |
|
| 259 | 259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 260 | 260 |
|
| 261 | 261 |
float[] getRowChances() |
| 262 | 262 |
{
|
| 263 |
int size = getSize();
|
|
| 264 |
int total = size*(size+1)/2;
|
|
| 263 |
int numLayers = getNumLayers();
|
|
| 264 |
int total = numLayers*(numLayers+1)/2;
|
|
| 265 | 265 |
float running=0.0f; |
| 266 |
float[] chances = new float[size];
|
|
| 266 |
float[] chances = new float[numLayers];
|
|
| 267 | 267 |
|
| 268 |
for(int i=0; i<size; i++)
|
|
| 268 |
for(int i=0; i<numLayers; i++)
|
|
| 269 | 269 |
{
|
| 270 |
running += (size-i);
|
|
| 270 |
running += (numLayers-i);
|
|
| 271 | 271 |
chances[i] = running / total; |
| 272 | 272 |
} |
| 273 | 273 |
|
| ... | ... | |
| 349 | 349 |
if ( cubit.mQuatIndex == quatIndex ) return true; |
| 350 | 350 |
|
| 351 | 351 |
int belongsToHowManyFaces = 0; |
| 352 |
int size = getSize()-1;
|
|
| 352 |
int numLayers = getNumLayers()-1;
|
|
| 353 | 353 |
float row; |
| 354 | 354 |
final float MAX_ERROR = 0.01f; |
| 355 | 355 |
|
| 356 | 356 |
for(int i=0; i<NUM_AXIS; i++) |
| 357 | 357 |
{
|
| 358 | 358 |
row = cubit.mRotationRow[i]; |
| 359 |
if( (row <MAX_ERROR && row >-MAX_ERROR) ||
|
|
| 360 |
(row-size<MAX_ERROR && row-size>-MAX_ERROR) ) belongsToHowManyFaces++;
|
|
| 359 |
if( (row <MAX_ERROR && row >-MAX_ERROR) ||
|
|
| 360 |
(row-numLayers<MAX_ERROR && row-numLayers>-MAX_ERROR) ) belongsToHowManyFaces++;
|
|
| 361 | 361 |
} |
| 362 | 362 |
|
| 363 | 363 |
switch(belongsToHowManyFaces) |
| ... | ... | |
| 385 | 385 |
row1 = computeRow(x1,y1,z1,i); |
| 386 | 386 |
row2 = computeRow(x2,y2,z2,i); |
| 387 | 387 |
|
| 388 |
if( (row1==0 && row2==0) || (row1==size || row2==size) ) return true;
|
|
| 388 |
if( (row1==0 && row2==0) || (row1==numLayers || row2==numLayers) ) return true;
|
|
| 389 | 389 |
} |
| 390 | 390 |
return false; |
| 391 | 391 |
|
| src/main/java/org/distorted/objects/TwistyRedi.java | ||
|---|---|---|
| 140 | 140 |
TwistyRedi(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
| 141 | 141 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 142 | 142 |
{
|
| 143 |
super(size, 60, quat, texture, mesh, effects, moves, ObjectList.REDI, res, scrWidth); |
|
| 143 |
super(size, size, 60, quat, texture, mesh, effects, moves, ObjectList.REDI, res, scrWidth);
|
|
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/TwistySkewb.java | ||
|---|---|---|
| 123 | 123 |
TwistySkewb(int size, Static4D quat, DistortedTexture texture, |
| 124 | 124 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
| 125 | 125 |
{
|
| 126 |
super(size, 60, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth); |
|
| 126 |
super(size, 2*size-2, 60, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth);
|
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 | 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 151 | 151 |
|
| 152 | 152 |
float getScreenRatio() |
| 153 | 153 |
{
|
| 154 |
int size = getSize(); |
|
| 155 |
return size/ (2.0f*(size-1)); |
|
| 154 |
return 1.0f; |
|
| 156 | 155 |
} |
| 157 | 156 |
|
| 158 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 400 | 399 |
{
|
| 401 | 400 |
MeshBase mesh; |
| 402 | 401 |
|
| 403 |
int size = getSize();
|
|
| 404 |
int numCorners = getNumCorners(size);
|
|
| 405 |
int numEdges = getNumEdges(size);
|
|
| 402 |
int numLayers = getNumLayers();
|
|
| 403 |
int numCorners = getNumCorners(numLayers);
|
|
| 404 |
int numEdges = getNumEdges(numLayers);
|
|
| 406 | 405 |
|
| 407 | 406 |
if( cubit<numCorners ) |
| 408 | 407 |
{
|
| ... | ... | |
| 427 | 426 |
mesh = mFaceMesh.copy(true); |
| 428 | 427 |
} |
| 429 | 428 |
|
| 430 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,size), new Static3D(0,0,0) );
|
|
| 429 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
| 431 | 430 |
mesh.apply(quat,0xffffffff,0); |
| 432 | 431 |
|
| 433 | 432 |
return mesh; |
| ... | ... | |
| 500 | 499 |
|
| 501 | 500 |
float[] getRowChances() |
| 502 | 501 |
{
|
| 503 |
int size = getSize();
|
|
| 504 |
float[] chances = new float[size];
|
|
| 502 |
int numLayers = getNumLayers();
|
|
| 503 |
float[] chances = new float[numLayers];
|
|
| 505 | 504 |
|
| 506 |
for(int i=0; i<size; i++)
|
|
| 505 |
for(int i=0; i<numLayers; i++)
|
|
| 507 | 506 |
{
|
| 508 |
chances[i] = (float)(i+1)/size;
|
|
| 507 |
chances[i] = (float)(i+1)/numLayers;
|
|
| 509 | 508 |
} |
| 510 | 509 |
|
| 511 | 510 |
return chances; |
Also available in: Unified diff
Spearate the concept of number of layers of an object and its size.
In case of the Skewb family, this is no longer the same (Master Skewb has 3 layers but it's twice bigger than the 2-layered Skewb)