Project

General

Profile

« Previous | Next » 

Revision 3d8237cc

Added by Leszek Koltunski over 3 years ago

Progress with Megaminx.

View differences:

src/main/java/org/distorted/objects/TwistyMegaminx.java
33 33
import org.distorted.main.R;
34 34
import org.distorted.main.RubikSurfaceView;
35 35

  
36
import static org.distorted.objects.FactoryCubit.COS18;
37
import static org.distorted.objects.FactoryCubit.SIN18;
38

  
36 39
///////////////////////////////////////////////////////////////////////////////////////////////////
37 40

  
38 41
public class TwistyMegaminx extends TwistyMinx
......
76 79
           {  9, 11,  3, 11},
77 80
           { 11, 18,  2, 11},
78 81
           { 18,  2,  1, 11},
79
           { 18,  6,  2,  1},
80
           {  6, 16,  7,  1},
82
           { 18,  6,  1,  2},
83
           {  6, 16,  1,  7},
81 84
           { 16,  0,  8,  1},
82
           { 16, 10,  8,  7},
83
           { 10,  8,  8, 10},
84
           {  8, 12,  8,  9},
85
           { 16, 10,  7,  8},
86
           { 10,  8, 10,  8},
87
           {  8, 12,  9,  8},
85 88
           {  8, 13,  9, 10},
86 89
           { 13,  5,  9,  5},
87 90
           {  5,  4,  9,  4},
88
           {  5, 15,  4,  5},
89
           { 15,  9,  4,  3},
91
           {  5, 15,  5,  4},
92
           { 15,  9,  3,  4},
90 93
           { 11, 19,  2,  3},
91 94
           { 19,  7,  2,  6},
92 95
           {  7,  6,  2,  7},
93 96
           {  7, 17,  7,  6},
94 97
           { 17, 10,  7, 10},
95
           { 17,  1,  6, 10},
96
           {  1,  3,  6,  4},
97
           {  3, 19,  6,  3},
98
           { 17,  1, 10,  6},
99
           {  1,  3,  5,  6},
100
           {  3, 19,  3,  6},
98 101
           {  1, 13, 10,  5},
99
           {  3, 15,  5,  3},
102
           {  3, 15,  3,  5},
100 103
         };
101 104

  
102 105
  private static final float[][] mCenterCoords = new float[NUM_CENTERS][3];
......
232 235
      }
233 236
    else
234 237
      {
235
      float E = 2.0f*(numLayers/6.0f - MEGA_D)/(0.5f*(numLayers-1));
238
      float E = 2.0f*(numLayers/3.0f)*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
236 239
      int N = (numCubitsPerCorner-1)/3;
237 240
      int block = (part-1) % N;
238 241
      int index = (part-1) / N;
......
260 263

  
261 264
  private void computeEdge(Static3D pos, int numLayers, int edge, int part)
262 265
    {
266
    float corr = numLayers/3.0f;
267

  
263 268
    Static3D c1 = CORNERS[ mEdgeMap[edge][0] ];
264 269
    Static3D c2 = CORNERS[ mEdgeMap[edge][1] ];
265
    float x = (c1.get0() + c2.get0())/2;
266
    float y = (c1.get1() + c2.get1())/2;
267
    float z = (c1.get2() + c2.get2())/2;
270
    float x = corr*(c1.get0() + c2.get0())/2;
271
    float y = corr*(c1.get1() + c2.get1())/2;
272
    float z = corr*(c1.get2() + c2.get2())/2;
268 273

  
269 274
    if( part==0 )
270 275
      {
......
276 281
      int dir  = (part+1)%2;
277 282
      float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
278 283

  
279
      float vX = center[0]-x;
280
      float vY = center[1]-y;
281
      float vZ = center[2]-z;
284
      float vX = corr*center[0] - x;
285
      float vY = corr*center[1] - y;
286
      float vZ = corr*center[2] - z;
282 287

  
283
      float A = mult*(0.5f-MEGA_D)/((1+SQ5/5)*(numLayers-1));
288
      float len = (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
289
      float A = mult*corr*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f)/len;
284 290

  
285 291
      pos.set( x+A*vX, y+A*vY, z+A*vZ );
286 292
      }
......
383 389

  
384 390
      if( mEdgeMeshes[index][type]==null )
385 391
        {
386
        mEdgeMeshes[index][type] = FactoryCubit.getInstance().createMegaminxEdgeMesh(index,type);
392
        float height= (numLayers/3.0f)*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
393
        float width = (numLayers/3.0f)*2*MEGA_D + 2*type*height*SIN18/COS18;
394

  
395
        mEdgeMeshes[index][type] = FactoryCubit.getInstance().createMegaminxEdgeMesh(width,height);
387 396
        }
388 397

  
389 398
      mesh = mEdgeMeshes[index][type].copy(true);
......
394 403
      // TODO: centers
395 404
      }
396 405
*/
397
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[getQuat(cubit,numLayers)], new Static3D(0,0,0) );
406
    Static4D q = QUATS[getQuat(cubit,numLayers)];
407
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( q, new Static3D(0,0,0) );
398 408
    mesh.apply(quat,0xffffffff,0);
399 409

  
400 410
    return mesh;

Also available in: Unified diff