Project

General

Profile

« Previous | Next » 

Revision 963921af

Added by Leszek Koltunski about 3 years ago

Remove statics from the Ultimate class.

View differences:

src/main/java/org/distorted/objects/TwistyObject.java
271 271
    int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers);
272 272
    int resourceID= list.getResourceIDs()[sizeIndex];
273 273

  
274
    if( false ) // resourceID!=0 )
274
    if( resourceID!=0 )
275 275
      {
276 276
      InputStream is = res.openRawResource(resourceID);
277 277
      DataInputStream dos = new DataInputStream(is);
src/main/java/org/distorted/objects/TwistyUltimate.java
66 66
           new Static3D( 0,C,-B)
67 67
         };
68 68

  
69
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
70

  
71 69
  private static final int[] FACE_COLORS = new int[]
72 70
         {
73 71
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
......
75 73
           MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
76 74
         };
77 75

  
78
  private static final Static4D[] QUATS = new Static4D[]
79
         {
80
           new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
81
           new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
82
           new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
83
           new Static4D( 0.0f,    F,   -E, 0.5f ),
84
           new Static4D( 0.0f,   -F,    E, 0.5f ),
85
           new Static4D(    E, 0.0f,    F, 0.5f ),
86
           new Static4D(   -E, 0.0f,   -F, 0.5f ),
87
           new Static4D(    F,    E, 0.0f, 0.5f ),
88
           new Static4D(   -F,   -E, 0.0f, 0.5f ),
89
           new Static4D(    E,    F,-0.5f, 0.0f ),
90
           new Static4D( 0.5f,   -E,    F, 0.0f ),
91
           new Static4D(    F, 0.5f,    E, 0.0f )
92
         };
93

  
94
  // Colors of the faces of cubits.
95
  private static final int[][] mFaceMap = new int[][]
96
         {
97
           { 25,24,35, 36,36,36,36,36 },
98
           { 27,28,29, 36,36,36,36,36 },
99
           { 31,26,30, 36,36,36,36,36 },
100
           { 32,34,33, 36,36,36,36,36 },
101

  
102
           { 31,32,25, 36,36,36,36,36 },
103
           { 33,28,24, 36,36,36,36,36 },
104
           { 26,35,27, 36,36,36,36,36 },
105
           { 30,29,34, 36,36,36,36,36 },
106

  
107
           {  8, 0,13,21, 36,36,36,36 },
108
           {  1, 2,19,23, 36,36,36,36 },
109
           {  4,11,12,15, 36,36,36,36 },
110
           {  3, 6,14,17, 36,36,36,36 },
111
           {  5, 9,22,16, 36,36,36,36 },
112
           {  7,10,20,18, 36,36,36,36 }
113
         };
114

  
115
  // centers of the 14 cubits.
116
  static final float[][] CENTERS = new float[][]
117
         {
118
           { 0.0f,-0.5f,    G },
119
           {    E,   -E,   -E },
120
           {   -G, 0.0f,-0.5f },
121
           { 0.5f,    G, 0.0f },
122

  
123
           {   -E,    E,    E },
124
           {    G, 0.0f, 0.5f },
125
           {-0.5f,   -G, 0.0f },
126
           { 0.0f, 0.5f,   -G },
127

  
128
           {        E/2, (E+0.5f)/2,    (E+G)/2 },
129
           {   -(E+G)/2,       -E/2, (E+0.5f)/2 },
130
           { (E+0.5f)/2,   -(E+G)/2,        E/2 },
131
           {       -E/2,-(E+0.5f)/2,   -(E+G)/2 },
132
           {    (E+G)/2,        E/2,-(E+0.5f)/2 },
133
           {-(E+0.5f)/2,    (E+G)/2,       -E/2 }
134
         };
135

  
136
  private static final double[][] VERTICES_SMALL_LEFT = new double[][]
137
         {
138
            {         0.000,         0.000,         0.000},
139
            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 - 0.375},
140
            { SQ5/8 + 0.125,-SQ5/8 - 0.375,       + 0.250},
141
            { SQ5/8 + 0.375,       + 0.250,-SQ5/8 - 0.125},
142
            { SQ5/4 + 0.250,-SQ5/4 - 0.250,-SQ5/4 - 0.250},
143
            { SQ5/8 - 0.125,       + 0.250,-SQ5/8 - 0.125},
144
            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 + 0.125},
145
            { SQ5/8 + 0.125,-SQ5/8 + 0.125,       + 0.250}
146
         };
147

  
148
  private static final int[][] VERT_INDEXES_SMALL_LEFT  = new int[][]
149
         {
150
           {6,0,5,1},   // counterclockwise!
151
           {0,7,3,5},
152
           {0,6,2,7},
153
           {1,5,3,4},
154
           {3,7,2,4},
155
           {2,6,1,4},
156
         };
157

  
158
  private static final double[][] VERTICES_SMALL_RIGHT = new double[][]
159
         {
160
           { 0.0       ,  0.0      , 0.0       },
161
           { -0.5*E    , 0.5*E+0.25, -0.25     },
162
           {-0.25      , -E/2      , (-2*E-1)/4},
163
           { 0.5*E+0.25, 0.25      , -E/2      },
164
           { 0.0       , 0.5       , -E-0.5    },
165
           { 0.0       , 0.5       , 0.0       },
166
           { -0.5*E    ,-0.5*E+0.25, -0.25     },
167
           {  0.5*E    ,-0.5*E+0.25, -0.25     }
168
         };
169

  
170
  private static final int[][] VERT_INDEXES_SMALL_RIGHT = new int[][]
171
         {
172
           {6,0,5,1},   // counterclockwise!
173
           {0,7,3,5},
174
           {0,6,2,7},
175
           {4,3,5,1},
176
           {4,2,7,3},
177
           {4,1,6,2},
178
         };
179

  
180
  private static final double[][] VERTICES_BIG = new double[][]
181
         {
182
           {-E/2     ,-E/2+0.25,     0.25},
183
           { E/2     , E/2-0.25,    -0.25},
184
           {-E       ,     0.00,     0.00},
185
           {     0.25, E/2     ,-E/2-0.25},
186
           {-E/2     ,-E/2-0.25,     0.25},
187
           { E/2+0.25,    -0.25,-E/2     },
188
           {-E       ,    -0.50,     0.00},
189
           {     0.50,     0.00,-E       },
190
           {-E  +0.25, E/2     ,-E/2-0.25},
191
           {     0.25,-E/2-0.50,-E/2+0.25},
192
           {-E/2     ,-E/2-0.25,-E  -0.25}
193
         };
194

  
195
  private static final int[][] VERT_INDEXES_BIG = new int[][]
196
         {
197
           {0,1,3,8,2},   // counterclockwise!
198
           {0,4,9,5,1},
199
           { 0,2,6,4},
200
           { 1,5,7,3},
201
           {10,9,4,6},
202
           {10,9,5,7},
203
           {10,8,3,7},
204
           {10,8,2,6}
205
         };
206

  
207
  private static final int[] QUAT_INDEX = new int[]
208
         {
209
           0,6,1,2,0,4,6,5,0,1,4,9,5,2
210
         };
211

  
212
  private static final float[][] STICKERS = new float[][]
213
         {
214
           { -0.14400357f, -0.47894150f, 0.50000000f,-0.011045523f, 0.37700626f, 0.36749030f,-0.26699730f, 0.36749026f, -0.46600536f, -0.24499352f }, // Big cubit 1st
215
           {  0.36327127f,  0.26393202f,-0.36327127f, 0.500000000f,-0.36327127f,-0.26393202f, 0.36327127f,-0.50000000f },                             // Big cubit 2nd
216
           { -0.29389262f, -0.50000000f, 0.29389262f,-0.309017000f, 0.29389262f, 0.30901700f,-0.29389262f, 0.50000000f },                             // Small cubit 1st
217
         };
218

  
219
  private static final ObjectSticker[] mStickers;
220

  
221
  static
