Project

General

Profile

« Previous | Next » 

Revision 166e4113

Added by Leszek Koltunski about 1 year ago

Coin Tetrahedron: progress

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyCoinTetrahedron.java
174 174
      {
175 175
      if( V==null ) initVertices();
176 176

  
177
      float A = -0.015f;
178
      float[] r0 = new float[] { A*(V[0][0]-M[0][0]), A*(V[0][1]-M[0][1]), A*(V[0][2]-M[0][2]) };
179
      float[] r1 = new float[] { A*(V[1][0]-M[1][0]), A*(V[1][1]-M[1][1]), A*(V[1][2]-M[1][2]) };
180
      float[] r2 = new float[] { A*(V[2][0]-M[2][0]), A*(V[2][1]-M[2][1]), A*(V[2][2]-M[2][2]) };
181
      float[] r3 = new float[] { A*(V[3][0]-M[3][0]), A*(V[3][1]-M[3][1]), A*(V[3][2]-M[3][2]) };
182

  
177 183
      mPosition = new float[][]
178 184
         {
179 185
             {V[1][0],V[1][1],V[1][2]},
......
186 192
             {M[2][0],M[2][1],M[2][2]},
187 193
             {M[3][0],M[3][1],M[3][2]},
188 194

  
189
             {L[ 0][0],L[ 0][1],L[ 0][2]},
190
             {L[ 1][0],L[ 1][1],L[ 1][2]},
191
             {L[ 2][0],L[ 2][1],L[ 2][2]},
192
             {L[ 3][0],L[ 3][1],L[ 3][2]},
193
             {L[ 4][0],L[ 4][1],L[ 4][2]},
194
             {L[ 5][0],L[ 5][1],L[ 5][2]},
195
             {L[ 6][0],L[ 6][1],L[ 6][2]},
196
             {L[ 7][0],L[ 7][1],L[ 7][2]},
197
             {L[ 8][0],L[ 8][1],L[ 8][2]},
198
             {L[ 9][0],L[ 9][1],L[ 9][2]},
199
             {L[10][0],L[10][1],L[10][2]},
200
             {L[11][0],L[11][1],L[11][2]},
195
             {L[ 0][0] +r0[0],L[ 0][1] +r0[1],L[ 0][2] +r0[2]},
196
             {L[ 1][0] +r0[0],L[ 1][1] +r0[1],L[ 1][2] +r0[2]},
197
             {L[ 2][0] +r0[0],L[ 2][1] +r0[1],L[ 2][2] +r0[2]},
198
             {L[ 3][0] +r1[0],L[ 3][1] +r1[1],L[ 3][2] +r1[2]},
199
             {L[ 4][0] +r1[0],L[ 4][1] +r1[1],L[ 4][2] +r1[2]},
200
             {L[ 5][0] +r1[0],L[ 5][1] +r1[1],L[ 5][2] +r1[2]},
201
             {L[ 6][0] +r2[0],L[ 6][1] +r2[1],L[ 6][2] +r2[2]},
202
             {L[ 7][0] +r2[0],L[ 7][1] +r2[1],L[ 7][2] +r2[2]},
203
             {L[ 8][0] +r2[0],L[ 8][1] +r2[1],L[ 8][2] +r2[2]},
204
             {L[ 9][0] +r3[0],L[ 9][1] +r3[1],L[ 9][2] +r3[2]},
205
             {L[10][0] +r3[0],L[10][1] +r3[1],L[10][2] +r3[2]},
206
             {L[11][0] +r3[0],L[11][1] +r3[1],L[11][2] +r3[2]},
201 207
         };
202 208
      }
203 209

  
......
245 251

  
246 252
  private float[][] produceCorner()
247 253
    {
248
    float[][] ret = new float[5 + 3*(N+1)][];
254
    float[][] ret = new float[5 + 3*(N+1) +3][];
249 255

  
250 256
    ret[0] = new float[] { 0.00f, 0.0f     , 0.00f };
251 257
    ret[1] = new float[] { 0.00f, 0.0f     ,-1.50f };
......
285 291
      ret[5+2*(N+1)+i] = rotateVertices(angle,vect3,center3,rot3);
286 292
      }
287 293

  
294
    float B = 0.85f;
295
    ret[ 5 + 3*(N+1)  ] = new float[] { ret[0][0]*B + ret[1][0]*(1-B), ret[0][1]*B + ret[1][1]*(1-B), ret[0][2]*B + ret[1][2]*(1-B) };
296
    ret[ 5 + 3*(N+1)+1] = new float[] { ret[0][0]*B + ret[2][0]*(1-B), ret[0][1]*B + ret[2][1]*(1-B), ret[0][2]*B + ret[2][2]*(1-B) };
297
    ret[ 5 + 3*(N+1)+2] = new float[] { ret[0][0]*B + ret[3][0]*(1-B), ret[0][1]*B + ret[3][1]*(1-B), ret[0][2]*B + ret[3][2]*(1-B) };
298

  
288 299
    return ret;
289 300
    }
290 301

  
......
362 373

  
363 374
  private int[][] produceCornerShape()
364 375
    {
365
    int[][] ret = new int[9+3*N][];
376
    int[][] ret = new int[9+3*N+3][];
366 377

  
367 378
    ret[0] = new int[N+4];
368 379
    ret[0][0] = 3;
......
396 407
      ret[9+2*N+i] = new int[] {7+2*N+i, 8+2*N+i, 4};
397 408
      }
398 409

  
410
    ret[3*N+ 9] = new int[] { 3*N+8, 3*N+ 9, 3 };
411
    ret[3*N+10] = new int[] { 3*N+9, 3*N+10, 1 };
412
    ret[3*N+11] = new int[] { 3*N+8, 3*N+10, 2 };
413

  
399 414
    return ret;
400 415
    }
401 416

  
......
488 503
    {
489 504
    if( variant==0 )
490 505
      {
491
      float h1 = isInIconMode() ? 0.001f : 0.035f;
506
      float h1 = isInIconMode() ? 0.001f : 0.02f;
492 507
      float h2 = isInIconMode() ? 0.001f : 0.01f;
493 508
      float[][] bands = { {h1,35,0.2f,0.4f,5,1,0}, {h2,35,0.2f,0.4f,2,0,0} };
494
      int[] indices   = new int[9+3*N];
495
      for(int i=3; i<9+3*N; i++) indices[i] = 1;
509
      int num = 9+3*N+3;
510
      int[] indices   = new int[num];
511
      for(int i=3; i<num; i++) indices[i] = 1;
496 512
      float A = 0.5f;
497 513
      float[] convexCenter = { 0.0f*A, 0.75f*SQ2*A, -1.50f*A};
498 514
      return new ObjectFaceShape(bands,indices,convexCenter);
......
509 525
      }
510 526
    else
511 527
      {
512
      float h1 = isInIconMode() ? 0.001f : 0.0f;
513
      float h2 = isInIconMode() ? 0.001f : 0.0f;
528
      float h1 = isInIconMode() ? 0.001f : 0.02f;
529
      float h2 = isInIconMode() ? 0.001f : 0.00f;
514 530
      float[][] bands = { {h1,15,0.250f,0.7f,5,0,0}, {h2,15,0.125f,0.2f,2,0,0} };
515 531
      int num = 2+2*(N-1)+1;
516 532
      int[] indices   = new int[num];
......
525 541
    {
526 542
    if( variant==0 )
527 543
      {
528
      float[][] corners = { {0.04f,0.15f} };
529
      int[] indices     = new int[5 + 3*(N+1)];
530
      for(int i=4; i<5 + 3*(N+1); i++) indices[i] = -1;
544
      float[][] corners = { {0.04f,0.10f} };
545
      int num = 5 + 3*(N+1) + 3;
546
      int[] indices     = new int[num];
547
      for(int i=4; i<num; i++) indices[i] = -1;
531 548
      float[][] centers = { { 0.00f, 0.75f*SQ2,-1.50f} };
532 549
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
533 550
      }
......
567 584

  
568 585
  public float getStickerRadius()
569 586
    {
570
    return 0.09f;
587
    return 0.12f;
571 588
    }
572 589

  
573 590
///////////////////////////////////////////////////////////////////////////////////////////////////
574 591

  
575 592
  public float getStickerStroke()
576 593
    {
577
    return isInIconMode() ? 0.20f : 0.09f;
594
    return isInIconMode() ? 0.20f : 0.12f;
595
    }
596

  
597
///////////////////////////////////////////////////////////////////////////////////////////////////
598

  
599
  @Override
600
  public void adjustStickerCoords()
601
    {
602
    float B = 0.06422593f;
603
    float C = 0.43301257f;
604
    float D = 0.3580885f;
605
    float E = 0.12022744f;
606
    float F = 0.32227963f - 0.015f;
607
    float G = 0.14090173f + 0.01f;
608

  
609
    mStickerCoords = new float[][]
610
          {
611
            { -D, E, 0.0f, -0.5f, D, E, F, G, -F, G },
612
            { -C, -0.25f, 0.0f, 0.5f, C, -0.25f },
613
            { -0.5f, B, 0.5f, B }
614
          };
578 615
    }
579 616

  
580 617
///////////////////////////////////////////////////////////////////////////////////////////////////
581 618

  
582 619
  public float[][] getStickerAngles()
583 620
    {
584
    return null;   // TODO
621
    float D1 = (float)(Math.PI/3);
622
    float D2 = (float)(Math.PI/8);  // really 6, but with 8 it looks better
623
    return new float[][] { { 0,0,0,-D1,0 },{-D2,-D2,-D2},{D1,D2} };
585 624
    }
586 625

  
587 626
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff