Revision b3c9061a
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/helpers/FactoryCubit.java | ||
---|---|---|
2354 | 2354 |
|
2355 | 2355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
2356 | 2356 |
|
2357 |
private void prepareAndRoundCorners(MeshBase mesh, double[][] vertices, int[][] vertIndexes, |
|
2358 |
float[][] corners, int[] cornerIndexes ) |
|
2357 |
private void prepareAndRoundCorners(MeshBase mesh, double[][] vertices, |
|
2358 |
float[][] corners, int[] cornerIndexes, |
|
2359 |
float[][] centers, int[] centerIndexes ) |
|
2359 | 2360 |
{ |
2360 |
int numNeig, lenFV; |
|
2361 | 2361 |
int lenV = vertices.length; |
2362 |
int[] verts = new int[2*(lenV-1)]; |
|
2363 | 2362 |
Static3D[] staticVert = new Static3D[1]; |
2364 | 2363 |
Static3D center = new Static3D(0,0,0); |
2365 |
double cx, cy, cz; |
|
2366 |
double[] singleV; |
|
2367 | 2364 |
|
2368 | 2365 |
for(int v=0; v<lenV; v++) |
2369 | 2366 |
{ |
2370 |
// prepare verts[] |
|
2371 |
numNeig = 0; |
|
2372 |
|
|
2373 |
for (int[] vertIndex : vertIndexes) |
|
2374 |
{ |
|
2375 |
lenFV = vertIndex.length; |
|
2376 |
|
|
2377 |
for (int fv = 0; fv < lenFV; fv++) |
|
2378 |
if (vertIndex[fv] == v) |
|
2379 |
{ |
|
2380 |
int prev = fv > 0 ? fv - 1 : lenFV - 1; |
|
2381 |
int next = fv < lenFV - 1 ? fv + 1 : 0; |
|
2382 |
|
|
2383 |
verts[numNeig++] = vertIndex[prev]; |
|
2384 |
verts[numNeig++] = vertIndex[next]; |
|
2385 |
} |
|
2386 |
} |
|
2387 |
|
|
2388 |
cx=cy=cz=0.0f; |
|
2389 |
|
|
2390 |
// from verts[] prepare center |
|
2391 |
for(int n=0; n<numNeig; n++) |
|
2392 |
{ |
|
2393 |
singleV = vertices[verts[n]]; |
|
2394 |
|
|
2395 |
cx += singleV[0]; |
|
2396 |
cy += singleV[1]; |
|
2397 |
cz += singleV[2]; |
|
2398 |
} |
|
2399 |
center.set( (float)(cx/numNeig - vertices[v][0]), |
|
2400 |
(float)(cy/numNeig - vertices[v][1]), |
|
2401 |
(float)(cz/numNeig - vertices[v][2])); |
|
2402 |
|
|
2403 |
android.util.Log.e("D", "vertex: "+v+" CENTER: "+center.get0()+" "+center.get1()+" "+center.get2()); |
|
2404 |
|
|
2405 |
// round Corners |
|
2406 | 2367 |
staticVert[0] = new Static3D( (float)vertices[v][0], (float)vertices[v][1], (float)vertices[v][2]); |
2407 | 2368 |
|
2369 |
int cent = centerIndexes[v]; |
|
2370 |
center.set( centers[cent][0], centers[cent][1], centers[cent][2]); |
|
2371 |
|
|
2408 | 2372 |
int corn = cornerIndexes[v]; |
2409 | 2373 |
float strength = corners[corn][0]; |
2410 | 2374 |
float radius = corners[corn][1]; |
... | ... | |
2536 | 2500 |
public MeshBase createRoundedSolid(final double[][] vertices, final int[][] vertIndexes, |
2537 | 2501 |
final float[][] bands , final int[] bandIndexes, |
2538 | 2502 |
final float[][] corners , final int[] cornerIndexes, |
2503 |
final float[][] centers , final int[] centerIndexes, |
|
2539 | 2504 |
final int numComponents ) |
2540 | 2505 |
{ |
2541 | 2506 |
int numFaces = vertIndexes.length; |
... | ... | |
2586 | 2551 |
mesh.apply(new MatrixEffectMove(move3D) ,assoc,-1); |
2587 | 2552 |
} |
2588 | 2553 |
|
2589 |
prepareAndRoundCorners(mesh, vertices, vertIndexes, corners, cornerIndexes);
|
|
2554 |
prepareAndRoundCorners(mesh, vertices, corners, cornerIndexes, centers, centerIndexes);
|
|
2590 | 2555 |
|
2591 | 2556 |
correctComponents(mesh,numComponents); |
2592 | 2557 |
|
Also available in: Unified diff
New Cubit Engine: add adjustable centers.