222
    {
223
    mStickers = new ObjectSticker[STICKERS.length];
224
    final float R1 = 0.08f;
225
    final float R2 = 0.13f;
226
    final float R3 = 0.11f;
227
    final float[][] radii  = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
228
    final float[] strokes = { 0.07f, 0.09f, 0.08f };
229

  
230
    for(int s=0; s<STICKERS.length; s++)
231
      {
232
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
233
      }
234
    }
235

  
236 76
  private int mCurrState;
237 77
  private int mIndexExcluded;
238 78
  private final ScrambleState[] mStates;
239 79
  private int[][] mScrambleTable;
240 80
  private int[] mNumOccurences;
81
  private int[] mBasicAngle;
82
  private Static4D[] mQuats;
83
  private int[][] mFaceMap;
84
  private float[][] mCenters;
85
  private int[] mQuatIndex;
86
  private ObjectSticker[] mStickers;
241 87

  
242 88
///////////////////////////////////////////////////////////////////////////////////////////////////
243 89

  
......
254 100
      };
255 101
    }
256 102

  
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

  
105
  private void initializeQuats()
106
    {
107
    mQuats = new Static4D[]
108
         {
109
         new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
110
         new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
111
         new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
112
         new Static4D( 0.0f,    F,   -E, 0.5f ),
113
         new Static4D( 0.0f,   -F,    E, 0.5f ),
114
         new Static4D(    E, 0.0f,    F, 0.5f ),
115
         new Static4D(   -E, 0.0f,   -F, 0.5f ),
116
         new Static4D(    F,    E, 0.0f, 0.5f ),
117
         new Static4D(   -F,   -E, 0.0f, 0.5f ),
118
         new Static4D(    E,    F,-0.5f, 0.0f ),
119
         new Static4D( 0.5f,   -E,    F, 0.0f ),
120
         new Static4D(    F, 0.5f,    E, 0.0f )
121
         };
122
    }
123

  
257 124
///////////////////////////////////////////////////////////////////////////////////////////////////
258 125

  
259 126
  int[] getSolvedQuats(int cubit, int numLayers)
260 127
    {
128
    if( mQuats==null ) initializeQuats();
261 129
    int status = retCubitSolvedStatus(cubit,numLayers);
262
    return status<0 ? null : buildSolvedQuats(MovementUltimate.FACE_AXIS[status],QUATS);
130
    return status<0 ? null : buildSolvedQuats(MovementUltimate.FACE_AXIS[status],mQuats);
263 131
    }
264 132

  
265 133
///////////////////////////////////////////////////////////////////////////////////////////////////
......
270 138

  
271 139
    if( variant==0 )
272 140
      {
141
      double[][] vertices = new double[][]
142
         {
143
           { 0.0       ,  0.0      , 0.0       },
144
           { -0.5*E    , 0.5*E+0.25, -0.25     },
145
           {-0.25      , -E/2      , (-2*E-1)/4},
146
           { 0.5*E+0.25, 0.25      , -E/2      },
147
           { 0.0       , 0.5       , -E-0.5    },
148
           { 0.0       , 0.5       , 0.0       },
149
           { -0.5*E    ,-0.5*E+0.25, -0.25     },
150
           {  0.5*E    ,-0.5*E+0.25, -0.25     }
151
         };
152
      int[][] vert_indices = new int[][]
153
         {
154
           {6,0,5,1},
155
           {0,7,3,5},
156
           {0,6,2,7},
157
           {4,3,5,1},
158
           {4,2,7,3},
159
           {4,1,6,2},
160
         };
161

  
273 162
      float[][] bands     = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
274 163
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
275 164
      float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
276 165
      int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
277 166
      float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
278 167
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
279
      return new ObjectShape(VERTICES_SMALL_RIGHT,VERT_INDEXES_SMALL_RIGHT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
168
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
280 169
      }
281 170
    else if( variant==1 )
282 171
      {
172
      double[][] vertices = new double[][]
173
         {
174
            {         0.000,         0.000,         0.000},
175
            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 - 0.375},
176
            { SQ5/8 + 0.125,-SQ5/8 - 0.375,       + 0.250},
177
            { SQ5/8 + 0.375,       + 0.250,-SQ5/8 - 0.125},
178
            { SQ5/4 + 0.250,-SQ5/4 - 0.250,-SQ5/4 - 0.250},
179
            { SQ5/8 - 0.125,       + 0.250,-SQ5/8 - 0.125},
180
            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 + 0.125},
181
            { SQ5/8 + 0.125,-SQ5/8 + 0.125,       + 0.250}
182
         };
