Project

General

Profile

« Previous | Next » 

Revision ede1b68c

Added by Leszek Koltunski over 3 years ago

Progress with Megaminx.

View differences:

src/main/java/org/distorted/objects/MovementMinx.java
26 26
import static org.distorted.objects.FactoryCubit.SIN54;
27 27
import static org.distorted.objects.FactoryCubit.COS54;
28 28
import static org.distorted.objects.TwistyObject.SQ5;
29
import static org.distorted.objects.FactoryCubit.COS18;
30
import static org.distorted.objects.TwistyMegaminx.MEGA_D;
29 31

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

  
......
54 56

  
55 57
  MovementMinx()
56 58
    {
57
    super(TwistyKilominx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
59
    super(TwistyMinx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
58 60
    }
59 61

  
60 62
///////////////////////////////////////////////////////////////////////////////////////////////////
61 63

  
62 64
  int computeRowFromOffset(int face, int size, float offset)
63 65
    {
64
    return offset<DIST2D ? 0:2;
66
    if( size==3 )
67
      {
68
      return offset<DIST2D ? 0:2;
69
      }
70
    if( size==5 )
71
      {
72
      // TODO
73

  
74
      float LEN = (0.5f-MEGA_D)*COS18/3;
75

  
76
      android.util.Log.e("mega", "offset = "+offset+" len="+LEN+" dist2D="+DIST2D);
77

  
78
      if( offset<LEN/2 ) return 0;
79
      if( offset<LEN   ) return 1;
80
      }
81

  
82
    return 0;
65 83
    }
66 84

  
67 85
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMegaminx.java
34 34
import org.distorted.main.RubikSurfaceView;
35 35

  
36 36
import static org.distorted.objects.FactoryCubit.COS18;
37
import static org.distorted.objects.FactoryCubit.COS54;
37 38
import static org.distorted.objects.FactoryCubit.SIN18;
39
import static org.distorted.objects.FactoryCubit.SIN54;
38 40

  
39 41
///////////////////////////////////////////////////////////////////////////////////////////////////
40 42

  
......
196 198
  float[] getCuts(int numLayers)
197 199
    {
198 200
    float[] cuts = new float[numLayers-1];
199
    float D = (numLayers/3.0f)*MovementMinx.DIST3D;
201
    float D = numLayers*MovementMinx.DIST3D;
200 202
    float E = 2*C1;           // 2*cos(36 deg)
201 203
    float X = 2*D*E/(1+2*E);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
202
                              // its height is then 2*DIST3D, it has one 'lower' part of height X, one
204
                              // its height is then D*2*DIST3D, it has one 'lower' part of height X, one
203 205
                              // 'middle' part of height Y and one upper part of height X again.
204 206
                              // It's edge length = numLayers/3.0f.
205 207
    int num = (numLayers-1)/2;
......
207 209

  
208 210
    for(int i=0; i<num; i++)
209 211
      {
210
      cuts[        i] = -MovementMinx.DIST3D + (i+0.5f)*G;
212
      cuts[        i] = -D + (i+0.5f)*G;
211 213
      cuts[2*num-1-i] = -cuts[i];
212 214
      }
213 215

  
......
511 513

  
512 514
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
513 515
    {
514
    paint.setColor(FACE_COLORS[face%NUM_FACES]);
515
    paint.setStyle(Paint.Style.FILL);
516
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
516
    int COLORS = FACE_COLORS.length;
517
    float R,S;
518
    float[] vertices;
519

  
520
    int variant = face/COLORS;
521

  
522
    if( variant==0 )
523
      {
524
      float Y = COS54/(2*SIN54);
525
      R = 0.05f;
526
      S = 0.06f;
527
      vertices = new float[] { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
528
      }
529
    else
530
      {
531
      int numLayers = getNumLayers();
532
      float height= (numLayers/3.0f)*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
533
      float W = height*SIN18/COS18;
534
      float width = (numLayers/3.0f)*2*MEGA_D + 2*(variant-1)*W;
535

  
536
      if( variant < (numLayers+1)/2 )
537
        {
538
        float X1 = 0.5f*height;
539
        float Y1 = 0.5f*width;
540
        float Y2 = 0.5f*width + W;
541

  
542
        R = 0.04f;
543
        S = 0.055f;
544
        vertices = new float[] { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
545
        }
546
      else
547
        {
548
        float Z = width/(2*COS54);
549
        float X1 = 0.5f*width;
550
        float Y1 = Z*SIN54;
551
        float X2 = Z*COS18;
552
        float Y2 = Z*SIN18;
553

  
554
        R = 0.05f;
555
        S = 0.05f;
556
        vertices = new float[] { -X1,+Y1, -X2,-Y2, 0.0f,-Z, +X2,-Y2, +X1,+Y1 };
557
        }
558
      }
559

  
560
    FactorySticker factory = FactorySticker.getInstance();
561
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face%COLORS], R);
517 562
    }
518 563

  
519 564
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff