Revision 45f63f17
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
---|---|---|
44 | 44 |
16, 18, 22, 1, 20, 13, 14, 15, 0, 12, 2, 3 |
45 | 45 |
}; |
46 | 46 |
|
47 |
private static MeshBase[] mCenterMeshes, mCornerMeshes; |
|
48 |
private static MeshBase[][] mEdgeMeshes; |
|
47 |
private static MeshBase[][] mMeshes; |
|
49 | 48 |
|
50 | 49 |
private static final float[][] STICKERS = new float[][] |
51 | 50 |
{ |
... | ... | |
415 | 414 |
int index = (numLayers-3)/2; |
416 | 415 |
int[] sizes = ObjectList.MEGA.getSizes(); |
417 | 416 |
int variants = sizes.length; |
417 |
int numShapes = 2+(sizes[variants-1]-1)/2; |
|
418 | 418 |
MeshBase mesh; |
419 | 419 |
|
420 |
if( mCornerMeshes==null ) mCornerMeshes = new MeshBase[variants]; |
|
421 |
if( mEdgeMeshes ==null ) mEdgeMeshes = new MeshBase[variants][(sizes[variants-1]-1)/2]; |
|
422 |
if( mCenterMeshes==null ) mCenterMeshes = new MeshBase[variants]; |
|
420 |
if( mMeshes==null ) mMeshes = new MeshBase[variants][numShapes]; |
|
423 | 421 |
|
424 | 422 |
if( cubit < NUM_CORNERS*numCubitsPerCorner ) |
425 | 423 |
{ |
426 |
if( mCornerMeshes[index]==null )
|
|
424 |
if( mMeshes[index][0]==null )
|
|
427 | 425 |
{ |
428 | 426 |
float width = (numLayers/3.0f)*(0.5f-MEGA_D)/(0.5f*(numLayers-1)); |
429 |
mCornerMeshes[index] = createCornerMesh(numLayers, width);
|
|
427 |
mMeshes[index][0] = createCornerMesh(numLayers, width);
|
|
430 | 428 |
} |
431 |
mesh = mCornerMeshes[index].copy(true);
|
|
429 |
mesh = mMeshes[index][0].copy(true);
|
|
432 | 430 |
} |
433 | 431 |
else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge ) |
434 | 432 |
{ |
435 | 433 |
int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge); |
436 | 434 |
|
437 |
if( mEdgeMeshes[index][type]==null )
|
|
435 |
if( mMeshes[index][1+type]==null )
|
|
438 | 436 |
{ |
439 | 437 |
float height= (numLayers/3.0f)*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f); |
440 | 438 |
float width = (numLayers/3.0f)*2*MEGA_D + 2*type*height*SIN18/COS18; |
441 | 439 |
|
442 |
mEdgeMeshes[index][type] = createEdgeMesh(numLayers,width,height);
|
|
440 |
mMeshes[index][1+type] = createEdgeMesh(numLayers,width,height);
|
|
443 | 441 |
} |
444 |
|
|
445 |
mesh = mEdgeMeshes[index][type].copy(true); |
|
442 |
mesh = mMeshes[index][1+type].copy(true); |
|
446 | 443 |
} |
447 | 444 |
else |
448 | 445 |
{ |
449 |
if( mCenterMeshes[index]==null )
|
|
446 |
if( mMeshes[index][numShapes-1]==null )
|
|
450 | 447 |
{ |
451 | 448 |
float width = 2 * (numLayers/3.0f) * (MEGA_D+(0.5f-MEGA_D)*SIN18); |
452 |
mCenterMeshes[index] = createCenterMesh(numLayers,width);
|
|
449 |
mMeshes[index][numShapes-1] = createCenterMesh(numLayers,width);
|
|
453 | 450 |
} |
454 | 451 |
|
455 |
mesh = mCenterMeshes[index].copy(true);
|
|
452 |
mesh = mMeshes[index][numShapes-1].copy(true);
|
|
456 | 453 |
} |
457 | 454 |
|
458 | 455 |
Static4D q = QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)]; |
Also available in: Unified diff
Introduce ObjectShape - a class encapsulating a shape of a Cubit.
Make the Megaminx cubit creation a bit more standard.