183
      int[][] vert_indices  = new int[][]
184
         {
185
           {6,0,5,1},
186
           {0,7,3,5},
187
           {0,6,2,7},
188
           {1,5,3,4},
189
           {3,7,2,4},
190
           {2,6,1,4},
191
         };
192

  
283 193
      float[][] bands     = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
284 194
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
285 195
      float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
286 196
      int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
287 197
      float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
288 198
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
289
      return new ObjectShape(VERTICES_SMALL_LEFT,VERT_INDEXES_SMALL_LEFT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
199
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
290 200
      }
291 201
    else
292 202
      {
203
      double[][] vertices = new double[][]
204
         {
205
           {-E/2     ,-E/2+0.25,     0.25},
206
           { E/2     , E/2-0.25,    -0.25},
207
           {-E       ,     0.00,     0.00},
208
           {     0.25, E/2     ,-E/2-0.25},
209
           {-E/2     ,-E/2-0.25,     0.25},
210
           { E/2+0.25,    -0.25,-E/2     },
211
           {-E       ,    -0.50,     0.00},
212
           {     0.50,     0.00,-E       },
213
           {-E  +0.25, E/2     ,-E/2-0.25},
214
           {     0.25,-E/2-0.50,-E/2+0.25},
215
           {-E/2     ,-E/2-0.25,-E  -0.25}
216
         };
217
      int[][] vert_indices = new int[][]
218
         {
219
           {0,1,3,8,2},   // counterclockwise!
220
           {0,4,9,5,1},
221
           { 0,2,6,4},
222
           { 1,5,7,3},
223
           {10,9,4,6},
224
           {10,9,5,7},
225
           {10,8,3,7},
226
           {10,8,2,6}
227
         };
228

  
293 229
      float[][] bands     = new float[][] { {0.04f,17,0.5f,0.2f,5,2,2}, {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
294 230
      int[] bandIndices   = new int[] { 0,0,1,1,2,2,2,2 };
295 231
      float[][] corners   = new float[][] { { 0.013f, 0.08f } };
296 232
      int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 };
297 233
      float[][] centers   = new float[][] { { -(SQ5+1)/8, 0.25f, -(SQ5+5)/8 } };
298 234
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
299
      return new ObjectShape(VERTICES_BIG,VERT_INDEXES_BIG,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
235
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
300 236
      }
301 237
    }
302 238

  
......
304 240

  
305 241
  Static4D getQuat(int cubit, int numLayers)
306 242
    {
307
    return QUATS[QUAT_INDEX[cubit]];
243
    if( mQuats     ==null ) initializeQuats();
244
    if( mQuatIndex ==null ) mQuatIndex = new int[] { 0,6,1,2,0,4,6,5,0,1,4,9,5,2 };
245
    return mQuats[mQuatIndex[cubit]];
308 246
    }
309 247

  
310 248
///////////////////////////////////////////////////////////////////////////////////////////////////
......
325 263

  
326 264
  float[][] getCubitPositions(int numLayers)
327 265
    {
328
    return CENTERS;
266
    if( mCenters==null )
267
      {
268
      mCenters = new float[][]
269
         {
270
           { 0.0f,-0.5f,    G },
271
           {    E,   -E,   -E },
272
           {   -G, 0.0f,-0.5f },
273
           { 0.5f,    G, 0.0f },
274

  
275
           {   -E,    E,    E },
276
           {    G, 0.0f, 0.5f },
277
           {-0.5f,   -G, 0.0f },
278
           { 0.0f, 0.5f,   -G },
279

  
280
           {        E/2, (E+0.5f)/2,    (E+G)/2 },
281
           {   -(E+G)/2,       -E/2, (E+0.5f)/2 },
282
           { (E+0.5f)/2,   -(E+G)/2,        E/2 },
283
           {       -E/2,-(E+0.5f)/2,   -(E+G)/2 },
284
           {    (E+G)/2,        E/2,-(E+0.5f)/2 },
285
           {-(E+0.5f)/2,    (E+G)/2,       -E/2 }
286
         };
287
      }
288

  
289
    return mCenters;
329 290
    }
330 291

  
331 292
///////////////////////////////////////////////////////////////////////////////////////////////////
332 293

  
333 294
  int getFaceColor(int cubit, int cubitface, int size)
334 295
    {
296
    if( mFaceMap==null )
297
      {
298
      mFaceMap = new int[][]
299
         {
300
           { 25,24,35, 36,36,36,36,36 },
301
           { 27,28,29, 36,36,36,36,36 },
302
           { 31,26,30, 36,36,36,36,36 },
303
           { 32,34,33, 36,36,36,36,36 },
304

  
305
           { 31,32,25, 36,36,36,36,36 },
306
           { 33,28,24, 36,36,36,36,36 },
307
           { 26,35,27, 36,36,36,36,36 },
308
           { 30,29,34, 36,36,36,36,36 },
309

  
310
           {  8, 0,13,21, 36,36,36,36 },
311
           {  1, 2,19,23, 36,36,36,36 },
312
           {  4,11,12,15, 36,36,36,36 },
313
           {  3, 6,14,17, 36,36,36,36 },
314
           {  5, 9,22,16, 36,36,36,36 },
315
           {  7,10,20,18, 36,36,36,36 }
316
         };
317
      }
318

  
335 319
    return mFaceMap[cubit][cubitface];
336 320
    }
337 321

  
......
346 330

  
347 331
  ObjectSticker retSticker(int face)
348 332
    {
333
    if( mStickers==null )
334
      {
335
      float[][] STICKERS = new float[][]
336
         {
337
           { -0.14400357f, -0.47894150f, 0.50000000f,-0.011045523f, 0.37700626f, 0.36749030f,-0.26699730f, 0.36749026f, -0.46600536f, -0.24499352f }, // Big cubit 1st
338
           {  0.36327127f,  0.26393202f,-0.36327127f, 0.500000000f,-0.36327127f,-0.26393202f, 0.36327127f,-0.50000000f },                             // Big cubit 2nd
339
           { -0.29389262f, -0.50000000f, 0.29389262f,-0.309017000f, 0.29389262f, 0.30901700f,-0.29389262f, 0.50000000f },                             // Small cubit 1st
340
         };
341

  
342
      final float R1 = 0.08f;
343
      final float R2 = 0.13f;
344
      final float R3 = 0.11f;
345
      final float[][] radii  = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
346
      final float[] strokes = { 0.07f, 0.09f, 0.08f };
347

  
348
      mStickers = new ObjectSticker[STICKERS.length];
349

  
350
      for(int s=0; s<STICKERS.length; s++)
351
        {
352
        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
353
        }
354
      }
355

  
349 356
    return mStickers[face/NUM_FACES];
350 357
    }
351 358

  
......
360 367

  
361 368
  Static4D[] getQuats()
362 369
    {
363
    return QUATS;
370
    if( mQuats==null ) initializeQuats();
371
    return mQuats;
364 372
    }
365 373

  
366 374
///////////////////////////////////////////////////////////////////////////////////////////////////
......
396 404

  
397 405
  int getNumStickerTypes(int numLayers)
398 406
    {
399
    return STICKERS.length;
407
    return 3;
400 408
    }
401 409

  
402 410
///////////////////////////////////////////////////////////////////////////////////////////////////
......
473 481

  
474 482
  public int[] getBasicAngle()
475 483
    {
476
    return BASIC_ANGLE;
484
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
485
    return mBasicAngle;
477 486
    }
478 487

  
479 488
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff