Revision 886d1ebb
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/objects/FactoryCubit.java | ||
---|---|---|
36 | 36 |
class FactoryCubit |
37 | 37 |
{ |
38 | 38 |
static final float IVY_D = 0.02f; |
39 |
static final float IVY_C = 0.60f; |
|
40 |
static final float IVY_M = 0.35f; |
|
39 | 41 |
|
40 | 42 |
private static final float SQ2 = (float)Math.sqrt(2); |
41 | 43 |
private static final float SQ3 = (float)Math.sqrt(3); |
... | ... | |
505 | 507 |
|
506 | 508 |
final float angle = (float)Math.PI/(2*IVY_N); |
507 | 509 |
final float CORR = 1.0f - 2*IVY_D; |
508 |
final float DIST = 0.4f; |
|
509 |
final float DIST2 = -0.5f*CORR + IVY_D; |
|
510 |
final float CORR2 = 0.5f; |
|
511 |
float[] vertices = new float[2*(IVY_N+1)+6]; |
|
512 |
|
|
513 |
vertices[0] = (0.5f -DIST) * CORR2; |
|
514 |
vertices[1] = (DIST2-DIST) * CORR2; |
|
515 |
vertices[2] = (0.5f -DIST) * CORR2; |
|
516 |
vertices[3] = (0.5f -DIST) * CORR2; |
|
517 |
vertices[4] = (DIST2-DIST) * CORR2; |
|
518 |
vertices[5] = (0.5f -DIST) * CORR2; |
|
510 |
final float DIST = -0.5f*CORR + IVY_D; |
|
511 |
float[] vertices = new float[2*(IVY_N+1)+6]; |
|
512 |
|
|
513 |
vertices[0] = (0.5f-IVY_M) * IVY_C; |
|
514 |
vertices[1] = (DIST-IVY_M) * IVY_C; |
|
515 |
vertices[2] = (0.5f-IVY_M) * IVY_C; |
|
516 |
vertices[3] = (0.5f-IVY_M) * IVY_C; |
|
517 |
vertices[4] = (DIST-IVY_M) * IVY_C; |
|
518 |
vertices[5] = (0.5f-IVY_M) * IVY_C; |
|
519 | 519 |
|
520 | 520 |
for(int i=0; i<=IVY_N; i++) |
521 | 521 |
{ |
... | ... | |
523 | 523 |
float sin = (float)Math.sin(ang); |
524 | 524 |
float cos = (float)Math.cos(ang); |
525 | 525 |
|
526 |
vertices[2*i+6] = (CORR*(cos-0.5f)-DIST)*CORR2;
|
|
527 |
vertices[2*i+7] = (CORR*(sin-0.5f)-DIST)*CORR2;
|
|
526 |
vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
|
|
527 |
vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
|
|
528 | 528 |
} |
529 | 529 |
|
530 |
float[] bands0 = computeBands(+0.02f,12,0.2f,0.5f,5);
|
|
530 |
float[] bands0 = computeBands(+0.01f,12,0.2f,0.5f,5);
|
|
531 | 531 |
float[] bands1 = computeBands(-0.10f,20,0.2f,0.0f,2); |
532 | 532 |
|
533 | 533 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0); |
... | ... | |
567 | 567 |
vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f); |
568 | 568 |
} |
569 | 569 |
|
570 |
float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
|
|
570 |
float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
|
|
571 | 571 |
float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2); |
572 | 572 |
|
573 | 573 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0); |
... | ... | |
983 | 983 |
|
984 | 984 |
VertexEffect[] createVertexEffectsIvyCorner() |
985 | 985 |
{ |
986 |
float DIST=0.1f; |
|
987 |
|
|
988 | 986 |
Static3D axisX = new Static3D(1,0,0); |
989 | 987 |
Static3D axisY = new Static3D(0,1,0); |
990 | 988 |
Static1D angle1 = new Static1D(+90); |
991 | 989 |
Static1D angle2 = new Static1D(-90); |
992 | 990 |
Static3D center = new Static3D(0,0,0); |
993 |
Static3D move1 = new Static3D(-DIST,-DIST,0);
|
|
991 |
Static3D move1 = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
|
|
994 | 992 |
|
995 | 993 |
VertexEffect[] effect = new VertexEffect[5]; |
996 | 994 |
|
997 |
effect[0] = new VertexEffectScale(2.0f);
|
|
995 |
effect[0] = new VertexEffectScale(1/IVY_C);
|
|
998 | 996 |
effect[1] = new VertexEffectMove(move1); |
999 | 997 |
effect[2] = new VertexEffectScale(new Static3D(1,1,-1)); |
1000 | 998 |
effect[3] = new VertexEffectRotate(angle1,axisX,center); |
src/main/java/org/distorted/objects/FactorySticker.java | ||
---|---|---|
25 | 25 |
import static org.distorted.objects.TwistyObject.TEXTURE_HEIGHT; |
26 | 26 |
import static org.distorted.objects.TwistyObject.COLOR_BLACK; |
27 | 27 |
import static org.distorted.objects.FactoryCubit.IVY_D; |
28 |
import static org.distorted.objects.FactoryCubit.IVY_C; |
|
29 |
import static org.distorted.objects.FactoryCubit.IVY_M; |
|
28 | 30 |
|
29 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 32 |
|
... | ... | |
168 | 170 |
paint.setStyle(Paint.Style.FILL); |
169 | 171 |
canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint); |
170 | 172 |
|
171 |
float CORR = 0.5f; |
|
172 |
float DIST = 0.4f; |
|
173 |
|
|
174 | 173 |
paint.setColor(COLOR_BLACK); |
175 | 174 |
paint.setStyle(Paint.Style.STROKE); |
176 |
paint.setStrokeWidth(CORR*stroke*TEXTURE_HEIGHT);
|
|
175 |
paint.setStrokeWidth(IVY_C*stroke*TEXTURE_HEIGHT);
|
|
177 | 176 |
|
178 |
float tmp1 = ((IVY_D-0.5f)-DIST)*CORR;
|
|
177 |
float tmp1 = ((IVY_D-0.5f)-IVY_M)*IVY_C;
|
|
179 | 178 |
float cx1 = TEXTURE_HEIGHT*(tmp1 + 0.5f); |
180 | 179 |
float cy1 = TEXTURE_HEIGHT*(0.5f - tmp1); |
181 | 180 |
|
182 |
float halfL1 = CORR*TEXTURE_HEIGHT*(1.0f-2*IVY_D);
|
|
181 |
float halfL1 = IVY_C*TEXTURE_HEIGHT*(1.0f-2*IVY_D);
|
|
183 | 182 |
|
184 | 183 |
canvas.drawArc( left+cx1-halfL1, top+cy1-halfL1, left+cx1+halfL1, top+cy1+halfL1, 270, 90, false, paint); |
185 | 184 |
|
186 |
float tmp2 = (+0.5f-DIST)*CORR;
|
|
187 |
float tmp3 = (-0.5f-DIST)*CORR;
|
|
185 |
float tmp2 = (+0.5f-IVY_M)*IVY_C;
|
|
186 |
float tmp3 = (-0.5f-IVY_M)*IVY_C;
|
|
188 | 187 |
|
189 | 188 |
float x0 = TEXTURE_HEIGHT*(+tmp2 + 0.5f); |
190 | 189 |
float y0 = TEXTURE_HEIGHT*(-tmp3 + 0.5f); |
... | ... | |
196 | 195 |
canvas.drawLine(left+x0,top+y0,left+x1,top+y1,paint); |
197 | 196 |
canvas.drawLine(left+x1,top+y1,left+x2,top+y2,paint); |
198 | 197 |
|
199 |
float tmp4 = ((0.5f-stroke/2-radius/2)-DIST)*CORR;
|
|
198 |
float tmp4 = ((0.5f-stroke/2-radius/2)-IVY_M)*IVY_C;
|
|
200 | 199 |
float cx2 = TEXTURE_HEIGHT*(tmp4 + 0.5f); |
201 | 200 |
float cy2 = TEXTURE_HEIGHT*(0.5f - tmp4); |
202 | 201 |
|
203 |
float halfL2 = CORR*TEXTURE_HEIGHT*radius;
|
|
202 |
float halfL2 = IVY_C*TEXTURE_HEIGHT*radius;
|
|
204 | 203 |
|
205 |
paint.setStrokeWidth(CORR*radius*TEXTURE_HEIGHT);
|
|
204 |
paint.setStrokeWidth(IVY_C*radius*TEXTURE_HEIGHT);
|
|
206 | 205 |
canvas.drawArc( left+cx2-halfL2, top+cy2-halfL2, left+cx2+halfL2, top+cy2+halfL2, 270, 90, false, paint); |
207 | 206 |
} |
208 | 207 |
|
... | ... | |
228 | 227 |
|
229 | 228 |
canvas.drawArc( left+cx1-halfL, top+cy1-halfL, left+cx1+halfL, top+cy1+halfL, 270, 90, false, paint); |
230 | 229 |
canvas.drawArc( left+cx2-halfL, top+cy2-halfL, left+cx2+halfL, top+cy2+halfL, 90, 90, false, paint); |
230 |
|
|
231 |
float tmp = TEXTURE_HEIGHT*(IVY_D+stroke*0.5f+radius*0.5f); |
|
232 |
float cx3 = tmp; |
|
233 |
float cy3 = tmp; |
|
234 |
float cx4 = TEXTURE_HEIGHT - cx3; |
|
235 |
float cy4 = TEXTURE_HEIGHT - cy3; |
|
236 |
float halfR = TEXTURE_HEIGHT*radius; |
|
237 |
|
|
238 |
paint.setStrokeWidth(radius*TEXTURE_HEIGHT); |
|
239 |
canvas.drawArc( left+cx3-halfR, top+cy3-halfR, left+cx3+halfR, top+cy3+halfR, 180, 90, false, paint); |
|
240 |
canvas.drawArc( left+cx4-halfR, top+cy4-halfR, left+cx4+halfR, top+cy4+halfR, 0, 90, false, paint); |
|
231 | 241 |
} |
232 | 242 |
} |
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
235 | 235 |
int COLORS = FACE_COLORS.length; |
236 | 236 |
FactorySticker factory = FactorySticker.getInstance(); |
237 | 237 |
float S = 0.08f; |
238 |
float R = 0.06f;
|
|
238 |
float R = 0.12f;
|
|
239 | 239 |
|
240 | 240 |
if( face<COLORS ) |
241 | 241 |
{ |
Also available in: Unified diff
Progress with the Ivy.