Project

General

Profile

« Previous | Next » 

Revision 834b2618

Added by Leszek Koltunski over 3 years ago

Square-1: beginnings

View differences:

src/main/java/org/distorted/control/RubikControlWhole.java
543 543
    mDyn1.add(point2);
544 544
    mDyn1.add(point3);
545 545
    mDyn1.add(point0);
546

  
546 547
    mDyn2.add(point2);
547 548
    mDyn2.add(point3);
548 549
    mDyn2.add(point0);
......
552 553
    mDyn1.setConvexity(1.0f);
553 554
    mDyn2.setConvexity(1.0f);
554 555

  
556
    mDyn1.setSpeedMode(Dynamic.SPEED_MODE_SEGMENT_CONSTANT);
557
    mDyn2.setSpeedMode(Dynamic.SPEED_MODE_SEGMENT_CONSTANT);
558

  
555 559
    mPosition1.set(point0);
556 560
    mPosition2.set(point2);
557 561

  
......
592 596
    mDyn1.setConvexity(0.0f);
593 597
    mDyn2.setConvexity(0.0f);
594 598

  
599
    mDyn1.setSpeedMode(Dynamic.SPEED_MODE_SMOOTH);
600
    mDyn2.setSpeedMode(Dynamic.SPEED_MODE_SMOOTH);
601

  
595 602
    mPosition1.set(point1f);
596 603
    mPosition2.set(point2f);
597 604

  
src/main/java/org/distorted/main/RubikSurfaceView.java
373 373
        float distQuot = mInitDistance<0 ? 1.0f : distNow/ mInitDistance;
374 374
        mInitDistance = distNow;
375 375

  
376
if( angleDiff< 0.00001f && angleDiff>-0.00001f)
377
  android.util.Log.e("D", " distQuot="+distQuot);
378
else
379
 android.util.Log.e("D", "angelDiff "+angleDiff+" distQuot="+distQuot);
380

  
376 381
        TwistyObject object = mPreRender.getObject();
377 382
        if( object!=null ) object.setObjectRatio(distQuot);
378 383
        }
src/main/java/org/distorted/objects/MovementSquare.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 MovementSquare extends Movement
27
{
28
  static final float DIST3D = 0.5f;
29
  static final float DIST2D = 0.5f;
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
  MovementSquare()
41
    {
42
    super(TwistySquare1.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
43
    }
44

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

  
47
  int computeRowFromOffset(int face, int size, float offset)
48
    {
49
    return (int)(size*offset);
50
    }
51

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

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

  
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

  
61
  boolean isInsideFace(int face, float[] p)
62
    {
63
    return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
64
    }
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

  
68
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
69
    {
70
    enabled[0] = 2;
71

  
72
    switch(face)
73
      {
74
      case 0:
75
      case 1: enabled[1]=1; enabled[2]=2; break;
76
      case 2:
77
      case 3: enabled[1]=0; enabled[2]=2; break;
78
      case 4:
79
      case 5: enabled[1]=0; enabled[2]=1; break;
80
      }
81
    }
82
}
src/main/java/org/distorted/objects/ObjectList.java
212 212
         6,
213 213
         60
214 214
       ),
215

  
216
  SQU1 (
217
         new int[][] {
218
                       {2 , 18, 0, R.drawable.ui_small_diam2, R.drawable.ui_medium_diam2, R.drawable.ui_big_diam2, R.drawable.ui_huge_diam2} ,
219
                     },
220
         TwistySquare1.class,
221
         new MovementSquare(),
222
         6,
223
         60
224
       ),
215 225
  ;
216 226

  
217 227
  public static final int NUM_OBJECTS = values().length;
......
610 620
      case 14: return new TwistyBandaged3Plate(size, quat, texture, mesh, effects, moves, res, scrWidth);
611 621
      case 15: return new TwistyBandagedEvil  (size, quat, texture, mesh, effects, moves, res, scrWidth);
612 622
      case 16: return new TwistyDiamond       (size, quat, texture, mesh, effects, moves, res, scrWidth);
623
      case 17: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
613 624
      }
614 625

  
615 626
    return null;
src/main/java/org/distorted/objects/TwistyRedi.java
106 106
         };
107 107

  
108 108
  // Colors of the faces of cubits.
109
  // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4  BROWN 5
110
  // YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 BROWN 11
109
  // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4  ORANGE 5
110
  // YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 ORANGE 11
111 111
  private static final int[][] mFaceMap = new int[][]
112 112
         {
113 113
           {  4, 2, 0,12,12,12 },
src/main/java/org/distorted/objects/TwistySquare1.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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
class TwistySquare1 extends TwistyObject
42
{
43
  private static final float COS15 = (SQ6+SQ2)/4;
44
  private static final float SIN15 = (SQ6-SQ2)/4;
45
  private static final float     X = 3*(2-SQ3)/2;
46

  
47
  static final Static3D[] ROT_AXIS = new Static3D[]
48
         {
49
           new Static3D(0,1,0),
50
           new Static3D(COS15,0,SIN15)
51
         };
52

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

  
60
  private static final Static4D[] QUATS = new Static4D[]
61
         {
62
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
63
           new Static4D(  0.0f, SIN15,  0.0f, COS15 ),
64
           new Static4D(  0.0f,  0.5f,  0.0f, SQ3/2 ),
65
           new Static4D(  0.0f, SQ2/2,  0.0f, SQ2/2 ),
66
           new Static4D(  0.0f, SQ3/2,  0.0f,  0.5f ),
67
           new Static4D(  0.0f, COS15,  0.0f, SIN15 ),
68
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
69
           new Static4D(  0.0f, COS15,  0.0f,-SIN15 ),
70
           new Static4D(  0.0f, SQ3/2,  0.0f, -0.5f ),
71
           new Static4D(  0.0f, SQ2/2,  0.0f,-SQ2/2 ),
72
           new Static4D(  0.0f,  0.5f,  0.0f,-SQ3/2 ),
73
           new Static4D(  0.0f, SIN15,  0.0f,-COS15 ),
74

  
75
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
76
           new Static4D( COS15,  0.0f, SIN15,  0.0f ),
77
           new Static4D( SQ3/2,  0.0f,  0.5f,  0.0f ),
78
           new Static4D( SQ2/2,  0.0f, SQ2/2,  0.0f ),
79
           new Static4D(  0.5f,  0.0f, SQ3/2,  0.0f ),
80
           new Static4D( SIN15,  0.0f, COS15,  0.0f ),
81
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
82
           new Static4D(-SIN15,  0.0f, COS15,  0.0f ),
83
           new Static4D( -0.5f,  0.0f, SQ3/2,  0.0f ),
84
           new Static4D(-SQ2/2,  0.0f, SQ2/2,  0.0f ),
85
           new Static4D(-SQ3/2,  0.0f,  0.5f,  0.0f ),
86
           new Static4D(-COS15,  0.0f, SIN15,  0.0f )
87
         };
88

  
89
  private static final int[] QUAT_NUMBER = new int[]
90
         {
91
           0, 6,
92
           0, 9, 6, 3, 18, 15, 12, 21,
93
           0, 9, 6, 3, 15, 12, 21, 18
94
         };
95

  
96
  // centers of the 2 middles + 8 edges + 8 corners
97
  private static final float[][] CENTERS = new float[][]
98
         {
99
             { 1.5f, 0.0f, 0.0f },
100
             {-1.5f, 0.0f, 0.0f },
101

  
102
             { 0.0f, 1.0f, 1.5f },
103
             { 1.5f, 1.0f, 0.0f },
104
             { 0.0f, 1.0f,-1.5f },
105
             {-1.5f, 1.0f, 0.0f },
106
             { 0.0f,-1.0f, 1.5f },
107
             { 1.5f,-1.0f, 0.0f },
108
             { 0.0f,-1.0f,-1.5f },
109
             {-1.5f,-1.0f, 0.0f },
110

  
111
             { 1.5f, 1.0f, 1.5f },
112
             { 1.5f, 1.0f,-1.5f },
113
             {-1.5f, 1.0f,-1.5f },
114
             {-1.5f, 1.0f, 1.5f },
115
             { 1.5f,-1.0f, 1.5f },
116
             { 1.5f,-1.0f,-1.5f },
117
             {-1.5f,-1.0f,-1.5f },
118
             {-1.5f,-1.0f, 1.5f },
119
         };
120

  
121
  private static final double[][] VERTICES_MIDDLE = new double[][]
122
          {
123
              { -1.5-X, 0.5, 1.5 },
124
              {    0.0, 0.5, 1.5 },
125
              {    0.0, 0.5,-1.5 },
126
              { -1.5+X, 0.5,-1.5 },
127
              { -1.5-X,-0.5, 1.5 },
128
              {    0.0,-0.5, 1.5 },
129
              {    0.0,-0.5,-1.5 },
130
              { -1.5+X,-0.5,-1.5 }
131
          };
132

  
133
  private static final int[][] VERT_INDEXES_MIDDLE = new int[][]
134
          {
135
              {0,1,2,3},   // counterclockwise!
136
              {4,5,6,7},
137
              {4,5,1,0},
138
              {5,6,2,1},
139
              {6,7,3,2},
140
              {7,4,0,3}
141
          };
142

  
143
  private static final double[][] VERTICES_EDGE = new double[][]
144
          {
145
              { -X, 0.5, 0.0 },
146
              { +X, 0.5, 0.0 },
147
              {0.0, 0.5,-1.5 },
148
              { -X,-0.5, 0.0 },
149
              { +X,-0.5, 0.0 },
150
              {0.0,-0.5,-1.5 },
151
          };
152

  
153
  private static final int[][] VERT_INDEXES_EDGE = new int[][]
154
          {
155
              {0,1,2},   // counterclockwise!
156
              {3,4,5},
157
              {3,4,1,0},
158
              {4,5,2,1},
159
              {5,3,0,2}
160
          };
161

  
162
  private static final double[][] VERTICES_CORNER = new double[][]
163
          {
164
              { X-1.5, 0.5,  0.0 },
165
              {   0.0, 0.5,  0.0 },
166
              {   0.0, 0.5,X-1.5 },
167
              {  -1.5, 0.5, -1.5 },
168
              { X-1.5,-0.5,  0.0 },
169
              {   0.0,-0.5,  0.0 },
170
              {   0.0,-0.5,X-1.5 },
171
              {  -1.5,-0.5, -1.5 }
172
          };
173

  
174
  private static final int[][] VERT_INDEXES_CORNER = new int[][]
175
          {
176
              {0,1,2,3},   // counterclockwise!
177
              {4,5,6,7},
178
              {4,5,1,0},
179
              {5,6,2,1},
180
              {7,4,0,3},
181
              {6,7,3,2}
182
          };
183

  
184
  // TODO
185
  private static final float[][] STICKERS = new float[][]
186
          {
187
              { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f }
188
          };
189

  
190
  private static final int NUM_ST = STICKERS.length;
191

  
192
  private static final int[][] mStickerType = new int[][]
193
         {
194
           {  NUM_ST,NUM_ST,0,     1,     2,NUM_ST },
195
           {       4,NUM_ST,3,NUM_ST,NUM_ST,NUM_ST },
196
           {       5,NUM_ST,2,     2,NUM_ST,NUM_ST }
197
         };
198

  
199
  // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4  ORANGE 5
200
  private static final int[][] mStickerColor = new int[][]
201
         {
202
           { 0, 0, 5, 0, 4, 0 },
203
           { 0, 0, 4, 1, 5, 0 },
204

  
205
           { 3, 0, 5, 0, 0, 0 },
206
           { 3, 0, 0, 0, 0, 0 },
207
           { 3, 0, 4, 0, 0, 0 },
208
           { 3, 0, 1, 0, 0, 0 },
209
           { 2, 0, 5, 0, 0, 0 },
210
           { 2, 0, 0, 0, 0, 0 },
211
           { 2, 0, 4, 0, 0, 0 },
212
           { 2, 0, 1, 0, 0, 0 },
213

  
214
           { 3, 0, 5, 0, 0, 0 },
215
           { 3, 0, 0, 4, 0, 0 },
216
           { 3, 0, 4, 1, 0, 0 },
217
           { 3, 0, 1, 5, 0, 0 },
218
           { 2, 0, 5, 0, 0, 0 },
219
           { 2, 0, 0, 4, 0, 0 },
220
           { 2, 0, 4, 1, 0, 0 },
221
           { 2, 0, 1, 5, 0, 0 },
222
         };
223

  
224
  private static MeshBase[] mMeshes;
225

  
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227

  
228
  TwistySquare1(int size, Static4D quat, DistortedTexture texture,
229
                MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
230
    {
231
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.SQU1, res, scrWidth);
232
    }
233

  
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235

  
236
  private Static4D getQuat(int cubit)
237
    {
238
    return QUATS[QUAT_NUMBER[cubit]];
239
    }
240

  
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242

  
243
  MeshBase createCubitMesh(int cubit, int numLayers)
244
    {
245
    if( mMeshes==null )
246
      {
247
      FactoryCubit factory = FactoryCubit.getInstance();
248
      factory.clear();
249
      mMeshes = new MeshBase[3];
250
      }
251

  
252
    MeshBase mesh;
253

  
254
    if( cubit<2 )
255
      {
256
      if( mMeshes[0]==null )
257
        {
258
        float[][] bands= new float[][]
259
          {
260
             {0.06f,35,0.5f,0.7f,6,2,2},
261
             {0.03f,35,0.5f,0.7f,6,2,2},
262
             {0.00f, 0,1.0f,0.0f,2,0,0}
263
          };
264
        int[] bandIndexes   = new int[] { 2,2,1,1,0,2 };
265
        float[][] corners   = new float[][] { {0.06f,0.08f} };
266
        int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
267
        float[][] centers   = new float[][] { { -0.75f, 0.0f, 0.0f} };
268
        int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
269

  
270
        FactoryCubit factory = FactoryCubit.getInstance();
271
        factory.createNewFaceTransform(VERTICES_MIDDLE,VERT_INDEXES_MIDDLE);
272
        mMeshes[0] = factory.createRoundedSolid(VERTICES_MIDDLE, VERT_INDEXES_MIDDLE,
273
                                                bands, bandIndexes,
274
                                                corners, cornerIndexes,
275
                                                centers, centerIndexes,
276
                                                getNumCubitFaces() );
277
        }
278
      mesh = mMeshes[0].copy(true);
279
      }
280
    else if( cubit<10 )
281
      {
282
      if( mMeshes[1]==null )
283
        {
284
        float[][] bands= new float[][]
285
          {
286
            {0.038f,35,0.250f,0.7f, 7,2,2},
287
            {0.000f, 0,0.125f,0.2f, 3,1,1}
288
          };
289
        int[] bandIndexes   = new int[] { 1,1,0,1,1 };
290
        float[][] corners   = new float[][] { {0.06f,0.20f} };
291
        int[] cornerIndexes = new int[] { 0,0,-1,0,0,-1 };
292
        float[][] centers   = new float[][] { { 0.0f, 0.0f,-0.5f} };
293
        int[] centerIndexes = new int[] { 0,0,-1,0,0,-1 };
294

  
295
        FactoryCubit factory = FactoryCubit.getInstance();
296
        factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE);
297
        mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE,
298
                                                bands, bandIndexes,
299
                                                corners, cornerIndexes,
300
                                                centers, centerIndexes,
301
                                                getNumCubitFaces() );
302
        }
303
      mesh = mMeshes[1].copy(true);
304
      }
305
    else
306
      {
307
      if( mMeshes[2]==null )
308
        {
309
        float[][] bands= new float[][]
310
          {
311
            {0.038f,35,0.250f,0.7f, 7,2,2},
312
            {0.000f, 0,0.125f,0.2f, 3,1,1}
313
          };
314
        int[] bandIndexes   = new int[] { 1,1,0,0,1,1 };
315
        float[][] corners   = new float[][] { {0.08f,0.20f} };
316
        int[] cornerIndexes = new int[] { 0,0,0,-1,0,0,0,-1 };
317
        float[][] centers   = new float[][] { { -0.5f, 0.0f,-0.5f} };
318
        int[] centerIndexes = new int[] { -1,0,-1,-1,-1,0,-1,-1 };
319

  
320
        FactoryCubit factory = FactoryCubit.getInstance();
321
        factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER);
322
        mMeshes[2] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER,
323
                                                bands, bandIndexes,
324
                                                corners, cornerIndexes,
325
                                                centers, centerIndexes,
326
                                                getNumCubitFaces() );
327
        }
