Project

General

Profile

« Previous | Next » 

Revision 60cc43cc

Added by Leszek Koltunski 10 months ago

progress with TwistyBandagedMegaminx.

View differences:

src/main/java/org/distorted/objectlib/bandaged/FactoryBandagedMegaminx.java
39 39
  private static final int NUM_CENTERS = 12;
40 40
  private static final int NUM_EDGES   = 30;
41 41

  
42
  private static final float CENT_DIST_SQ = DIST3D*DIST3D;
43
  private static final float CORN_DIST_SQ = (18+6*SQ5)/16;
44
  private static final float EDGE_DIST_SQ = (14+6*SQ5)/16;
45
  private static final float EDHA_DIST_SQ = (15+6*SQ5)/16;
46

  
42 47
  private static FactoryBandagedMegaminx mThis;
43 48

  
44 49
  private static final Static3D[] ROT_AXIS = new Static3D[]
......
76 81

  
77 82
///////////////////////////////////////////////////////////////////////////////////////////////////
78 83

  
79
  private float[][] retCornerKilominx(int numL)
84
  private float[][] retCenterKilominx(float width)
80 85
    {
81
    float width = 1;//(1+0.5f*(numL-3)*SIN18)*numL/(numL-1);
82 86
    float X = width*COS18*SIN_HALFD;
83 87
    float Y = width*SIN18;
84 88
    float Z = width*COS18*COS_HALFD;
85 89
    float H = width*(SIN54/COS54);
86
    float H3 = H/COS_HALFD;
87
    float X3 = H*SIN_HALFD;
88
    float Z3 = H*COS_HALFD;
89
    float C = 1/(COS54*(float) Math.sqrt(2-2*SIN18));
90
    float H3= H/COS_HALFD;
91
    float X3= H*SIN_HALFD;
92
    float Z3= H*COS_HALFD;
93
    float C = 1/(COS54*(float)Math.sqrt(2-2*SIN18));
90 94

  
91 95
    return new float[][]
92 96
      {
93
       {  0,      0,      0 },
94
       {  X,      Y,     -Z },
95
       {  0,  C*2*Y, -2*C*Z },
96
       { -X,      Y,     -Z },
97
       {  0, -width,      0 },
98
       { X3, -width,    -Z3 },
99
       {  0, -width,    -H3 },
100
       {-X3, -width,    -Z3 }
97
       {   0,   0  ,     0 },
98
       {   X,   Y  ,    -Z },
99
       {   0,C*2*Y ,-2*C*Z },
100
       {  -X,   Y  ,    -Z },
101
       {   0,-width,     0 },
102
       {  X3,-width,   -Z3 },
103
       {   0,-width,   -H3 },
104
       { -X3,-width,   -Z3 }
101 105
      };
102 106
    }
103 107

  
104 108
///////////////////////////////////////////////////////////////////////////////////////////////////
105 109

  
106
  private float[][] retEdgeKilominx(int numL, int variant)
110
  private float[][] retEdgeKilominx(int variant)
107 111
    {
108 112
    int type = variant-1;
109 113
    float tmpVal= 1.0f;//numL/(numL-1.0f);
......
136 140
    return vertices;
137 141
    }
138 142

  
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

  
141
  private float[][] retCenterKilominx(int numL)
142
    {
143
    float width = 1+SIN18;//(1+0.5f*(numL-3)*SIN18)*numL/(numL-1);
144
    float X = width*COS18*SIN_HALFD;
145
    float Y = width*SIN18;
146
    float Z = width*COS18*COS_HALFD;
147
    float H = width*(SIN54/COS54);
148
    float H3= H/COS_HALFD;
149
    float X3= H*SIN_HALFD;
150
    float Z3= H*COS_HALFD;
151
    float C = 1/(COS54*(float)Math.sqrt(2-2*SIN18));
152

  
153
    return new float[][]
154
      {
155
        {   0,   0  ,     0 },
156
        {   X,   Y  ,    -Z },
157
        {   0,C*2*Y ,-2*C*Z },
158
        {  -X,   Y  ,    -Z },
159
        {   0,-width,     0 },
160
        {  X3,-width,   -Z3 },
161
        {   0,-width,   -H3 },
162
        { -X3,-width,   -Z3 }
163
      };
164
    }
165

  
166 143
///////////////////////////////////////////////////////////////////////////////////////////////////
167 144

  
168 145
  private float[][] retCornerMegaminx(float width)
......
238 215

  
239 216
///////////////////////////////////////////////////////////////////////////////////////////////////
240 217

  
241
  private float[][] verticesKilominx(int variant)
218
  private float[][] verticesKilominx()
242 219
    {
243
    if( mVertices[0]==null ) mVertices[0] = retCornerKilominx(3);
220
    if( mVertices[0]==null ) mVertices[0] = retCenterKilominx(1.0f);
244 221
    return mVertices[0];
245 222
    }
246 223

  
......
269 246
      {
270 247
      case 0: if( mVertices[4]==null ) mVertices[4] = retCornerMegaminx( 1.0f );
271 248
              break;
272
      case 1: if( mVertices[5]==null ) mVertices[5] = retEdgeKilominx(4,variant);
249
      case 1: if( mVertices[5]==null ) mVertices[5] = retEdgeKilominx(variant);
273 250
              break;
274
      case 2: if( mVertices[6]==null ) mVertices[6] = retEdgeKilominx(4,variant);
251
      case 2: if( mVertices[6]==null ) mVertices[6] = retEdgeKilominx(variant);
275 252
              break;
276
      case 3: if( mVertices[7]==null ) mVertices[7] = retCenterKilominx(4);
253
      case 3: if( mVertices[7]==null ) mVertices[7] = retCenterKilominx(1+SIN18);
277 254
              break;
278 255
      }
279 256

  
......
307 284

  
308 285
    switch( numLayers[0] )
309 286
      {
310
      case 2: return verticesKilominx(variant);
287
      case 2: return verticesKilominx();
311 288
      case 3: return verticesMegaminx(variant);
312 289
      case 4: return verticesMasterKilominx(variant);
313 290
      case 5: return verticesGigaminx(variant);
......
348 325

  
349 326
///////////////////////////////////////////////////////////////////////////////////////////////////
350 327

  
351
  private int[][] indicesKilominx(int variant)
328
  private int[][] indicesKilominx()
352 329
    {
353 330
    if( mIndices[0]==null ) mIndices[0] = cornerIndices();
354 331
    return mIndices[0];
......
423 400

  
424 401
    switch( numLayers[0] )
425 402
      {
426
      case 2: return indicesKilominx(variant);
403
      case 2: return indicesKilominx();
427 404
      case 3: return indicesMegaminx(variant);
428 405
      case 4: return indicesMasterKilominx(variant);
429 406
      case 5: return indicesGigaminx(variant);
......
452 429
    float len0 = v0x*v0x + v0y*v0y + v0z*v0z;
453 430
    float len1 = v1x*v1x + v1y*v1y + v1z*v1z;
454 431

  
455
    if( v0x != 0 )
432
    if( v0x > MAXERR || v0x < -MAXERR )
456 433
      {
457 434
      float A = v1x/v0x;
458 435
      float errY = v1y - A*v0y;
......
460 437
      if( errY>-MAXERR && errY<MAXERR && errZ>-MAXERR && errZ<MAXERR ) return len0>len1 ? 1:2;
461 438
      else return 0;
462 439
      }
463
    else if( v0y != 0 )
440
    else if( v0y > MAXERR || v0y < -MAXERR )
464 441
      {
465 442
      float A = v1y/v0y;
466 443
      float errX = v1x - A*v0x;
......
468 445
      if( errX>-MAXERR && errX<MAXERR && errZ>-MAXERR && errZ<MAXERR ) return len0>len1 ? 1:2;
469 446
      else return 0;
470 447
      }
471
    else if( v0z != 0 )
448
    else if( v0z > MAXERR || v0z < -MAXERR )
472 449
      {
473 450
      float A = v1z/v0z;
474 451
      float errX = v1x - A*v0x;
......
500 477
  public int getElementVariant(int[] numLayers, float x, float y, float z)
501 478
    {
502 479
    int size = numLayers[0];
503

  
504
    float CENT_DIST_SQ = DIST3D*DIST3D;
505
    float CORN_DIST_SQ = (18+6*SQ5)/16;
506
    float EDGE_DIST_SQ = (14+6*SQ5)/16;
507
    float EDHA_DIST_SQ = (15+6*SQ5)/16;
508

  
509 480
    float d = x*x + y*y + z*z;
510 481
    float MAXERR = 0.01f;
511 482

  
......
537 508
                  int loc = belongsToEdge(c0, c1, xCorr, yCorr, zCorr);
538 509
                  if( loc!=0 ) return loc;
539 510
                  }
540

  
541 511
                return 1;
542 512
                }
543 513
              return 3;
......
1104 1074
  public float[][] getBands(boolean iconMode, int[] numLayers)
1105 1075
    {
1106 1076
    float height= iconMode ? 0.001f : 0.05f;
1107
    int[] angle = {72,55,45,40,35,30,25,20,15,10,5};
1077
    int[] angle = {72,55,50,46,42,39,36,34,31,29,27};
1108 1078
    float R     = 0.5f;
1109 1079
    float S     = 0.5f;
1110 1080
    int extraI  = 0;

Also available in: Unified diff