Revision eab9d8f8
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/RubikSkewb.java | ||
---|---|---|
107 | 107 |
new Static3D(-0.5f,-0.5f, 0.5f ), |
108 | 108 |
new Static3D(-0.5f,-0.5f,-0.5f ), |
109 | 109 |
|
110 |
new Static3D( 0.5f, 0.0f, 0.0f ),
|
|
111 |
new Static3D(-0.5f, 0.0f, 0.0f ),
|
|
112 |
new Static3D( 0.0f, 0.5f, 0.0f ),
|
|
113 |
new Static3D( 0.0f,-0.5f, 0.0f ),
|
|
114 |
new Static3D( 0.0f, 0.0f, 0.5f ),
|
|
115 |
new Static3D( 0.0f, 0.0f,-0.5f ),
|
|
110 |
new Static3D( 0.49f, 0.0f, 0.0f ),
|
|
111 |
new Static3D(-0.49f, 0.0f, 0.0f ),
|
|
112 |
new Static3D( 0.0f, 0.49f, 0.0f ),
|
|
113 |
new Static3D( 0.0f,-0.49f, 0.0f ),
|
|
114 |
new Static3D( 0.0f, 0.0f, 0.49f ),
|
|
115 |
new Static3D( 0.0f, 0.0f,-0.49f ),
|
|
116 | 116 |
}; |
117 | 117 |
|
118 | 118 |
// Colors of the faces of cubits. Each cubit, even the face pyramid, has 6 faces |
119 | 119 |
// (the face has one extra 'fake' face so that everything would have the same number) |
120 | 120 |
private static final int[][] mFaceMap = new int[][] |
121 | 121 |
{ |
122 |
{ 4,2,0, 6,6,6 },
|
|
123 |
{ 2,5,0, 6,6,6 },
|
|
124 |
{ 3,4,0, 6,6,6 },
|
|
125 |
{ 5,3,0, 6,6,6 },
|
|
126 |
{ 1,2,4, 6,6,6 },
|
|
127 |
{ 5,2,1, 6,6,6 },
|
|
128 |
{ 4,3,1, 6,6,6 },
|
|
129 |
{ 1,3,5, 6,6,6 },
|
|
130 |
|
|
131 |
{ 0, 6,6,6,6,6 },
|
|
132 |
{ 1, 6,6,6,6,6 },
|
|
133 |
{ 2, 6,6,6,6,6 },
|
|
134 |
{ 3, 6,6,6,6,6 },
|
|
135 |
{ 4, 6,6,6,6,6 },
|
|
136 |
{ 5, 6,6,6,6,6 },
|
|
122 |
{ 4,2,0, 12,12,12 },
|
|
123 |
{ 2,5,0, 12,12,12 },
|
|
124 |
{ 3,4,0, 12,12,12 },
|
|
125 |
{ 5,3,0, 12,12,12 },
|
|
126 |
{ 1,2,4, 12,12,12 },
|
|
127 |
{ 5,2,1, 12,12,12 },
|
|
128 |
{ 4,3,1, 12,12,12 },
|
|
129 |
{ 1,3,5, 12,12,12 },
|
|
130 |
|
|
131 |
{ 6 , 12,12,12,12,12 },
|
|
132 |
{ 7 , 12,12,12,12,12 },
|
|
133 |
{ 8 , 12,12,12,12,12 },
|
|
134 |
{ 9 , 12,12,12,12,12 },
|
|
135 |
{ 10, 12,12,12,12,12 },
|
|
136 |
{ 11, 12,12,12,12,12 },
|
|
137 | 137 |
}; |
138 | 138 |
|
139 | 139 |
private static MeshBase mCornerMesh, mFaceMesh; |
... | ... | |
174 | 174 |
meshes[2].setEffectAssociation(0,4,0); |
175 | 175 |
|
176 | 176 |
float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F }; |
177 |
float[] bands1 = { 1.0f, 0.0f, 0.0f, 0.0f }; |
|
177 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
178 | 178 |
|
179 |
meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
|
|
179 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
|
180 | 180 |
meshes[3].setEffectAssociation(0,8,0); |
181 | 181 |
meshes[4] = meshes[3].copy(true); |
182 | 182 |
meshes[4].setEffectAssociation(0,16,0); |
... | ... | |
281 | 281 |
float E = SQ2/4; |
282 | 282 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E }; |
283 | 283 |
|
284 |
float[] bands0 = { 1.0f ,0, |
|
285 |
1.0f-D/2,D*0.45f,
|
|
286 |
1.0f-D ,D*0.75f,
|
|
287 |
1.0f-2*D,D,
|
|
288 |
0.60f, 0.052f,
|
|
289 |
0.30f, 0.060f,
|
|
290 |
0.0f, 0.065f };
|
|
284 |
float[] bands0 = { 1.0f , 0,
|
|
285 |
1.0f-D/2, D*0.30f,
|
|
286 |
1.0f- D , D*0.50f,
|
|
287 |
1.0f-2*D, D*0.80f,
|
|
288 |
0.60f , D*1.40f,
|
|
289 |
0.30f , D*1.60f,
|
|
290 |
0.0f , D*1.70f };
|
|
291 | 291 |
|
292 | 292 |
MeshBase[] meshes = new MeshBase[FACES_PER_CUBIT]; |
293 | 293 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3); |
... | ... | |
296 | 296 |
association <<= 1; |
297 | 297 |
|
298 | 298 |
float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 }; |
299 |
float[] bands1 = { 1.0f, 0.0f, 0.0f, 0.0f }; |
|
299 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
300 | 300 |
|
301 | 301 |
meshes[1] = new MeshPolygon(vertices1,bands1,0,0); |
302 | 302 |
meshes[1].setEffectAssociation(0,association,0); |
... | ... | |
319 | 319 |
Static3D axis2 = new Static3D(0,0,1); |
320 | 320 |
float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3)); |
321 | 321 |
|
322 |
float f = 0.06f;
|
|
322 |
float f = 0.05f;
|
|
323 | 323 |
float r = 0.10f; |
324 | 324 |
float d = 0.5f; |
325 | 325 |
float e = +D*0.6f; |
... | ... | |
394 | 394 |
return FACE_COLORS.length; |
395 | 395 |
} |
396 | 396 |
|
397 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
398 |
// Each face has two types of a texture: the central square and the triangle in the corner. |
|
399 |
|
|
400 |
int getNumStickerTypes() |
|
401 |
{ |
|
402 |
return 2; |
|
403 |
} |
|
404 |
|
|
397 | 405 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
398 | 406 |
|
399 | 407 |
int getNumCubitFaces() |
... | ... | |
464 | 472 |
} |
465 | 473 |
|
466 | 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
467 |
// TODO |
|
468 | 475 |
|
469 | 476 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side) |
470 | 477 |
{ |
471 |
paint.setColor(FACE_COLORS[face]); |
|
472 |
paint.setStyle(Paint.Style.FILL); |
|
473 |
canvas.drawRect(left,top,left+side,top+side,paint); |
|
478 |
int COLORS = FACE_COLORS.length; |
|
479 |
|
|
480 |
if( face<COLORS ) |
|
481 |
{ |
|
482 |
float STROKE = 0.035f*side; |
|
483 |
float L= left+0.125f*side; |
|
484 |
float H= 0.375f*side; |
|
485 |
float LEN = 0.5f*side; |
|
486 |
|
|
487 |
paint.setAntiAlias(true); |
|
488 |
paint.setStrokeWidth(STROKE); |
|
489 |
paint.setColor(FACE_COLORS[face]); |
|
490 |
paint.setStyle(Paint.Style.FILL); |
|
491 |
|
|
492 |
canvas.drawRect(left,top,left+side,top+side,paint); |
|
493 |
|
|
494 |
paint.setColor(INTERIOR_COLOR); |
|
495 |
paint.setStyle(Paint.Style.STROKE); |
|
496 |
|
|
497 |
canvas.drawLine( L , H, L+LEN, H , paint); |
|
498 |
canvas.drawLine( L , H, L+LEN, H+LEN, paint); |
|
499 |
canvas.drawLine( L+LEN, H, L+LEN, H+LEN, paint); |
|
500 |
|
|
501 |
float S1 = 0.125f*side; |
|
502 |
float S2 = 0.070f*side; |
|
503 |
float X = 0.7f*S2; |
|
504 |
|
|
505 |
float LA = left+0.625f*side; |
|
506 |
float RA = left+0.125f*side; |
|
507 |
float TA = 0.375f*side; |
|
508 |
float BA = 0.875f*side; |
|
509 |
|
|
510 |
canvas.drawArc( LA-S1, TA , LA , TA+S1, 270, 90, false, paint); |
|
511 |
canvas.drawArc( RA+X , TA , RA+X+S2, TA+S2, 135,135, false, paint); |
|
512 |
canvas.drawArc( LA-S2, BA-X-S2, LA , BA-X , 0,135, false, paint); |
|
513 |
} |
|
514 |
else |
|
515 |
{ |
|
516 |
final float R = (SQ2/2)*side*0.10f; |
|
517 |
final float M = side*(0.5f-SQ2/4+0.018f); |
|
518 |
|
|
519 |
paint.setColor(FACE_COLORS[face-COLORS]); |
|
520 |
paint.setStyle(Paint.Style.FILL); |
|
521 |
canvas.drawRoundRect( left+M, top+M, left+side-M, top+side-M, R, R, paint); |
|
522 |
} |
|
474 | 523 |
} |
475 | 524 |
|
476 | 525 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with the Skewb.