Project

General

Profile

« Previous | Next » 

Revision 1ce7e2f6

Added by Leszek Koltunski 10 months ago

change the way the coordinates of stickers are kept from float[2*N] to float[N][2]

View differences:

src/main/java/org/distorted/library/mesh/MeshPolygon.java
34 34
  {
35 35
  private static final int NUM_CACHE = 20;
36 36

  
37
  private float[] mPolygonVertices;
37
  private float[][] mPolygonVertices;
38 38
  private int mNumPolygonVertices;
39 39
  private float[] mPolygonBands;
40 40
  private int mNumPolygonBands;
......
184 184
    {
185 185
    remainingVert--;
186 186

  
187
    float Xfirst= mPolygonVertices[2*polyVertex  ];
188
    float Yfirst= mPolygonVertices[2*polyVertex+1];
189
    float Xlast = mPolygonVertices[2*polyEndVer  ];
190
    float Ylast = mPolygonVertices[2*polyEndVer+1];
187
    float Xfirst= mPolygonVertices[polyVertex][0];
188
    float Yfirst= mPolygonVertices[polyVertex][1];
189
    float Xlast = mPolygonVertices[polyEndVer][0];
190
    float Ylast = mPolygonVertices[polyEndVer][1];
191 191

  
192 192
    float xEdge = Xfirst + quot*(Xlast-Xfirst);
193 193
    float yEdge = Yfirst + quot*(Ylast-Yfirst);
......
275 275
 * Create a polygon of any shape and varying elevations from the edges towards the center.
276 276
 * Optionally make it more dense at the vertices.
277 277
 *
278
 * @param verticesXY 2N floats - packed description of polygon vertices. N pairs (x,y).
278
 * @param verticesXY [N][2] floats - polygon vertices. N pairs (x,y).
279 279
 *                   Vertices HAVE TO be specified in a COUNTERCLOCKWISE order (starting from any).
280 280
 * @param bands      2K floats; K pairs of two floats each describing a single band.
281 281
 *                   From (1.0,Z[0]) (outer edge, its Z elevation) to (0.0,Z[K]) (the center,
......
290 290
 *                   all bands go to.
291 291
 * @param centerY    Y coordinate of the center.
292 292
 */
293
  public MeshPolygon(float[] verticesXY, float[] bands, int exBand, int exVertices, float centerX, float centerY)
293
  public MeshPolygon(float[][] verticesXY, float[] bands, int exBand, int exVertices, float centerX, float centerY)
294 294
    {
295 295
    super();
296 296

  
297 297
    mPolygonVertices   = verticesXY;
298 298
    mPolygonBands      = bands;
299
    mNumPolygonVertices= mPolygonVertices.length /2;
299
    mNumPolygonVertices= mPolygonVertices.length;
300 300
    mNumPolygonBands   = mPolygonBands.length /2;
301 301
    extraBand          = exBand;
302 302
    extraVertices      = exVertices;
......
305 305
      {
306 306
      for(int v=0; v<mNumPolygonVertices; v++)
307 307
        {
308
        mPolygonVertices[2*v  ] -= centerX;
309
        mPolygonVertices[2*v+1] -= centerY;
308
        mPolygonVertices[v][0] -= centerX;
309
        mPolygonVertices[v][1] -= centerY;
310 310
        }
311 311
      }
312 312

  
......
337 337

  
338 338
///////////////////////////////////////////////////////////////////////////////////////////////////
339 339

  
340
  public MeshPolygon(float[] verticesXY, float[] bands, int exIndex, int exVertices)
340
  public MeshPolygon(float[][] verticesXY, float[] bands, int exIndex, int exVertices)
341 341
    {
342 342
    this(verticesXY,bands,exIndex,exVertices,0.0f,0.0f);
343 343
    }
......
347 347
 * Create a polygon of any shape and varying elevations from the edges towards the center.
348 348
 * Equivalent of the previous with exIndex=0 or exVertices=0.
349 349
 */
350
  public MeshPolygon(float[] verticesXY, float[] bands)
350
  public MeshPolygon(float[][] verticesXY, float[] bands)
351 351
    {
352 352
    this(verticesXY,bands,0,0,0.0f,0.0f);
353 353
    }

Also available in: Unified diff