Project

General

Profile

« Previous | Next » 

Revision d92030e4

Added by Leszek Koltunski about 4 years ago

Improve the Skewb; set max components to 110 in MeshBase so that all of Professor Skewb's components fit.

View differences:

src/main/java/org/distorted/objects/FactoryCubit.java
232 232

  
233 233
    float E = 0.5f;
234 234
    float F = SQ2/2;
235
    float G = SQ6/16;
235 236
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
236 237
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
237 238

  
......
242 243
    meshes[2] = meshes[0].copy(true);
243 244
    meshes[2].setEffectAssociation(0,4,0);
244 245

  
245
    float[] vertices1 = { 0,0, F,0, 7*F/8,(SQ3/8)*F, 5*F/8,(3*SQ3/8)*F, F/2,(SQ3/2)*F };
246
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
246 247
    float[] bands1 = computeBands(0,0,1,0,3);
247 248

  
248 249
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
......
545 546
    Static3D center1= new Static3D(0,0,0);
546 547
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
547 548
    Static3D move1  = new Static3D(-E/4,-E/4,0);
548
    Static3D move2  = new Static3D(-0.5f,-0.5f,-0.5f);
549
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
549 550

  
550 551
    VertexEffect[] effect = new VertexEffect[10];
551 552

  
......
966 967
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
967 968
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
968 969
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
969
    roundCorners(mesh,roundingCenter,vertices,0.10f,0.10f);
970
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
970 971

  
971 972
    mesh.mergeEffComponents();
972 973
    mesh.addEmptyTexComponent();
src/main/java/org/distorted/objects/TwistySkewb.java
128 128

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

  
131
  private int getNumCorners(int layers)
131
  private int getNumCorners()
132 132
    {
133 133
    return 8;
134 134
    }
......
142 142

  
143 143
///////////////////////////////////////////////////////////////////////////////////////////////////
144 144

  
145
  private int getNumCenters(int layers)
145
  private int getNumCentersPerFace(int layers)
146 146
    {
147
    return ((layers-2)*(layers-2) + (layers-1)*(layers-1))*6;
147
    return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
148 148
    }
149 149

  
150 150
///////////////////////////////////////////////////////////////////////////////////////////////////
......
218 218
    final float DIST_EDGE   = (numLayers-1)*0.50f;
219 219
    final float DIST_CENTER = (numLayers-1)*0.50f;
220 220

  
221
    final int numCorners = getNumCorners(numLayers);
221
    final int numCorners = getNumCorners();
222 222
    final int numEdges   = getNumEdges(numLayers);
223
    final int numCenters = getNumCenters(numLayers);
223
    final int numCenters = 6*getNumCentersPerFace(numLayers);
224 224

  
225 225
    final Static3D[] CENTERS = new Static3D[numCorners+numEdges+numCenters];
226 226

  
......
340 340

  
341 341
///////////////////////////////////////////////////////////////////////////////////////////////////
342 342

  
343
  private Static4D getQuat(int cubit, int size)
343
  private Static4D getQuat(int cubit, int numLayers)
344 344
    {
345
    int numCorners = getNumCorners(size);
346
    int numEdges   = getNumEdges(size);
345
    int numCorners = getNumCorners();
346
    int numEdges   = getNumEdges(numLayers);
347 347

  
348 348
    if( cubit<numCorners )
349 349
      {
......
361 361
      }
362 362
    else if( cubit<numCorners+numEdges )
363 363
      {
364
      int edge = (cubit-numCorners)/(size-2);
364
      int edge = (cubit-numCorners)/(numLayers-2);
365 365

  
366 366
      switch(edge)
367 367
        {
......
381 381
      }
382 382
    else
383 383
      {
384
      int center = (cubit-numCorners-numEdges)/((size-2)*(size-2)+(size-1)*(size-1));
384
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
385 385

  
386 386
      switch(center)
387 387
        {
......
403 403
    {
404 404
    MeshBase mesh;
405 405

  
406
    int numLayers = getNumLayers();
407
    int numCorners = getNumCorners(numLayers);
406
    int numLayers  = getNumLayers();
407
    int numCorners = getNumCorners();
408 408
    int numEdges   = getNumEdges(numLayers);
409 409

  
410 410
    if( cubit<numCorners )
......
438 438

  
439 439
///////////////////////////////////////////////////////////////////////////////////////////////////
440 440

  
441
  int getFaceColor(int cubit, int cubitface, int size)
441
  int getFaceColor(int cubit, int cubitface, int numLayers)
442 442
    {
443
    int numCorners = getNumCorners(size);
444
    int numEdges   = getNumEdges(size);
443
    int numCorners = getNumCorners();
444
    int numEdges   = getNumEdges(numLayers);
445 445

  
446 446
    if( cubit<numCorners )
447 447
      {
......
449 449
      }
450 450
    else if( cubit<numCorners+numEdges )
451 451
      {
452
      int edge = (cubit-numCorners)/(size-2);
452
      int edge = (cubit-numCorners)/(numLayers-2);
453 453
      return mEdgeMap[edge][cubitface];
454 454
      }
455 455
    else
456 456
      {
457
      int center = (cubit-numCorners-numEdges)/((size-2)*(size-2)+(size-1)*(size-1));
457
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
458 458
      return mCenterMap[center][cubitface];
459 459
      }
460 460
    }
......
618 618
    {
619 619
    int q = CUBITS[0].mQuatIndex;
620 620

  
621
    int numLayers  = getNumLayers();
622
    int numCorners = getNumCorners(numLayers);
623
    int numEdges   = getNumEdges(numLayers);
624
    int cornersAndEdges = numCorners + numEdges;
625
    int cubitsPerFace = (numLayers-2)*(numLayers-2) + (numLayers-1)*(numLayers-1);
621
    int numLayers      = getNumLayers();
622
    int numCorners     = getNumCorners();
623
    int numEdges       = getNumEdges(numLayers);
624
    int cornersAndEdges= numCorners + numEdges;
625
    int centersPerFace = getNumCentersPerFace(numLayers);
626 626
    int cubit, q1=q;
627 627

  
628 628
    for(cubit=0; cubit<cornersAndEdges; cubit++)
......
634 634
      {
635 635
      if( face%2==0 ) q1 = mulQuat(q, (face/2)+1);
636 636

  
637
      for(int center=0; center<cubitsPerFace; center++)
637
      for(int center=0; center<centersPerFace; center++)
638 638
        {
639 639
        if( CUBITS[cubit].mQuatIndex != q && CUBITS[cubit].mQuatIndex != q1 ) return false;
640 640
        cubit++;

Also available in: Unified diff