Project

General

Profile

« Previous | Next » 

Revision a57e6870

Added by Leszek Koltunski over 2 years ago

make numLayers into an int[] (preparation for Cuboids)
Caution: because of previous changes to cubit order in cube, the Solver is broken!

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyMirror.java
87 87

  
88 88
///////////////////////////////////////////////////////////////////////////////////////////////////
89 89

  
90
  public TwistyMirror(int size, Static4D quat, Static3D move, DistortedTexture texture,
90
  public TwistyMirror(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
91 91
                      MeshSquare mesh, DistortedEffects effects, Resources res, int scrWidth)
92 92
    {
93
    super(size, size, quat, move, texture, mesh, effects, res, scrWidth);
93
    super(numL, numL[0], quat, move, texture, mesh, effects, res, scrWidth);
94 94
    }
95 95

  
96 96
///////////////////////////////////////////////////////////////////////////////////////////////////
......
99 99
    {
100 100
    if( mStates==null )
101 101
      {
102
      int size = getNumLayers();
102
      int[] numLayers = getNumLayers();
103 103
      int[][] m = new int[16][];
104
      for(int i=1; i<16; i++) m[i] = createEdges(size,i);
104
      for(int i=1; i<16; i++) m[i] = createEdges(numLayers[0],i);
105 105

  
106 106
      mStates = new ScrambleState[]
107 107
        {
......
129 129

  
130 130
///////////////////////////////////////////////////////////////////////////////////////////////////
131 131

  
132
  protected int getResource(int numLayers)
132
  protected int getResource(int[] numLayers)
133 133
    {
134
    switch(numLayers)
134
    switch(numLayers[0])
135 135
      {
136 136
      case 2: return R.raw.mirr2;
137 137
      case 3: return R.raw.mirr3;
......
201 201
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
202 202
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
203 203

  
204
  protected int[] getSolvedQuats(int cubit, int numLayers)
204
  protected int[] getSolvedQuats(int cubit, int[] numLayers)
205 205
    {
206
    if( numLayers==3 )
206
    if( numLayers[0]==3 )
207 207
      {
208 208
      switch(cubit)
209 209
        {
......
221 221

  
222 222
///////////////////////////////////////////////////////////////////////////////////////////////////
223 223

  
224
  protected int getFaceColor(int cubit, int cubitface, int numLayers)
224
  protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
225 225
    {
226
    if( numLayers==2 )
226
    int numL = numLayers[0];
227

  
228
    if( numL==2 )
227 229
      {
228 230
      switch(cubitface)
229 231
        {
......
259 261
                return NUM_TEXTURES;
260 262
        }
261 263
      }
262
    if( numLayers==3 )
264
    if( numL==3 )
263 265
      {
264 266
      switch(cubitface)
265 267
        {
......
338 340

  
339 341
///////////////////////////////////////////////////////////////////////////////////////////////////
340 342

  
341
  private float[] generateStrokes()
343
  private float[] generateStrokes(int numLayers)
342 344
    {
343
    int num = getNumLayers();
344

  
345
    if( num==2 )
345
    if( numLayers==2 )
346 346
      {
347 347
      int LEN = SEQ2.length;
348 348
      float[] tmp = new float[LEN];
......
370 370

  
371 371
///////////////////////////////////////////////////////////////////////////////////////////////////
372 372

  
373
  private float[][] generateStickers()
373
  private float[][] generateStickers(int numLayers)
374 374
    {
375
    int num = getNumLayers();
376

  
377
    if( num==2 )
375
    if( numLayers==2 )
378 376
      {
379 377
      int LEN = SEQ2.length;
380 378
      float[][] tmp = new float[LEN][];
......
396 394
    {
397 395
    if( mStickers==null )
398 396
      {
399
      final float[][] STICKERS = generateStickers();
397
      int[] numLayers = getNumLayers();
398
      int numL = numLayers[0];
399
      final float[][] STICKERS = generateStickers(numL);
400 400
      final int NUM_STICKERS = STICKERS.length;
401 401
      final float radius = 0.10f;
402 402
      final float[] radii = {radius,radius,radius,radius};
403
      float[] STROKES = generateStrokes();
403
      float[] STROKES = generateStrokes(numL);
404 404

  
405 405
      if( ObjectControl.isInIconMode() )
406 406
        {
407 407
        int len = STROKES.length;
408
        float mult = getNumLayers()==2 ? 1.8f: 2.0f;
408
        float mult = numL==2 ? 1.8f: 2.0f;
409 409
        for(int i=0; i<len; i++) STROKES[i]*=mult;
410 410
        }
411 411

  
......
422 422

  
423 423
///////////////////////////////////////////////////////////////////////////////////////////////////
424 424

  
425
  protected int getNumStickerTypes(int numLayers)
425
  protected int getNumStickerTypes(int[] numLayers)
426 426
    {
427
    return numLayers==2 ? SEQ2.length : SEQ3.length;
427
    return numLayers[0]==2 ? SEQ2.length : SEQ3.length;
428 428
    }
429 429

  
430 430
///////////////////////////////////////////////////////////////////////////////////////////////////
......
436 436

  
437 437
///////////////////////////////////////////////////////////////////////////////////////////////////
438 438

  
439
  protected ObjectShape getObjectShape(int cubit, int numLayers)
439
  protected ObjectShape getObjectShape(int cubit, int[] numLayers)
440 440
    {
441 441
    int extraI, extraV, num;
442 442
    float height;
443
    int numL = numLayers[0];
443 444

  
444
    switch(numLayers)
445
    switch(numL)
445 446
      {
446 447
      case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
447 448
      case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
......
449 450
      default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
450 451
      }
451 452

  
452
    int xrow = getRow(cubit,numLayers,0);
453
    int yrow = getRow(cubit,numLayers,1);
454
    int zrow = getRow(cubit,numLayers,2);
453
    int xrow = getRow(cubit,numL,0);
454
    int yrow = getRow(cubit,numL,1);
455
    int zrow = getRow(cubit,numL,2);
455 456

  
456
    float XL = -0.5f + (xrow==          0 ? DX : 0);
457
    float XR = +0.5f + (xrow==numLayers-1 ? DX : 0);
458
    float YL = -0.5f - (yrow==          0 ? DY : 0);
459
    float YR = +0.5f - (yrow==numLayers-1 ? DY : 0);
460
    float ZL = -0.5f - (zrow==          0 ? DZ : 0);
461
    float ZR = +0.5f - (zrow==numLayers-1 ? DZ : 0);
457
    float XL = -0.5f + (xrow==     0 ? DX : 0);
458
    float XR = +0.5f + (xrow==numL-1 ? DX : 0);
459
    float YL = -0.5f - (yrow==     0 ? DY : 0);
460
    float YR = +0.5f - (yrow==numL-1 ? DY : 0);
461
    float ZL = -0.5f - (zrow==     0 ? DZ : 0);
462
    float ZR = +0.5f - (zrow==numL-1 ? DZ : 0);
462 463

  
463 464
    double[][] vertices = new double[][]
464 465
          {
......
494 495

  
495 496
///////////////////////////////////////////////////////////////////////////////////////////////////
496 497

  
497
  protected Static4D getQuat(int cubit, int numLayers)
498
  protected Static4D getQuat(int cubit, int[] numLayers)
498 499
    {
499 500
    if( mQuats ==null ) initializeQuats();
500 501
    return mQuats[0];
......
502 503

  
503 504
///////////////////////////////////////////////////////////////////////////////////////////////////
504 505

  
505
  protected int getNumCubitVariants(int numLayers)
506
  protected int getNumCubitVariants(int[] numLayers)
506 507
    {
507
    return 6*numLayers*numLayers - 12*numLayers + 8;
508
    int numL = numLayers[0];
509
    return 6*numL*numL - 12*numL + 8;
508 510
    }
509 511

  
510 512
///////////////////////////////////////////////////////////////////////////////////////////////////
511 513

  
512
  protected int getCubitVariant(int cubit, int numLayers)
514
  protected int getCubitVariant(int cubit, int[] numLayers)
513 515
    {
514 516
    return cubit;
515 517
    }
......
523 525

  
524 526
///////////////////////////////////////////////////////////////////////////////////////////////////
525 527

  
526
  protected float[][] getCubitPositions(int numLayers)
528
  protected float[][] getCubitPositions(int[] numLayers)
527 529
    {
528 530
    if( mPositions==null )
529 531
      {
530
      int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
532
      int numL = numLayers[0];
533
      int numCubits = numL>1 ? 6*numL*numL - 12*numL + 8 : 1;
531 534
      mPositions = new float[numCubits][];
532 535

  
533
      float diff = 0.5f*(numLayers-1);
536
      float diff = 0.5f*(numL-1);
534 537
      int currentPosition = 0;
535 538

  
536
      for(int x = 0; x<numLayers; x++)
537
        for(int y = 0; y<numLayers; y++)
538
          for(int z = 0; z<numLayers; z++)
539
            if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
539
      for(int x = 0; x<numL; x++)
540
        for(int y = 0; y<numL; y++)
541
          for(int z = 0; z<numL; z++)
542
            if( x==0 || x==numL-1 || y==0 || y==numL-1 || z==0 || z==numL-1 )
540 543
              {
541 544
              mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
542 545
              }
......
562 565

  
563 566
///////////////////////////////////////////////////////////////////////////////////////////////////
564 567

  
565
  protected float[][] getCuts(int numLayers)
568
  protected float[][] getCuts(int[] numLayers)
566 569
    {
567 570
    if( mCuts==null )
568 571
      {
569
      mCuts = new float[3][numLayers-1];
572
      int numL = numLayers[0];
573
      mCuts = new float[3][numL-1];
570 574

  
571
      for(int i=0; i<numLayers-1; i++)
575
      for(int i=0; i<numL-1; i++)
572 576
        {
573
        float cut = (2-numLayers)*0.5f + i;
577
        float cut = (2-numL)*0.5f + i;
574 578
        mCuts[0][i] = cut;
575 579
        mCuts[1][i] = cut;
576 580
        mCuts[2][i] = cut;
......
582 586

  
583 587
///////////////////////////////////////////////////////////////////////////////////////////////////
584 588

  
585
  private void getLayerRotatable(int numLayers)
589
  private void getLayerRotatable(int[] numLayers)
586 590
    {
587 591
    if( mLayerRotatable==null )
588 592
      {
589 593
      int numAxis = ROT_AXIS.length;
590
      boolean[] tmp = new boolean[numLayers];
591
      for(int i=0; i<numLayers; i++) tmp[i] = true;
592 594
      mLayerRotatable = new boolean[numAxis][];
593
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
595

  
596
      for(int i=0; i<numAxis; i++)
597
        {
598
        mLayerRotatable[i] = new boolean[numLayers[i]];
599
        for(int j=0; j<numLayers[i]; j++) mLayerRotatable[i][j] = true;
600
        }
594 601
      }
595 602
    }
596 603

  
......
622 629
    {
623 630
    if( mMovement==null )
624 631
      {
625
      int numLayers = getNumLayers();
632
      int[] numLayers = getNumLayers();
626 633
      if( mCuts==null ) getCuts(numLayers);
627 634
      getLayerRotatable(numLayers);
628
      mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED);
635
      mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,numLayers[0],TYPE_NOT_SPLIT,ENABLED);
629 636
      }
630 637
    return mMovement;
631 638
    }
......
640 647

  
641 648
///////////////////////////////////////////////////////////////////////////////////////////////////
642 649

  
643
  public ObjectType intGetObjectType(int numLayers)
650
  public ObjectType intGetObjectType(int[] numLayers)
644 651
    {
645
    switch(numLayers)
652
    switch(numLayers[0])
646 653
      {
647 654
      case 2: return ObjectType.MIRR_2;
648 655
      case 3: return ObjectType.MIRR_3;
......
653 660

  
654 661
///////////////////////////////////////////////////////////////////////////////////////////////////
655 662

  
656
  public int getObjectName(int numLayers)
663
  public int getObjectName(int[] numLayers)
657 664
    {
658
    switch(numLayers)
665
    switch(numLayers[0])
659 666
      {
660 667
      case 2: return R.string.mirr2;
661 668
      case 3: return R.string.mirr3;
......
665 672

  
666 673
///////////////////////////////////////////////////////////////////////////////////////////////////
667 674

  
668
  public int getInventor(int numLayers)
675
  public int getInventor(int[] numLayers)
669 676
    {
670
    switch(numLayers)
677
    switch(numLayers[0])
671 678
      {
672 679
      case 2: return R.string.mirr2_inventor;
673 680
      case 3: return R.string.mirr3_inventor;
......
677 684

  
678 685
///////////////////////////////////////////////////////////////////////////////////////////////////
679 686

  
680
  public int getComplexity(int numLayers)
687
  public int getComplexity(int[] numLayers)
681 688
    {
682
    switch(numLayers)
689
    switch(numLayers[0])
683 690
      {
684 691
      case 2: return 5;
685 692
      case 3: return 7;

Also available in: Unified diff