Project

General

Profile

« Previous | Next » 

Revision 94a4edcf

Added by Leszek Koltunski over 3 years ago

Move 1) Jing 2) Kilominx to the new cubit creation scheme.
Make the Master Kilominx mesh a bit smaller.

View differences:

src/main/java/org/distorted/objects/TwistyJing.java
22 22
import android.content.res.Resources;
23 23

  
24 24
import org.distorted.helpers.FactoryCubit;
25
import org.distorted.helpers.ObjectShape;
25 26
import org.distorted.helpers.ObjectSticker;
26 27
import org.distorted.library.effect.MatrixEffectQuaternion;
27 28
import org.distorted.library.main.DistortedEffects;
......
291 292

  
292 293
///////////////////////////////////////////////////////////////////////////////////////////////////
293 294

  
294
  MeshBase createCubitMesh(int cubit, int numLayers)
295
  ObjectShape getObjectShape(int cubit, int numLayers)
295 296
    {
296
    if( mMeshes==null )
297
      {
298
      FactoryCubit factory = FactoryCubit.getInstance();
299
      factory.clear();
300
      mMeshes = new MeshBase[3];
301
      }
302

  
303
    MeshBase mesh;
297
    int variant = getCubitVariant(cubit,numLayers);
304 298

  
305
    if( cubit<4 )
299
    if( variant==0 )
306 300
      {
307
      if( mMeshes[0]==null )
308
        {
309
        float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
310
        int[] bandIndexes   = new int[] { 0,0,0,1,1,1 };
311
        float[][] corners   = new float[][] { {0.08f,0.20f*F},{0.07f,0.20f*F} };
312
        int[] cornerIndexes = new int[] { 0,1,1,-1,1,-1,-1,-1 };
313
        float[][] centers   = new float[][] { { 0.0f, F*SQ2/2, -F} };
314
        int[] centerIndexes = new int[] { 0,0,0,-1,0,-1,-1,-1 };
315

  
316
        FactoryCubit factory = FactoryCubit.getInstance();
317

  
318
        factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER);
319
        mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER,
320
                                                bands, bandIndexes,
321
                                                corners, cornerIndexes,
322
                                                centers, centerIndexes,
323
                                                getNumCubitFaces(), null );
324
        }
325
      mesh = mMeshes[0].copy(true);
301
      float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
302
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
303
      float[][] corners   = new float[][] { {0.08f,0.20f*F},{0.07f,0.20f*F} };
304
      int[] cornerIndices = new int[] { 0,1,1,-1,1,-1,-1,-1 };
305
      float[][] centers   = new float[][] { { 0.0f, F*SQ2/2, -F} };
306
      int[] centerIndices = new int[] { 0,0,0,-1,0,-1,-1,-1 };
307
      return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
326 308
      }
327
    else if( cubit<10 )
309
    else if( variant==1 )
328 310
      {
329
      if( mMeshes[1]==null )
330
        {
331
        float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
332
        int[] bandIndexes   = new int[] { 0,0,1,1,1,1 };
333
        float[][] corners   = new float[][] { {0.07f,0.20f*F} };
334
        int[] cornerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
335
        float[][] centers   = new float[][] { { 0, F*SQ2/2, 0 } };
336
        int[] centerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
337

  
338
        FactoryCubit factory = FactoryCubit.getInstance();
339

  
340
        factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE);
341
        mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE,
342
                                                bands, bandIndexes,
343
                                                corners, cornerIndexes,
344
                                                centers, centerIndexes,
345
                                                getNumCubitFaces(), null );
346

  
347
        factory.printStickerCoords();
348
        }
349
      mesh = mMeshes[1].copy(true);
