Project

General

Profile

« Previous | Next » 

Revision bbc6da6c

Added by Leszek Koltunski almost 4 years ago

Megaminx family: part1 (doesn't work yet)

View differences:

src/main/java/org/distorted/objects/FactoryCubit.java
674 674
    return new MeshJoined(meshes);
675 675
    }
676 676

  
677

  
678
///////////////////////////////////////////////////////////////////////////////////////////////////
679

  
680
  MeshBase createFacesMinxCorner()
681
    {
682
    MeshBase[] meshes = new MeshPolygon[6];
683

  
684
    float[] vertices0 = {  };   // TODO
685
    float[] bands0 = computeBands(0.03f,27,0.25f,0.5f,5);
686
    float[] vertices1 = {  };   // TODO
687
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,2);
688

  
689
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
690
    meshes[0].setEffectAssociation(0, 1,0);
691
    meshes[1] = meshes[0].copy(true);
692
    meshes[1].setEffectAssociation(0, 2,0);
693
    meshes[2] = meshes[0].copy(true);
694
    meshes[2].setEffectAssociation(0, 4,0);
695
    meshes[3] = new MeshPolygon(vertices1, bands1, 0, 0);
696
    meshes[3].setEffectAssociation(0, 8,0);
697
    meshes[4] = meshes[3].copy(true);
698
    meshes[4].setEffectAssociation(0,16,0);
699
    meshes[5] = meshes[3].copy(true);
700
    meshes[5].setEffectAssociation(0,32,0);
701

  
702
    return new MeshJoined(meshes);
703
    }
704

  
677 705
///////////////////////////////////////////////////////////////////////////////////////////////////
678 706
// EFFECTS
679 707
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1171 1199
    return effect;
1172 1200
    }
1173 1201

  
1202
///////////////////////////////////////////////////////////////////////////////////////////////////
1203

  
1204
  VertexEffect[] createVertexEffectsMinxCorner()
1205
    {
1206
    // TODO
1207

  
1208
    return null;
1209
    }
1210

  
1174 1211
///////////////////////////////////////////////////////////////////////////////////////////////////
1175 1212
// OBJECTS
1176 1213
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1521 1558

  
1522 1559
    mesh.mergeEffComponents();
1523 1560

  
1561
    return mesh;
1562
    }
1563

  
1564
///////////////////////////////////////////////////////////////////////////////////////////////////
1565

  
1566
  MeshBase createMinxCornerMesh()
1567
    {
1568
    MeshBase mesh = createFacesMinxCorner();
1569
    VertexEffect[] effects = createVertexEffectsMinxCorner();
1570
    for( VertexEffect effect : effects ) mesh.apply(effect);
1571
/*
1572
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1573
    Static3D[] vertices = new Static3D[2];
1574
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1575
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1576
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1577
*/
1578
    mesh.mergeEffComponents();
1579

  
1524 1580
    return mesh;
1525 1581
    }
1526 1582
  }
src/main/java/org/distorted/objects/MovementMinx.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objects;
21

  
22
import org.distorted.library.type.Static3D;
23

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

  
26
class MovementMinx extends Movement
27
{
28
  static final float DIST3D = 0.25f;
29
  static final float DIST2D = 0.25f;
30

  
31
  static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(1,0,0), new Static3D(-1,0,0),
34
           new Static3D(0,1,0), new Static3D(0,-1,0),
35
           new Static3D(0,0,1), new Static3D(0,0,-1)
36
         };
37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
  MovementMinx()
41
    {
42
    super(TwistyMinx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
43
    }
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

  
47
  int computeRowFromOffset(int face, int size, float offset)
48
    {
49
    return offset<DIST2D ? 0:1;
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  public float returnRotationFactor(int size, int row)
55
    {
56
    return 1.0f;
57
    }
58

  
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
// faces 0,1,2,3  --> /
61
// faces 4,5      --> \
62

  
63
  private boolean isTopHalf(int face, float[] touchPoint)
64
    {
65
    if( face==4 || face==5 ) return touchPoint[1] >=-touchPoint[0];
66
    else                     return touchPoint[1] >= touchPoint[0];
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  boolean isInsideFace(int face, float[] p)
72
    {
73
    return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
74
    }
75

  
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77
// 0 +++
78
// 1 ++-
79
// 2 +-+
80
// 3 +--
81

  
82
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
83
    {
84
    enabled[0] = 1;
85

  
86
    boolean isTop = isTopHalf(face,touchPoint);
87

  
88
    switch(face)
89
      {
90
      case 0: enabled[1] = isTop ? 0:3; break;
91
      case 1: enabled[1] = isTop ? 2:1; break;
92
      case 2: enabled[1] = isTop ? 2:0; break;
93
      case 3: enabled[1] = isTop ? 1:3; break;
94
      case 4: enabled[1] = isTop ? 0:1; break;
95
      case 5: enabled[1] = isTop ? 2:3; break;
96
      }
97
    }
98
}
src/main/java/org/distorted/objects/ObjectList.java
112 112
         3
113 113
       ),
114 114

  
115
   IVY (
115
  IVY  (
116 116
         new int[][] {
117 117
                       {2 , 8, R.raw.ivy, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
118 118
                     },
......
121 121
         3
122 122
       ),
123 123

  
124
   REX (
124
  REX  (
125 125
         new int[][] {
126 126
                       {3 , 16, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
127 127
                     },
......
129 129
         new MovementRex(),
130 130
         3
131 131
       ),
132

  
133
  MINX (
134
         new int[][] {
135
                       {3 , 18, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
136
                     },
137
         TwistyMinx.class,
138
         new MovementMinx(),
139
         4
140
       ),
132 141
  ;
133 142

  
134 143
  public static final int NUM_OBJECTS = values().length;
......
501 510

  
502 511
    switch(ordinal())
503 512
      {
504
      case 0: return new TwistyCube      (size, quat, texture, mesh, effects, moves, res, scrWidth);
505
      case 1: return new TwistyPyraminx  (size, quat, texture, mesh, effects, moves, res, scrWidth);
506
      case 2: return new TwistyDiamond   (size, quat, texture, mesh, effects, moves, res, scrWidth);
507
      case 3: return new TwistyDino6     (size, quat, texture, mesh, effects, moves, res, scrWidth);
508
      case 4: return new TwistyDino4     (size, quat, texture, mesh, effects, moves, res, scrWidth);
509
      case 5: return new TwistyRedi      (size, quat, texture, mesh, effects, moves, res, scrWidth);
510
      case 6: return new TwistyHelicopter(size, quat, texture, mesh, effects, moves, res, scrWidth);
511
      case 7: return new TwistySkewb     (size, quat, texture, mesh, effects, moves, res, scrWidth);
512
      case 8: return new TwistyIvy       (size, quat, texture, mesh, effects, moves, res, scrWidth);
513
      case 9: return new TwistyRex       (size, quat, texture, mesh, effects, moves, res, scrWidth);
513
      case  0: return new TwistyCube      (size, quat, texture, mesh, effects, moves, res, scrWidth);
514
      case  1: return new TwistyPyraminx  (size, quat, texture, mesh, effects, moves, res, scrWidth);
515
      case  2: return new TwistyDiamond   (size, quat, texture, mesh, effects, moves, res, scrWidth);
516
      case  3: return new TwistyDino6     (size, quat, texture, mesh, effects, moves, res, scrWidth);
517
      case  4: return new TwistyDino4     (size, quat, texture, mesh, effects, moves, res, scrWidth);
518
      case  5: return new TwistyRedi      (size, quat, texture, mesh, effects, moves, res, scrWidth);
519
      case  6: return new TwistyHelicopter(size, quat, texture, mesh, effects, moves, res, scrWidth);
520
      case  7: return new TwistySkewb     (size, quat, texture, mesh, effects, moves, res, scrWidth);
521
      case  8: return new TwistyIvy       (size, quat, texture, mesh, effects, moves, res, scrWidth);
522
      case  9: return new TwistyRex       (size, quat, texture, mesh, effects, moves, res, scrWidth);
523
      case 10: return new TwistyMinx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
514 524
      }
515 525

  
516 526
    return null;
src/main/java/org/distorted/objects/TwistyMinx.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objects;
21

  
22
import android.content.res.Resources;
23
import android.graphics.Canvas;
24
import android.graphics.Paint;
25

  
26
import org.distorted.library.effect.MatrixEffectQuaternion;
27
import org.distorted.library.main.DistortedEffects;
28
import org.distorted.library.main.DistortedTexture;
29
import org.distorted.library.mesh.MeshBase;
30
import org.distorted.library.mesh.MeshSquare;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33
import org.distorted.main.R;
34

  
35
import java.util.Random;
36

  
37
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
public class TwistyMinx extends TwistyObject
42
{
43
  private static final int FACES_PER_CUBIT =6;
44
  private static final float AXIS_LEN = 1.0f/(float)Math.sqrt(2.5f+0.5f*SQ5);
45
  private static final float C0 = (SQ5-1)/4;
46
  private static final float C1 = (SQ5+1)/4;
47

  
48
  // the six rotation axis of a RubikMegaminx. Must be normalized.
49
  static final Static3D[] ROT_AXIS = new Static3D[]
50
         {
51
           new Static3D( AXIS_LEN*C1, AXIS_LEN   , 0          ),
52
           new Static3D(-AXIS_LEN*C1, AXIS_LEN   , 0          ),
53
           new Static3D( 0          , AXIS_LEN*C1, AXIS_LEN   ),
54
           new Static3D( 0          ,-AXIS_LEN*C1, AXIS_LEN   ),
55
           new Static3D( AXIS_LEN   , 0          , AXIS_LEN*C1),
56
           new Static3D( AXIS_LEN   , 0          ,-AXIS_LEN*C1)
57
         };
58

  
59
  private static final int MINX_LGREEN = 0xff53aa00;
60
  private static final int MINX_PINK   = 0xfffd7ab7;
61
  private static final int MINX_SANDY  = 0xffefd48b;
62
  private static final int MINX_LBLUE  = 0xff00a2d7;
63
  private static final int MINX_ORANGE = 0xffff6200;
64
  private static final int MINX_VIOLET = 0xff7d59a4;
65
  private static final int MINX_DGREEN = 0xff007a47;
66
  private static final int MINX_DRED   = 0xffbd0000;
67
  private static final int MINX_DBLUE  = 0xff1a29b2;
68
  private static final int MINX_DYELLOW= 0xffffc400;
69
  private static final int MINX_WHITE  = 0xffffffff;
70
  private static final int MINX_GREY   = 0xff727c7b;
71

  
72
  private static final int[] FACE_COLORS = new int[]
73
         {
74
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
75
           MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
76
           MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
77
         };
78

  
79
  // All 60 legal rotation quats of a RubikMegaminx
80
  private static final Static4D[] QUATS = new Static4D[]
81
         {
82
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
83
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
84
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
85
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
86

  
87
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
88
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
89
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
90
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
91
           new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
92
           new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
93
           new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
94
           new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
95

  
96
           new Static4D(  0.5f,    C1,    C0,  0.0f ),
97
           new Static4D(  0.5f,    C1,   -C0,  0.0f ),
98
           new Static4D(  0.5f,   -C1,    C0,  0.0f ),
99
           new Static4D(  0.5f,   -C1,   -C0,  0.0f ),
100
           new Static4D(    C0,  0.5f,    C1,  0.0f ),
101
           new Static4D(    C0,  0.5f,   -C1,  0.0f ),
102
           new Static4D(   -C0,  0.5f,    C1,  0.0f ),
103
           new Static4D(   -C0,  0.5f,   -C1,  0.0f ),
104
           new Static4D(    C1,    C0,  0.5f,  0.0f ),
105
           new Static4D(    C1,   -C0,  0.5f,  0.0f ),
106
           new Static4D(   -C1,    C0,  0.5f,  0.0f ),
107
           new Static4D(   -C1,   -C0,  0.5f,  0.0f ),
108

  
109
           new Static4D(  0.0f,    C0,    C1,  0.5f ),
110
           new Static4D(  0.0f,    C0,   -C1,  0.5f ),
111
           new Static4D(  0.0f,   -C0,    C1,  0.5f ),
112
           new Static4D(  0.0f,   -C0,   -C1,  0.5f ),
113
           new Static4D(    C0,    C1,  0.0f,  0.5f ),
114
           new Static4D(    C0,   -C1,  0.0f,  0.5f ),
115
           new Static4D(   -C0,    C1,  0.0f,  0.5f ),
116
           new Static4D(   -C0,   -C1,  0.0f,  0.5f ),
117
           new Static4D(    C1,  0.0f,    C0,  0.5f ),
118
           new Static4D(    C1,  0.0f,   -C0,  0.5f ),
119
           new Static4D(   -C1,  0.0f,    C0,  0.5f ),
120
           new Static4D(   -C1,  0.0f,   -C0,  0.5f ),
121

  
122
           new Static4D(  0.0f,    C1,  0.5f,    C0 ),
123
           new Static4D(  0.0f,    C1, -0.5f,    C0 ),
124
           new Static4D(  0.0f,   -C1,  0.5f,    C0 ),
125
           new Static4D(  0.0f,   -C1, -0.5f,    C0 ),
126
           new Static4D(  0.5f,  0.0f,    C1,    C0 ),
127
           new Static4D(  0.5f,  0.0f,   -C1,    C0 ),
128
           new Static4D( -0.5f,  0.0f,    C1,    C0 ),
129
           new Static4D( -0.5f,  0.0f,   -C1,    C0 ),
130
           new Static4D(    C1,  0.5f,  0.0f,    C0 ),
131
           new Static4D(    C1, -0.5f,  0.0f,    C0 ),
132
           new Static4D(   -C1,  0.5f,  0.0f,    C0 ),
133
           new Static4D(   -C1, -0.5f,  0.0f,    C0 ),
134

  
135
           new Static4D(  0.0f,  0.5f,    C0,    C1 ),
136
           new Static4D(  0.0f,  0.5f,   -C0,    C1 ),
137
           new Static4D(  0.0f, -0.5f,    C0,    C1 ),
138
           new Static4D(  0.0f, -0.5f,   -C0,    C1 ),
139
           new Static4D(  0.5f,    C0,  0.0f,    C1 ),
140
           new Static4D(  0.5f,   -C0,  0.0f,    C1 ),
141
           new Static4D( -0.5f,    C0,  0.0f,    C1 ),
142
           new Static4D( -0.5f,   -C0,  0.0f,    C1 ),
143
           new Static4D(    C0,  0.0f,  0.5f,    C1 ),
144
           new Static4D(    C0,  0.0f, -0.5f,    C1 ),
145
           new Static4D(   -C0,  0.0f,  0.5f,    C1 ),
146
           new Static4D(   -C0,  0.0f, -0.5f,    C1 ),
147
         };
148

  
149
  private static final int[][] mFaceMap =
150
         {
151
           {  0, 1, 2, 12,12,12 },
152
           {  2, 3, 4, 12,12,12 },
153
           {  3, 4, 5, 12,12,12 },
154
           {  4, 5, 6, 12,12,12 },
155
           {  5, 6, 7, 12,12,12 },
156
           {  6, 7, 8, 12,12,12 },
157
           {  7, 8, 9, 12,12,12 },
158
           { 10,11, 0, 12,12,12 },
159
           { 11, 0, 1, 12,12,12 },
160
           {  0, 1, 2, 12,12,12 },
161
           {  0, 1, 2, 12,12,12 },
162
           {  2, 3, 4, 12,12,12 },
163
           {  3, 4, 5, 12,12,12 },
164
           {  4, 5, 6, 12,12,12 },
165
           {  5, 6, 7, 12,12,12 },
166
           {  6, 7, 8, 12,12,12 },
167
           {  7, 8, 9, 12,12,12 },
168
           { 10,11, 0, 12,12,12 },
169
           { 11, 0, 1, 12,12,12 },
170
           {  0, 1, 2, 12,12,12 },
171
         };
172

  
173
  private static MeshBase mMesh;
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  TwistyMinx(int size, Static4D quat, DistortedTexture texture,
178
             MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
179
    {
180
    super(size, size, 60, quat, texture, mesh, effects, moves, ObjectList.MINX, res, scrWidth);
181
    }
182

  
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184

  
185
  float getScreenRatio()
186
    {
187
    return 1.0f;
188
    }
189

  
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

  
192
  Static4D[] getQuats()
193
    {
194
    return QUATS;
195
    }
196

  
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

  
199
  int getNumFaces()
200
    {
201
    return FACE_COLORS.length;
202
    }
203

  
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

  
206
  boolean shouldResetTextureMaps()
207
    {
208
    return false;
209
    }
210

  
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

  
213
  int getNumStickerTypes()
214
    {
215
    return 1;
216
    }
217

  
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

  
220
  float[] getCuts(int numLayers)
221
    {
222
    return new float[] { -0.5f , 0.5f };
223
    }
224

  
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226

  
227
  int getNumCubitFaces()
228
    {
229
    return FACES_PER_CUBIT;
230
    }
231

  
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

  
234
  Static3D[] getCubitPositions(int numLayers)
235
    {
236
    final float C0 = (SQ5+1)/4;
237
    final float C1 = (SQ5+3)/4;
238

  
239
    final Static3D[] CENTERS = new Static3D[20];
240

  
241
    CENTERS[ 0] = new Static3D( 0.0f, 0.5f,   C1);
242
    CENTERS[ 1] = new Static3D( 0.0f, 0.5f,  -C1);
243
    CENTERS[ 2] = new Static3D( 0.0f,-0.5f,   C1);
244
    CENTERS[ 3] = new Static3D( 0.0f,-0.5f,  -C1);
245
    CENTERS[ 4] = new Static3D(   C1, 0.0f, 0.5f);
246
    CENTERS[ 5] = new Static3D(   C1, 0.0f,-0.5f);
247
    CENTERS[ 6] = new Static3D(  -C1, 0.0f, 0.5f);
248
    CENTERS[ 7] = new Static3D(  -C1, 0.0f,-0.5f);
249
    CENTERS[ 8] = new Static3D( 0.5f,   C1, 0.0f);
250
    CENTERS[ 9] = new Static3D( 0.5f,  -C1, 0.0f);
251
    CENTERS[10] = new Static3D(-0.5f,   C1, 0.0f);
252
    CENTERS[11] = new Static3D(-0.5f,  -C1, 0.0f);
253
    CENTERS[12] = new Static3D(   C0,   C0,   C0);
254
    CENTERS[13] = new Static3D(   C0,   C0,  -C0);
255
    CENTERS[14] = new Static3D(   C0,  -C0,   C0);
256
    CENTERS[15] = new Static3D(   C0,  -C0,  -C0);
257
    CENTERS[16] = new Static3D(  -C0,   C0,   C0);
258
    CENTERS[17] = new Static3D(  -C0,   C0,  -C0);
259
    CENTERS[18] = new Static3D(  -C0,  -C0,   C0);
260
    CENTERS[19] = new Static3D(  -C0,  -C0,  -C0);
261

  
262
    return CENTERS;
263
    }
264

  
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

  
267
  private int getQuat(int cubit)
268
    {
269
    switch(cubit)
270
      {
271
      case  0: return 0;
272
      case  1: return 2;
273
      case  2: return 3;
274
      case  3: return 1;
275
      case  4: return 43;
276
      case  5: return 9;
277
      case  6: return 42;
278
      case  7: return 10;
279
      case  8: return 36;
280
      case  9: return 5;
281
      case 10: return 39;
282
      case 11: return 6;
283
      case 12: return 59;
284
      case 13: return 32;
285
      case 14: return 47;
286
      case 15: return 21;
287
      case 16: return 58;
288
      case 17: return 34;
289
      case 18: return 46;
290
      case 19: return 23;
291
      }
292

  
293
    return 0;
294
    }
295

  
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

  
298
  MeshBase createCubitMesh(int cubit)
299
    {
300
    if( mMesh==null ) mMesh = FactoryCubit.getInstance().createMinxCornerMesh();
301
    MeshBase mesh = mMesh.copy(true);
302

  
303
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[getQuat(cubit)], new Static3D(0,0,0) );
304
    mesh.apply(quat,0xffffffff,0);
305

  
306
    return mesh;
307
    }
308

  
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

  
311
  int getFaceColor(int cubit, int cubitface, int numLayers)
312
    {
313
    return mFaceMap[cubit][cubitface];
314
    }
315

  
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

  
318
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
319
    {
320
    float S = 0.08f;
321
    float R = 0.12f;
322

  
323
    float[] vertices = {  };   // TODO
324

  
325
    FactorySticker factory = FactorySticker.getInstance();
326
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
327
    }
328

  
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

  
331
  float returnMultiplier()
332
    {
333
    return 2.0f;
334
    }
335

  
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

  
338
  float[] getRowChances()
339
    {
340
    return new float[] { 0.5f, 0.5f, 1.0f };
341
    }
342

  
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344
// PUBLIC API
345

  
346
  public Static3D[] getRotationAxis()
347
    {
348
    return ROT_AXIS;
349
    }
350

  
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

  
353
  public int getBasicAngle()
354
    {
355
    return 5;
356
    }
357

  
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

  
360
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
361
    {
362
    int numAxis = ROTATION_AXIS.length;
363

  
364
    if( oldRotAxis == START_AXIS )
365
      {
366
      return rnd.nextInt(numAxis);
367
      }
368
    else
369
      {
370
      int newVector = rnd.nextInt(numAxis-1);
371
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
372
      }
373
    }
374

  
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

  
377
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
378
    {
379
    float rowFloat = rnd.nextFloat();
380

  
381
    for(int row=0; row<mRowChances.length; row++)
382
      {
383
      if( rowFloat<=mRowChances[row] ) return row;
384
      }
385

  
386
    return 0;
387
    }
388

  
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390
// The Kilominx is solved if and only if:
391
//
392
// all cubits are rotated with the same quat.
393

  
394
  public boolean isSolved()
395
    {
396
    int q = CUBITS[0].mQuatIndex;
397

  
398
    for(int i=0; i<NUM_CUBITS; i++)
399
      {
400
      if( CUBITS[i].mQuatIndex != q ) return false;
401
      }
402

  
403
    return true;
404
    }
405

  
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407
// only needed for solvers - there are no Ivy solvers ATM)
408

  
409
  public String retObjectString()
410
    {
411
    return "";
412
    }
413

  
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

  
416
  public int getObjectName(int numLayers)
417
    {
418
    return R.string.minx2;
419
    }
420

  
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

  
423
  public int getInventor(int numLayers)
424
    {
425
    return R.string.minx2_inventor;
426
    }
427

  
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429

  
430
  public int getComplexity(int numLayers)
431
    {
432
    return 3;
433
    }
434
}
src/main/java/org/distorted/objects/TwistyObject.java
72 72

  
73 73
  static final float SQ2 = (float)Math.sqrt(2);
74 74
  static final float SQ3 = (float)Math.sqrt(3);
75
  static final float SQ5 = (float)Math.sqrt(5);
75 76
  static final float SQ6 = (float)Math.sqrt(6);
76 77

  
77 78
  private static final float NODE_RATIO = 1.40f;
src/main/res/values/strings.xml
87 87
    <string name="rex3"  translatable="false">Rex Cube</string>
88 88
    <string name="dino3" translatable="false">Dino Cube (6 color)</string>
89 89
    <string name="din43" translatable="false">Dino Cube (4 color)</string>
90
    <string name="minx2" translatable="false">Kilominx</string>
91
    <string name="minx3" translatable="false">Megaminx</string>
92
    <string name="minx4" translatable="false">Gigaminx</string>
90 93

  
91 94
    <string name="cube2_inventor" translatable="false">Larry Nichols, 1970</string>
92 95
    <string name="cube3_inventor" translatable="false">Ernő Rubik, 1974</string>
......
104 107
    <string name="rex3_inventor"  translatable="false">Andrew Cormier, 2009</string>
105 108
    <string name="dino3_inventor" translatable="false">Robert Webb, 1985</string>
106 109
    <string name="din43_inventor" translatable="false">Robert Webb, 1985</string>
110
    <string name="minx2_inventor" translatable="false">Thomas de Bruin, 2008</string>
111
    <string name="minx3_inventor" translatable="false">Ferenc Szlivka, 1982</string>
112
    <string name="minx4_inventor" translatable="false">Tyler Fox, 2006</string>
107 113

  
108 114
</resources>

Also available in: Unified diff