Project

General

Profile

« Previous | Next » 

Revision 3e605536

Added by Leszek Koltunski over 2 years ago

Finally remove cubit creation from the implementation classes and move it to the TwistyObject.

View differences:

src/main/java/org/distorted/objects/TwistySkewb.java
407 407

  
408 408
///////////////////////////////////////////////////////////////////////////////////////////////////
409 409

  
410
  private Static4D getQuat(int cubit, int numLayers)
410
  Static4D getQuat(int cubit, int numLayers)
411 411
    {
412 412
    int numCorners = getNumCorners();
413 413
    int numEdges   = getNumEdges(numLayers);
......
475 475
      int N = numLayers==2 ? 7:5;
476 476
      int E1= numLayers==2 ? 3:2;
477 477
      int E2= numLayers==2 ? 5:3;
478
      float[][] bands= new float[][]
479
          {
480
             {0.028f,35,0.16f,0.7f,N,E1,E1},
481
             {0.000f, 0,1.00f,0.0f,3, 1,E2}
482
          };
478
      float[][] bands     = new float[][] { {0.028f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} };
483 479
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
484 480
      float[][] corners   = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} };
485 481
      int[] cornerIndices = new int[] { 1,1,1,0,0 };
486 482
      float[][] centers   = new float[][] { {-0.25f, -0.25f, -0.25f} };
487 483
      int[] centerIndices = new int[] { 0,0,0,-1,0 };
488

  
489 484
      return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
490 485
      }
491 486
    else if( variant==1 )
492 487
      {
493 488
      int N = numLayers==2 ? 7:5;
494 489
      int E = numLayers==2 ? 5:2;
495
      float[][] bands= new float[][]
496
          {
497
             {0.035f,30,0.16f,0.8f,N,2,E},
498
             {0.020f,45,0.16f,0.2f,3,1,2}
499
          };
490
      float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} };
500 491
      int[] bandIndices   = new int[] { 0,0,1,1 };
501 492
      float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
502 493
      int[] cornerIndices = new int[] { 0,0,1,1 };
503 494
      float[][] centers   = new float[][] { {0.0f, -0.25f, -0.25f} };
504 495
      int[] centerIndices = new int[] { 0,0,0,0 };
505

  
506 496
      return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
507 497
      }
508 498
    else
509 499
      {
510 500
      int N = numLayers==2 ? 7:6;
511 501
      int E = numLayers==2 ? 3:1;
512
      float[][] bands= new float[][]
513
          {
514
             {0.051f,35,SQ2/8,0.9f, N,E,E},
515
             {0.000f, 0,    1,0.0f, 3,0,0}
516
          };
502
      float[][] bands     = new float[][] { {0.051f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} };
517 503
      int[] bandIndices   = new int[] { 0,1,1,1,1 };
518 504
      float[][] corners   = new float[][] { {0.06f,0.10f} };
519 505
      int[] cornerIndices = new int[] { 0,0,0,0,0 };
520 506
      float[][] centers   = new float[][] { {0,0,-0.2f} };
521 507
      int[] centerIndices = new int[] { 0,0,0,0,-1 };
522

  
523 508
      return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
524 509
      }
525 510
    }
526 511

  
527 512
///////////////////////////////////////////////////////////////////////////////////////////////////
528 513

  
529
  private int getNumCubitVariants(int numLayers)
514
  int getNumCubitVariants(int numLayers)
530 515
    {
531 516
    return 3;
532 517
    }
......
541 526
    return cubit<numCorners+numEdges ? 1:2;
542 527
    }
543 528

  
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545

  
546
  MeshBase createCubitMesh(int cubit, int numLayers)
547
    {
548
    int variant = getCubitVariant(cubit,numLayers);
549

  
550
    if( mMeshes==null )
551
      {
552
      FactoryCubit factory = FactoryCubit.getInstance();
553
      factory.clear();
554
      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
555
      }
556

  
557
    if( mMeshes[variant]==null )
558
      {
559
      ObjectShape shape = getObjectShape(cubit,numLayers);
560
      FactoryCubit factory = FactoryCubit.getInstance();
561
      factory.createNewFaceTransform(shape);
562
      mMeshes[variant] = factory.createRoundedSolid(shape);
563
      }
564

  
565
    MeshBase mesh = mMeshes[variant].copy(true);
566
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
567
    mesh.apply(quat,0xffffffff,0);
568

  
569
    return mesh;
570
    }
571

  
572 529
///////////////////////////////////////////////////////////////////////////////////////////////////
573 530

  
574 531
  int getFaceColor(int cubit, int cubitface, int numLayers)

Also available in: Unified diff