Project

General

Profile

« Previous | Next » 

Revision df9739f8

Added by Leszek Koltunski over 3 years ago

New 'JingPyraminx' object.

View differences:

src/main/java/org/distorted/objects/MovementJing.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 MovementJing extends Movement
27
{
28
  static final float DIST3D = SQ6/12;
29
  static final float DIST2D = SQ3/6;
30

  
31
  static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(     0,+SQ3/3,+SQ6/3),
34
           new Static3D(     0,+SQ3/3,-SQ6/3),
35
           new Static3D(-SQ6/3,-SQ3/3,     0),
36
           new Static3D(+SQ6/3,-SQ3/3,     0),
37
         };
38

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

  
41
  MovementJing()
42
    {
43
    super(TwistyJing.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
44
    }
45

  
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

  
48
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
49
    {
50
    return (int)(numLayers*offset/(SQ6/3));
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  public float returnRotationFactor(int numLayers, int row)
56
    {
57
    return ((float)numLayers)/(numLayers-row);
58
    }
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  boolean isInsideFace(int face, float[] p)
63
    {
64
    float y = (face > 1 ? p[1] : -p[1]);
65
    float x = p[0];
66

  
67
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
73
    {
74
    enabled[0] = 3;
75

  
76
    switch(face)
77
      {
78
      case 0: enabled[1]=1; enabled[2]=2; enabled[3]=3; break;
79
      case 1: enabled[1]=0; enabled[2]=2; enabled[3]=3; break;
80
      case 2: enabled[1]=0; enabled[2]=1; enabled[3]=3; break;
81
      case 3: enabled[1]=0; enabled[2]=1; enabled[3]=2; break;
82
      }
83
    }
84
}
src/main/java/org/distorted/objects/ObjectList.java
49 49
         60
50 50
       ),
51 51

  
52
  PYRA (
52
  JING (
53 53
         new int[][] {
54
                       {3 , 10, 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
55
                       {4 , 15, 17, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
56
                       {5 , 20, 23, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
54
                       {2 , 10, 10, 0, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
57 55
                     },
58
         TwistyPyraminx.class,
59
         new MovementPyraminx(),
56
         TwistyJing.class,
57
         new MovementJing(),
60 58
         1,
61 59
         30
62 60
       ),
63 61

  
64
  ULTI (
62
  PYRA (
65 63
         new int[][] {
66
                       {2 , 18, 18, R.raw.ulti, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
64
                       {3 , 10, 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
65
                       {4 , 15, 17, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
66
                       {5 , 20, 23, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
67 67
                     },
68
         TwistyUltimate.class,
69
         new MovementUltimate(),
68
         TwistyPyraminx.class,
69
         new MovementPyraminx(),
70 70
         1,
71 71
         30
72 72
       ),
......
234 234
         6,
235 235
         60
236 236
       ),
237

  
238
  ULTI (
239
         new int[][] {
240
                       {2 , 18, 18, R.raw.ulti, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
241
                     },
242
         TwistyUltimate.class,
243
         new MovementUltimate(),
244
         7,
245
         30
246
       ),
237 247
  ;
238 248

  
239 249
  public static final int NUM_OBJECTS = values().length;
......
642 652
    switch(ordinal())
643 653
      {
644 654
      case  0: return new TwistyCube          (size, quat, texture, mesh, effects, moves, res, scrWidth);
645
      case  1: return new TwistyPyraminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
646
      case  2: return new TwistyUltimate      (size, quat, texture, mesh, effects, moves, res, scrWidth);
655
      case  1: return new TwistyJing          (size, quat, texture, mesh, effects, moves, res, scrWidth);
656
      case  2: return new TwistyPyraminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
647 657
      case  3: return new TwistyKilominx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
648 658
      case  4: return new TwistyMegaminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
649 659
      case  5: return new TwistyDino6         (size, quat, texture, mesh, effects, moves, res, scrWidth);
......
660 670
      case 16: return new TwistyDiamond       (size, quat, texture, mesh, effects, moves, res, scrWidth);
661 671
      case 17: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
662 672
      case 18: return new TwistySquare2       (size, quat, texture, mesh, effects, moves, res, scrWidth);
673
      case 19: return new TwistyUltimate      (size, quat, texture, mesh, effects, moves, res, scrWidth);
663 674
      }
664 675

  
665 676
    return null;
src/main/java/org/distorted/objects/TwistyJing.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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.helpers.FactoryCubit;
27
import org.distorted.helpers.FactorySticker;
28
import org.distorted.library.effect.MatrixEffectQuaternion;
29
import org.distorted.library.main.DistortedEffects;
30
import org.distorted.library.main.DistortedTexture;
31
import org.distorted.library.mesh.MeshBase;
32
import org.distorted.library.mesh.MeshSquare;
33
import org.distorted.library.type.Static3D;
34
import org.distorted.library.type.Static4D;
35
import org.distorted.main.R;
36

  
37
import java.util.Random;
38

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

  
41
public class TwistyJing extends TwistyObject
42
{
43
  static final float F = 0.24f;
44

  
45
  static final Static3D[] ROT_AXIS = new Static3D[]
46
         {
47
           new Static3D(     0,-SQ3/3,-SQ6/3),
48
           new Static3D(     0,-SQ3/3,+SQ6/3),
49
           new Static3D(+SQ6/3,+SQ3/3,     0),
50
           new Static3D(-SQ6/3,+SQ3/3,     0),
51
         };
52

  
53
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
54

  
55
  private static final int[] FACE_COLORS = new int[]
56
         {
57
           COLOR_GREEN , COLOR_YELLOW,
58
           COLOR_BLUE  , COLOR_RED
59
         };
60

  
61
  // computed with res/raw/compute_quats.c
62
  private static final Static4D[] QUATS = new Static4D[]
63
         {
64
           new Static4D(  0.0f,   0.0f,   0.0f,  1.0f),
65
           new Static4D(  0.0f,   1.0f,   0.0f,  0.0f),
66
           new Static4D( SQ2/2,   0.5f,   0.0f,  0.5f),
67
           new Static4D(-SQ2/2,   0.5f,   0.0f,  0.5f),
68
           new Static4D(  0.0f,  -0.5f, -SQ2/2,  0.5f),
69
           new Static4D(  0.0f,  -0.5f,  SQ2/2,  0.5f),
70
           new Static4D( SQ2/2,   0.5f,   0.0f, -0.5f),
71
           new Static4D(-SQ2/2,   0.5f,   0.0f, -0.5f),
72
           new Static4D(  0.0f,  -0.5f, -SQ2/2, -0.5f),
73
           new Static4D(  0.0f,  -0.5f,  SQ2/2, -0.5f),
74
           new Static4D( SQ2/2,   0.0f,  SQ2/2,  0.0f),
75
           new Static4D(-SQ2/2,   0.0f,  SQ2/2,  0.0f)
76
         };
77

  
78

  
79
static float H = 0.120f;
80

  
81
  static final float[][] CENTERS = new float[][]
82
         {
83
           { 0.000f, -SQ2/4,  0.500f },
84
           { 0.000f, -SQ2/4, -0.500f },
85
           {-0.500f,  SQ2/4,  0.000f },
86
           { 0.500f,  SQ2/4,  0.000f },
87

  
88
           { 0.000f, -SQ2/4, 0.000f },
89
           {-0.250f, 0.000f, 0.250f },
90
           { 0.250f, 0.000f, 0.250f },
91
           {-0.250f, 0.000f,-0.250f },
92
           { 0.250f, 0.000f,-0.250f },
93
           { 0.000f,  SQ2/4, 0.000f },
94

  
95
           { 0.000f, H, 1.0f/6 },
96
           { 0.000f, H,-1.0f/6 },
97
           {-1.0f/6,-H, 0.000f },
98
           { 1.0f/6,-H, 0.000f },
99
         };
100

  
101
  // Colors of the faces of cubits.
102
  // GREEN 0 YELLOW 1 BLUE  2 RED 3
103
  // GREEN 4 YELLOW 5 BLUE  6 RED 7
104
  // GREEN 8 YELLOW 9 BLUE 10 RED 11
105
  private static final int[][] mFaceMap = new int[][]
106
         {
107
           {  2, 3, 1, 12, 12, 12 },
108
           {  0, 1, 3, 12, 12, 12 },
109
           {  0, 2, 1, 12, 12, 12 },
110
           {  0, 3, 2, 12, 12, 12 },
111

  
112
           {  7, 5, 12, 12, 12, 12 },
113
           {  6, 5, 12, 12, 12, 12 },
114
           {  7, 6, 12, 12, 12, 12 },
115
           {  4, 5, 12, 12, 12, 12 },
116
           {  7, 4, 12, 12, 12, 12 },
117
           {  6, 4, 12, 12, 12, 12 },
118

  
119
           { 10, 12, 12, 12, 12, 12 },
120
           {  8, 12, 12, 12, 12, 12 },
121
           {  9, 12, 12, 12, 12, 12 },
122
           { 11, 12, 12, 12, 12, 12 },
123
         };
124

  
125
  private static final float X = F/2;
126
  private static final float Y = F*SQ2/2;
127
  private static final float Z =-F/2;
128
  private static final float L = (1-3*F);
129
  private static final float X2= L/2;
130
  private static final float Y2= L*SQ2/2;
131
  private static final float Z2=-L/2;
132
  private static final float D = F/L;
133

  
134
  private static final double[][] VERTICES_CORNER = new double[][]
135
          {
136
             { 0.0, 0.0, 0.0 },
137
             {   X,   Y,   Z },
138
             { 0.0, 2*Y, 2*Z },
139
             {  -X,   Y,   Z },
140
             { 0.0, 0.0,    -F },
141
             {   X,   Y,   Z-F },
142
             { 0.0, 2*Y, 2*Z-F },
143
             {  -X,   Y,   Z-F },
144
          };
145

  
146
  private static final int[][] VERT_INDEXES_CORNER = new int[][]
147
          {
148
             {0,1,2,3},
149
             {1,0,4,5},
150
             {7,4,0,3},
151
             {1,5,6,2},
152
             {7,3,2,6},
153
             {4,7,6,5}
154
          };
155

  
156
  private static final double[][] VERTICES_EDGE = new double[][]
157
          {
158
             { 0.0, 0.0,     0.5-F },
159
             {   X,   Y,   Z+0.5-F },
160
             { 0.0, 2*Y, 2*Z+0.5-F },
161
             {  -X,   Y,   Z+0.5-F },
162
             { 0.0, 0.0,    -0.5+F },
163
             {   X,   Y,  -Z-0.5+F },
164
             { 0.0, 2*Y,-2*Z-0.5+F },
165
             {  -X,   Y,  -Z-0.5+F },
166
          };
167

  
168
  private static final int[][] VERT_INDEXES_EDGE = new int[][]
169
          {
170
             {0,4,5,1},
171
             {3,7,4,0},
172
             {0,1,2,3},
173
             {4,7,6,5},
174
             {1,5,6,2},
175
             {2,6,7,3}
176
          };
177

  
178
  private static final double[][] VERTICES_FACE = new double[][]
179
          {
180
             {    0.0,     -2*Y2/3,   -2*Z2/3 },
181
             {      X2,       Y2/3,      Z2/3 },
182
             {     -X2,       Y2/3,      Z2/3 },
183
             {    0.0,     -2*Y2/3,-2*Z2/3+2*D*Z2 },
184
             {  X2-D*X2, Y2/3-D*Y2, Z2/3+D*Z2 },
185
             { -X2+D*X2, Y2/3-D*Y2, Z2/3+D*Z2 },
186
          };
187

  
188
  private static final int[][] VERT_INDEXES_FACE = new int[][]
189
          {
190
             {0,1,2},
191
             {3,5,4},
192
             {0,3,4,1},
193
             {5,3,0,2},
194
             {4,5,2,1}
195
          };
196

  
197
  private static final float[][] STICKERS = new float[][]
198
          {
199
             { 0.0f, -0.5f, 0.28867516f, 0.0f, 0.0f, 0.5f, -0.28867516f, 0.0f },
200
             { -0.5f, 0.11983269f, 0.27964598f, -0.43146032f, 0.3200817f, 0.007388768f, -0.09972769f, 0.30423886f },
201
             { 0.0f, -0.5f, 0.43301272f, 0.25f, -0.43301272f, 0.25f },
202
          };
203

  
204
  private static MeshBase[] mMeshes;
205

  
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

  
208
  TwistyJing(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
209
             DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
210
    {
211
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.JING, res, scrWidth);
212
    }
213

  
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215

  
216
  float[][] getCubitPositions(int size)
217
    {
218
    return CENTERS;
219
    }
220

  
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

  
223
  Static4D[] getQuats()
224
    {
225
    return QUATS;
226
    }
227

  
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

  
230
  int getNumFaces()
231
    {
232
    return FACE_COLORS.length;
233
    }
234

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
  int getNumStickerTypes(int numLayers)
238
    {
239
    return STICKERS.length;
240
    }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  float[][] getCuts(int size)
245
    {
246
    float[] cut = {F-0.5f};
247
    return new float[][] { cut,cut,cut,cut };
248
    }
249

  
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251

  
252
  int getNumCubitFaces()
253
    {
254
    return 6;
255
    }
256

  
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258

  
259
  float getScreenRatio()
260
    {
261
    return 1.64f;
262
    }
263

  
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

  
266
  boolean shouldResetTextureMaps()
267
    {
268
    return false;
269
    }
270

  
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

  
273
  int getFaceColor(int cubit, int cubitface, int size)
274
    {
275
    return mFaceMap[cubit][cubitface];
276
    }
277

  
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

  
280
  private int getQuat(int cubit)
281
    {
282
    switch(cubit)
283
      {
284
      case  0: return 0;
285
      case  1: return 1;
286
      case  2: return 2;
287
      case  3: return 7;
288

  
289
      case  4: return 0;
290
      case  5: return 2;
291
      case  6: return 7;
292
      case  7: return 6;
293
      case  8: return 3;
294
      case  9: return 10;
295

  
296
      case 10: return 0;
297
      case 11: return 1;
298
      case 12: return 3;
299
      case 13: return 5;
300
      }
301

  
302
    return 0;
303
    }
304

  
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

  
307
  MeshBase createCubitMesh(int cubit, int numLayers)
308
    {
309
    if( mMeshes==null )
310
      {
311
      FactoryCubit factory = FactoryCubit.getInstance();
312
      factory.clear();
313
      mMeshes = new MeshBase[3];
314
      }
315

  
316
    MeshBase mesh;
317

  
318
    if( cubit<4 )
319
      {
320
      if( mMeshes[0]==null )
321
        {
322
        float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
323
        int[] bandIndexes   = new int[] { 0,0,0,1,1,1 };
324
        float[][] corners   = new float[][] { {0.10f,0.20f*F},{0.07f,0.20f*F} };
325
        int[] cornerIndexes = new int[] { 0,1,1,-1,1,-1,-1,-1 };
326
        float[][] centers   = new float[][] { { 0.0f, F*SQ2/2, -F} };
327
        int[] centerIndexes = new int[] { 0,0,0,-1,0,-1,-1,-1 };
328

  
329
        FactoryCubit factory = FactoryCubit.getInstance();
330

  
331
        factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER);
332
        mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER,
333
                                                bands, bandIndexes,
334
                                                corners, cornerIndexes,
335
                                                centers, centerIndexes,
336
                                                getNumCubitFaces() );
337
        }
338
      mesh = mMeshes[0].copy(true);
339
      }
340
    else if( cubit<10 )
341
      {
342
      if( mMeshes[1]==null )
343
        {
344
        float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
345
        int[] bandIndexes   = new int[] { 0,0,1,1,1,1 };
346
        float[][] corners   = new float[][] { {0.07f,0.20f*F} };
347
        int[] cornerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
348
        float[][] centers   = new float[][] { { 0, F*SQ2/2, 0 } };
349
        int[] centerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
350

  
351
        FactoryCubit factory = FactoryCubit.getInstance();
352

  
353
        factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE);
354
        mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE,
355
                                                bands, bandIndexes,
356
                                                corners, cornerIndexes,
357
                                                centers, centerIndexes,
358
                                                getNumCubitFaces() );
359

  
360
        factory.printStickerCoords();
361
        }
362
      mesh = mMeshes[1].copy(true);
363
      }
364
    else
365
      {
366
      if( mMeshes[2]==null )
367
        {
368
        float[][] bands     = new float[][] { {0.020f,35,0.20f*(1-3*F),0.6f*(1-3*F),5,1,1},
369
                                              {0.001f,35,0.05f*(1-3*F),0.1f*(1-3*F),5,1,1} };
370
        int[] bandIndexes   = new int[] { 0,1,1,1,1,1 };
371
        float[][] corners   = new float[][] { {0.04f,0.15f} };
372
        int[] cornerIndexes = new int[] { 0,0,0,-1,-1,-1 };
373
        float[][] centers   = new float[][] { { 0, -2*Y/3, 4*Z/3 } };
374
        int[] centerIndexes = new int[] { 0,0,0,-1,-1,-1 };
375

  
376
        FactoryCubit factory = FactoryCubit.getInstance();
377

  
378
        factory.createNewFaceTransform(VERTICES_FACE,VERT_INDEXES_FACE);
379
        mMeshes[2] = factory.createRoundedSolid(VERTICES_FACE, VERT_INDEXES_FACE,
380
                                                bands, bandIndexes,
381
                                                corners, cornerIndexes,
382
                                                centers, centerIndexes,
383
                                                getNumCubitFaces() );
384

  
385
        factory.printStickerCoords();
386
        }
387
      mesh = mMeshes[2].copy(true);
388
      }
389

  
390
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[getQuat(cubit)], new Static3D(0,0,0) );
391
    mesh.apply(quat,0xffffffff,0);
392

  
393
    return mesh;
394
    }
395

  
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397

  
398
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
399
    {
400
    int COLORS = FACE_COLORS.length;
401
    int stickerType = face/COLORS;
402
    float R,S;
403

  
404
    switch(stickerType)
405
      {
406
      case 0:  R = 0.05f; S = 0.05f; break;
407
      case 1:  R = 0.03f; S = 0.03f; break;
408
      default: R = 0.05f; S = 0.06f; break;
409
      }
410

  
411
    FactorySticker factory = FactorySticker.getInstance();
412
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], S, FACE_COLORS[face%COLORS], R);
413
    }
414

  
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416
// SQ6/3 = height of the tetrahedron
417

  
418
  float returnMultiplier()
419
    {
420
    return getNumLayers()/(SQ6/3);
421
    }
422

  
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424
// PUBLIC API
425

  
426
  public Static3D[] getRotationAxis()
427
    {
428
    return ROT_AXIS;
429
    }
430

  
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432

  
433
  public int[] getBasicAngle()
434
    {
435
    return BASIC_ANGLE;
436
    }
437

  
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

  
440
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
441
    {
442
    if( curr==0 )
443
      {
444
      scramble[curr][0] = rnd.nextInt(NUM_AXIS);
445
      }
446
    else
447
      {
448
      int newVector = rnd.nextInt(NUM_AXIS-1);
449
      scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
450
      }
451

  
452
    scramble[curr][1] = rnd.nextInt(2);
453

  
454
    switch( rnd.nextInt(2) )
455
      {
456
      case 0: scramble[curr][2] = -1; break;
457
      case 1: scramble[curr][2] =  1; break;
458
      }
459
    }
460

  
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462
// JingPyraminx is solved iff
463
// a) all of its corner and edge cubits are rotated with the same quat
464
// b) its 4 face cubits might also be rotated along the axis perpendicular to the face.
465
//
466
// So:
467
// [10] might be extra QUAT[] or QUAT[]
468
// [11] might be extra QUAT[] or QUAT[]
469
// [12] might be extra QUAT[] or QUAT[]
470
// [13] might be extra QUAT[] or QUAT[]
471

  
472
  public boolean isSolved()
473
    {
474
    int index = CUBITS[0].mQuatIndex;
475

  
476
    if( CUBITS[1].mQuatIndex != index ) return false;
477
    if( CUBITS[2].mQuatIndex != index ) return false;
478
    if( CUBITS[3].mQuatIndex != index ) return false;
479
    if( CUBITS[4].mQuatIndex != index ) return false;
480
    if( CUBITS[5].mQuatIndex != index ) return false;
481
    if( CUBITS[6].mQuatIndex != index ) return false;
482
    if( CUBITS[7].mQuatIndex != index ) return false;
483
    if( CUBITS[8].mQuatIndex != index ) return false;
484
    if( CUBITS[9].mQuatIndex != index ) return false;
485

  
486
    // TODO: face cubits
487

  
488
    return true;
489
    }
490

  
491
////////////////////////////////////////////////////////////////////////
492
// only needed for solvers - there are no JingPyraminx solvers ATM)
493

  
494
  public String retObjectString()
495
    {
496
    return "";
497
    }
498

  
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

  
501
  public int getObjectName(int numLayers)
502
    {
503
    return R.string.jing;
504
    }
505

  
506
///////////////////////////////////////////////////////////////////////////////////////////////////
507

  
508
  public int getInventor(int numLayers)
509
    {
510
    return R.string.jing_inventor;
511
    }
512

  
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514

  
515
  public int getComplexity(int numLayers)
516
    {
517
    return 3;
518
    }
519
}
src/main/res/values/strings.xml
98 98
    <string name="ulti2" translatable="false">Skewb Ultimate</string>
99 99
    <string name="squa1" translatable="false">Square-1</string>
100 100
    <string name="squa2" translatable="false">Square-2</string>
101
    <string name="jing"  translatable="false">Jing Pyraminx</string>
101 102

  
102 103
    <string name="bandaged_fused"  translatable="false">Fused Cube</string>
103 104
    <string name="bandaged_2bar"   translatable="false">2Bar Cube</string>
......
128 129
    <string name="ulti2_inventor" translatable="false">Tony Fisher, 2000</string>
129 130
    <string name="squa1_inventor" translatable="false">Vojtech Kopsky, Harel Hrsel, 1999</string>
130 131
    <string name="squa2_inventor" translatable="false">David Litwin, 1995</string>
132
    <string name="jing_inventor"  translatable="false">Tony Fisher, 1991</string>
131 133

  
132 134
    <string name="bandaged_fused_inventor"  translatable="false">who knows</string>
133 135
    <string name="bandaged_2bar_inventor"   translatable="false">who knows</string>

Also available in: Unified diff