Project

General

Profile

« Previous | Next » 

Revision dad33773

Added by Leszek Koltunski over 3 years ago

Progress with the Rex Cube (stickers)

View differences:

src/main/java/org/distorted/objects/FactorySticker.java
27 27
import static org.distorted.objects.FactoryCubit.IVY_D;
28 28
import static org.distorted.objects.FactoryCubit.IVY_C;
29 29
import static org.distorted.objects.FactoryCubit.IVY_M;
30
import static org.distorted.objects.FactoryCubit.REX_D;
30 31

  
31 32
///////////////////////////////////////////////////////////////////////////////////////////////////
32 33

  
33 34
class FactorySticker
34 35
  {
36
  private static final float SQ2 = (float)Math.sqrt(2);
37
  private static final float SQ3 = (float)Math.sqrt(3);
38

  
35 39
  private static FactorySticker mThis;
36 40

  
37 41
///////////////////////////////////////////////////////////////////////////////////////////////////
......
248 252
    paint.setColor(color);
249 253
    paint.setStyle(Paint.Style.FILL);
250 254
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
255

  
256
    paint.setColor(COLOR_BLACK);
257
    paint.setStyle(Paint.Style.STROKE);
258
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
259

  
260
    float T  = (0.5f-REX_D)*SQ2*(SQ3-1);
261
    float H1 = T*(1.0f + 2*SQ3/3);
262
    float H2 = T*(0.5f +   SQ3/6);
263
    float D  = H2*SQ3;
264

  
265
    float cx1 = left+ TEXTURE_HEIGHT*0.5f;
266
    float cy1 = top + TEXTURE_HEIGHT*(0.5f+H1);
267
    float cx2 = left+ TEXTURE_HEIGHT*(0.5f-D);
268
    float cy2 = top + TEXTURE_HEIGHT*(0.5f+H2);
269
    float cx3 = left+ TEXTURE_HEIGHT*(0.5f+D);
270
    float cy3 = top + TEXTURE_HEIGHT*(0.5f+H2);
271

  
272
    float R1= TEXTURE_HEIGHT*(1-2*REX_D);
273

  
274
    canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 255, 30, false ,paint);
275
    canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1, 315, 30, false ,paint);
276
    canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 195, 30, false ,paint);
277
/*
278
    float cx   = left+ TEXTURE_HEIGHT*0.5f;
279
    float cy   = top + TEXTURE_HEIGHT*0.5f;
280
    float R2   = radius*TEXTURE_HEIGHT;
281
    float dist = ( (0.5f-REX_D)*(SQ3-1) - (2*SQ3/3)*radius )*TEXTURE_HEIGHT;
282

  
283
    canvas.drawArc( cx+dist-R2, cy-R2, cx+dist+R2, cy+R2, 330, 60, false ,paint);
284
    canvas.drawArc( cx-R2, cy+dist-R2, cx+R2, cy+dist+R2,  60, 60, false ,paint);
285
    canvas.drawArc( cx-dist-R2, cy-R2, cx-dist+R2, cy+R2, 150, 60, false ,paint);
286
    canvas.drawArc( cx-R2, cy-dist-R2, cx+R2, cy-dist+R2, 240, 60, false ,paint);
287
 */
251 288
    }
252 289

  
253 290
///////////////////////////////////////////////////////////////////////////////////////////////////
254
// TODO
255 291

  
256 292
  void drawRexFaceSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius)
257 293
    {
258 294
    paint.setColor(color);
259 295
    paint.setStyle(Paint.Style.FILL);
260 296
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
297

  
298
    paint.setColor(COLOR_BLACK);
299
    paint.setStyle(Paint.Style.STROKE);
300
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
301

  
302
    float cx1 = left+ TEXTURE_HEIGHT*REX_D;
303
    float cy1 = top + TEXTURE_HEIGHT*(1-REX_D);
304
    float cx2 = left+ TEXTURE_HEIGHT*REX_D;
305
    float cy2 = top + TEXTURE_HEIGHT*REX_D;
306
    float cx3 = left+ TEXTURE_HEIGHT*(1-REX_D);
307
    float cy3 = top + TEXTURE_HEIGHT*REX_D;
308
    float cx4 = left+ TEXTURE_HEIGHT*(1-REX_D);
309
    float cy4 = top + TEXTURE_HEIGHT*(1-REX_D);
310
    float R1  = TEXTURE_HEIGHT*(1-2*REX_D);
311

  
312
    canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 300, 30, false ,paint);
313
    canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1,  30, 30, false ,paint);
314
    canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 120, 30, false ,paint);
315
    canvas.drawArc( cx4-R1, cy4-R1, cx4+R1, cy4+R1, 210, 30, false ,paint);
316

  
317
    float cx   = left+ TEXTURE_HEIGHT*0.5f;
318
    float cy   = top + TEXTURE_HEIGHT*0.5f;
319
    float R2   = radius*TEXTURE_HEIGHT;
320
    float dist = ( (0.5f-REX_D)*(SQ3-1) - (2*SQ3/3)*radius )*TEXTURE_HEIGHT;
321

  
322
    canvas.drawArc( cx+dist-R2, cy-R2, cx+dist+R2, cy+R2, 330, 60, false ,paint);
323
    canvas.drawArc( cx-R2, cy+dist-R2, cx+R2, cy+dist+R2,  60, 60, false ,paint);
324
    canvas.drawArc( cx-dist-R2, cy-R2, cx-dist+R2, cy+R2, 150, 60, false ,paint);
325
    canvas.drawArc( cx-R2, cy-dist-R2, cx+R2, cy-dist+R2, 240, 60, false ,paint);
261 326
    }
262 327

  
263 328
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRex.java
112 112
           { 10, 18,18,18 },
113 113
           { 11, 18,18,18 },
114 114

  
115
           {  4, 2, 18,18 },
116
           {  4, 0, 18,18 },
117
           {  4, 3, 18,18 },
118
           {  4, 1, 18,18 },
119
           {  0, 2, 18,18 },
120
           {  3, 0, 18,18 },
121
           {  3, 1, 18,18 },
122
           {  1, 2, 18,18 },
123
           {  2, 5, 18,18 },
124
           {  0, 5, 18,18 },
125
           {  5, 3, 18,18 },
126
           {  1, 5, 18,18 },
115
           { 16,14, 18,18 },
116
           { 16,12, 18,18 },
117
           { 16,15, 18,18 },
118
           { 16,13, 18,18 },
119
           { 12,14, 18,18 },
120
           { 15,12, 18,18 },
121
           { 15,13, 18,18 },
122
           { 13,14, 18,18 },
123
           { 14,17, 18,18 },
124
           { 12,17, 18,18 },
125
           { 17,15, 18,18 },
126
           { 13,17, 18,18 },
127 127
         };
128 128

  
129 129
  private static MeshBase mCornerMesh, mFaceMesh, mEdgeMesh;

Also available in: Unified diff