Project

General

Profile

« Previous | Next » 

Revision 3f7a9aec

Added by Leszek Koltunski about 3 years ago

Float vertices - scratchbook

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
289 289
      {
290 290
      int mode            = 5;
291 291
      int numComponents   = 0;
292
      double[][] vertices = null;
292
      float[][] vertices  = null;
293 293
      int[][] vertIndexes = null;
294 294
      float[][] bands     = null;
295 295
      int[] bandIndexes   = null;
......
303 303

  
304 304
      if( mode==0 )
305 305
        {
306
        vertices = new double[][]
306
        vertices = new float[][]
307 307
          {
308
              { 0.5, 0.5, 0.5 },
309
              { 0.5, 0.5,-0.5 },
310
              { 0.5,-0.5, 0.5 },
311
              { 0.5,-0.5,-0.5 },
312
              {-0.5, 0.5, 0.5 },
313
              {-0.5, 0.5,-0.5 },
314
              {-0.5,-0.5, 0.5 },
315
              {-0.5,-0.5,-0.5 },
308
              { 0.5f, 0.5f, 0.5f },
309
              { 0.5f, 0.5f,-0.5f },
310
              { 0.5f,-0.5f, 0.5f },
311
              { 0.5f,-0.5f,-0.5f },
312
              {-0.5f, 0.5f, 0.5f },
313
              {-0.5f, 0.5f,-0.5f },
314
              {-0.5f,-0.5f, 0.5f },
315
              {-0.5f,-0.5f,-0.5f },
316 316
          };
317 317

  
318 318
        vertIndexes = new int[][]
......
353 353

  
354 354
      else if( mode==1 )
355 355
        {
356
        vertices = new double[][]
356
        vertices = new float[][]
357 357
          {
358
              {-0.5, SQ2/4, 0.0},
359
              { 0.5, SQ2/4, 0.0},
360
              { 0.0,-SQ2/4, 0.5},
361
              { 0.0,-SQ2/4,-0.5}
358
              {-0.5f, SQ2/4, 0.0f},
359
              { 0.5f, SQ2/4, 0.0f},
360
              { 0.0f,-SQ2/4, 0.5f},
361
              { 0.0f,-SQ2/4,-0.5f}
362 362
          };
363 363

  
364 364
        vertIndexes = new int[][]
......
397 397

  
398 398
      else if( mode==2 )
399 399
        {
400
        vertices = new double[][]
400
        vertices = new float[][]
401 401
          {
402
             {-1.5, 0.0, 0.0},
403
             { 1.5, 0.0, 0.0},
404
             { 0.0,-1.5, 0.0},
405
             { 0.0, 0.0,-1.5}
402
             {-1.5f, 0.0f, 0.0f},
403
             { 1.5f, 0.0f, 0.0f},
404
             { 0.0f,-1.5f, 0.0f},
405
             { 0.0f, 0.0f,-1.5f}
406 406
          };
407 407

  
408 408
        vertIndexes = new int[][]
......
443 443

  
444 444
      else if( mode==3 )
445 445
        {
446
        vertices = new double[][]
446
        vertices = new float[][]
447 447
          {
448
              { 0.5,   0.0, 0.5},
449
              { 0.5,   0.0,-0.5},
450
              {-0.5,   0.0,-0.5},
451
              {-0.5,   0.0, 0.5},
452
              { 0.0, SQ2/2, 0.0},
453
              { 0.0,-SQ2/2, 0.0},
448
              { 0.5f,   0.0f, 0.5f},
449
              { 0.5f,   0.0f,-0.5f},
450
              {-0.5f,   0.0f,-0.5f},
451
              {-0.5f,   0.0f, 0.5f},
452
              { 0.0f,  SQ2/2, 0.0f},
453
              { 0.0f, -SQ2/2, 0.0f},
454 454
          };
455 455

  
456 456
        vertIndexes = new int[][]
......
493 493

  
494 494
      else if( mode==4 )
495 495
        {
496
        double SQ5  = Math.sqrt(5);
497
        double SIN18= (SQ5-1)/4;
498
        double COS18= 0.25*Math.sqrt(10.0+2.0*SQ5);
499
        double H = 1.0;
500
        double L = 2.0;
501
        double X = H*Math.sqrt((5+SQ5)/10);
502
        double Y = H*Math.sqrt((5-SQ5)/10);
503
        double D = H*SIN18/COS18;
504

  
505
        vertices = new double[][]
506
          {
507
              { 0.0,   Y, L/2},
508
              {   X, 0.0, L/2},
509
              { 0.0,  -Y, L/2},
510
              {  -X, 0.0, L/2},
511
              { 0.0,  Y, -L/2 +D},
512
              {   X, 0.0,-L/2   },
513
              { 0.0, -Y, -L/2-D },
514
              {  -X, 0.0,-L/2   }
496
        float SQ5  = (float)Math.sqrt(5);
497
        float SIN18= (SQ5-1)/4;
498
        float COS18= 0.25f*(float)Math.sqrt(10.0+2.0*SQ5);
499
        float H = 1.0f;
500
        float L = 2.0f;
501
        float X = H*(float)Math.sqrt((5+SQ5)/10);
502
        float Y = H*(float)Math.sqrt((5-SQ5)/10);
503
        float D = H*SIN18/COS18;
504

  
505
        vertices = new float[][]
506
          {
507
              { 0.0f,    Y, L/2},
508
              {    X, 0.0f, L/2},
509
              { 0.0f,   -Y, L/2},
510
              {   -X, 0.0f, L/2},
511
              { 0.0f,    Y, -L/2 +D},
512
              {    X, 0.0f,-L/2   },
513
              { 0.0f,   -Y, -L/2-D },
514
              {   -X, 0.0f,-L/2   }
515 515
          };
516 516

  
517 517
        vertIndexes = new int[][]
......
555 555
        {
556 556
        int IVY_N = 8;
557 557
        final float IVY_D = 0.003f;
558
        final double angle = Math.PI/(2*IVY_N);
559
        final double CORR  = 1.0 - 2*IVY_D;
558
        final float angle = (float)Math.PI/(2*IVY_N);
559
        final float CORR  = 1.0f - 2*IVY_D;
560 560

  
561
        vertices = new double[3*IVY_N+7][3];
561
        vertices = new float[3*IVY_N+7][3];
562 562
        vertIndexes = new int[6][IVY_N+4];
563 563

  
564
        vertices[0][0] = 0.0;
565
        vertices[0][1] = 0.0;
566
        vertices[0][2] = 0.0;
567
        vertices[1][0] =-1.0;
568
        vertices[1][1] = 0.0;
569
        vertices[1][2] = 0.0;
570
        vertices[2][0] = 0.0;
571
        vertices[2][1] =-1.0;
572
        vertices[2][2] = 0.0;
573
        vertices[3][0] = 0.0;
574
        vertices[3][1] = 0.0;
575
        vertices[3][2] =-1.0;
564
        vertices[0][0] = 0.0f;
565
        vertices[0][1] = 0.0f;
566
        vertices[0][2] = 0.0f;
567
        vertices[1][0] =-1.0f;
568
        vertices[1][1] = 0.0f;
569
        vertices[1][2] = 0.0f;
570
        vertices[2][0] = 0.0f;
571
        vertices[2][1] =-1.0f;
572
        vertices[2][2] = 0.0f;
573
        vertices[3][0] = 0.0f;
574
        vertices[3][1] = 0.0f;
575
        vertices[3][2] =-1.0f;
576 576

  
577 577
        vertIndexes[0][0] = 2;
578 578
        vertIndexes[0][1] = 0;
......
601 601

  
602 602
        for(int i=0; i<=IVY_N; i++)
603 603
          {
604
          double cos1 = Math.cos((IVY_N-i)*angle);
605
          double sin1 = Math.sin((IVY_N-i)*angle);
606
          double cos2 = Math.cos((      i)*angle);
607
          double sin2 = Math.sin((      i)*angle);
604
          float cos1 = (float)Math.cos((IVY_N-i)*angle);
605
          float sin1 = (float)Math.sin((IVY_N-i)*angle);
606
          float cos2 = (float)Math.cos((      i)*angle);
607
          float sin2 = (float)Math.sin((      i)*angle);
608 608

  
609
          vertices[N1+i][0] = CORR*(cos1-0.5) - 0.5;
610
          vertices[N1+i][1] = CORR*(sin1-0.5) - 0.5;
611
          vertices[N1+i][2] = 0.0;
609
          vertices[N1+i][0] = CORR*(cos1-0.5f) - 0.5f;
610
          vertices[N1+i][1] = CORR*(sin1-0.5f) - 0.5f;
611
          vertices[N1+i][2] = 0.0f;
612 612

  
613
          vertices[N2+i][0] = 0.0;
614
          vertices[N2+i][1] = CORR*(sin2-0.5) - 0.5;
615
          vertices[N2+i][2] = CORR*(cos2-0.5) - 0.5;
613
          vertices[N2+i][0] = 0.0f;
614
          vertices[N2+i][1] = CORR*(sin2-0.5f) - 0.5f;
615
          vertices[N2+i][2] = CORR*(cos2-0.5f) - 0.5f;
616 616

  
617
          vertices[N3+i][0] = CORR*(cos2-0.5) - 0.5;
618
          vertices[N3+i][1] = 0.0;
619
          vertices[N3+i][2] = CORR*(sin2-0.5) - 0.5;
617
          vertices[N3+i][0] = CORR*(cos2-0.5f) - 0.5f;
618
          vertices[N3+i][1] = 0.0f;
619
          vertices[N3+i][2] = CORR*(sin2-0.5f) - 0.5f;
620 620

  
621 621
          vertIndexes[0][i+3] = N1 + i;
622 622
          vertIndexes[1][i+3] = N2 + i;
......
671 671
        {
672 672
        int IVY_N = 6;
673 673
        final float IVY_D = 0.003f;
674
        final double angle = Math.PI/(2*IVY_N);
675
        final double CORR  = 1.0 - 2*IVY_D;
674
        final float angle = (float)Math.PI/(2*IVY_N);
675
        final float CORR  = 1.0f - 2*IVY_D;
676 676

  
677
        vertices   = new double[2*IVY_N][3];
677
        vertices   = new float[2*IVY_N][3];
678 678
        vertIndexes= new int[2][2*IVY_N];
679 679

  
680 680
        for(int i=0; i<IVY_N; i++)
681 681
          {
682
          double cos = Math.cos(i*angle);
683
          double sin = Math.sin(i*angle);
682
          float cos = (float)Math.cos(i*angle);
683
          float sin = (float)Math.sin(i*angle);
684 684

  
685
          vertices[i      ][0] = CORR*(0.5-cos);
686
          vertices[i      ][1] = CORR*(0.5-sin);
687
          vertices[i      ][2] = 0.0;
688
          vertices[i+IVY_N][0] = CORR*(cos-0.5);
689
          vertices[i+IVY_N][1] = CORR*(sin-0.5);
690
          vertices[i+IVY_N][2] = 0.0;
685
          vertices[i      ][0] = CORR*(0.5f-cos);
686
          vertices[i      ][1] = CORR*(0.5f-sin);
687
          vertices[i      ][2] = 0.0f;
688
          vertices[i+IVY_N][0] = CORR*(cos-0.5f);
689
          vertices[i+IVY_N][1] = CORR*(sin-0.5f);
690
          vertices[i+IVY_N][2] = 0.0f;
691 691

  
692 692
          vertIndexes[0][i      ] = i;
693 693
          vertIndexes[0][i+IVY_N] = i+IVY_N;
......
734 734

  
735 735
      else if( mode==7 )
736 736
        {
737
        double S = (SQ5+1)/4;
737
        float S = (SQ5+1)/4;
738 738

  
739
        vertices = new double[][]
739
        vertices = new float[][]
740 740
          {
741
              { 0.0       ,  0.0      , 0.0       },
742
              { -0.5*S    , 0.5*S+0.25, -0.25     },
743
              {-0.25      , -S/2      , (-2*S-1)/4},
744
              { 0.5*S+0.25, 0.25      , -S/2      },
745
              { 0.0       , 0.5       , -S-0.5    },
746
              { 0.0       , 0.5       , 0.0       },
747
              { -0.5*S    ,-0.5*S+0.25, -0.25     },
748
              {  0.5*S    ,-0.5*S+0.25, -0.25     }
741
              { 0.0f        ,  0.0f       , 0.0f       },
742
              { -0.5f*S     , 0.5f*S+0.25f, -0.25f     },
743
              {-0.25f       , -S/2        , (-2*S-1)/4 },
744
              { 0.5f*S+0.25f, 0.25f       , -S/2       },
745
              { 0.0f        , 0.5f        , -S-0.5f    },
746
              { 0.0f        , 0.5f        , 0.0f       },
747
              { -0.5f*S     ,-0.5f*S+0.25f, -0.25f     },
748
              {  0.5f*S     ,-0.5f*S+0.25f, -0.25f     }
749 749
          };
750 750

  
751 751
        vertIndexes = new int[][]
......
787 787

  
788 788
      else if( mode==8 )
789 789
        {
790
        double S = (SQ5+1)/4;
790
        float S = (SQ5+1)/4;
791 791

  
792
        vertices = new double[][]
792
        vertices = new float[][]
793 793
          {
794
              {-S/2     ,-S/2+0.25,     0.25},
795
              { S/2     , S/2-0.25,    -0.25},
796
              {-S       ,     0.00,     0.00},
797
              {     0.25, S/2     ,-S/2-0.25},
798
              {-S/2     ,-S/2-0.25,     0.25},
799
              { S/2+0.25,    -0.25,-S/2     },
800
              {-S       ,    -0.50,     0.00},
801
              {     0.50,     0.00,-S       },
802
              {-S  +0.25, S/2     ,-S/2-0.25},
803
              {     0.25,-S/2-0.50,-S/2+0.25},
804
              {-S/2     ,-S/2-0.25,-S  -0.25}
794
              {-S/2      ,-S/2+0.25f,     0.25f},
795
              { S/2      , S/2-0.25f,    -0.25f},
796
              {-S        ,     0.00f,     0.00f},
797
              {     0.25f, S/2      ,-S/2-0.25f},
798
              {-S/2      ,-S/2-0.25f,     0.25f},
799
              { S/2+0.25f,    -0.25f,-S/2      },
800
              {-S        ,    -0.50f,     0.00f},
801
              {     0.50f,     0.00f,-S        },
802
              {-S  +0.25f, S/2      ,-S/2-0.25f},
803
              {     0.25f,-S/2-0.50f,-S/2+0.25f},
804
              {-S/2      ,-S/2-0.25f,-S  -0.25f}
805 805
          };
806 806

  
807 807
        vertIndexes = new int[][]
......
848 848
        {
849 849
        final float X = 3*(2-SQ3)/2;
850 850

  
851
        vertices = new double[][]
851
        vertices = new float[][]
852 852
          {
853
              { -1.5-X, 0.5, 1.5 },
854
              {    0.0, 0.5, 1.5 },
855
              {    0.0, 0.5,-1.5 },
856
              { -1.5+X, 0.5,-1.5 },
857
              { -1.5-X,-0.5, 1.5 },
858
              {    0.0,-0.5, 1.5 },
859
              {    0.0,-0.5,-1.5 },
860
              { -1.5+X,-0.5,-1.5 }
853
              { -1.5f-X, 0.5f, 1.5f },
854
              {    0.0f, 0.5f, 1.5f },
855
              {    0.0f, 0.5f,-1.5f },
856
              { -1.5f+X, 0.5f,-1.5f },
857
              { -1.5f-X,-0.5f, 1.5f },
858
              {    0.0f,-0.5f, 1.5f },
859
              {    0.0f,-0.5f,-1.5f },
860
              { -1.5f+X,-0.5f,-1.5f }
861 861
          };
862 862

  
863 863
        vertIndexes = new int[][]
......
902 902
        {
903 903
        final float X = 3*(2-SQ3)/2;
904 904

  
905
        vertices = new double[][]
905
        vertices = new float[][]
906 906
          {
907
              { -X, 0.5, 0.0 },
908
              { +X, 0.5, 0.0 },
909
              {0.0, 0.5,-1.5 },
910
              { -X,-0.5, 0.0 },
911
              { +X,-0.5, 0.0 },
912
              {0.0,-0.5,-1.5 },
907
              {  -X, 0.5f, 0.0f },
908
              {  +X, 0.5f, 0.0f },
909
              {0.0f, 0.5f,-1.5f },
910
              {  -X,-0.5f, 0.0f },
911
              {  +X,-0.5f, 0.0f },
912
              {0.0f,-0.5f,-1.5f },
913 913
          };
914 914

  
915 915
        vertIndexes = new int[][]
......
952 952
        {
953 953
        final float X = 3*(2-SQ3)/2;
954 954

  
955
        vertices = new double[][]
955
        vertices = new float[][]
956 956
          {
957
              { X-1.5, 0.5,  0.0 },
958
              {   0.0, 0.5,  0.0 },
959
              {   0.0, 0.5,X-1.5 },
960
              {  -1.5, 0.5, -1.5 },
961
              { X-1.5,-0.5,  0.0 },
962
              {   0.0,-0.5,  0.0 },
963
              {   0.0,-0.5,X-1.5 },
964
              {  -1.5,-0.5, -1.5 }
957
              { X-1.5f, 0.5f,  0.0f },
958
              {   0.0f, 0.5f,  0.0f },
959
              {   0.0f, 0.5f,X-1.5f },
960
              {  -1.5f, 0.5f, -1.5f },
961
              { X-1.5f,-0.5f,  0.0f },
962
              {   0.0f,-0.5f,  0.0f },
963
              {   0.0f,-0.5f,X-1.5f },
964
              {  -1.5f,-0.5f, -1.5f }
965 965
          };
966 966

  
967 967
        vertIndexes = new int[][]
......
1006 1006
        final float X = 3*(2-SQ3)/2;
1007 1007
        final float Z = 0.75f - X/2;
1008 1008

  
1009
        vertices = new double[][]
1009
        vertices = new float[][]
1010 1010
          {
1011
              { X-1.5+Z, 0.5,  0.0 },
1012
              {       Z, 0.5,  0.0 },
1013
              {  -1.5+Z, 0.5, -1.5 },
1014
              { X-1.5+Z,-0.5,  0.0 },
1015
              {       Z,-0.5,  0.0 },
1016
              {  -1.5+Z,-0.5, -1.5 }
1011
              { X-1.5f+Z, 0.5f,  0.0f },
1012
              {        Z, 0.5f,  0.0f },
1013
              {  -1.5f+Z, 0.5f, -1.5f },
1014
              { X-1.5f+Z,-0.5f,  0.0f },
1015
              {        Z,-0.5f,  0.0f },
1016
              {  -1.5f+Z,-0.5f, -1.5f }
1017 1017
          };
1018 1018

  
1019 1019
        vertIndexes = new int[][]
......
1054 1054

  
1055 1055
      else if( mode==13 )
1056 1056
        {
1057
        vertices = new double[][]
1057
        vertices = new float[][]
1058 1058
          {
1059 1059
             { 0.0f, 0.0f, 0.0f },
1060 1060
             {-0.5f, 0.5f, 0.5f },
......
1114 1114
        final float Y = F*SQ2/2;
1115 1115
        final float Z =-F/2;
1116 1116

  
1117
        vertices = new double[][]
1117
        vertices = new float[][]
1118 1118
          {
1119
             { 0.0, 0.0, 0.0 },
1120
             {   X,   Y,   Z },
1121
             { 0.0, 2*Y, 2*Z },
1122
             {  -X,   Y,   Z },
1123
             { 0.0, 0.0,    -F },
1124
             {   X,   Y,   Z-F },
1125
             { 0.0, 2*Y, 2*Z-F },
1126
             {  -X,   Y,   Z-F },
1119
             { 0.0f, 0.0f,  0.0f },
1120
             {    X,    Y,     Z },
1121
             { 0.0f,  2*Y,   2*Z },
1122
             {   -X,    Y,     Z },
1123
             { 0.0f, 0.0f,    -F },
1124
             {    X,    Y,   Z-F },
1125
             { 0.0f,  2*Y, 2*Z-F },
1126
             {   -X,    Y,   Z-F },
1127 1127
          };
1128 1128

  
1129 1129
        vertIndexes = new int[][]
......
1171 1171
        final float Y = F*SQ2/2;
1172 1172
        final float Z =-F/2;
1173 1173

  
1174
        vertices = new double[][]
1174
        vertices = new float[][]
1175 1175
          {
1176
             { 0.0, 0.0,     0.5-F },
1177
             {   X,   Y,   Z+0.5-F },
1178
             { 0.0, 2*Y, 2*Z+0.5-F },
1179
             {  -X,   Y,   Z+0.5-F },
1180
             { 0.0, 0.0,    -0.5+F },
1181
             {   X,   Y,  -Z-0.5+F },
1182
             { 0.0, 2*Y,-2*Z-0.5+F },
1183
             {  -X,   Y,  -Z-0.5+F },
1176
             { 0.0f, 0.0f,     0.5f-F },
1177
             {    X,    Y,   Z+0.5f-F },
1178
             { 0.0f,  2*Y, 2*Z+0.5f-F },
1179
             {   -X,    Y,   Z+0.5f-F },
1180
             { 0.0f, 0.0f,    -0.5f+F },
1181
             {    X,    Y,  -Z-0.5f+F },
1182
             { 0.0f,  2*Y,-2*Z-0.5f+F },
1183
             {   -X,    Y,  -Z-0.5f+F },
1184 1184
          };
1185 1185

  
1186 1186
        vertIndexes = new int[][]
......
1229 1229
        final float Z =-L/2;
1230 1230
        final float D = F/L;
1231 1231

  
1232
        vertices = new double[][]
1232
        vertices = new float[][]
1233 1233
          {
1234
              {    0.0,     -2*Y/3,   -2*Z/3 },
1235
              {      X,        Y/3,      Z/3 },
1236
              {     -X,        Y/3,      Z/3 },
1237
              {    0.0,     -2*Y/3,   -2*Z/3+2*D*Z },
1238
              {  X-D*X,    Y/3-D*Y,  Z/3+D*Z },
1239
              { -X+D*X,    Y/3-D*Y,  Z/3+D*Z },
1234
              {    0.0f,     -2*Y/3,   -2*Z/3 },
1235
              {       X,        Y/3,      Z/3 },
1236
              {      -X,        Y/3,      Z/3 },
1237
              {    0.0f,     -2*Y/3,   -2*Z/3+2*D*Z },
1238
              {   X-D*X,    Y/3-D*Y,  Z/3+D*Z },
1239
              {  -X+D*X,    Y/3-D*Y,  Z/3+D*Z },
1240 1240
          };
1241 1241

  
1242 1242
        vertIndexes = new int[][]

Also available in: Unified diff