311
      float[][] bands     = new float[][] { {0.015f,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
312
      int[] bandIndices   = new int[] { 0,0,1,1,1,1 };
313
      float[][] corners   = new float[][] { {0.07f,0.20f*F} };
314
      int[] cornerIndices = new int[] { 0,0,-1,0,0,0,-1,0 };
315
      float[][] centers   = new float[][] { { 0, F*SQ2/2, 0 } };
316
      int[] centerIndices = new int[] { 0,0,-1,0,0,0,-1,0 };
317
      return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
350 318
      }
351 319
    else
352 320
      {
353
      if( mMeshes[2]==null )
354
        {
355
        float[][] bands     = new float[][] { {0.020f,35,0.20f*(1-3*F),0.6f*(1-3*F),5,1,1},
321
      float[][] bands     = new float[][] { {0.020f,35,0.20f*(1-3*F),0.6f*(1-3*F),5,1,1},
356 322
                                              {0.001f,35,0.05f*(1-3*F),0.1f*(1-3*F),5,1,1} };
357
        int[] bandIndexes   = new int[] { 0,1,1,1,1,1 };
358
        float[][] corners   = new float[][] { {0.04f,0.15f} };
359
        int[] cornerIndexes = new int[] { 0,0,0,-1,-1,-1 };
360
        float[][] centers   = new float[][] { { 0, -2*Y/3, 4*Z/3 } };
361
        int[] centerIndexes = new int[] { 0,0,0,-1,-1,-1 };
362

  
363
        FactoryCubit factory = FactoryCubit.getInstance();
364

  
365
        factory.createNewFaceTransform(VERTICES_FACE,VERT_INDEXES_FACE);
366
        mMeshes[2] = factory.createRoundedSolid(VERTICES_FACE, VERT_INDEXES_FACE,
367
                                                bands, bandIndexes,
368
                                                corners, cornerIndexes,
369
                                                centers, centerIndexes,
370
                                                getNumCubitFaces(), null );
371

  
372
        factory.printStickerCoords();
373
        }
374
      mesh = mMeshes[2].copy(true);
323
      int[] bandIndices   = new int[] { 0,1,1,1,1,1 };
324
      float[][] corners   = new float[][] { {0.04f,0.15f} };
325
      int[] cornerIndices = new int[] { 0,0,0,-1,-1,-1 };
326
      float[][] centers   = new float[][] { { 0, -2*Y/3, 4*Z/3 } };
327
      int[] centerIndices = new int[] { 0,0,0,-1,-1,-1 };
328
      return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
329
      }
330
    }
331

  
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

  
334
  private Static4D getQuat(int cubit, int numLayers)
335
    {
336
    return QUATS[ROT_QUAT[cubit]];
337
    }
338

  
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

  
341
  private int getNumCubitVariants(int numLayers)
342
    {
343
    return 3;
344
    }
345

  
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

  
348
  int getCubitVariant(int cubit, int numLayers)
349
    {
350
    return cubit<4 ? 0 : (cubit<10?1:2);
351
    }
352

  
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

  
355
  MeshBase createCubitMesh(int cubit, int numLayers)
356
    {
357
    int variant = getCubitVariant(cubit,numLayers);
358

  
359
    if( mMeshes==null )
360
      {
361
      FactoryCubit factory = FactoryCubit.getInstance();
362
      factory.clear();
363
      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
364
      }
365

  
366
    if( mMeshes[variant]==null )
367
      {
368
      ObjectShape shape = getObjectShape(cubit,numLayers);
369
      FactoryCubit factory = FactoryCubit.getInstance();
370
      factory.createNewFaceTransform(shape);
371
      mMeshes[variant] = factory.createRoundedSolid(shape);
375 372
      }
376 373

  
377
    int q = ROT_QUAT[cubit];
378
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[q], new Static3D(0,0,0) );
374
    MeshBase mesh = mMeshes[variant].copy(true);
375
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
379 376
    mesh.apply(quat,0xffffffff,0);
380 377

  
381 378
    return mesh;
src/main/java/org/distorted/objects/TwistyKilominx.java
22 22
import android.content.res.Resources;
23 23

  
24 24
import org.distorted.helpers.FactoryCubit;
25
import org.distorted.helpers.ObjectShape;
25 26
import org.distorted.helpers.ObjectSticker;
26 27
import org.distorted.helpers.QuatHelper;
27 28
import org.distorted.library.effect.MatrixEffectQuaternion;
......
360 361

  
361 362
///////////////////////////////////////////////////////////////////////////////////////////////////
362 363

  
363
  private MeshBase createCenterMesh(float width)
364
  ObjectShape getObjectShape(int cubit, int numLayers)
364 365
    {
365
    double X = width*COS18*SIN_HALFD;
366
    double Y = width*SIN18;
367
    double Z = width*COS18*COS_HALFD;
368
    double H = width*(SIN54/COS54);
369
    double H3= H/COS_HALFD;
370
    double X3= H*SIN_HALFD;
371
    double Z3= H*COS_HALFD;
372
    double C = 1/(COS54*Math.sqrt(2-2*SIN18));
373

  
374
    double[][] vertices = new double[][]
366
    int variant = getCubitVariant(cubit,numLayers);
367
    int numVariants = getNumCubitVariants(numLayers);
368

  
369
    if( variant==0 )
370
      {
371
      float width = (numLayers/3.0f)/(numLayers-1);
372
      float A = (2*SQ3/3)*SIN54;
373
      float B = 0.4f;
374
      double X = width*COS18*SIN_HALFD;
375
      double Y = width*SIN18;
376
      double Z = width*COS18*COS_HALFD;
377

  
378
      double[][] vertices = new double[][]
375 379
        {
376
            { 0.0, 0.0  ,   0.0 },
377
            {   X,   Y  ,    -Z },
378
            { 0.0,C*2*Y ,-2*C*Z },
379
            {  -X,   Y  ,    -Z },
380
            { 0.0,-width,   0.0 },
381
            {  X3,-width,   -Z3 },
382
            { 0.0,-width,   -H3 },
383
            { -X3,-width,   -Z3 }
380
            { 0.0, 0.0      , 0.0 },
381
            {   X,   Y      ,  -Z },
382
            { 0.0, 2*Y      ,-2*Z },
383
            {  -X,   Y      ,  -Z },
384
            { 0.0, 0.0-width, 0.0 },
385
            {   X,   Y-width,  -Z },
386
            { 0.0, 2*Y-width,-2*Z },
387
            {  -X,   Y-width,  -Z },
384 388
        };
385 389

  
386
    int[][] vertIndexes = new int[][]
390
      int[][] vertIndexes = new int[][]
387 391
        {
388 392
            {4,5,1,0},
389 393
            {7,4,0,3},
390 394
            {0,1,2,3},
391
            {7,6,2,3},
395
            {4,5,6,7},
392 396
            {6,5,1,2},
393
            {4,5,6,7}
397
            {7,6,2,3}
394 398
        };
395 399

  
396
    float[][] bands = new float[][]
397
      {
398
         {0.04f,17,0.3f,0.2f,4,1,1},
399
         {0.00f,17,0.3f,0.2f,4,1,1}
400
      };
401

  
402
    float A = (2*SQ3/3)*SIN54;
403
    float B = 0.4f;
404

  
405
    int[] bandIndexes   = new int[] { 0,0,0,1,1,1};
406
    float[][] corners   = new float[][] { {0.03f,0.10f} };
407
    int[] cornerIndexes = new int[] { 0, 0,-1, 0, 0,-1,-1,-1 };
408
    float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
409
    int[] centerIndexes = new int[] { 0, 0,-1, 0, 0,-1,-1,-1 };
410

  
411
    FactoryCubit factory = FactoryCubit.getInstance();
412
    factory.createNewFaceTransform(vertices,vertIndexes);
413

  
414
    return factory.createRoundedSolid(vertices, vertIndexes,
415
                                      bands, bandIndexes,
416
                                      corners, cornerIndexes,
417
                                      centers, centerIndexes,
418
                                      getNumCubitFaces(), null );
419
    }
420

  
421
///////////////////////////////////////////////////////////////////////////////////////////////////
400
      float[][] bands     = new float[][]
401
        {
402
         {0.04f,34,0.3f,0.2f, 3, 1, 0},
403
         {0.00f, 0,0.0f,0.0f, 2, 1, 0}
404
        };
422 405

  
423
  private MeshBase createEdgeMesh(int numLayers, float width, float height, boolean left)
424
    {
425
    double X = height*SIN_HALFD;
426
    double Y = height*SIN18/COS18;
427
    double Z = height*COS_HALFD;
406
      int[] bandIndices   = new int[] { 0,0,0,1,1,1};
407
      float[][] corners   = new float[][] { {0.04f,0.10f} };
408
      int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
409
      float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
410
      int[] centerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
428 411

  
429
    double[][] vertices = new double[][]
412
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
413
      }
414
    if( variant<numVariants-1 )
415
      {
416
      int numCubitsPerCorner = numCubitsPerCorner(numLayers);
417
      int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
418
      int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
419
      float tmpVal= (numLayers/3.0f)/(numLayers-1);
420
      float height= tmpVal*COS18;
421
      float width = tmpVal + (type/2)*tmpVal*SIN18;
422
      boolean left = (type%2)==0;
423

  
424
      double X = height*SIN_HALFD;
425
      double Y = height*SIN18/COS18;
426
      double Z = height*COS_HALFD;
427

  
428
      double[][] vertices = new double[][]
430 429
        {
431 430
            { 0.0, 0.0   , 0.0 },
432 431
            {   X,   Y   ,  -Z },
......
438 437
            {  -X, -width,  -Z },
439 438
        };
440 439

  
441
    int[][] vertIndexes = new int[][]
440
      int[][] vertIndexes = new int[][]
442 441
        {
443 442
            {4,5,1,0},
444 443
            {7,4,0,3},
......
448 447
            {4,5,6,7}
449 448
        };
450 449

  
451
    if( !left )
452
      {
453
      int tmp, len = vertices.length;
454
      for(int i=0; i<len; i++) vertices[i][1] = -vertices[i][1];
455

  
456
      len = vertIndexes.length;
457
      for(int i=0; i<len; i++)
450
      if( !left )
458 451
        {
459
        tmp = vertIndexes[i][0];
460
        vertIndexes[i][0] = vertIndexes[i][3];
461
        vertIndexes[i][3] = tmp;
452
        int tmp, len = vertices.length;
453
        for(int i=0; i<len; i++) vertices[i][1] = -vertices[i][1];
462 454

  
463
        tmp = vertIndexes[i][1];
464
        vertIndexes[i][1] = vertIndexes[i][2];
465
        vertIndexes[i][2] = tmp;
455
        len = vertIndexes.length;
456
        for(int i=0; i<len; i++)
457
          {
458
          tmp = vertIndexes[i][0];
459
          vertIndexes[i][0] = vertIndexes[i][3];
460
          vertIndexes[i][3] = tmp;
461
          tmp = vertIndexes[i][1];
462
          vertIndexes[i][1] = vertIndexes[i][2];
463
          vertIndexes[i][2] = tmp;
464
          }
466 465
        }
467
      }
468 466

  
469
    int numBands0 = numLayers<=5 ? 5 : 3;
470
    int numBands1 = numLayers<=5 ? 3 : 2;
467
      int numBands0 = numLayers<=5 ? 4 : 3;
468
      int numBands1 = numLayers<=5 ? 3 : 2;
471 469

  
472
    float[][] bands     = new float[][]
473
      {
470
      float[][] bands     = new float[][]
471
        {
474 472
         {0.04f,34,0.2f,0.2f,numBands0,1,1},
475 473
         {0.00f, 0,0.0f,0.0f,numBands1,0,0}
476
      };
477
    int[] bandIndexes   = new int[] { 0,0,1,1,1,1};
478
    float[][] corners   = new float[][] { {0.04f,0.10f} };
479
    int[] cornerIndexes = new int[] { 0,-1,-1,-1, 0,-1,-1,-1 };
480
    float[][] centers   = new float[][] { {0.0f, -width/2, (float)(-2*Z)} };
481
    int[] centerIndexes = new int[] { 0,-1,-1,-1, 0,-1,-1,-1 };
482

  
483
    FactoryCubit factory = FactoryCubit.getInstance();
484
    factory.createNewFaceTransform(vertices,vertIndexes);
485

  
486
    return factory.createRoundedSolid(vertices, vertIndexes,
487
                                      bands, bandIndexes,
488
                                      corners, cornerIndexes,
489
                                      centers, centerIndexes,
490
                                      getNumCubitFaces(), null );
474
        };
475

  
476
      int[] bandIndices   = new int[] { 0,0,1,1,1,1};
477
      float[][] corners   = new float[][] { {0.04f,0.10f} };
478
      int[] cornerIndices = new int[] { 0,-1,-1,-1, 0,-1,-1,-1 };
479
      float[][] centers   = new float[][] { {0.0f, -width/2, (float)(-2*Z)} };
480
      int[] centerIndices = new int[] { 0,-1,-1,-1, 0,-1,-1,-1 };
481

  
482
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
483
      }
484
    else
485
      {
486
      float width = (1+0.5f*(numLayers-3)*SIN18)*(numLayers/3.0f)/(numLayers-1);
487

  
488
      double X = width*COS18*SIN_HALFD;
489
      double Y = width*SIN18;
490
      double Z = width*COS18*COS_HALFD;
491
      double H = width*(SIN54/COS54);
492
      double H3= H/COS_HALFD;
493
      double X3= H*SIN_HALFD;
494
      double Z3= H*COS_HALFD;
495
      double C = 1/(COS54*Math.sqrt(2-2*SIN18));
496
      int N = numLayers==3 ? 4 : 3;
497
      int E = numLayers==3 ? 1 : 0;
498

  
499
      double[][] vertices = new double[][]
500
        {
501
            { 0.0, 0.0  ,   0.0 },
502
            {   X,   Y  ,    -Z },
503
            { 0.0,C*2*Y ,-2*C*Z },
504
            {  -X,   Y  ,    -Z },
505
            { 0.0,-width,   0.0 },
506
            {  X3,-width,   -Z3 },
507
            { 0.0,-width,   -H3 },
508
            { -X3,-width,   -Z3 }
509
        };
510

  
511
      int[][] vertIndexes = new int[][]
512
        {
513
            {4,5,1,0},
514
            {7,4,0,3},
515
            {0,1,2,3},
516
            {7,6,2,3},
517
            {6,5,1,2},
518
            {4,5,6,7}
519
        };
520

  
521
      float[][] bands = new float[][]
522
        {
523
         {0.04f,17,0.3f,0.2f,N,1,E},
524
         {0.00f,17,0.3f,0.2f,N,1,E}
525
        };
526

  
527
      float A = (2*SQ3/3)*SIN54;
528
      float B = 0.4f;
529

  
530
      int[] bandIndices   = new int[] { 0,0,0,1,1,1};
531
      float[][] corners   = new float[][] { {0.03f,0.10f} };
532
      int[] cornerIndices = new int[] { 0, 0,-1, 0, 0,-1,-1,-1 };
533
      float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
534
      int[] centerIndices = new int[] { 0, 0,-1, 0, 0,-1,-1,-1 };
535

  
536
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
537
      }
491 538
    }
492 539

  
493 540
///////////////////////////////////////////////////////////////////////////////////////////////////
494 541

  
495
  MeshBase createCubitMesh(int cubit, int numLayers)
542
  private Static4D getQuat(int cubit, int numLayers)
496 543
    {
497 544
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
498 545
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
546

  
547
    return QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
548
    }
549

  
550
///////////////////////////////////////////////////////////////////////////////////////////////////
551

  
552
  private int getNumCubitVariants(int numLayers)
553
    {
499 554
    int[] sizes = ObjectList.KILO.getSizes();
500 555
    int variants = sizes.length;
501 556
    int highestSize = sizes[variants-1];
502
    MeshBase mesh;
503 557

  
504
    if( mMeshes==null ) mMeshes = new MeshBase[highestSize-1];
558
    return highestSize-1;
559
    }
505 560

  
506
    if( cubit < NUM_CORNERS*numCubitsPerCorner )
561
///////////////////////////////////////////////////////////////////////////////////////////////////
562

  
563
  int getCubitVariant(int cubit, int numLayers)
564
    {
565
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
566

  
567
    if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
568

  
569
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
570

  
571
    if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
507 572
      {
508
      if( mMeshes[0]==null )
509
        {
510
        float width = (numLayers/3.0f)/(numLayers-1);
511
        mMeshes[0] = createCornerMesh(numLayers,width);
512
        }
513
      mesh = mMeshes[0].copy(true);
573
      int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
574
      return type+1;
514 575
      }
515
    else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
516
      {
517
      int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);  // left-top, right-top, left-second, right-second, left-third...
518 576

  
519
      if( mMeshes[1+type]==null )
520
        {
521
        float tmp   = (numLayers/3.0f)/(numLayers-1);
522
        float height= tmp*COS18;
523
        float width = tmp + (type/2)*tmp*SIN18;
577
    int[] sizes = ObjectList.KILO.getSizes();
578
    int variants = sizes.length;
579
    int highestSize = sizes[variants-1];
524 580

  
525
        mMeshes[1+type] = createEdgeMesh(numLayers,width,height, (type%2)==0 );
526
        }
581
    return highestSize-2;
582
    }
527 583

  
528
      mesh = mMeshes[1+type].copy(true);
529
      }