328
      mesh = mMeshes[2].copy(true);
329
      }
330

  
331
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit), new Static3D(0,0,0) );
332
    mesh.apply(quat,0xffffffff,0);
333

  
334
    return mesh;
335
    }
336

  
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338
// TODO
339

  
340
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
341
    {
342
    float R = 0.10f;
343
    float S = 0.08f;
344

  
345
    FactorySticker factory = FactorySticker.getInstance();
346
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], S, FACE_COLORS[face], R);
347
    }
348

  
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

  
351
  float[][] getCubitPositions(int size)
352
    {
353
    return CENTERS;
354
    }
355

  
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

  
358
  Static4D[] getQuats()
359
    {
360
    return QUATS;
361
    }
362

  
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

  
365
  boolean shouldResetTextureMaps()
366
    {
367
    return false;
368
    }
369

  
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

  
372
  int getNumFaces()
373
    {
374
    return FACE_COLORS.length;
375
    }
376

  
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
// TODO
379

  
380
  float[] getCuts(int numLayers)
381
    {
382
    float[] cuts = new float[numLayers-1];
383

  
384
    for(int i=0; i<numLayers-1; i++)
385
      {
386
      cuts[i] = (2-numLayers)*0.5f + i;
387
      }
388

  
389
    return cuts;
390
    }
391

  
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

  
394
  int getNumStickerTypes(int numLayers)
395
    {
396
    return STICKERS.length;
397
    }
398

  
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

  
401
  int getNumCubitFaces()
402
    {
403
    return 6;
404
    }
405

  
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

  
408
  float getScreenRatio()
409
    {
410
    return 0.36f;
411
    }
412

  
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

  
415
  int getFaceColor(int cubit, int cubitface, int size)
416
    {
417
    int type;
418

  
419
         if( cubit< 2 ) type = 0;
420
    else if( cubit<10 ) type = 1;
421
    else                type = 2;
422

  
423
    return 0;//mStickerType[type][cubitface]*FACE_COLORS.length + mStickerColor[cubit][cubitface];
424
    }
425

  
426
///////////////////////////////////////////////////////////////////////////////////////////////////
427

  
428
  float returnMultiplier()
429
    {
430
    return 1.0f;
431
    }
432

  
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434
// TODO
435

  
436
  float[] getRowChances(int numLayers)
437
    {
438
    float[] chances = new float[numLayers];
439

  
440
    for(int i=0; i<numLayers; i++)
441
      {
442
      chances[i] = (i+1.0f) / numLayers;
443
      }
444

  
445
    return chances;
446
    }
447

  
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449
// PUBLIC API
450

  
451
  public Static3D[] getRotationAxis()
