Revision b3c9061a
Added by Leszek Koltunski over 4 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 |
|
| src/main/java/org/distorted/objects/TwistyCube.java | ||
|---|---|---|
| 180 | 180 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0};
|
| 181 | 181 |
float[][] corners = new float[][] { {0.036f,0.12f} };
|
| 182 | 182 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
| 183 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 184 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
|
| 183 | 185 |
|
| 184 | 186 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 185 | 187 |
|
| ... | ... | |
| 187 | 189 |
mMeshes[index] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
| 188 | 190 |
bands, bandIndexes, |
| 189 | 191 |
corners, cornerIndexes, |
| 192 |
centers, centerIndexes, |
|
| 190 | 193 |
getNumCubitFaces() ); |
| 191 | 194 |
} |
| 192 | 195 |
|
| src/main/java/org/distorted/objects/TwistyDiamond.java | ||
|---|---|---|
| 433 | 433 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
| 434 | 434 |
float[][] corners = new float[][] { {0.04f,0.20f} };
|
| 435 | 435 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0 };
|
| 436 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 437 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0 };
|
|
| 436 | 438 |
|
| 437 | 439 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 438 | 440 |
|
| ... | ... | |
| 440 | 442 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_OCTA, VERT_INDEXES_OCTA, |
| 441 | 443 |
bands, bandIndexes, |
| 442 | 444 |
corners, cornerIndexes, |
| 445 |
centers, centerIndexes, |
|
| 443 | 446 |
getNumCubitFaces() ); |
| 444 | 447 |
} |
| 445 | 448 |
mesh = mMeshes[0].copy(true); |
| ... | ... | |
| 452 | 455 |
int[] bandIndexes = new int[] { 0,0,0,0 };
|
| 453 | 456 |
float[][] corners = new float[][] { {0.08f,0.15f} };
|
| 454 | 457 |
int[] cornerIndexes = new int[] { 0,0,0,0 };
|
| 458 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 459 |
int[] centerIndexes = new int[] { 0,0,0,0 };
|
|
| 455 | 460 |
|
| 456 | 461 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 457 | 462 |
|
| ... | ... | |
| 459 | 464 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_TETRA, VERT_INDEXES_TETRA, |
| 460 | 465 |
bands, bandIndexes, |
| 461 | 466 |
corners, cornerIndexes, |
| 467 |
centers, centerIndexes, |
|
| 462 | 468 |
getNumCubitFaces() ); |
| 463 | 469 |
} |
| 464 | 470 |
mesh = mMeshes[1].copy(true); |
| src/main/java/org/distorted/objects/TwistyDino.java | ||
|---|---|---|
| 250 | 250 |
int[] bandIndexes = new int[] { 0,0,1,1 };
|
| 251 | 251 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} };
|
| 252 | 252 |
int[] cornerIndexes = new int[] { 0,0,1,1 };
|
| 253 |
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} };
|
|
| 254 |
int[] centerIndexes = new int[] { 0,0,0,0 };
|
|
| 253 | 255 |
|
| 254 | 256 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 255 | 257 |
|
| ... | ... | |
| 257 | 259 |
mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
| 258 | 260 |
bands, bandIndexes, |
| 259 | 261 |
corners, cornerIndexes, |
| 262 |
centers, centerIndexes, |
|
| 260 | 263 |
getNumCubitFaces() ); |
| 261 | 264 |
} |
| 262 | 265 |
|
| src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
|---|---|---|
| 313 | 313 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
| 314 | 314 |
float[][] corners = new float[][] { {0.04f,0.20f} };
|
| 315 | 315 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0 };
|
| 316 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 317 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0 };
|
|
| 316 | 318 |
|
| 317 | 319 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 318 | 320 |
|
| ... | ... | |
| 320 | 322 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_OCTA, VERT_INDEXES_OCTA, |
| 321 | 323 |
bands, bandIndexes, |
| 322 | 324 |
corners, cornerIndexes, |
| 325 |
centers, centerIndexes, |
|
| 323 | 326 |
getNumCubitFaces() ); |
| 324 | 327 |
} |
| 325 | 328 |
mesh = mMeshes[0].copy(true); |
| ... | ... | |
| 332 | 335 |
int[] bandIndexes = new int[] { 0,0,0,0 };
|
| 333 | 336 |
float[][] corners = new float[][] { {0.06f,0.15f} };
|
| 334 | 337 |
int[] cornerIndexes = new int[] { 0,0,0,0 };
|
| 338 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 339 |
int[] centerIndexes = new int[] { 0,0,0,0 };
|
|
| 335 | 340 |
|
| 336 | 341 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 337 | 342 |
|
| ... | ... | |
| 339 | 344 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_TETRA, VERT_INDEXES_TETRA, |
| 340 | 345 |
bands, bandIndexes, |
| 341 | 346 |
corners, cornerIndexes, |
| 347 |
centers, centerIndexes, |
|
| 342 | 348 |
getNumCubitFaces() ); |
| 343 | 349 |
|
| 344 | 350 |
factory.printStickerCoords(); |
| src/main/java/org/distorted/objects/TwistySkewb.java | ||
|---|---|---|
| 495 | 495 |
int[] bandIndexes = new int[] { 0,0,1,1 };
|
| 496 | 496 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
|
| 497 | 497 |
int[] cornerIndexes = new int[] { 0,0,1,1 };
|
| 498 |
float[][] centers = new float[][] { {0.0f, -0.25f, -0.25f} };
|
|
| 499 |
int[] centerIndexes = new int[] { 0,0,0,0 };
|
|
| 498 | 500 |
|
| 499 | 501 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 500 |
|
|
| 501 | 502 |
factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE); |
| 502 | 503 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE, |
| 503 | 504 |
bands, bandIndexes, |
| 504 | 505 |
corners, cornerIndexes, |
| 506 |
centers, centerIndexes, |
|
| 505 | 507 |
getNumCubitFaces() ); |
| 506 | 508 |
} |
| 507 | 509 |
mesh = mMeshes[1].copy(true); |
Also available in: Unified diff
New Cubit Engine: add adjustable centers.