Project

General

Profile

« Previous | Next » 

Revision bb11be2a

Added by Leszek Koltunski about 3 years ago

New cubit engine: finish converting Kilominx & Megaminx.

View differences:

src/main/java/org/distorted/objects/TwistyKilominx.java
35 35
import org.distorted.main.R;
36 36
import org.distorted.main.RubikSurfaceView;
37 37

  
38
import static org.distorted.helpers.FactoryCubit.COS18;
39
import static org.distorted.helpers.FactoryCubit.COS54;
40
import static org.distorted.helpers.FactoryCubit.COS_HALFD;
41
import static org.distorted.helpers.FactoryCubit.SIN18;
42
import static org.distorted.helpers.FactoryCubit.SIN54;
43
import static org.distorted.helpers.FactoryCubit.SIN_HALFD;
44

  
45 38
///////////////////////////////////////////////////////////////////////////////////////////////////
46 39

  
47 40
public class TwistyKilominx extends TwistyMinx
......
65 58
        2,2,2,2,2
66 59
      };
67 60

  
61
  private static final float CENTER_CORR = 0.87f;
62

  
63
  private static final float[][] STICKERS = new float[][]
64
      {
65
        { -0.36616942f, -0.36327124f, 0.5f, -0.36327124f, 0.23233888f, 0.4605048f, -0.36616942f, 0.26603764f },
66
        { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
67
        { -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f }
68
      };
69

  
68 70
  private static final int mNumCornerEdgeVariants;
69 71

  
70 72
  static
......
72 74
    int[] sizes = ObjectList.KILO.getSizes();
73 75
    int variants = sizes.length;
74 76
    mNumCornerEdgeVariants = sizes[0]==3 ? variants-1 : variants;
77

  
78
    STICKERS[0][2] *= CENTER_CORR;
79
    STICKERS[0][3] *= CENTER_CORR;
75 80
    }
76 81

  
77 82
///////////////////////////////////////////////////////////////////////////////////////////////////
......
116 121
    {
117 122
    float[] cuts = new float[numLayers-1];
118 123
    float D = numLayers*MovementMinx.DIST3D;
119
    float E = 2*C1;           // 2*cos(36 deg)
124
    float E = 2*SIN54;
120 125
    float X = 2*D*E/(1+2*E);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
121 126
                              // its height is then D*2*DIST3D, it has one 'lower' part of height X, one
122 127
                              // 'middle' part of height Y and one upper part of height X again.
......
625 630
      {
626 631
      float R = 0.10f;
627 632
      float S = 0.09f;
628
      float A = 0.87f;
629
      float[] vertices = { -0.36616942f, -0.36327124f, 0.5f, -0.36327124f, 0.23233888f, 0.4605048f, -0.36616942f, 0.26603764f };
630

  
631
      float cx = vertices[2];
632
      float cy = vertices[3];
633
      vertices[2] *= A;
634
      vertices[3] *= A;
633
      float cx = STICKERS[0][2]/CENTER_CORR;
634
      float cy = STICKERS[0][3]/CENTER_CORR;
635 635

  
636 636
      FactorySticker factory = FactorySticker.getInstance();
637
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face%NUM_FACES], R);
637
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], S, FACE_COLORS[face%NUM_FACES], R);
638 638
      canvas.drawCircle(left+(0.5f+cx)*TEXTURE_HEIGHT, top+(0.5f-cy)*TEXTURE_HEIGHT, 0.05f*TEXTURE_HEIGHT, paint);
639 639
      }
640 640
    else if( variant==0 ) // corner
641 641
      {
642 642
      float R = 0.10f;
643 643
      float S = 0.11f;
644
      float[] vertices = { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f };
645

  
646 644
      FactorySticker factory = FactorySticker.getInstance();
647
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face%COLORS], R);
645
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[1], S, FACE_COLORS[face%COLORS], R);
648 646
      }
649 647
    else  // edge
650 648
      {
651 649
      float R = 0.10f;
652 650
      float S = 0.10f;
653
      float[] vertices = { -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f };
654

  
655 651
      FactorySticker factory = FactorySticker.getInstance();
656
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face%COLORS], R);
652
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[2], S, FACE_COLORS[face%COLORS], R);
657 653
      }
658 654
    }
659 655

  

Also available in: Unified diff