Project

General

Profile

« Previous | Next » 

Revision 89a00832

Added by Leszek Koltunski almost 4 years ago

Convert Minx'es.

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
175 175
  private void initialize(int meshState,Static4D quat, Static3D move, float scale, InputStream stream, boolean fromJSON)
176 176
    {
177 177
    mQuat = quat;
178
    mOrigPos = getCubitPositions(mNumLayers);
179 178
    mAxis = getRotationAxis();
180 179
    mInitScreenRatio = getScreenRatio();
181 180
    mSolvedFunctionIndex = getSolvedFunctionIndex();
182 181
    mBasicAngles = getBasicAngles();
182
    mObjectQuats = getQuats();
183
    mNumQuats = mObjectQuats.length;
184
    mOrigPos = getCubitPositions(mNumLayers);
183 185

  
184 186
    int numAxis = mAxis.length;
185 187
    mMaxNumLayers = -1;
186

  
187 188
    mCuts = getCuts(mNumLayers);
188 189
    mNumCuts = new int[numAxis];
189 190
    for(int i=0; i<numAxis; i++)
......
196 197
    mNumFaceColors = getNumFaceColors();
197 198
    mNumAxis = mAxis.length;
198 199

  
199
    mObjectQuats = getQuats();
200
    mNumQuats = mObjectQuats.length;
201

  
202 200
    int scramblingType = getScrambleType();
203 201
    ScrambleState[] states = getScrambleStates();
204 202
    mScrambler = new TwistyObjectScrambler(scramblingType, mNumAxis,mNumLayers,states);
src/main/java/org/distorted/objectlib/objects/TwistyKilominx.java
70 70
  private void computeBasicCornerVectors(int corner)
71 71
    {
72 72
    if( mQuatCornerIndices==null ) initializeQuatIndices();
73
    if( mQuats==null ) initializeQuats();
74 73
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
75 74

  
76
    Static4D quat = mQuats[mQuatCornerIndices[corner]];
75
    Static4D quat = mObjectQuats[mQuatCornerIndices[corner]];
77 76

  
78 77
    mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
79 78
    mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
......
245 244

  
246 245
  public Static4D getCubitQuats(int cubit, int[] numLayers)
247 246
    {
248
    if( mQuats==null ) initializeQuats();
249

  
250 247
    int numL = numLayers[0];
251 248
    int numCubitsPerCorner = numCubitsPerCorner(numL);
252 249
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
253

  
254
    return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
250
    int q = getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge);
251
    return mObjectQuats[q];
255 252
    }
256 253

  
257 254
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/objects/TwistyMegaminx.java
51 51

  
52 52
  private void initializeCenterIndices()
53 53
    {
54
    mQuatCenterIndices = new int[] { 16, 18, 22,  1, 20, 13, 14, 15,  0, 12,  2,  3 };
54
    mQuatCenterIndices = new int[] { 35, 55, 38, 48, 41, 42, 58, 57,  0, 46, 29, 59 };
55 55
    }
56 56

  
57 57
///////////////////////////////////////////////////////////////////////////////////////////////////
......
93 93
  private void computeBasicCornerVectors(int corner)
94 94
    {
95 95
    if( mQuatCornerIndices==null ) initializeQuatIndices();
96
    if( mQuats==null ) initializeQuats();
97 96
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
98 97

  
99
    Static4D quat = mQuats[mQuatCornerIndices[corner]];
98
    Static4D quat = mObjectQuats[mQuatCornerIndices[corner]];
100 99

  
101 100
    mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
102 101
    mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
......
224 223

  
225 224
  public Static4D getCubitQuats(int cubit, int[] numLayers)
226 225
    {
227
    if( mQuats==null ) initializeQuats();
228

  
229 226
    int numL = numLayers[0];
230 227
    int numCubitsPerCorner = numCubitsPerCorner(numL);
231 228
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
232 229

  
233
    return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
230
    return mObjectQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
234 231
    }
235 232

  
236 233
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/objects/TwistyMinx.java
63 63
  float[][] mCenterCoords,mCorners;
64 64
  int[] mQuatEdgeIndices,mQuatCornerIndices;
65 65
  int[][] mEdgeMap,mCenterMap;
66
  Static4D[] mBasicCornerV, mCurrCornerV, mQuats;
66
  Static4D[] mBasicCornerV, mCurrCornerV;
67 67

  
68 68
///////////////////////////////////////////////////////////////////////////////////////////////////
69 69

  
......
168 168
    {
169 169
    mQuatEdgeIndices = new int[]
170 170
      {
171
        56, 40, 43, 59,  0, 19,  9, 54, 58, 49,
172
        48, 24, 52,  4, 16, 32, 20, 11, 21, 35,
173
        37, 30,  8, 28, 36, 44,  1, 46, 12, 47
171
        17, 18, 19, 20,  0, 56, 25,  5, 24, 16,
172
         9, 44,  1, 34, 35, 27, 41, 50, 26, 54,
173
        15, 49, 39, 28, 10,  2, 48,  6, 46,  3
174 174
      };
175 175
    mQuatCornerIndices = new int[]
176 176
      {
177
         0,  2,  3,  1, 40, 31, 41, 30, 39, 35,
178
        36, 34, 56, 32, 43, 21, 48, 28, 42, 23
177
         0, 29, 59, 48, 18, 53, 22, 49, 11, 54,
178
        10, 52, 17, 27, 19, 26,  9, 28, 23, 45
179 179
      };
180 180
    }
181 181

  
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

  
184
  void initializeQuats()
185
    {
186
    mQuats = new Static4D[]
187
         {
188
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
189
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
190
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
191
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
192

  
193
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
194
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
195
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
196
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
197
         new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
198
         new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
199
         new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
200
         new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
201

  
202
         new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
203
         new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
204
         new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
205
         new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
206
         new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
207
         new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
208
         new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
209
         new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
210
         new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
211
         new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
212
         new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
213
         new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
214

  
215
         new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
216
         new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
217
         new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
218
         new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
219
         new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
220
         new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
221
         new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
222
         new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
223
         new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
224
         new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
225
         new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
226
         new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
227

  
228
         new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
229
         new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
230
         new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
231
         new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
232
         new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
233
         new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
234
         new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
235
         new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
236
         new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
237
         new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
238
         new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
239
         new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
240

  
241
         new Static4D(  0.0f,  0.5f, SIN18, SIN54 ), //48
242
         new Static4D(  0.0f,  0.5f,-SIN18, SIN54 ),
243
         new Static4D(  0.0f, -0.5f, SIN18, SIN54 ),
244
         new Static4D(  0.0f, -0.5f,-SIN18, SIN54 ),
245
         new Static4D(  0.5f, SIN18,  0.0f, SIN54 ),
246
         new Static4D(  0.5f,-SIN18,  0.0f, SIN54 ),
247
         new Static4D( -0.5f, SIN18,  0.0f, SIN54 ),
248
         new Static4D( -0.5f,-SIN18,  0.0f, SIN54 ),
249
         new Static4D( SIN18,  0.0f,  0.5f, SIN54 ),
250
         new Static4D( SIN18,  0.0f, -0.5f, SIN54 ),
251
         new Static4D(-SIN18,  0.0f,  0.5f, SIN54 ),
252
         new Static4D(-SIN18,  0.0f, -0.5f, SIN54 ),
253
         };
254
    }
255

  
256 182
///////////////////////////////////////////////////////////////////////////////////////////////////
257 183
// Coordinates of all 20 corners of a Minx
258 184

  
......
454 380

  
455 381
  public int[] getSolvedQuats(int cubit, int[] numLayers)
456 382
    {
457
    if( mQuats==null ) initializeQuats();
458 383
    int status = retCubitSolvedStatus(cubit,numLayers);
459
    return status<0 ? null : buildSolvedQuats(TouchControlDodecahedron.FACE_AXIS[status],mQuats);
460
    }
461

  
462
///////////////////////////////////////////////////////////////////////////////////////////////////
463

  
464
  public Static4D[] getQuats()
465
    {
466
    if( mQuats==null ) initializeQuats();
467
    return mQuats;
384
    return status<0 ? null : buildSolvedQuats(TouchControlDodecahedron.FACE_AXIS[status],mObjectQuats);
468 385
    }
469 386

  
470 387
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff