Project

General

Profile

« Previous | Next » 

Revision da681e7e

Added by Leszek Koltunski over 5 years ago

Some simplifications in Meshes. Hide stuff inside MeshBase.

View differences:

src/main/java/org/distorted/library/mesh/MeshFlat.java
19 19

  
20 20
package org.distorted.library.mesh;
21 21

  
22
import java.nio.ByteBuffer;
23
import java.nio.ByteOrder;
24

  
25 22
///////////////////////////////////////////////////////////////////////////////////////////////////
26 23
/**
27 24
 * Create a flat, rectangular grid.
......
33 30
  {
34 31
  private int mCols, mRows;
35 32
  private int remainingVert;
33
  private int numVertices;
36 34

  
37 35
///////////////////////////////////////////////////////////////////////////////////////////////////
38 36
// Create a flat, full grid.
......
44 42

  
45 43
     if( cols==1 && rows==1 )
46 44
       {
47
       mNumVertices = 4;
45
       numVertices = 4;
48 46
       }
49 47
     else
50 48
       {
51
       mNumVertices = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
49
       numVertices = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
52 50
                     (mCols>=2 && mRows>=2 ? 2*mRows-2 : 1);
53 51
       }
54 52

  
55 53
     //android.util.Log.e("MeshFlat","vertices="+numVertices+" rows="+mRows+" cols="+mCols);
56 54

  
57
     remainingVert = mNumVertices;
55
     remainingVert = numVertices;
58 56
     }
59 57

  
60 58

  
......
178 176
    super(0.0f);
179 177
    computeNumberOfVertices(cols,rows);
180 178

  
181
    float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*mNumVertices];
179
    float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*numVertices];
182 180

  
183 181
    buildGrid(attribs);
184 182

  
......
188 186
    if( remainingVert!=0 )
189 187
      android.util.Log.d("MeshFlat", "remainingVert " +remainingVert );
190 188

  
191
    mVertAttribs = ByteBuffer.allocateDirect(mNumVertices*VERTSIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
192
    mVertAttribs.put(attribs).position(0);
193

  
194
    setData(mNumVertices, mVertAttribs);
189
    setData(numVertices, attribs);
195 190
    }
196 191
 }

Also available in: Unified diff