Project

General

Profile

« Previous | Next » 

Revision e28ba324

Added by Leszek Koltunski 9 months ago

Cleanup

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
126 126
    mErrorString = null;
127 127
    }
128 128

  
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

  
131
  public abstract int getTouchControlType();
132
  public abstract int getTouchControlSplit();
133
  public abstract boolean[][] getLayerRotatable(int[] numLayers);
134
  public abstract int[][][] getEnabled();
135
  public abstract int[][] getScrambleEdges();
136
  public abstract float getStickerRadius();
137
  public abstract float getStickerStroke();
138
  public abstract float[][][] getStickerAngles();
139
  public abstract float getScreenRatio();
140
  public abstract int[] getColorTable();
141
  public abstract String getShortName();
142
  public abstract String printColor(int color);
143
  public abstract int getNumPuzzleFaces();
144
  public abstract int getFOV();
145
  public abstract String[][] getTutorials();
146

  
129 147
///////////////////////////////////////////////////////////////////////////////////////////////////
130 148

  
131 149
  private void initialize(int iconMode, Static4D quat, Static3D move, float scale, InitAssets asset, boolean fromJSON)
......
176 194
    mNode = new DistortedNode(mTexture,mEffects,mMesh);
177 195
    }
178 196

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

  
199
  private TablebasesAbstract getTablebase(OperatingSystemInterface os)
200
    {
201
    String shortName = getShortName();
202
    return ImplementedTablebasesList.createPacked(os,shortName);
203
    }
204

  
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206

  
207
  public int[][] getSolvedQuats()
208
    {
209
    return null;
210
    }
211

  
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

  
214
  protected int[][] getOldSolvedQuats()
215
    {
216
    return mSolved.getSolvedQuats(mNumLayers);
217
    }
218

  
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220
// 0: old, groups-of-quaternions based function.
221
// Still used by: Masterball, Mirror Skewb, Mirror Jing, Mirror Pyraminx & the Penrose Cubes.
222
//
223
// 1: specific function only for the Dino4.
224
//
225
// 2: the new default; automatic way based on automatic detection of monochromatic puzzle surfaces.
226

  
227
  public int getSolvedFunctionIndex()
228
    {
229
    return 2;
230
    }
231

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

  
234
  boolean isSolved()
235
    {
236
    for(int c=0; c<mNumCubits; c++) mCubitQuats[c] = getCubitQuatIndex(c);
237
    boolean solved = mSolved.isSolved(mCubitQuats);
238
    return mRotation.isSolved(solved);
239
    }
240

  
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242
// LATER
179 243
///////////////////////////////////////////////////////////////////////////////////////////////////
180 244

  
181 245
  public void recreateFaceColors()
......
192 256
    return 0;
193 257
    }
194 258

  
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

  
197
  private TablebasesAbstract getTablebase(OperatingSystemInterface os)
198
    {
199
    String shortName = getShortName();
200
    return ImplementedTablebasesList.createPacked(os,shortName);
201
    }
202

  
203 259
///////////////////////////////////////////////////////////////////////////////////////////////////
204 260

  
205 261
  private void figureOutBitmapDimensions(int numTextures)
......
286 342
    return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngles);
287 343
    }
288 344

  
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

  
291
  public int[][] getSolvedQuats()
292
    {
293
    return null;
294
    }
295

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

  
298
  protected int[][] getOldSolvedQuats()
299
    {
300
    return mSolved.getSolvedQuats(mNumLayers,mNumCubitFaces);
301
    }
302

  
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304
// 0: old, groups-of-quaternions based function.
305
// Still used by: Masterball, Mirror Skewb, Mirror Jing, Mirror Pyraminx & the Penrose Cubes.
306
//
307
// 1: specific function only for the Dino4.
308
//
309
// 2: the new default; automatic way based on automatic detection of monochromatic puzzle surfaces.
310

  
311
  public int getSolvedFunctionIndex()
312
    {
313
    return 2;
314
    }
315

  
316 345
///////////////////////////////////////////////////////////////////////////////////////////////////
317 346

  
318 347
  public int getScrambleType()
......
390 419
    final float ratioH = 1.0f/mNumTexRows;
391 420
    final Static4D[] maps = new Static4D[1];
392 421
    maps[0] = new Static4D(col*ratioW, row*ratioH, ratioW, ratioH);
393
    mMesh.setTextureMap(maps,mNumCubitFaces*cubit+face);
422
    mMesh.setTextureMap(maps, mMaxNumCubitFaces*cubit+face);
394 423
    }
395 424

  
396 425
///////////////////////////////////////////////////////////////////////////////////////////////////
......
443 472

  
444 473
    for(int cubit=0; cubit<mNumCubits; cubit++)
445 474
      {
446
      final Static4D[] maps = new Static4D[mNumCubitFaces];
475
      final Static4D[] maps = new Static4D[mMaxNumCubitFaces];
447 476
      variant = getCubitVariant(cubit,mNumLayers);
448 477

  
449
      for(int face=0; face<mNumCubitFaces; face++)
478
      for( int face=0; face<mMaxNumCubitFaces; face++)
450 479
        {
451 480
        cubColor = getDefaultCubitFaceColor(cubit,face);
452 481
        stiShape = getVariantStickerShape(variant,face);
......
457 486
        maps[face] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH);
458 487
        }
459 488

  
460
      mMesh.setTextureMap(maps,mNumCubitFaces*cubit);
489
      mMesh.setTextureMap(maps, mMaxNumCubitFaces*cubit);
461 490
      }
462 491

  
463 492
    overrideCubitFaceColor();
......
484 513
        int cubit = cubitFaces[2*j];
485 514
        int face  = cubitFaces[2*j+1];
486 515
        maps[0] = new Static4D(col*ratioW, row*ratioH, ratioW, ratioH);
487
        mMesh.setTextureMap(maps,mNumCubitFaces*cubit+face);
516
        mMesh.setTextureMap(maps, mMaxNumCubitFaces*cubit+face);
488 517
        }
489 518
      }
490 519
    }
......
892 921
    return mObjectScreenRatio*mInitScreenRatio;
893 922
    }
894 923

  
895
///////////////////////////////////////////////////////////////////////////////////////////////////
896

  
897
  boolean isSolved()
898
    {
899
    for(int c=0; c<mNumCubits; c++) mCubitQuats[c] = getCubitQuatIndex(c);
900
    boolean solved = mSolved.isSolved(mCubitQuats);
901
    return mRotation.isSolved(solved);
902
    }
903

  
904 924
///////////////////////////////////////////////////////////////////////////////////////////////////
905 925
// INTERNAL API - those are called from 'effects' package
906 926
///////////////////////////////////////////////////////////////////////////////////////////////////
......
965 985

  
966 986
  public int getCubitFaceStickerIndex(int cubit, int face)
967 987
    {
968
    Static4D texMap = mMesh.getTextureMap(mNumCubitFaces*cubit + face);
988
    Static4D texMap = mMesh.getTextureMap(mMaxNumCubitFaces*cubit + face);
969 989

  
970 990
    int x = (int)(texMap.get0()/texMap.get2());
971 991
    int y = (int)(texMap.get1()/texMap.get3());
......
1070 1090
  public ObjectSignature getSignature()       { return mMetadata.getSignature(); }
1071 1091
  public int getCategory()                    { return mMetadata!=null ? mMetadata.getCategory() : 0; }
1072 1092
  public boolean isSubmittable()              { return mCurrentColorSchemeSubmittable; }
1073

  
1074
///////////////////////////////////////////////////////////////////////////////////////////////////
1075

  
1076
  public abstract int getTouchControlType();
1077
  public abstract int getTouchControlSplit();
1078
  public abstract boolean[][] getLayerRotatable(int[] numLayers);
1079
  public abstract int[][][] getEnabled();
1080
  public abstract int[][] getScrambleEdges();
1081
  public abstract float getStickerRadius();
1082
  public abstract float getStickerStroke();
1083
  public abstract float[][][] getStickerAngles();
1084
  public abstract float getScreenRatio();
1085
  public abstract int[] getColorTable();
1086
  public abstract String getShortName();
1087
  public abstract String printColor(int color);
1088
  public abstract int getNumPuzzleFaces();
1089
  public abstract int getFOV();
1090
  public abstract String[][] getTutorials();
1091 1093
  }
src/main/java/org/distorted/objectlib/main/TwistyObjectSolved.java
119 119
// Color index, i.e. the index into the 'FACE_COLORS' table.
120 120
// else (edge or corner cubit, more than one non-black face): return -2.
121 121

  
122
  private int retCubitSolvedStatus(int cubit, int[] numLayers, int numCubitFaces)
122
  private int retCubitSolvedStatus(int cubit, int[] numLayers)
123 123
    {
124
    int numNonBlack=0, nonBlackIndex=-1, stiShape, cubColor;
124
    int numNonBlack=0, nonBlackIndex=-1;
125 125
    int variant = mParent.getCubitVariant(cubit,numLayers);
126
    ObjectShape shape = mParent.getObjectShape(variant);
127
    int numFaces = shape.getNumFaces();
126 128

  
127
    for(int face=0; face<numCubitFaces; face++)
128
      {
129
      stiShape = mParent.getVariantStickerShape(variant,face);
130
      cubColor = mParent.getCubitFaceMap(cubit,face);
131

  
132
      if( stiShape>=0 && cubColor>=0 )
129
    for(int face=0; face<numFaces; face++)
130
      if( mParent.faceIsOuter(cubit,face) )
133 131
        {
134 132
        numNonBlack++;
135
        nonBlackIndex = cubColor;
133
        nonBlackIndex = mParent.getCubitFaceMap(cubit,face);
136 134
        }
137
      }
138 135

  
139 136
    if( numNonBlack==0 ) return -1;
140 137
    if( numNonBlack>=2 ) return -2;
......
599 596
// Called from TwistyObject
600 597
///////////////////////////////////////////////////////////////////////////////////////////////////
601 598

  
602
  int[][] getSolvedQuats(int[] numLayers, int numCubitFaces)
599
  int[][] getSolvedQuats(int[] numLayers)
603 600
    {
604 601
    int[] groups = new int[mNumCubits];
605 602
    int numGroups = 1;
......
607 604

  
608 605
    for(int cubit=0; cubit<mNumCubits; cubit++)
609 606
      {
610
      groups[cubit] = retCubitSolvedStatus(cubit,numLayers,numCubitFaces);
607
      groups[cubit] = retCubitSolvedStatus(cubit,numLayers);
611 608
      if( groups[cubit]>=0 ) numGroups++;
612 609
      else                   numFirst++;
613 610
      }
src/main/java/org/distorted/objectlib/main/TwistyObjectWithMesh.java
49 49
  protected int[] mNumLayers;
50 50
  protected MeshBase mMesh;
51 51
  protected DistortedEffects mEffects;
52
  protected int mNumCubitFaces;
52
  protected int mMaxNumCubitFaces;
53 53

  
54 54
  private Static4D[] mCubitOrigQuat;
55 55
  private MeshBase[] mMeshes;
......
252 252
// it is possible to provide some artificial surfaces - for example, in case of the Penrose, the
253 253
// three surfaces can be only the single 'middle' plane [the one on the bend].
254 254

  
255
  public float[] getMonochromaticSurface(int variant, int cubitIndex, int faceIndex, float px, float py, float pz)
255
  public float[] getMonochromaticSurface(int variant, int cubit, int face, float px, float py, float pz)
256 256
    {
257
    if( !faceIsOuter(cubitIndex,faceIndex) ) return null;
257
    if( !faceIsOuter(cubit,face) ) return null;
258 258

  
259
    Static4D cubitQuat = getCubitQuats(cubitIndex,mNumLayers);
259
    Static4D cubitQuat = getCubitQuats(cubit,mNumLayers);
260 260

  
261 261
    float[] normal   = new float[4];
262 262
    float[] intPoint = new float[3];
......
264 264
    float[] surface  = new float[4];
265 265

  
266 266
    ObjectShape objShape = mShapes[variant];
267
    objShape.getFacePoint(faceIndex,intPoint);
268
    objShape.getFaceNormal(faceIndex,normal);
267
    objShape.getFacePoint(face,intPoint);
268
    objShape.getFaceNormal(face,normal);
269 269

  
270 270
    QuatHelper.rotateVectorByQuat(rotPoint,intPoint[0],intPoint[1],intPoint[2],1,cubitQuat);
271 271
    QuatHelper.rotateVectorByQuat(surface,normal[0],normal[1],normal[2],0,cubitQuat);
......
376 376
    {
377 377
    mNumCubitVariants = getNumCubitVariants(mNumLayers);
378 378

  
379
    if( fromJSON ) mNumCubitFaces = getNumCubitFaces();
379
    if( fromJSON ) mMaxNumCubitFaces= getNumCubitFaces();
380 380

  
381 381
    if( !fromDMESH || !fromJSON )
382 382
      {
......
385 385

  
386 386
      mShapes = new ObjectShape[mNumCubitVariants];
387 387
      for(int v=0; v<mNumCubitVariants; v++) mShapes[v] = getObjectShape(v);
388
      mNumCubitFaces = ObjectShape.computeNumComponents(mShapes);
388
      mMaxNumCubitFaces= ObjectShape.computeNumComponents(mShapes);
389 389
      mVariantFaceIsOuter = new int[mNumCubitVariants][];
390 390

  
391 391
      if( !fromJSON )
......
425 425

  
426 426
      for(int i=0; i<mNumCubits; i++)
427 427
        {
428
        cubitMesh[i] = createSingleCubitMesh(i,mNumLayers,mNumCubitFaces);
428
        cubitMesh[i] = createSingleCubitMesh(i,mNumLayers,mMaxNumCubitFaces);
429 429
        Static3D pos = getPos(mCubitPos[i]);
430 430
        cubitMesh[i].apply(new MatrixEffectMove(pos),1,0);
431 431
        }

Also available in: Unified diff