452
    {
453
    return ROT_AXIS;
454
    }
455

  
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457
// TODO
458

  
459
  public int getBasicAngle()
460
    {
461
    return 4;
462
    }
463

  
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
// TODO
466

  
467
  public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
468
    {
469
    if( num==0 )
470
      {
471
      scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
472
      }
473
    else
474
      {
475
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
476
      scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
477
      }
478

  
479
    float rowFloat = rnd.nextFloat();
480

  
481
    for(int row=0; row<mRowChances.length; row++)
482
      {
483
      if( rowFloat<=mRowChances[row] )
484
        {
485
        scramble[num][1] = row;
486
        break;
487
        }
488
      }
489

  
490
    switch( rnd.nextInt(4) )
491
      {
492
      case 0: scramble[num][2] = -2; break;
493
      case 1: scramble[num][2] = -1; break;
494
      case 2: scramble[num][2] =  1; break;
495
      case 3: scramble[num][2] =  2; break;
496
      }
497
    }
498

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

  
501
  public boolean isSolved()
502
    {
503
    int index = CUBITS[0].mQuatIndex;
504

  
505
    for(int i=1; i<NUM_CUBITS; i++)
506
      {
507
      if( CUBITS[i].mQuatIndex != index ) return false;
508
      }
509

  
510
    return true;
511
    }
