Project

General

Profile

« Previous | Next » 

Revision 6f2d931d

Added by Leszek Koltunski about 6 years ago

Added a new attribute to vertices of a MeshBase object: the vec3 'inflate' vector.
This vector describes the direction where the vertex needs to be moved when we 'inflate' the whole mesh.
If the mesh is locally smooth, this is simply the normal vector; otherwise (for example in the corners of the MeshCubes) - not.

Currently the new attribute is always set to (1,0,0) and not used yet.

View differences:

src/main/java/org/distorted/library/mesh/MeshBase.java
39 39
 */
40 40
public abstract class MeshBase
41 41
   {
42
   static final int POS_DATA_SIZE= 3;
43
   static final int NOR_DATA_SIZE= 3;
44
   static final int TEX_DATA_SIZE= 2;
42
   private static final int POS_DATA_SIZE= 3;
43
   private static final int NOR_DATA_SIZE= 3;
44
   private static final int INF_DATA_SIZE= 3;
45
   private static final int TEX_DATA_SIZE= 2;
46

  
47
   static final int POS_ATTRIB   = 0;
48
   static final int NOR_ATTRIB   = POS_DATA_SIZE;
49
   static final int INF_ATTRIB   = POS_DATA_SIZE + NOR_DATA_SIZE;
50
   static final int TEX_ATTRIB   = POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE;
51
   static final int VERT_ATTRIBS = POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE + TEX_DATA_SIZE;
45 52

  
46 53
   private static final int BYTES_PER_FLOAT = 4;
47 54

  
48
   private static final int OFFSET_POS =                                                        0;
49
   private static final int OFFSET_NOR = (POS_DATA_SIZE                         )*BYTES_PER_FLOAT;
50
   private static final int OFFSET_TEX = (POS_DATA_SIZE+NOR_DATA_SIZE           )*BYTES_PER_FLOAT;
55
   private static final int OFFSET_POS = POS_ATTRIB*BYTES_PER_FLOAT;
56
   private static final int OFFSET_NOR = NOR_ATTRIB*BYTES_PER_FLOAT;
57
   private static final int OFFSET_INF = INF_ATTRIB*BYTES_PER_FLOAT;
58
   private static final int OFFSET_TEX = TEX_ATTRIB*BYTES_PER_FLOAT;
51 59

  
52
   private static final int TFSIZE  = (POS_DATA_SIZE+POS_DATA_SIZE              )*BYTES_PER_FLOAT;
53
   private static final int VERTSIZE= (POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*BYTES_PER_FLOAT;
60
   private static final int TFSIZE  = (POS_DATA_SIZE+POS_DATA_SIZE                            )*BYTES_PER_FLOAT;
61
   private static final int VERTSIZE= (POS_DATA_SIZE+NOR_DATA_SIZE+INF_DATA_SIZE+TEX_DATA_SIZE)*BYTES_PER_FLOAT;
54 62

  
55 63
   private boolean mShowNormals;       // when rendering this mesh, draw normal vectors?
56 64
   private DistortedBuffer mVBO, mTFO; // main vertex buffer and transform feedback buffer
......
128 136
     GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mVBO.mIndex[0] );
129 137
     GLES31.glVertexAttribPointer(program.mAttribute[0], MeshBase.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshBase.VERTSIZE, MeshBase.OFFSET_POS);
130 138
     GLES31.glVertexAttribPointer(program.mAttribute[1], MeshBase.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshBase.VERTSIZE, MeshBase.OFFSET_NOR);
131
     GLES31.glVertexAttribPointer(program.mAttribute[2], MeshBase.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshBase.VERTSIZE, MeshBase.OFFSET_TEX);
139
     GLES31.glVertexAttribPointer(program.mAttribute[2], MeshBase.INF_DATA_SIZE, GLES31.GL_FLOAT, false, MeshBase.VERTSIZE, MeshBase.OFFSET_INF);
140
     GLES31.glVertexAttribPointer(program.mAttribute[3], MeshBase.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshBase.VERTSIZE, MeshBase.OFFSET_TEX);
132 141
     GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
133 142
     }
134 143

  
src/main/java/org/distorted/library/mesh/MeshCubes.java
461 461
     return vertex;
462 462
     }
463 463

  
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

  
466
  private int repeatLast(int vertex, float[] attribs)
467
     {
468
     //android.util.Log.e("CUBES", "repeating last vertex!");
469

  
470
     if( vertex>0 )
471
       {
472
       remainingVert--;
473

  
474
       attribs[8*vertex  ] = attribs[8*vertex-8];
475
       attribs[8*vertex+1] = attribs[8*vertex-7];
476
       attribs[8*vertex+2] = attribs[8*vertex-6];
477
       attribs[8*vertex+3] = attribs[8*vertex-5];
478
       attribs[8*vertex+4] = attribs[8*vertex-4];
479
       attribs[8*vertex+5] = attribs[8*vertex-3];
480
       attribs[8*vertex+6] = attribs[8*vertex-2];
481
       attribs[8*vertex+7] = attribs[8*vertex-1];
482
         
483
       vertex++;     
484
       }
485
     
486
     return vertex;
487
     }
488
   
489 464
///////////////////////////////////////////////////////////////////////////////////////////////////
490 465

  
491 466
  private int buildSideGrid(int vertex, float[] attribs)
......
607 582
     float x = (float)col/mCols;
608 583
     float y = (float)row/mRows;
609 584

  
610
     attribs[8*vertex  ] = x-0.5f;
611
     attribs[8*vertex+1] = 0.5f-y;
612
     attribs[8*vertex+2] = vectZ;
613
     attribs[8*vertex+3] = mNormalX[index];
614
     attribs[8*vertex+4] = mNormalY[index];
615
     attribs[8*vertex+5] = mNormalZ[index];
616
     attribs[8*vertex+6] = x;
617
     attribs[8*vertex+7] = 1.0f-y;
585
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x-0.5f;
586
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f-y;
587
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = vectZ;
588

  
589
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = mNormalX[index];
590
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = mNormalY[index];
591
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = mNormalZ[index];
592

  
593
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
594
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
595
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
596

  
597
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
598
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y;
618 599

  
619 600
     return vertex+1;
620 601
     }
......
633 614
       {
634 615
       case NORTH: x = (float)(back ? (curr.col  ):(curr.col+1))/mCols;
635 616

  
636
                   attribs[8*vertex  ] = x - 0.5f;
637
                   attribs[8*vertex+1] = 0.5f - (float)curr.row/mRows;
638
                   attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
639
                   attribs[8*vertex+3] = side==NORTH ? 0.0f : (side==WEST?-R:R);
640
                   attribs[8*vertex+4] = 1.0f;
641
                   attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) );
642
                   attribs[8*vertex+6] = x;
643
                   attribs[8*vertex+7] = 1.0f-(float)(curr.row-slice)/mRows;
617
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x - 0.5f;
618
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f - (float)curr.row/mRows;
619
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.5f - (float)slice/mSlices;
620

  
621
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = side==NORTH ? 0.0f : (side==WEST?-R:R);
622
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 1.0f;
623
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
624

  
625
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
626
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
627
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
628

  
629
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
630
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-(float)(curr.row-slice)/mRows;
644 631
                   break;
645 632
       case SOUTH: x = (float)(back ? (curr.col+1):(curr.col  ))/mCols;
646 633

  
647
                   attribs[8*vertex  ] = x - 0.5f;
648
                   attribs[8*vertex+1] = 0.5f - (float)(curr.row+1)/mRows;
649
                   attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
650
                   attribs[8*vertex+3] = side==SOUTH ? 0.0f: (side==EAST?-R:R);
651
                   attribs[8*vertex+4] =-1.0f;
652
                   attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) );
653
                   attribs[8*vertex+6] = x;
654
                   attribs[8*vertex+7] = 1.0f - (float)(curr.row+1+slice)/mRows;
634
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x - 0.5f;
635
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f - (float)(curr.row+1)/mRows;
636
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.5f - (float)slice/mSlices;
637

  
638
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = side==SOUTH ? 0.0f: (side==EAST?-R:R);
639
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] =-1.0f;
640
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
641

  
642
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
643
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
644
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
645

  
646
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
647
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f - (float)(curr.row+1+slice)/mRows;
655 648
                   break;
656 649
       case WEST : y = (float)(back  ? (curr.row+1):(curr.row))/mRows;
657 650

  
658
                   attribs[8*vertex  ] = (float)curr.col/mCols -0.5f;
659
                   attribs[8*vertex+1] = 0.5f - y;
660
                   attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
661
                   attribs[8*vertex+3] =-1.0f;
662
                   attribs[8*vertex+4] = side==WEST ? 0.0f : (side==NORTH?-R:R);
663
                   attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) );
664
                   attribs[8*vertex+6] = (float)(curr.col-slice)/mCols;
665
                   attribs[8*vertex+7] = 1.0f - y;
651
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = (float)curr.col/mCols -0.5f;
652
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f - y;
653
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.5f - (float)slice/mSlices;
654

  
655
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] =-1.0f;
656
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = side==WEST ? 0.0f : (side==NORTH?-R:R);
657
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
658

  
659
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
660
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
661
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
662

  
663
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = (float)(curr.col-slice)/mCols;
664
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f - y;
666 665
                   break;
667 666
       case EAST : y = (float)(back  ? (curr.row):(curr.row+1))/mRows;
668 667

  
669
                   attribs[8*vertex  ] = (float)(curr.col+1)/mCols -0.5f;
670
                   attribs[8*vertex+1] = 0.5f - y;
671
                   attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
672
                   attribs[8*vertex+3] = 1.0f;
673
                   attribs[8*vertex+4] = side==EAST ? 0.0f : (side==SOUTH?-R:R);
674
                   attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) );
675
                   attribs[8*vertex+6] = (float)(curr.col+1+slice)/mCols;
676
                   attribs[8*vertex+7] = 1.0f - y;
668
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = (float)(curr.col+1)/mCols -0.5f;
669
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f - y;
670
                   attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.5f - (float)slice/mSlices;
671

  
672
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = 1.0f;
673
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = side==EAST ? 0.0f : (side==SOUTH?-R:R);
674
                   attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
675

  
676
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
677
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
678
                   attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
679

  
680
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = (float)(curr.col+1+slice)/mCols;
681
                   attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f - y;
677 682
                   break;
678 683
       }
679
     
680
     if(attribs[8*vertex+6]>1.0f) attribs[8*vertex+6] = 2.0f-attribs[8*vertex+6];
681
     if(attribs[8*vertex+6]<0.0f) attribs[8*vertex+6] =     -attribs[8*vertex+6];
682
     if(attribs[8*vertex+7]>1.0f) attribs[8*vertex+7] = 2.0f-attribs[8*vertex+7];
683
     if(attribs[8*vertex+7]<0.0f) attribs[8*vertex+7] =     -attribs[8*vertex+7];
684

  
685
     float tex0 =  attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ];
686
     float tex1 =  attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1];
687

  
688
     if(tex0>1.0f) attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = 2.0f-tex0;
689
     if(tex0<0.0f) attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] =     -tex0;
690
     if(tex1>1.0f) attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 2.0f-tex1;
691
     if(tex1<0.0f) attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] =     -tex1;
692
     }
693

  
694
///////////////////////////////////////////////////////////////////////////////////////////////////
695

  
696
   private int repeatLast(int vertex, float[] attribs)
697
     {
698
     //android.util.Log.e("CUBES", "repeating last vertex!");
699

  
700
     if( vertex>0 )
701
       {
702
       remainingVert--;
703

  
704
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB  ];
705
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+1];
706
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+2];
707

  
708
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB  ];
709
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+1];
710
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+2];
711

  
712
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB  ];
713
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+1];
714
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+2];
715

  
716
       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB  ];
717
       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB+1];
718

  
719

  
720
       vertex++;
721
       }
722

  
723
     return vertex;
684 724
     }
685 725

  
686 726
///////////////////////////////////////////////////////////////////////////////////////////////////
......
688 728
  private void build()
689 729
     {
690 730
     int vertSoFar=0;
691
     float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*numVertices];
731
     float[] attribs= new float[VERT_ATTRIBS*numVertices];
692 732

  
693 733
     vertSoFar = buildFrontBackGrid(true, vertSoFar,attribs);
694 734

  
src/main/java/org/distorted/library/mesh/MeshFlat.java
62 62
     {
63 63
     remainingVert--;
64 64

  
65
     attribs[8*vertex  ] = x-0.5f;
66
     attribs[8*vertex+1] = 0.5f-y;
67
     attribs[8*vertex+2] = 0;
65
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x-0.5f;
66
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f-y;
67
     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0;
68 68

  
69
     attribs[8*vertex+3] = 0.0f;
70
     attribs[8*vertex+4] = 0.0f;
71
     attribs[8*vertex+5] = 1.0f;
69
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = 0.0f;
70
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 0.0f;
71
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = 1.0f;
72 72

  
73
     attribs[8*vertex+6] = x;
74
     attribs[8*vertex+7] = 1.0f-y;
73
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = 1.0f;  //
74
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f;  // TODO
75
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f;  //
76

  
77
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
78
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y;
75 79

  
76 80
     return vertex+1;
77 81
     }
......
80 84

  
81 85
  private int repeatLast(int vertex, float[] attribs)
82 86
     {
83
     remainingVert--;
84

  
85 87
     //android.util.Log.e("MeshFlat", "repeating last vertex!");
86 88

  
87 89
     if( vertex>0 )
88 90
       {
89
       attribs[8*vertex  ] = attribs[8*vertex-8];
90
       attribs[8*vertex+1] = attribs[8*vertex-7];
91
       attribs[8*vertex+2] = attribs[8*vertex-6];
92
       attribs[8*vertex+3] = attribs[8*vertex-5];
93
       attribs[8*vertex+4] = attribs[8*vertex-4];
94
       attribs[8*vertex+5] = attribs[8*vertex-3];
95
       attribs[8*vertex+6] = attribs[8*vertex-2];
96
       attribs[8*vertex+7] = attribs[8*vertex-1];
91
       remainingVert--;
92

  
93
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB  ];
94
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+1];
95
       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+2];
96

  
97
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB  ];
98
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+1];
99
       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+2];
100

  
101
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB  ];
102
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+1];
103
       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+2];
104

  
105
       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB  ];
106
       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB+1];
97 107

  
98 108
       vertex++;
99 109
       }
......
176 186
    super(0.0f);
177 187
    computeNumberOfVertices(cols,rows);
178 188

  
179
    float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*numVertices];
189
    float[] attribs= new float[VERT_ATTRIBS*numVertices];
180 190

  
181 191
    buildGrid(attribs);
182 192

  
183 193
    //android.util.Log.e("MeshFlat", "dataLen="+numVertices);
184
    //android.util.Log.d("MeshFlat", "attribs: "+debug(attribs,8) );
194
    //android.util.Log.d("MeshFlat", "attribs: "+debug(attribs,VERT_ATTRIBS) );
185 195

  
186 196
    if( remainingVert!=0 )
187 197
      android.util.Log.d("MeshFlat", "remainingVert " +remainingVert );
src/main/res/raw/main_vertex_shader.glsl
22 22

  
23 23
in vec3 a_Position;                  // Per-vertex position.
24 24
in vec3 a_Normal;                    // Per-vertex normal vector.
25
in vec3 a_Inflate;                   // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh.
26
                                     // If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no.
25 27
in vec2 a_TexCoordinate;             // Per-vertex texture coordinate.
28

  
26 29
out vec3 v_Position;                 //
27 30
out vec3 v_endPosition;              // for Transform Feedback only
28 31
out vec3 v_Normal;                   //

Also available in: Unified diff