Project

General

Profile

« Previous | Next » 

Revision 5e06e92f

Added by Leszek Koltunski about 3 years ago

New cubit engine: convert Kiliminx & some Megaminx.

View differences:

src/main/java/org/distorted/objects/TwistyMinx.java
21 21

  
22 22
import android.content.res.Resources;
23 23

  
24
import org.distorted.helpers.FactoryCubit;
24 25
import org.distorted.library.main.DistortedEffects;
25 26
import org.distorted.library.main.DistortedTexture;
27
import org.distorted.library.mesh.MeshBase;
26 28
import org.distorted.library.mesh.MeshSquare;
27 29
import org.distorted.library.type.Static3D;
28 30
import org.distorted.library.type.Static4D;
29 31

  
30 32
import java.util.Random;
31 33

  
34
import static org.distorted.helpers.FactoryCubit.COS18;
35
import static org.distorted.helpers.FactoryCubit.COS_HALFD;
36
import static org.distorted.helpers.FactoryCubit.SIN18;
37
import static org.distorted.helpers.FactoryCubit.SIN54;
38
import static org.distorted.helpers.FactoryCubit.SIN_HALFD;
39

  
32 40
///////////////////////////////////////////////////////////////////////////////////////////////////
33 41

  
34 42
abstract class TwistyMinx extends TwistyObject
......
376 384
    return chances;
377 385
    }
378 386

  
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

  
389
  MeshBase createCornerMesh(int numLayers, float width)
390
    {
391
    float A = (2*SQ3/3)*SIN54;
392
    float B = 0.4f;
393
    int   N = numLayers==3 ? 5 : 3;
394
    int   E = numLayers==3 ? 4 : 1;
395

  
396
    double X = width*COS18*SIN_HALFD;
397
    double Y = width*SIN18;
398
    double Z = width*COS18*COS_HALFD;
399

  
400
    double[][] vertices = new double[][]
401
        {
402
            { 0.0, 0.0      , 0.0 },
403
            {   X,   Y      ,  -Z },
404
            { 0.0, 2*Y      ,-2*Z },
405
            {  -X,   Y      ,  -Z },
406
            { 0.0, 0.0-width, 0.0 },
407
            {   X,   Y-width,  -Z },
408
            { 0.0, 2*Y-width,-2*Z },
409
            {  -X,   Y-width,  -Z },
410
        };
411

  
412
    int[][] vertIndexes = new int[][]
413
        {
414
            {4,5,1,0},
415
            {7,4,0,3},
416
            {0,1,2,3},
417
            {4,5,6,7},
418
            {6,5,1,2},
419
            {7,6,2,3}
420
        };
421

  
422
    float[][] bands     = new float[][]
423
      {
424
         {0.04f,34,0.3f,0.2f, N, 1, 1},
425
         {0.00f, 0,0.0f,0.0f, 2, 1, E}
426
      };
427
    int[] bandIndexes   = new int[] { 0,0,0,1,1,1};
428
    float[][] corners   = new float[][] { {0.04f,0.10f} };
429
    int[] cornerIndexes = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
430
    float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
431
    int[] centerIndexes = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
432

  
433
    FactoryCubit factory = FactoryCubit.getInstance();
434
    factory.createNewFaceTransform(vertices,vertIndexes);
435

  
436
    return factory.createRoundedSolid(vertices, vertIndexes,
437
                                      bands, bandIndexes,
438
                                      corners, cornerIndexes,
439
                                      centers, centerIndexes,
440
                                      getNumCubitFaces() );
441
    }
442

  
379 443
///////////////////////////////////////////////////////////////////////////////////////////////////
380 444
// PUBLIC API
381 445

  

Also available in: Unified diff