Project

General

Profile

« Previous | Next » 

Revision 0b8ffe1a

Added by Leszek Koltunski about 4 years ago

Progress with the Rex Cube (stickers)

View differences:

src/main/java/org/distorted/objects/FactoryCubit.java
1521 1521
    Static3D center = new Static3D(0.0f,0.0f,-H);
1522 1522
    Static3D[] vertices = new Static3D[1];
1523 1523
    vertices[0] = new Static3D(+G,-G,+0.0f);
1524
    roundCorners(mesh,center,vertices,0.12f,0.15f);
1524
    roundCorners(mesh,center,vertices,0.08f,0.10f);
1525 1525

  
1526 1526
    mesh.mergeEffComponents();
1527 1527
    mesh.addEmptyTexComponent();
......
1555 1555
    Static3D[] vertices = new Static3D[2];
1556 1556
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1557 1557
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1558
    roundCorners(mesh,center,vertices,0.08f,0.15f);
1558
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1559 1559

  
1560 1560
    mesh.mergeEffComponents();
1561 1561

  
src/main/java/org/distorted/objects/FactorySticker.java
245 245
    }
246 246

  
247 247
///////////////////////////////////////////////////////////////////////////////////////////////////
248
// TODO
249 248

  
250 249
  void drawRexCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius)
251 250
    {
......
257 256
    paint.setStyle(Paint.Style.STROKE);
258 257
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
259 258

  
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);
259
    float F  = (0.5f-REX_D)*SQ2*(SQ3-1);
260
    float H1 = F*(1.0f + 2*SQ3/3);
261
    float H2 = F*(0.5f +   SQ3/6);
263 262
    float D  = H2*SQ3;
264 263

  
265 264
    float cx1 = left+ TEXTURE_HEIGHT*0.5f;
......
274 273
    canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 255, 30, false ,paint);
275 274
    canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1, 315, 30, false ,paint);
276 275
    canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 195, 30, false ,paint);
277
/*
276

  
278 277
    float cx   = left+ TEXTURE_HEIGHT*0.5f;
279 278
    float cy   = top + TEXTURE_HEIGHT*0.5f;
280 279
    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
 */
280
    float dist = ( (SQ3/3)*F - SQ2*radius )*TEXTURE_HEIGHT;
281
    float dist2= 1.0f*(SQ3/3)*F*TEXTURE_HEIGHT;
282
    float tmp  = SQ2*radius*TEXTURE_HEIGHT;
283
    float distX= (SQ3/2)*dist2 - 1.05f*tmp;
284
    float distY= (0.5f )*dist2 - 0.90f*tmp;
285

  
286
    canvas.drawArc( cx      -R2, cy-dist -R2, cx      +R2, cy-dist +R2, 225, 90, false ,paint);
287
    canvas.drawArc( cx-distX-R2, cy+distY-R2, cx-distX+R2, cy+distY+R2,  75,120, false ,paint);
288
    canvas.drawArc( cx+distX-R2, cy+distY-R2, cx+distX+R2, cy+distY+R2, 345,120, false ,paint);
288 289
    }
289 290

  
290 291
///////////////////////////////////////////////////////////////////////////////////////////////////
......
326 327
    }
327 328

  
328 329
///////////////////////////////////////////////////////////////////////////////////////////////////
329
// TODO
330 330

  
331 331
  void drawRexEdgeSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius)
332 332
    {
333 333
    paint.setColor(color);
334 334
    paint.setStyle(Paint.Style.FILL);
335 335
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
336

  
337
    paint.setColor(COLOR_BLACK);
338
    paint.setStyle(Paint.Style.STROKE);
339
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
340

  
341
    final float D = 0.5f - REX_D;
342
    final float F = 0.5f*(0.5f - D*(SQ3-1));
343

  
344
    float cx1 = left+ TEXTURE_HEIGHT*REX_D;
345
    float cy  = top + TEXTURE_HEIGHT*(1-REX_D-F+0.5f);
346
    float cx2 = left+ TEXTURE_HEIGHT*(1-REX_D);
347
    float R1  = 1.0f*TEXTURE_HEIGHT*(1-2*REX_D);
348

  
349
    canvas.drawArc( cx1-R1, cy-R1, cx1+R1, cy+R1, 270, 30, false ,paint);
350
    canvas.drawArc( cx2-R1, cy-R1, cx2+R1, cy+R1, 240, 30, false ,paint);
351

  
352
    float cx = left + TEXTURE_HEIGHT*0.5f;
353
    float R2 = radius*TEXTURE_HEIGHT;
354
    cy       = top + TEXTURE_HEIGHT*(0.5f+F-(2*SQ3/3)*radius);
355

  
356
    canvas.drawArc( cx-R2, cy-R2, cx+R2, cy+R2, 60, 60, false ,paint);
357

  
358
    cy = top + (0.5f-F)*TEXTURE_HEIGHT;
359

  
360
    paint.setStrokeWidth(0.6f*stroke*TEXTURE_HEIGHT);
361
    canvas.drawLine(left, cy, left+TEXTURE_HEIGHT, cy, paint);
336 362
    }
337 363
  }
src/main/java/org/distorted/objects/TwistyRex.java
352 352
    {
353 353
    int COLORS = FACE_COLORS.length;
354 354
    FactorySticker factory = FactorySticker.getInstance();
355
    float S = 0.08f;
356
    float R = 0.12f;
355
    float S  = 0.04f;
356
    float R1 = 0.12f;
357
    float R2 = 0.06f;
357 358

  
358 359
    if( face<COLORS )
359 360
      {
360
      factory.drawRexCornerSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R);
361
      factory.drawRexCornerSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R2);
361 362
      }
362 363
    else if( face<2*COLORS )
363 364
      {
364
      factory.drawRexFaceSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R);
365
      factory.drawRexFaceSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R1);
365 366
      }
366 367
    else
367 368
      {
368
      factory.drawRexEdgeSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R);
369
      factory.drawRexEdgeSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R1);
369 370
      }
370 371
    }
371 372

  

Also available in: Unified diff