Revision bc6adbb5
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/library/mesh/MeshMultigon.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 49 |
|
50 |
private static int isUp(float[][] vertices, int polygon, int edge) |
|
50 |
private static int isUp(float[][][] vertices, int polygon, int edge)
|
|
51 | 51 |
{ |
52 |
float[] p= vertices[polygon]; |
|
53 |
int lenP = p.length/2;
|
|
52 |
float[][] p= vertices[polygon];
|
|
53 |
int lenP = p.length; |
|
54 | 54 |
int len = vertices.length; |
55 | 55 |
int next = (edge==lenP-1 ? 0 : edge+1); |
56 | 56 |
|
57 |
float v1x = p[2*edge ];
|
|
58 |
float v1y = p[2*edge+1];
|
|
59 |
float v2x = p[2*next ];
|
|
60 |
float v2y = p[2*next+1];
|
|
57 |
float v1x = p[edge][0];
|
|
58 |
float v1y = p[edge][1];
|
|
59 |
float v2x = p[next][0];
|
|
60 |
float v2y = p[next][1];
|
|
61 | 61 |
|
62 | 62 |
for(int i=0; i<len; i++) |
63 | 63 |
if( i!=polygon ) |
64 | 64 |
{ |
65 |
int num = vertices[i].length/2;
|
|
65 |
int num = vertices[i].length; |
|
66 | 66 |
|
67 | 67 |
for(int j=0; j<num; j++) |
68 | 68 |
{ |
69 | 69 |
int n = (j==num-1 ? 0 : j+1); |
70 |
float[] v = vertices[i]; |
|
71 |
float x1 = v[2*j ];
|
|
72 |
float y1 = v[2*j+1];
|
|
73 |
float x2 = v[2*n ];
|
|
74 |
float y2 = v[2*n+1];
|
|
70 |
float[][] v = vertices[i];
|
|
71 |
float x1 = v[j][0];
|
|
72 |
float y1 = v[j][1];
|
|
73 |
float x2 = v[n][0];
|
|
74 |
float y2 = v[n][1];
|
|
75 | 75 |
|
76 | 76 |
if( isSame(v2x-x1,v2y-y1) && isSame(v1x-x2,v1y-y2) ) return i; |
77 | 77 |
} |
... | ... | |
82 | 82 |
|
83 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
84 | 84 |
|
85 |
private static float[] detectFirstOuterVertex(float[][] vertices) |
|
85 |
private static float[] detectFirstOuterVertex(float[][][] vertices)
|
|
86 | 86 |
{ |
87 | 87 |
float X = -Float.MAX_VALUE; |
88 | 88 |
int I=0,J=0, len = vertices.length; |
89 | 89 |
|
90 | 90 |
for(int i=0; i<len; i++ ) |
91 | 91 |
{ |
92 |
float[] v = vertices[i]; |
|
93 |
int num = v.length/2;
|
|
92 |
float[][] v = vertices[i];
|
|
93 |
int num = v.length; |
|
94 | 94 |
|
95 | 95 |
for(int j=0; j<num; j++) |
96 |
if(v[2*j]>X)
|
|
96 |
if( v[j][0]>X )
|
|
97 | 97 |
{ |
98 |
X = v[2*j];
|
|
98 |
X = v[j][0];
|
|
99 | 99 |
I = i; |
100 | 100 |
J = j; |
101 | 101 |
} |
102 | 102 |
} |
103 | 103 |
|
104 |
float[] v = vertices[I]; |
|
105 |
return new float[] {v[2*J],v[2*J+1]};
|
|
104 |
float[] v = vertices[I][J];
|
|
105 |
return new float[] {v[0],v[1]};
|
|
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
115 | 115 |
|
116 | 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
117 | 117 |
|
118 |
private static float[] detectNextOuterVertex(float[][] vertices, float[] curr, float[] vect, int[][] edgesUp) |
|
118 |
private static float[] detectNextOuterVertex(float[][][] vertices, float[] curr, float[] vect, int[][] edgesUp)
|
|
119 | 119 |
{ |
120 | 120 |
double maxAngle = 0; |
121 | 121 |
float x=0, y=0; |
... | ... | |
123 | 123 |
|
124 | 124 |
for( int c=0; c<numC; c++ ) |
125 | 125 |
{ |
126 |
float[] vert = vertices[c]; |
|
127 |
int numV = vert.length/2;
|
|
126 |
float[][] vert = vertices[c];
|
|
127 |
int numV = vert.length; |
|
128 | 128 |
|
129 | 129 |
for( int v=0; v<numV; v++) |
130 | 130 |
{ |
131 |
float xc = vert[2*v];
|
|
132 |
float yc = vert[2*v+1];
|
|
131 |
float xc = vert[v][0];
|
|
132 |
float yc = vert[v][1];
|
|
133 | 133 |
|
134 | 134 |
if( edgesUp[c][v]<0 && isSame(xc-curr[0],yc-curr[1]) ) |
135 | 135 |
{ |
136 | 136 |
int n = (v==numV-1 ? 0 : v+1); |
137 |
float xn = vert[2*n];
|
|
138 |
float yn = vert[2*n+1];
|
|
137 |
float xn = vert[n][0];
|
|
138 |
float yn = vert[n][1];
|
|
139 | 139 |
|
140 | 140 |
double angle = computeAngle(vect[0], vect[1], xn-xc, yn-yc); |
141 | 141 |
|
... | ... | |
156 | 156 |
|
157 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
158 | 158 |
|
159 |
private static int getNextIndex(float[][] vertices, int[][] unclaimedEdges, int currIndex, int numHoleVerts) |
|
159 |
private static int getNextIndex(float[][][] vertices, int[][] unclaimedEdges, int currIndex, int numHoleVerts)
|
|
160 | 160 |
{ |
161 | 161 |
int[] currEdge = unclaimedEdges[currIndex]; |
162 | 162 |
int currP = currEdge[0]; |
163 | 163 |
int currE = currEdge[1]; |
164 |
float[] polygon = vertices[currP]; |
|
165 |
int numV = polygon.length/2;
|
|
164 |
float[][] polygon = vertices[currP];
|
|
165 |
int numV = polygon.length; |
|
166 | 166 |
int nextE= currE<numV-1 ? currE+1 : 0; |
167 | 167 |
|
168 |
float x = polygon[2*nextE];
|
|
169 |
float y = polygon[2*nextE+1];
|
|
168 |
float x = polygon[nextE][0];
|
|
169 |
float y = polygon[nextE][1];
|
|
170 | 170 |
|
171 | 171 |
for(int e=0; e<numHoleVerts; e++) |
172 | 172 |
{ |
... | ... | |
177 | 177 |
int po = edge[0]; |
178 | 178 |
int ed = edge[1]; |
179 | 179 |
|
180 |
float cx = vertices[po][2*ed];
|
|
181 |
float cy = vertices[po][2*ed+1];
|
|
180 |
float cx = vertices[po][ed][0];
|
|
181 |
float cy = vertices[po][ed][1];
|
|
182 | 182 |
|
183 | 183 |
if( isSame(cx-x,cy-y) ) |
184 | 184 |
{ |
... | ... | |
193 | 193 |
|
194 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
195 | 195 |
|
196 |
private static int generateHole(float[][] vertices, int[][] unclaimedEdges, float[][] output, int[][] edgesUp, int holeNumber, int numHoleVerts) |
|
196 |
private static int generateHole(float[][][] vertices, int[][] unclaimedEdges, float[][] output, int[][] edgesUp, int holeNumber, int numHoleVerts)
|
|
197 | 197 |
{ |
198 | 198 |
int firstIndex=-1; |
199 | 199 |
|
... | ... | |
217 | 217 |
edgesUp[p][v] = -holeNumber-2; |
218 | 218 |
currIndex = nextIndex; |
219 | 219 |
int[] e = unclaimedEdges[nextIndex]; |
220 |
float[] polygon = vertices[e[0]];
|
|
221 |
output[numAdded][0] = polygon[2*e[1]];
|
|
222 |
output[numAdded][1] = polygon[2*e[1]+1];
|
|
220 |
float[] ve = vertices[e[0]][e[1]];
|
|
221 |
output[numAdded][0] = ve[0];
|
|
222 |
output[numAdded][1] = ve[1];
|
|
223 | 223 |
numAdded++; |
224 | 224 |
} |
225 | 225 |
|
... | ... | |
238 | 238 |
|
239 | 239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
240 | 240 |
|
241 |
private static float[][][] computeHoles(float[][] vertices, int[][] edgesUp, float[][] outer, int numHoleVerts) |
|
241 |
private static float[][][] computeHoles(float[][][] vertices, int[][] edgesUp, float[][] outer, int numHoleVerts)
|
|
242 | 242 |
{ |
243 | 243 |
int[][] unclaimedEdges = new int[numHoleVerts][]; |
244 | 244 |
int index = 0; |
... | ... | |
246 | 246 |
|
247 | 247 |
for(int p=0; p<numPoly; p++) |
248 | 248 |
{ |
249 |
float[] ve = vertices[p]; |
|
250 |
int numEdges = ve.length/2;
|
|
249 |
float[][] ve = vertices[p];
|
|
250 |
int numEdges = ve.length; |
|
251 | 251 |
|
252 | 252 |
for(int e=0; e<numEdges; e++) |
253 | 253 |
if( edgesUp[p][e]<0 ) |
254 | 254 |
{ |
255 |
float x1 = ve[2*e];
|
|
256 |
float y1 = ve[2*e+1];
|
|
255 |
float x1 = ve[e][0];
|
|
256 |
float y1 = ve[e][1];
|
|
257 | 257 |
|
258 | 258 |
int n = e<numEdges-1 ? e+1 : 0; |
259 |
float x2 = ve[2*n];
|
|
260 |
float y2 = ve[2*n+1];
|
|
259 |
float x2 = ve[n][0];
|
|
260 |
float y2 = ve[n][1];
|
|
261 | 261 |
|
262 | 262 |
// yes, we need to check both ends of the edge - otherwise the |
263 | 263 |
// following 3x3 situation (x - wall, o - hole ) does not work: |
... | ... | |
315 | 315 |
|
316 | 316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
317 | 317 |
|
318 |
private float[] produceNormalVector(float[][] verts, float xs, float ys)
|
|
318 |
private float[] produceNormalVector(float[][] outerAndHole, float xs, float ys)
|
|
319 | 319 |
{ |
320 |
int vCurr,len = verts.length;
|
|
320 |
int vCurr,len = outerAndHole.length;
|
|
321 | 321 |
|
322 | 322 |
for(vCurr=0; vCurr<len; vCurr++) |
323 | 323 |
{ |
324 |
float[] vs = verts[vCurr];
|
|
324 |
float[] vs = outerAndHole[vCurr];
|
|
325 | 325 |
if( isSame(vs[0]-xs,vs[1]-ys) ) break; |
326 | 326 |
} |
327 | 327 |
|
... | ... | |
329 | 329 |
|
330 | 330 |
int vPrev = vCurr==0 ? len-1 : vCurr-1; |
331 | 331 |
int vNext = vCurr>=len-1 ? 0 : vCurr+1; |
332 |
float[] vp = verts[vPrev];
|
|
333 |
float[] vn = verts[vNext];
|
|
332 |
float[] vp = outerAndHole[vPrev];
|
|
333 |
float[] vn = outerAndHole[vNext];
|
|
334 | 334 |
|
335 | 335 |
return new float[] { vp[1]-vn[1], vn[0]-vp[0] }; |
336 | 336 |
} |
337 | 337 |
|
338 | 338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
339 | 339 |
|
340 |
private float[] produceNormalVector(float[][] verts, float xs, float ys, float xe, float ye)
|
|
340 |
private float[] produceNormalVector(float[][] outerAndHole, float xs, float ys, float xe, float ye)
|
|
341 | 341 |
{ |
342 |
int vCurr,len = verts.length;
|
|
342 |
int vCurr,len = outerAndHole.length;
|
|
343 | 343 |
|
344 | 344 |
for(vCurr=0; vCurr<len; vCurr++) |
345 | 345 |
{ |
346 |
float[] vs = verts[vCurr];
|
|
346 |
float[] vs = outerAndHole[vCurr];
|
|
347 | 347 |
|
348 | 348 |
if( isSame(vs[0]-xs,vs[1]-ys) ) |
349 | 349 |
{ |
350 | 350 |
int vNext = vCurr==len-1 ? 0 : vCurr+1; |
351 |
float[] ve = verts[vNext];
|
|
351 |
float[] ve = outerAndHole[vNext];
|
|
352 | 352 |
if( isSame(ve[0]-xe,ve[1]-ye) ) break; |
353 | 353 |
} |
354 | 354 |
} |
355 | 355 |
|
356 | 356 |
int vPrev = vCurr==0 ? len-1 : vCurr-1; |
357 | 357 |
int vNext = vCurr>=len-1 ? 0 : vCurr+1; |
358 |
float[] vp = verts[vPrev];
|
|
359 |
float[] vn = verts[vNext];
|
|
358 |
float[] vp = outerAndHole[vPrev];
|
|
359 |
float[] vn = outerAndHole[vNext];
|
|
360 | 360 |
|
361 | 361 |
return new float[] { vp[1]-vn[1], vn[0]-vp[0] }; |
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
365 | 365 |
|
366 |
private void computeEdgeVectors(float[][] vertices, int[][] edgesUp) |
|
366 |
private void computeEdgeVectors(float[][][] vertices, int[][] edgesUp)
|
|
367 | 367 |
{ |
368 |
int numComponents = vertices.length;
|
|
369 |
mEdgeVectors = new float[numComponents][][];
|
|
368 |
int numPoly = vertices.length;
|
|
369 |
mEdgeVectors = new float[numPoly][][];
|
|
370 | 370 |
|
371 |
for(int c=0; c<numComponents; c++)
|
|
371 |
for(int c=0; c<numPoly; c++)
|
|
372 | 372 |
{ |
373 |
float[] polygon = vertices[c]; |
|
374 |
int numV = polygon.length/2;
|
|
373 |
float[][] polygon = vertices[c];
|
|
374 |
int numV = polygon.length; |
|
375 | 375 |
mEdgeVectors[c] = new float[numV][]; |
376 | 376 |
|
377 | 377 |
for(int v=0; v<numV; v++) |
378 | 378 |
{ |
379 | 379 |
int edgeUp = edgesUp[c][v]; |
380 |
float xs = polygon[2*v];
|
|
381 |
float ys = polygon[2*v+1];
|
|
380 |
float xs = polygon[v][0];
|
|
381 |
float ys = polygon[v][1];
|
|
382 | 382 |
int n = v==numV-1 ? 0 : v+1; |
383 |
float xe = polygon[2*n];
|
|
384 |
float ye = polygon[2*n+1];
|
|
383 |
float xe = polygon[n][0];
|
|
384 |
float ye = polygon[n][1];
|
|
385 | 385 |
|
386 | 386 |
if( edgeUp<0 ) // external edge, normal vector |
387 | 387 |
{ |
... | ... | |
432 | 432 |
|
433 | 433 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
434 | 434 |
|
435 |
private boolean[][] computeVertsUp(float[][] vertices) |
|
435 |
private boolean[][] computeVertsUp(float[][][] vertices)
|
|
436 | 436 |
{ |
437 |
int num = vertices.length; |
|
438 |
boolean[][] up = new boolean[num][]; |
|
437 |
int numPoly = vertices.length;
|
|
438 |
boolean[][] up = new boolean[numPoly][];
|
|
439 | 439 |
|
440 |
for(int i=0; i<num; i++) |
|
440 |
for(int i=0; i<numPoly; i++)
|
|
441 | 441 |
{ |
442 |
float[] v = vertices[i]; |
|
443 |
int len = v.length/2;
|
|
442 |
float[][] v = vertices[i];
|
|
443 |
int len = v.length; |
|
444 | 444 |
up[i] = new boolean[len]; |
445 | 445 |
|
446 | 446 |
for(int j=0; j<len; j++) |
... | ... | |
455 | 455 |
|
456 | 456 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
457 | 457 |
|
458 |
private float[] computeCenter(float[] vertices) |
|
458 |
private float[] computeCenter(float[][] vertices)
|
|
459 | 459 |
{ |
460 |
int num = vertices.length/2;
|
|
460 |
int num = vertices.length; |
|
461 | 461 |
float[] ret = new float[2]; |
462 | 462 |
|
463 |
for(int i=0; i<num; i++)
|
|
463 |
for(float[] vertex : vertices)
|
|
464 | 464 |
{ |
465 |
ret[0] += vertices[2*i];
|
|
466 |
ret[1] += vertices[2*i+1];
|
|
465 |
ret[0] += vertex[0];
|
|
466 |
ret[1] += vertex[1];
|
|
467 | 467 |
} |
468 | 468 |
|
469 | 469 |
ret[0] /= num; |
... | ... | |
474 | 474 |
|
475 | 475 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
476 | 476 |
|
477 |
private float[][] computeCenters(float[][] vertices) |
|
477 |
private float[][] computeCenters(float[][][] vertices)
|
|
478 | 478 |
{ |
479 | 479 |
int num = vertices.length; |
480 | 480 |
float[][] ret = new float[num][]; |
... | ... | |
485 | 485 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
486 | 486 |
|
487 | 487 |
private int computeMode(float[] vL, float[] vR, float[] vT, float[] normL, float[] normR, |
488 |
int[][] edgesUp, boolean[][] vertsUp, float[][] vertices, float[][] centers, int component, int curr) |
|
488 |
int[][] edgesUp, boolean[][] vertsUp, float[][][] vertices, float[][] centers, int component, int curr)
|
|
489 | 489 |
{ |
490 |
float[] v = vertices[component]; |
|
490 |
float[][] v = vertices[component];
|
|
491 | 491 |
int[] edges = edgesUp[component]; |
492 |
int len = v.length /2;
|
|
493 |
int next= curr==len-1 ? 0 : curr+1;
|
|
494 |
int prev= curr==0 ? len-1 : curr-1;
|
|
492 |
int numPoly = v.length;
|
|
493 |
int next= curr==numPoly-1 ? 0 : curr+1;
|
|
494 |
int prev= curr==0 ? numPoly-1 : curr-1;
|
|
495 | 495 |
int eupc = edges[curr]; |
496 | 496 |
|
497 | 497 |
if( eupc<0 ) |
498 | 498 |
{ |
499 |
vL[0] = v[2*curr];
|
|
500 |
vL[1] = v[2*curr+1];
|
|
501 |
vR[0] = v[2*next];
|
|
502 |
vR[1] = v[2*next+1];
|
|
499 |
vL[0] = v[curr][0];
|
|
500 |
vL[1] = v[curr][1];
|
|
501 |
vR[0] = v[next][0];
|
|
502 |
vR[1] = v[next][1];
|
|
503 | 503 |
vT[0] = centers[component][0]; |
504 | 504 |
vT[1] = centers[component][1]; |
505 | 505 |
|
... | ... | |
520 | 520 |
|
521 | 521 |
if( eupp<0 ) |
522 | 522 |
{ |
523 |
normL[0]=vL[0]-vT[0]; |
|
524 |
normL[1]=vL[1]-vT[1]; |
|
523 |
normL[0]= vL[0]-vT[0];
|
|
524 |
normL[1]= vL[1]-vT[1];
|
|
525 | 525 |
} |
526 | 526 |
else |
527 | 527 |
{ |
528 |
normL[0]= v[2*curr ] - v[2*prev ];
|
|
529 |
normL[1]= v[2*curr+1] - v[2*prev+1];
|
|
528 |
normL[0]= v[curr][0] - v[prev][0];
|
|
529 |
normL[1]= v[curr][1] - v[prev][1];
|
|
530 | 530 |
} |
531 | 531 |
|
532 | 532 |
if( eupn<0 ) |
533 | 533 |
{ |
534 |
normR[0]=vR[0]-vT[0]; |
|
535 |
normR[1]=vR[1]-vT[1]; |
|
534 |
normR[0]= vR[0]-vT[0];
|
|
535 |
normR[1]= vR[1]-vT[1];
|
|
536 | 536 |
} |
537 | 537 |
else |
538 | 538 |
{ |
539 |
int nnxt= next==len-1 ? 0 : next+1;
|
|
540 |
normR[0]= v[2*next ] - v[2*nnxt ];
|
|
541 |
normR[1]= v[2*next+1] - v[2*nnxt+1];
|
|
539 |
int nnxt= next==numPoly-1 ? 0 : next+1;
|
|
540 |
normR[0]= v[next][0] - v[nnxt][0];
|
|
541 |
normR[1]= v[next][1] - v[nnxt][1];
|
|
542 | 542 |
} |
543 | 543 |
} |
544 | 544 |
|
... | ... | |
550 | 550 |
vL[1] = centers[eupc][1]; |
551 | 551 |
vR[0] = centers[component][0]; |
552 | 552 |
vR[1] = centers[component][1]; |
553 |
vT[0] = v[2*curr];
|
|
554 |
vT[1] = v[2*curr+1];
|
|
553 |
vT[0] = v[curr][0];
|
|
554 |
vT[1] = v[curr][1];
|
|
555 | 555 |
|
556 | 556 |
boolean vup = vertsUp[component][curr]; |
557 | 557 |
|
... | ... | |
577 | 577 |
} |
578 | 578 |
else |
579 | 579 |
{ |
580 |
float dx = v[2*next ]-v[2*curr ];
|
|
581 |
float dy = v[2*next+1]-v[2*curr+1];
|
|
580 |
float dx = v[next][0]-v[curr][0];
|
|
581 |
float dy = v[next][1]-v[curr][1];
|
|
582 | 582 |
normL[0]= dx; |
583 | 583 |
normL[1]= dy; |
584 | 584 |
normR[0]= dx; |
... | ... | |
594 | 594 |
// PUBLIC API |
595 | 595 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
596 | 596 |
|
597 |
public static int[][] computeEdgesUp(float[][] vertices) |
|
597 |
public static int[][] computeEdgesUp(float[][][] vertices)
|
|
598 | 598 |
{ |
599 | 599 |
int numPoly = vertices.length; |
600 | 600 |
int[][] up = new int[numPoly][]; |
601 | 601 |
|
602 | 602 |
for(int p=0; p<numPoly; p++) |
603 | 603 |
{ |
604 |
int numEdges = vertices[p].length/2;
|
|
604 |
int numEdges = vertices[p].length; |
|
605 | 605 |
up[p] = new int[numEdges]; |
606 |
|
|
607 |
for(int e=0; e<numEdges; e++) |
|
608 |
up[p][e] = isUp(vertices,p,e); |
|
606 |
for(int e=0; e<numEdges; e++) up[p][e] = isUp(vertices,p,e); |
|
609 | 607 |
} |
610 | 608 |
|
611 | 609 |
return up; |
... | ... | |
613 | 611 |
|
614 | 612 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
615 | 613 |
|
616 |
public static float[][][] computeOuterAndHoleVertices(float[][] vertices, int[][] edgesUp) |
|
614 |
public static float[][][] computeOuterAndHoleVertices(float[][][] vertices, int[][] edgesUp)
|
|
617 | 615 |
{ |
618 | 616 |
ArrayList<float[]> tmp = new ArrayList<>(); |
619 | 617 |
|
... | ... | |
653 | 651 |
* If two such polygons share an edge (or several edges) then the edge in both of them is |
654 | 652 |
* marked 'up'. |
655 | 653 |
* |
656 |
* @param vertices an array of arrays, each specifying vertices of a single polygon.
|
|
654 |
* @param vertices an array float[][]s, each specifying vertices of a single polygon.
|
|
657 | 655 |
* @param band see MeshPolygon. Shared among all polygons. |
658 | 656 |
* @param exBands see MeshPolygon. Shared among all polygons. |
659 | 657 |
* @param exVertices see MeshPolygon. Shared among all polygons. |
660 | 658 |
*/ |
661 |
public MeshMultigon(float[][] vertices, float[] band, int exBands, int exVertices) |
|
659 |
public MeshMultigon(float[][][] vertices, float[] band, int exBands, int exVertices)
|
|
662 | 660 |
{ |
663 | 661 |
super(); |
664 | 662 |
|
665 | 663 |
int numTriangles=0; |
666 |
for(float[] vertex : vertices) numTriangles+=vertex.length/2;
|
|
664 |
for(float[][] vertex : vertices) numTriangles+=vertex.length;
|
|
667 | 665 |
MeshBandedTriangle[] triangles = new MeshBandedTriangle[numTriangles]; |
668 | 666 |
|
669 | 667 |
int[][] edgesUp = computeEdgesUp(vertices); |
... | ... | |
684 | 682 |
|
685 | 683 |
for(int i=0; i<len; i++) |
686 | 684 |
{ |
687 |
int num=vertices[i].length/2;
|
|
685 |
int num=vertices[i].length; |
|
688 | 686 |
|
689 | 687 |
for(int j=0; j<num; j++) |
690 | 688 |
{ |
Also available in: Unified diff
also change the fullVertices to the same format