Project

General

Profile

« Previous | Next » 

Revision 28b54fe3

Added by Leszek Koltunski over 3 years ago

Progress with Megaminx. Darken the RED color.

View differences:

src/main/java/org/distorted/objects/TwistyMegaminx.java
59 59
           { 1,  3, 19,  7, 17},
60 60
         };
61 61

  
62
  private static MeshBase mCenterMesh, mCornerMesh;
63
  private static MeshBase[] mEdgeMesh;
62
  private static MeshBase[] mCenterMeshes, mCornerMeshes, mEdgeMeshes;
64 63

  
65 64
  private static final Static4D[] mBasicV, mCurrV;
66 65

  
67 66
  static
68 67
    {
69
    float D = 0.5f-MEGA_D;
70

  
71 68
    mBasicV = new Static4D[3];
72 69
    mCurrV  = new Static4D[3];
73 70

  
74
    mBasicV[0] = new Static4D( (SQ5+1)*0.125f*D, (SQ5-1)*0.125f*D, 0.250f*D, 0.0f );
75
    mBasicV[1] = new Static4D(-(SQ5+1)*0.125f*D, (SQ5-1)*0.125f*D, 0.250f*D, 0.0f );
76
    mBasicV[2] = new Static4D(                0,        -0.500f*D,     0.0f, 0.0f );
71
    mBasicV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
72
    mBasicV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
73
    mBasicV[2] = new Static4D(              0,        -0.500f,    0.0f, 0.0f );
77 74
    };
78 75

  
79 76
///////////////////////////////////////////////////////////////////////////////////////////////////
......
181 178
      }
182 179
    else
183 180
      {
184
      float E = 2.0f/(numLayers-1);
181
      float E = 2.0f*(numLayers/6.0f - MEGA_D)/(0.5f*(numLayers-1));
185 182
      int N = (numCubitsPerCorner-1)/3;
186 183
      int b1 = (part-1) % N;
187 184
      int b2 = (part-1) / N;
188 185
      Static4D pri = mCurrV[b2];
189 186
      Static4D sec = mCurrV[(b2+2)%3];
190 187

  
191
      int multP = b1 % ((numLayers-3)/2);
192
      int multS = b1 / ((numLayers-3)/2);
188
      int multP = (b1 % ((numLayers-3)/2)) + 1;
189
      int multS = (b1 / ((numLayers-3)/2));
193 190

  
194 191
      pos.set( corn.get0()*D + (pri.get0()*multP + sec.get0()*multS)*E,
195 192
               corn.get1()*D + (pri.get1()*multP + sec.get1()*multS)*E,
......
287 284
    {
288 285
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
289 286
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
287
    int index = (numLayers-3)/2;
290 288
    MeshBase mesh;
291 289

  
290
    if( mCornerMeshes==null ) mCornerMeshes = new MeshBase[ObjectList.MEGA.getNumVariants()];
291

  
292 292
//    if( cubit < NUM_CORNERS*numCubitsPerCorner )
293 293
      {
294
      if( mCenterMesh==null ) mCenterMesh = FactoryCubit.getInstance().createMegaminxCornerMesh(numLayers);
295
      mesh = mCenterMesh.copy(true);
294
      if( mCornerMeshes[index]==null ) mCornerMeshes[index] = FactoryCubit.getInstance().createMegaminxCornerMesh(numLayers);
295
      mesh = mCornerMeshes[index].copy(true);
296 296
      }
297 297
/*
298 298
    else if( cubit<NUM_CENTERS + NUM_CORNERS*numCubitsPerCorner )

Also available in: Unified diff