Revision eab9d8f8
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/objects/RubikCube.java | ||
---|---|---|
167 | 167 |
return FACE_COLORS.length; |
168 | 168 |
} |
169 | 169 |
|
170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
171 |
|
|
172 |
int getNumStickerTypes() |
|
173 |
{ |
|
174 |
return 1; |
|
175 |
} |
|
176 |
|
|
170 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
171 | 178 |
|
172 | 179 |
int getNumCubitFaces() |
src/main/java/org/distorted/objects/RubikDino.java | ||
---|---|---|
266 | 266 |
return FACE_COLORS.length; |
267 | 267 |
} |
268 | 268 |
|
269 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
270 |
|
|
271 |
int getNumStickerTypes() |
|
272 |
{ |
|
273 |
return 1; |
|
274 |
} |
|
275 |
|
|
269 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
270 | 277 |
|
271 | 278 |
int getNumCubitFaces() |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
70 | 70 |
final Static4D[] QUATS; |
71 | 71 |
final Cubit[] CUBITS; |
72 | 72 |
final int NUM_FACES; |
73 |
final int NUM_TEXTURES; |
|
73 | 74 |
final int NUM_CUBIT_FACES; |
74 | 75 |
final int NUM_AXIS; |
75 | 76 |
final int NUM_CUBITS; |
... | ... | |
122 | 123 |
mInitScreenRatio = mObjectScreenRatio; |
123 | 124 |
NUM_FACES = getNumFaces(); |
124 | 125 |
NUM_CUBIT_FACES = getNumCubitFaces(); |
126 |
NUM_TEXTURES = getNumStickerTypes()*NUM_FACES; |
|
125 | 127 |
|
126 | 128 |
mSize = size; |
127 | 129 |
computeStartAndStep(mOrigPos); |
... | ... | |
385 | 387 |
Bitmap bitmap; |
386 | 388 |
|
387 | 389 |
Paint paint = new Paint(); |
388 |
bitmap = Bitmap.createBitmap( (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
|
|
390 |
bitmap = Bitmap.createBitmap( (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
|
|
389 | 391 |
Canvas canvas = new Canvas(bitmap); |
390 | 392 |
|
391 | 393 |
paint.setAntiAlias(true); |
... | ... | |
393 | 395 |
paint.setStyle(Paint.Style.FILL); |
394 | 396 |
|
395 | 397 |
paint.setColor(INTERIOR_COLOR); |
396 |
canvas.drawRect(0, 0, (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
|
|
398 |
canvas.drawRect(0, 0, (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
|
|
397 | 399 |
|
398 |
for(int i=0; i<NUM_FACES; i++)
|
|
400 |
for(int i=0; i<NUM_TEXTURES; i++)
|
|
399 | 401 |
{ |
400 | 402 |
createFaceTexture(canvas, paint, i, i*TEXTURE_HEIGHT, 0, TEXTURE_HEIGHT); |
401 | 403 |
} |
... | ... | |
486 | 488 |
|
487 | 489 |
public void resetAllTextureMaps() |
488 | 490 |
{ |
489 |
final float ratio = 1.0f/(NUM_FACES+1);
|
|
491 |
final float ratio = 1.0f/(NUM_TEXTURES+1);
|
|
490 | 492 |
int color; |
491 | 493 |
|
492 | 494 |
for(int cubit=0; cubit<NUM_CUBITS; cubit++) |
... | ... | |
507 | 509 |
|
508 | 510 |
public void setTextureMap(int cubit, int face, int newColor) |
509 | 511 |
{ |
510 |
final float ratio = 1.0f/(NUM_FACES+1);
|
|
512 |
final float ratio = 1.0f/(NUM_TEXTURES+1);
|
|
511 | 513 |
final Static4D[] maps = new Static4D[NUM_CUBIT_FACES]; |
512 | 514 |
|
513 | 515 |
maps[face] = new Static4D( newColor*ratio, 0.0f, ratio, 1.0f); |
... | ... | |
686 | 688 |
abstract Static3D[] getCubitPositions(int size); |
687 | 689 |
abstract Static4D[] getQuats(); |
688 | 690 |
abstract int getNumFaces(); |
691 |
abstract int getNumStickerTypes(); |
|
689 | 692 |
abstract int getNumCubitFaces(); |
690 | 693 |
abstract MeshBase createCubitMesh(int cubit); |
691 | 694 |
abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side); |
src/main/java/org/distorted/objects/RubikPyraminx.java | ||
---|---|---|
221 | 221 |
return FACE_COLORS.length; |
222 | 222 |
} |
223 | 223 |
|
224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
225 |
|
|
226 |
int getNumStickerTypes() |
|
227 |
{ |
|
228 |
return 1; |
|
229 |
} |
|
230 |
|
|
224 | 231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
225 | 232 |
|
226 | 233 |
int getNumCubitFaces() |
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.