512

  
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514
// only needed for solvers - there are no Square solvers ATM)
515

  
516
  public String retObjectString()
517
    {
518
    return "";
519
    }
520

  
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

  
523
  public int getObjectName(int numLayers)
524
    {
525
    return R.string.squa1;
526
    }
527

  
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

  
530
  public int getInventor(int numLayers)
531
    {
532
    return R.string.squa1_inventor;
533
    }
534

  
535
///////////////////////////////////////////////////////////////////////////////////////////////////
536

  
537
  public int getComplexity(int numLayers)
538
    {
539
    return 9;
540
    }
541
}
src/main/java/org/distorted/screens/RubikScreenPlay.java
398 398
      case 2: RubikControl control = RubikControl.getInstance();
399 399
              control.animateAll(act);
400 400
              break;
401
*/
401
 */
402 402
      case 2: ScreenList.switchScreen(act, ScreenList.SVER);
403 403
              break;
404 404
      case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
src/main/res/raw/compute_quats.c
2 2
#include <math.h>
3 3
#include <stdlib.h>
4 4

  
5
#define ULTI
5
#define SQUARE
6 6

  
7 7
#define SQ2 1.41421356237f
8 8
#define SQ3 1.73205080757f
......
11 11
#define NUM_QUATS  200
12 12

  
13 13
#ifdef PYRA 
14
#define NUM_AXIS    4
15
#define BASIC_ANGLE 3
14
int basic[] = { 3,3,3,3 };
16 15

  
17
float axis[NUM_AXIS][3] = { { SQ2*SQ3/3,   SQ3/3,          0 } ,
18
                            {-SQ2*SQ3/3,   SQ3/3,          0 } ,
19
                            {         0,  -SQ3/3, -SQ2*SQ3/3 } ,
20
                            {         0,  -SQ3/3,  SQ2*SQ3/3 } };
16
float axis[][3] = { { SQ2*SQ3/3,   SQ3/3,          0 } ,
17
                    {-SQ2*SQ3/3,   SQ3/3,          0 } ,
18
                    {         0,  -SQ3/3, -SQ2*SQ3/3 } ,
19
                    {         0,  -SQ3/3,  SQ2*SQ3/3 } };
21 20
#endif
22 21

  
23 22
#ifdef CUBE
24
#define NUM_AXIS    3
25
#define BASIC_ANGLE 4
23
int basic[] = { 4,4,4 };
26 24

  
27
float axis[NUM_AXIS][3] = { { 1,0,0 } , 
28
                            { 0,1,0 } , 
29
                            { 0,0,1 } };
25
float axis[][3] = { { 1,0,0 } , 
26
                    { 0,1,0 } , 
27
                    { 0,0,1 } };
30 28
#endif
31 29

  
32 30
#ifdef DINO
33
#define NUM_AXIS    4
34
#define BASIC_ANGLE 3
31
int basic[] = { 3,3,3,3 };
35 32

  
36
float axis[NUM_AXIS][3] = { {+SQ3/3,+SQ3/3,+SQ3/3} , 
37
                            {+SQ3/3,+SQ3/3,-SQ3/3} , 
38
                            {+SQ3/3,-SQ3/3,+SQ3/3} , 
39
                            {+SQ3/3,-SQ3/3,-SQ3/3} };
33
float axis[][3] = { {+SQ3/3,+SQ3/3,+SQ3/3} , 
34
                    {+SQ3/3,+SQ3/3,-SQ3/3} , 
35
                    {+SQ3/3,-SQ3/3,+SQ3/3} , 
36
                    {+SQ3/3,-SQ3/3,-SQ3/3} };
40 37
#endif
41 38

  
42 39
#ifdef DIAM
43
#define NUM_AXIS    4
44
#define BASIC_ANGLE 3
40
int basic[] = { 3,3,3,3 };
45 41

  
46
float axis[NUM_AXIS][3] = { {+SQ3*SQ2/3,+SQ3/3,         0} ,
47
                            {-SQ3*SQ2/3,+SQ3/3,         0} ,
48
                            {         0,+SQ3/3,+SQ3*SQ2/3} ,
49
                            {         0,+SQ3/3,-SQ3*SQ2/3} };
42
float axis[][3] = { {+SQ3*SQ2/3,+SQ3/3,         0} ,
43
                    {-SQ3*SQ2/3,+SQ3/3,         0} ,
44
                    {         0,+SQ3/3,+SQ3*SQ2/3} ,
45
                    {         0,+SQ3/3,-SQ3*SQ2/3} };
50 46
#endif
51 47

  
52 48
#ifdef HELI
53
#define NUM_AXIS 6
54
#define BASIC_ANGLE 2
49
int basic[] = { 2,2,2,2,2,2 };
55 50

  
56
float axis[NUM_AXIS][3] = { {     0, +SQ2/2, -SQ2/2} ,
57
                            {     0, -SQ2/2, -SQ2/2} ,
58
                            {+SQ2/2,      0, -SQ2/2} ,
59
                            {-SQ2/2,      0, -SQ2/2} ,
60
                            {+SQ2/2, -SQ2/2,      0} ,
61
                            {-SQ2/2, -SQ2/2,      0} };
51
float axis[][3] = { {     0, +SQ2/2, -SQ2/2} ,
52
                    {     0, -SQ2/2, -SQ2/2} ,
53
                    {+SQ2/2,      0, -SQ2/2} ,
54
                    {-SQ2/2,      0, -SQ2/2} ,
55
                    {+SQ2/2, -SQ2/2,      0} ,
56
                    {-SQ2/2, -SQ2/2,      0} };
62 57

  
63 58
#endif
64 59

  
65 60
#ifdef ULTI
66
#define NUM_AXIS 4
67
#define BASIC_ANGLE 3
61
int basic[] = { 3,3,3,3 };
68 62

  
69
float axis[NUM_AXIS][3] = {   { 5*SQ5/16 + 11.0f/16,              0.0f   ,    SQ5/8  + 1.0f/4 } ,
70
                              {   SQ5/8  +  1.0f/4 ,  5*SQ5/16 + 11.0f/16,             0.0f   } ,
71
                              {-3*SQ5/16 -  7.0f/16,  3*SQ5/16 +  7.0f/16,  3*SQ5/16 + 7.0f/16} ,
72
                              {             0.0f   ,    SQ5/4  +  1.0f/2 , -5*SQ5/8  -11.0f/8 } };