530
    else
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

  
586
  MeshBase createCubitMesh(int cubit, int numLayers)
587
    {
588
    int variant = getCubitVariant(cubit,numLayers);
589

  
590
    if( mMeshes==null )
531 591
      {
532
      if( mMeshes[highestSize-2]==null )
533
        {
534
        float width = (1+0.5f*(numLayers-3)*SIN18)*(numLayers/3.0f)/(numLayers-1);
535
        mMeshes[highestSize-2] = createCenterMesh(width);
536
        }
592
      FactoryCubit factory = FactoryCubit.getInstance();
593
      factory.clear();
594
      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
595
      }
537 596

  
538
      mesh = mMeshes[highestSize-2].copy(true);
597
    if( mMeshes[variant]==null )
598
      {
599
      ObjectShape shape = getObjectShape(cubit,numLayers);
600
      FactoryCubit factory = FactoryCubit.getInstance();
601
      factory.createNewFaceTransform(shape);
602
      mMeshes[variant] = factory.createRoundedSolid(shape);
539 603
      }
540 604

  
541
    Static4D q = QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
542
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( q, new Static3D(0,0,0) );
605
    MeshBase mesh = mMeshes[variant].copy(true);
606
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
543 607
    mesh.apply(quat,0xffffffff,0);
544 608

  
545 609
    return mesh;

Also available in: Unified diff