Revision ae755eda
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/objects/FactoryCubit.java | ||
---|---|---|
289 | 289 |
{ |
290 | 290 |
MeshBase[] meshes = new MeshPolygon[8]; |
291 | 291 |
|
292 |
float E = SQ3/2;
|
|
292 |
float E = 0.75f;
|
|
293 | 293 |
float F = 0.5f; |
294 | 294 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
295 | 295 |
float[] bands = computeBands(0.05f,35,F,0.8f,6); |
... | ... | |
320 | 320 |
{ |
321 | 321 |
MeshBase[] meshes = new MeshBase[4]; |
322 | 322 |
|
323 |
float E = SQ3/2;
|
|
323 |
float E = 0.75f;
|
|
324 | 324 |
float F = 0.5f; |
325 | 325 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
326 | 326 |
float[] bands = computeBands(0.05f,35,F,0.8f,6); |
... | ... | |
478 | 478 |
meshes[2] = meshes[0].copy(true); |
479 | 479 |
meshes[2].setEffectAssociation(0,4,0); |
480 | 480 |
|
481 |
float F = SQ2/2;
|
|
481 |
float F = 0.5f;
|
|
482 | 482 |
float X = 0.5f; |
483 | 483 |
float G = 0.72f; |
484 | 484 |
float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F }; |
... | ... | |
616 | 616 |
Static3D cent0 = new Static3D(0,0,0); |
617 | 617 |
Static3D cent1 = new Static3D(0,SQ2/2,0); |
618 | 618 |
Static3D flipY = new Static3D( 1,-1, 1); |
619 |
Static3D scale = new Static3D( 1, 2*SQ3/3, 1); |
|
619 | 620 |
|
620 |
VertexEffect[] effect = new VertexEffect[6];
|
|
621 |
VertexEffect[] effect = new VertexEffect[7];
|
|
621 | 622 |
|
622 |
effect[0] = new VertexEffectMove(move1); |
|
623 |
effect[1] = new VertexEffectRotate(alpha , axisX, cent1); |
|
624 |
effect[2] = new VertexEffectRotate(angle1, axisY, cent0); |
|
625 |
effect[3] = new VertexEffectRotate(angle2, axisY, cent0); |
|
626 |
effect[4] = new VertexEffectRotate(angle3, axisY, cent0); |
|
627 |
effect[5] = new VertexEffectScale(flipY); |
|
623 |
effect[0] = new VertexEffectScale(scale); |
|
624 |
effect[1] = new VertexEffectMove(move1); |
|
625 |
effect[2] = new VertexEffectRotate(alpha , axisX, cent1); |
|
626 |
effect[3] = new VertexEffectRotate(angle1, axisY, cent0); |
|
627 |
effect[4] = new VertexEffectRotate(angle2, axisY, cent0); |
|
628 |
effect[5] = new VertexEffectRotate(angle3, axisY, cent0); |
|
629 |
effect[6] = new VertexEffectScale(flipY); |
|
628 | 630 |
|
629 |
effect[2].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
|
|
630 |
effect[3].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
|
|
631 |
effect[4].setMeshAssociation (136,-1); // apply to meshes 3 & 7
|
|
632 |
effect[5].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
|
|
631 |
effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
|
|
632 |
effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
|
|
633 |
effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
|
|
634 |
effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
|
|
633 | 635 |
|
634 | 636 |
return effect; |
635 | 637 |
} |
... | ... | |
639 | 641 |
VertexEffect[] createVertexEffectsTetra() |
640 | 642 |
{ |
641 | 643 |
Static3D flipZ = new Static3D( 1, 1,-1); |
642 |
|
|
643 | 644 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3))); |
644 | 645 |
Static1D angle1= new Static1D( 90); |
645 | 646 |
Static1D angle2= new Static1D(180); |
646 | 647 |
Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0); |
647 |
|
|
648 | 648 |
Static3D axisX = new Static3D(1,0,0); |
649 | 649 |
Static3D axisY = new Static3D(0,1,0); |
650 | 650 |
Static3D axisZ = new Static3D(0,0,1); |
651 |
|
|
652 | 651 |
Static3D cent0 = new Static3D(0,0,0); |
653 | 652 |
Static3D cent1 = new Static3D(0,SQ2/4,0); |
653 |
Static3D scale = new Static3D( 1, 2*SQ3/3, 1); |
|
654 | 654 |
|
655 |
VertexEffect[] effect = new VertexEffect[6];
|
|
655 |
VertexEffect[] effect = new VertexEffect[7];
|
|
656 | 656 |
|
657 |
effect[0] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
658 |
effect[1] = new VertexEffectMove(move1); |
|
659 |
effect[2] = new VertexEffectRotate(alpha , axisX, cent1); |
|
660 |
effect[3] = new VertexEffectScale(flipZ); |
|
661 |
effect[4] = new VertexEffectRotate(angle1, axisY, cent0); |
|
662 |
effect[5] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
663 |
|
|
664 |
effect[0].setMeshAssociation(15,-1); // meshes 0,1,2,3 |
|
665 |
effect[1].setMeshAssociation(15,-1); // meshes 0,1,2,3 |
|
666 |
effect[2].setMeshAssociation(15,-1); // meshes 0,1,2,3 |
|
667 |
effect[3].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
668 |
effect[4].setMeshAssociation(12,-1); // meshes 2 & 3 |
|
657 |
effect[0] = new VertexEffectScale(scale); |
|
658 |
effect[1] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
659 |
effect[2] = new VertexEffectMove(move1); |
|
660 |
effect[3] = new VertexEffectRotate(alpha , axisX, cent1); |
|
661 |
effect[4] = new VertexEffectScale(flipZ); |
|
662 |
effect[5] = new VertexEffectRotate(angle1, axisY, cent0); |
|
663 |
effect[6] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
664 |
|
|
665 |
effect[4].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
669 | 666 |
effect[5].setMeshAssociation(12,-1); // meshes 2 & 3 |
667 |
effect[6].setMeshAssociation(12,-1); // meshes 2 & 3 |
|
670 | 668 |
|
671 | 669 |
return effect; |
672 | 670 |
} |
... | ... | |
874 | 872 |
Static1D angle90 = new Static1D(90); |
875 | 873 |
Static1D angle270= new Static1D(270); |
876 | 874 |
Static1D angle45 = new Static1D(-45); |
875 |
Static3D scale = new Static3D(1.0f, SQ2, 1.0f); |
|
877 | 876 |
|
878 |
VertexEffect[] effect = new VertexEffect[6];
|
|
877 |
VertexEffect[] effect = new VertexEffect[7];
|
|
879 | 878 |
|
880 | 879 |
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f)); |
881 | 880 |
effect[1] = new VertexEffectRotate( angle270, axisX, center ); |
882 | 881 |
effect[2] = new VertexEffectRotate( angle90 , axisY, center ); |
883 |
effect[3] = new VertexEffectRotate( angle45 , axisX, center ); |
|
884 |
effect[4] = new VertexEffectRotate( angle90 , axisY, center ); |
|
885 |
effect[5] = new VertexEffectRotate( angle270, axisZ, center ); |
|
882 |
effect[3] = new VertexEffectScale(scale); |
|
883 |
effect[4] = new VertexEffectRotate( angle45 , axisX, center ); |
|
884 |
effect[5] = new VertexEffectRotate( angle90 , axisY, center ); |
|
885 |
effect[6] = new VertexEffectRotate( angle270, axisZ, center ); |
|
886 | 886 |
|
887 | 887 |
effect[0].setMeshAssociation( 7,-1); // 0,1,2 |
888 | 888 |
effect[1].setMeshAssociation( 2,-1); // 1 |
889 | 889 |
effect[2].setMeshAssociation( 4,-1); // 2 |
890 |
effect[3].setMeshAssociation(56,-1); // 3 |
|
891 |
effect[4].setMeshAssociation(16,-1); // 4 |
|
892 |
effect[5].setMeshAssociation(32,-1); // 5 |
|
890 |
effect[3].setMeshAssociation(56,-1); // 3,4,5 |
|
891 |
effect[4].setMeshAssociation(56,-1); // 3,4,5 |
|
892 |
effect[5].setMeshAssociation(16,-1); // 4 |
|
893 |
effect[6].setMeshAssociation(32,-1); // 5 |
|
893 | 894 |
|
894 | 895 |
return effect; |
895 | 896 |
} |
src/main/java/org/distorted/objects/FactorySticker.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 64 |
|
65 |
private void drawCurrVertex(Canvas canvas, Paint paint, float left, float r, float stroke, float pX, float pY, float cX, float cY, float nX, float nY)
|
|
65 |
private void drawCurrVertex(Canvas canvas, Paint paint, int left, int top, float r, float stroke, float pX, float pY, float cX, float cY, float nX, float nY)
|
|
66 | 66 |
{ |
67 | 67 |
pX = (0.5f+pX)*TEXTURE_HEIGHT; |
68 | 68 |
pY = (0.5f-pY)*TEXTURE_HEIGHT; |
... | ... | |
71 | 71 |
nX = (0.5f+nX)*TEXTURE_HEIGHT; |
72 | 72 |
nY = (0.5f-nY)*TEXTURE_HEIGHT; |
73 | 73 |
|
74 |
canvas.drawLine(left+pX,pY,left+cX,cY,paint);
|
|
74 |
canvas.drawLine(left+pX,top+pY,left+cX,top+cY,paint);
|
|
75 | 75 |
|
76 | 76 |
float aX = pX-cX; |
77 | 77 |
float aY = pY-cY; |
... | ... | |
107 | 107 |
startAngle *= 180/(Math.PI); |
108 | 108 |
sweepAngle *= 180/(Math.PI); |
109 | 109 |
|
110 |
canvas.drawArc( left+rX-R, rY-R, left+rX+R, rY+R, startAngle, sweepAngle, false, paint);
|
|
110 |
canvas.drawArc( left+rX-R, top+rY-R, left+rX+R, top+rY+R, startAngle, sweepAngle, false, paint);
|
|
111 | 111 |
} |
112 | 112 |
|
113 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
114 | 114 |
|
115 |
void drawRoundedPolygon(Canvas canvas, Paint paint, int left, float[] vertices, float stroke, int color, float r) |
|
115 |
void drawRoundedPolygon(Canvas canvas, Paint paint, int left, int top, float[] vertices, float stroke, int color, float r)
|
|
116 | 116 |
{ |
117 | 117 |
stroke *= TEXTURE_HEIGHT; |
118 | 118 |
|
... | ... | |
121 | 121 |
paint.setColor(color); |
122 | 122 |
paint.setStyle(Paint.Style.FILL); |
123 | 123 |
|
124 |
canvas.drawRect(left,0,left+TEXTURE_HEIGHT,TEXTURE_HEIGHT,paint);
|
|
124 |
canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
|
|
125 | 125 |
|
126 | 126 |
paint.setColor(COLOR_BLACK); |
127 | 127 |
paint.setStyle(Paint.Style.STROKE); |
... | ... | |
138 | 138 |
|
139 | 139 |
for(int vert=0; vert<numVertices; vert++) |
140 | 140 |
{ |
141 |
drawCurrVertex(canvas, paint, left, r, stroke, prevX,prevY,currX,currY,nextX,nextY); |
|
141 |
drawCurrVertex(canvas, paint, left, top, r, stroke, prevX,prevY,currX,currY,nextX,nextY);
|
|
142 | 142 |
|
143 | 143 |
prevX = currX; |
144 | 144 |
prevY = currY; |
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
123 | 123 |
|
124 | 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
125 | 125 |
|
126 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
126 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
127 | 127 |
{ |
128 | 128 |
float F = 0.5f; |
129 | 129 |
float R = 0.10f; |
... | ... | |
131 | 131 |
float[] vertices = { -F,-F, +F,-F, +F,+F, -F,+F}; |
132 | 132 |
|
133 | 133 |
FactorySticker factory = FactorySticker.getInstance(); |
134 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
134 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
135 | 135 |
} |
136 | 136 |
|
137 | 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
244 | 244 |
|
245 | 245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
246 | 246 |
|
247 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
247 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
248 | 248 |
{ |
249 |
float E = SQ3/2;
|
|
250 |
float F = 0.5f;
|
|
249 |
float E = 0.75f;
|
|
250 |
float F = 0.50f;
|
|
251 | 251 |
float R = 0.06f; |
252 | 252 |
float S = 0.07f; |
253 | 253 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
254 | 254 |
|
255 | 255 |
FactorySticker factory = FactorySticker.getInstance(); |
256 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
256 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
209 | 209 |
|
210 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
211 | 211 |
|
212 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
212 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
213 | 213 |
{ |
214 | 214 |
float F = 0.5f; |
215 | 215 |
float R = 0.025f; |
... | ... | |
217 | 217 |
float[] vertices = { -F,F/3, 0,-2*F/3, +F,F/3 }; |
218 | 218 |
|
219 | 219 |
FactorySticker factory = FactorySticker.getInstance(); |
220 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
220 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
288 | 288 |
|
289 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
290 | 290 |
|
291 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
291 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
292 | 292 |
{ |
293 | 293 |
float R = 0.023f; |
294 | 294 |
float S = 0.035f; |
... | ... | |
296 | 296 |
float[] vertices = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
297 | 297 |
|
298 | 298 |
FactorySticker factory = FactorySticker.getInstance(); |
299 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
299 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
300 | 300 |
} |
301 | 301 |
|
302 | 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
67 | 67 |
static final int COLOR_BLACK = 0xff000000; |
68 | 68 |
|
69 | 69 |
static final int TEXTURE_HEIGHT = 256; |
70 |
static final int NUM_STICKERS_IN_ROW = 4; |
|
70 | 71 |
|
71 | 72 |
static final float SQ2 = (float)Math.sqrt(2); |
72 | 73 |
static final float SQ3 = (float)Math.sqrt(3); |
... | ... | |
110 | 111 |
private Static3D mRotationAxis; |
111 | 112 |
private Static3D mObjectScale; |
112 | 113 |
private int[] mQuatDebug; |
114 |
private int mNumTexRows, mNumTexCols; |
|
113 | 115 |
|
114 | 116 |
float[] mRowChances; |
115 | 117 |
Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal; |
... | ... | |
170 | 172 |
MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale); |
171 | 173 |
nodeEffects.apply(nodeScaleEffect); |
172 | 174 |
|
175 |
mNumTexCols = NUM_STICKERS_IN_ROW; |
|
176 |
mNumTexRows = (NUM_TEXTURES+1)/NUM_STICKERS_IN_ROW; |
|
177 |
|
|
178 |
if( mNumTexCols*mNumTexRows < NUM_TEXTURES+1 ) mNumTexRows++; |
|
179 |
|
|
173 | 180 |
CUBITS = new Cubit[NUM_CUBITS]; |
174 | 181 |
createMeshAndCubits(list,res); |
175 | 182 |
|
... | ... | |
372 | 379 |
} |
373 | 380 |
|
374 | 381 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
375 |
// the getFaceColors + final black in a horizontal strip.
|
|
382 |
// the getFaceColors + final black in a grid (so that we do not exceed the maximum texture size)
|
|
376 | 383 |
|
377 | 384 |
public void createTexture() |
378 | 385 |
{ |
379 | 386 |
Bitmap bitmap; |
380 | 387 |
|
381 | 388 |
Paint paint = new Paint(); |
382 |
bitmap = Bitmap.createBitmap( (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
|
|
389 |
bitmap = Bitmap.createBitmap( mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
|
|
383 | 390 |
Canvas canvas = new Canvas(bitmap); |
384 | 391 |
|
385 | 392 |
paint.setAntiAlias(true); |
... | ... | |
387 | 394 |
paint.setStyle(Paint.Style.FILL); |
388 | 395 |
|
389 | 396 |
paint.setColor(COLOR_BLACK); |
390 |
canvas.drawRect(0, 0, (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
|
|
397 |
canvas.drawRect(0, 0, mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, paint);
|
|
391 | 398 |
|
392 |
for(int i=0; i<NUM_TEXTURES; i++) |
|
393 |
{ |
|
394 |
createFaceTexture(canvas, paint, i, i*TEXTURE_HEIGHT); |
|
395 |
} |
|
399 |
int tex = 0; |
|
400 |
|
|
401 |
for(int row=0; row<mNumTexRows; row++) |
|
402 |
for(int col=0; col<mNumTexCols; col++) |
|
403 |
{ |
|
404 |
if( tex>=NUM_TEXTURES ) break; |
|
405 |
createFaceTexture(canvas, paint, tex, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT); |
|
406 |
tex++; |
|
407 |
} |
|
396 | 408 |
|
397 | 409 |
if( !mTexture.setTexture(bitmap) ) |
398 | 410 |
{ |
... | ... | |
516 | 528 |
|
517 | 529 |
public void resetAllTextureMaps() |
518 | 530 |
{ |
519 |
final float ratio = 1.0f/(NUM_TEXTURES+1); |
|
520 |
int color; |
|
531 |
final float ratioW = 1.0f/mNumTexCols; |
|
532 |
final float ratioH = 1.0f/mNumTexRows; |
|
533 |
int color, row, col; |
|
521 | 534 |
|
522 | 535 |
for(int cubit=0; cubit<NUM_CUBITS; cubit++) |
523 | 536 |
{ |
... | ... | |
526 | 539 |
for(int cubitface=0; cubitface<NUM_CUBIT_FACES; cubitface++) |
527 | 540 |
{ |
528 | 541 |
color = getFaceColor(cubit,cubitface,mNumLayers); |
529 |
maps[cubitface] = new Static4D( color*ratio, 0.0f, ratio, 1.0f); |
|
542 |
row = (mNumTexRows-1) - color/mNumTexCols; |
|
543 |
col = color%mNumTexCols; |
|
544 |
maps[cubitface] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH); |
|
530 | 545 |
} |
531 | 546 |
|
532 | 547 |
mMesh.setTextureMap(maps,NUM_CUBIT_FACES*cubit); |
... | ... | |
713 | 728 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
714 | 729 |
|
715 | 730 |
abstract float getScreenRatio(); |
716 |
abstract Static3D[] getCubitPositions(int size);
|
|
731 |
abstract Static3D[] getCubitPositions(int numLayers);
|
|
717 | 732 |
abstract Static4D[] getQuats(); |
718 | 733 |
abstract int getNumFaces(); |
719 | 734 |
abstract int getNumStickerTypes(); |
720 | 735 |
abstract int getNumCubitFaces(); |
721 | 736 |
abstract MeshBase createCubitMesh(int cubit); |
722 |
abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left); |
|
723 |
abstract int getFaceColor(int cubit, int cubitface, int size);
|
|
737 |
abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top);
|
|
738 |
abstract int getFaceColor(int cubit, int cubitface, int numLayers);
|
|
724 | 739 |
abstract float returnMultiplier(); |
725 | 740 |
abstract float[] getRowChances(); |
726 |
abstract float[] getCuts(int size);
|
|
741 |
abstract float[] getCuts(int numLayers);
|
|
727 | 742 |
abstract boolean shouldResetTextureMaps(); |
728 | 743 |
|
729 | 744 |
public abstract boolean isSolved(); |
src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
---|---|---|
237 | 237 |
|
238 | 238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
239 | 239 |
|
240 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
240 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
241 | 241 |
{ |
242 |
float E = SQ3/2;
|
|
243 |
float F = 0.5f;
|
|
242 |
float E = 0.75f;
|
|
243 |
float F = 0.50f;
|
|
244 | 244 |
float R = 0.06f; |
245 | 245 |
float S = 0.08f; |
246 | 246 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
247 | 247 |
|
248 | 248 |
FactorySticker factory = FactorySticker.getInstance(); |
249 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
249 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
250 | 250 |
} |
251 | 251 |
|
252 | 252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
268 | 268 |
|
269 | 269 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
270 | 270 |
|
271 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
271 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
272 | 272 |
{ |
273 | 273 |
int COLORS = FACE_COLORS.length; |
274 | 274 |
FactorySticker factory = FactorySticker.getInstance(); |
... | ... | |
280 | 280 |
float S = 0.10f; |
281 | 281 |
float[] vertices = { -F,-F, +F,-F, +F,+F, -F,+F}; |
282 | 282 |
|
283 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
283 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
284 | 284 |
} |
285 | 285 |
else |
286 | 286 |
{ |
... | ... | |
289 | 289 |
float S = 0.05f; |
290 | 290 |
float[] vertices = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F }; |
291 | 291 |
|
292 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face-COLORS], R); |
|
292 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face-COLORS], R);
|
|
293 | 293 |
} |
294 | 294 |
} |
295 | 295 |
|
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
461 | 461 |
|
462 | 462 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
463 | 463 |
|
464 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left) |
|
464 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
|
465 | 465 |
{ |
466 | 466 |
int COLORS = FACE_COLORS.length; |
467 |
FactorySticker factory = FactorySticker.getInstance(); |
|
467 |
float R,S; |
|
468 |
float[] vertices; |
|
468 | 469 |
|
469 | 470 |
if( face<COLORS ) |
470 | 471 |
{ |
471 |
float R = 0.023f; |
|
472 |
float S = 0.035f; |
|
473 | 472 |
float E = 0.5f; |
474 |
float[] vertices = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
|
475 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R); |
|
473 |
R = 0.023f; |
|
474 |
S = 0.035f; |
|
475 |
vertices = new float[] { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
|
476 | 476 |
} |
477 | 477 |
else if( face<2*COLORS ) |
478 | 478 |
{ |
479 |
float F = 0.5f; |
|
480 |
float R = 0.025f; |
|
481 |
float S = 0.05f; |
|
482 |
float[] vertices = { -F,F/3, 0,-2*F/3, +F,F/3 }; |
|
483 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face-COLORS], R); |
|
479 |
float E = 0.5f; |
|
480 |
R = 0.025f; |
|
481 |
S = 0.05f; |
|
482 |
vertices = new float[] { -E,E/3, 0,-2*E/3, +E,E/3 }; |
|
484 | 483 |
} |
485 | 484 |
else |
486 | 485 |
{ |
487 |
float R = 0.055f; |
|
488 |
float S = 0.035f; |
|
489 | 486 |
float E = SQ2/4; |
490 |
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E }; |
|
491 |
factory.drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face-2*COLORS], R); |
|
487 |
R = 0.055f; |
|
488 |
S = 0.035f; |
|
489 |
vertices = new float[] { -E,-E, +E,-E, +E,+E, -E,+E }; |
|
492 | 490 |
} |
491 |
|
|
492 |
FactorySticker factory = FactorySticker.getInstance(); |
|
493 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face%COLORS], R); |
|
493 | 494 |
} |
494 | 495 |
|
495 | 496 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Make the texture multi-row: avoid the maximum texture size.