63
float axis[][3] = { { 5*SQ5/16 + 11.0f/16,              0.0f   ,    SQ5/8  + 1.0f/4 } ,
64
                    {   SQ5/8  +  1.0f/4 ,  5*SQ5/16 + 11.0f/16,             0.0f   } ,
65
                    {-3*SQ5/16 -  7.0f/16,  3*SQ5/16 +  7.0f/16,  3*SQ5/16 + 7.0f/16} ,
66
                    {             0.0f   ,    SQ5/4  +  1.0f/2 , -5*SQ5/8  -11.0f/8 } };
73 67

  
74 68
#endif
75 69

  
70
#ifdef SQUARE
71
#define COS15 (0.25f*SQ2*(SQ3+1))
72
#define SIN15 (0.25f*SQ2*(SQ3-1))
73

  
74
int basic[] = { 12, 2 };
75

  
76
float axis[][3] = { {     0, 1,     0 } ,
77
                    { COS15, 0, SIN15 } };
78
#endif
76 79

  
77 80
int inserted=0;
78 81

  
......
174 177
  {
175 178
  float tmp[4];
176 179
  float table[4*NUM_QUATS];
177
  int num;
180
  int num,NUM_AXIS = sizeof(axis) / sizeof(axis[0]);
178 181

  
179 182
  tmp[0] = 0.0f; tmp[1] = 0.0f; tmp[2] = 0.0f; tmp[3] = 1.0f;
180 183
  insert(tmp,table);
......
184 187
    normalize(ax);
185 188
    }
186 189

  
187
  for(int angle=1; angle<BASIC_ANGLE; angle++)
188
    for( int ax=0; ax<NUM_AXIS; ax++)
190
  for( int ax=0; ax<NUM_AXIS; ax++)
191
    for(int angle=1; angle<basic[ax]; angle++)
189 192
      {
190
      create_quat(axis[ax], 2*PI*angle/BASIC_ANGLE, tmp);
193
      create_quat(axis[ax], 2*PI*angle/basic[ax], tmp);
191 194
      insert(tmp,table); 
192 195
      }
193 196

  
......
204 207
    }
205 208
  while( num < inserted );
206 209

  
207
  printf("inserted: %d\n", inserted);
208

  
209 210
  for(int i=0; i<inserted; i++)
210 211
    {
211
    printf( "%d %7.4f %7.4f %7.4f %7.4f\n", i, table[4*i], table[4*i+1], table[4*i+2], table[4*i+3] );
212
    printf( "%2d %7.4f %7.4f %7.4f %7.4f\n", i, table[4*i], table[4*i+1], table[4*i+2], table[4*i+3] );
212 213
    }
213 214

  
214 215
return 0;
src/main/res/values/strings.xml
95 95
    <string name="minx4" translatable="false">Master Kilominx</string>
96 96
    <string name="minx5" translatable="false">Gigaminx</string>
97 97
    <string name="ulti2" translatable="false">Skewb Ultimate</string>
98
    <string name="squa1" translatable="false">Square-1</string>
99
    <string name="squa2" translatable="false">Square-2</string>
98 100

  
99 101
    <string name="bandaged_fused"  translatable="false">Fused Cube</string>
100 102
    <string name="bandaged_2bar"   translatable="false">2Bar Cube</string>
......
123 125
    <string name="minx4_inventor" translatable="false">David Gugl, 2010</string>
124 126
    <string name="minx5_inventor" translatable="false">Tyler Fox, 2006</string>
125 127
    <string name="ulti2_inventor" translatable="false">Tony Fisher, 2000</string>
128
    <string name="squa1_inventor" translatable="false">Vojtech Kopsky, Harel Hrsel, 1999</string>
129
    <string name="squa2_inventor" translatable="false">David Litwin, 1995</string>
126 130

  
127 131
    <string name="bandaged_fused_inventor"  translatable="false">who knows</string>
128 132
    <string name="bandaged_2bar_inventor"   translatable="false">who knows</string>

Also available in: Unified diff