Project

General

Profile

« Previous | Next » 

Revision 596d62a4

Added by Leszek Koltunski about 3 years ago

Convert the Dino and one of the Skewb's cubits to the new engine.

View differences:

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

  
26 26
import org.distorted.helpers.FactoryCubit;
27 27
import org.distorted.helpers.FactorySticker;
28
import org.distorted.library.effect.MatrixEffect;
29 28
import org.distorted.library.effect.MatrixEffectQuaternion;
30
import org.distorted.library.effect.MatrixEffectScale;
31 29
import org.distorted.library.main.DistortedEffects;
32 30
import org.distorted.library.main.DistortedTexture;
33 31
import org.distorted.library.mesh.MeshBase;
......
117 115
           { 17, 18,18,18,18,18 },
118 116
         };
119 117

  
120
  private static MeshBase mCornerMesh, mFaceMesh, mEdgeMesh;
118
  private static final double[][] VERTICES_CORNER = new double[][]
119
          {
120
             // TODO
121
          };
122

  
123
  private static final int[][] VERT_INDEXES_CORNER = new int[][]
124
          {
125
             // TODO
126
          };
127

  
128
  private static final double[][] VERTICES_EDGE = new double[][]
129
          {
130
             {-0.5, 0.0, 0.0},
131
             { 0.5, 0.0, 0.0},
132
             { 0.0,-0.5, 0.0},
133
             { 0.0, 0.0,-0.5}
134
          };
135

  
136
  private static final int[][] VERT_INDEXES_EDGE = new int[][]
137
          {
138
             {2,1,0},   // counterclockwise!
139
             {3,0,1},
140
             {2,3,1},
141
             {3,2,0},
142
          };
143

  
144
  private static final double[][] VERTICES_FACE = new double[][]
145
          {
146
             // TODO
147
          };
148

  
149
  private static final int[][] VERT_INDEXES_FACE = new int[][]
150
          {
151
             // TODO
152
          };
153

  
154
  private static MeshBase[] mMeshes;
121 155

  
122 156
///////////////////////////////////////////////////////////////////////////////////////////////////
123 157

  
......
128 162
    }
129 163

  
130 164
///////////////////////////////////////////////////////////////////////////////////////////////////
131
// TODO
132 165

  
133 166
  double[][] getVertices(int cubitType)
134 167
    {
168
    if( cubitType==0 ) return VERTICES_CORNER;
169
    if( cubitType==1 ) return VERTICES_EDGE;
170
    if( cubitType==2 ) return VERTICES_FACE;
135 171
    return null;
136 172
    }
137 173

  
138 174
///////////////////////////////////////////////////////////////////////////////////////////////////
139
// TODO
140 175

  
141 176
  int[][] getVertIndexes(int cubitType)
142 177
    {
178
    if( cubitType==0 ) return VERT_INDEXES_CORNER;
179
    if( cubitType==1 ) return VERT_INDEXES_EDGE;
180
    if( cubitType==2 ) return VERT_INDEXES_FACE;
143 181
    return null;
144 182
    }
145 183

  
......
425 463

  
426 464
  MeshBase createCubitMesh(int cubit, int numLayers)
427 465
    {
466
    if( mMeshes==null )
467
      {
468
      FactoryCubit factory = FactoryCubit.getInstance();
469
      factory.clear();
470
      mMeshes = new MeshBase[3];
471
      }
472

  
428 473
    MeshBase mesh;
429 474

  
430 475
    int numCorners = getNumCorners();
......
432 477

  
433 478
    if( cubit<numCorners )
434 479
      {
435
      if( mCornerMesh==null ) mCornerMesh = FactoryCubit.getInstance().createSkewbCornerMesh();
436
      mesh = mCornerMesh.copy(true);
480
      if( mMeshes[0]==null )
481
        {
482
        mMeshes[0] = FactoryCubit.getInstance().createSkewbCornerMesh();
483
        }
484
      mesh = mMeshes[0].copy(true);
437 485
      }
438 486
    else if( cubit<numCorners+numEdges )
439 487
      {
440
      if( mEdgeMesh==null )
488
      if( mMeshes[1]==null )
441 489
        {
442
        mEdgeMesh = FactoryCubit.getInstance().createDinoMesh();
443
        MatrixEffect effect = new MatrixEffectScale(1.0f/3);
444
        mEdgeMesh.apply(effect,-1,0);
445
        mEdgeMesh.addEmptyTexComponent();
446
        mEdgeMesh.addEmptyTexComponent();
490
        float[][] bands= new float[][]
491
          {
492
             {0.035f,30,0.16f,0.8f,7,2,5},
493
             {0.020f,45,0.16f,0.2f,3,1,2}
494
          };
495
        int[] bandIndexes   = new int[] { 0,0,1,1 };
496
        float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
497
        int[] cornerIndexes = new int[] { 0,0,1,1 };
498

  
499
        FactoryCubit factory = FactoryCubit.getInstance();
500

  
501
        factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE);
502
        mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE,
503
                                                bands, bandIndexes,
504
                                                corners, cornerIndexes,
505
                                                getNumCubitFaces() );
447 506
        }
448
      mesh = mEdgeMesh.copy(true);
507
      mesh = mMeshes[1].copy(true);
449 508
      }
450 509
    else
451 510
      {
452
      if( mFaceMesh==null ) mFaceMesh = FactoryCubit.getInstance().createSkewbFaceMesh();
453
      mesh = mFaceMesh.copy(true);
511
      if( mMeshes[2]==null )
512
        {
513
        mMeshes[2] = FactoryCubit.getInstance().createSkewbFaceMesh();
514
        }
515
      mesh = mMeshes[2].copy(true);
454 516
      }
455 517

  
456 518
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );

Also available in: Unified diff