Revision 7af68038
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistySkewb.java | ||
---|---|---|
148 | 148 |
return 0; |
149 | 149 |
} |
150 | 150 |
|
151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 |
|
|
153 |
public int getNumStickerTypes(int[] numLayers) |
|
154 |
{ |
|
155 |
return 3; |
|
156 |
} |
|
157 |
|
|
158 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
159 | 152 |
|
160 | 153 |
public float[][] getCuts(int[] numLayers) |
... | ... | |
249 | 242 |
CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER }; |
250 | 243 |
CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER }; |
251 | 244 |
|
252 |
/// EDGES /////////////////////////////////////////////// |
|
253 |
|
|
254 |
final float[][] edgeTable = |
|
255 |
{ |
|
256 |
{0,+DIST_EDGE,+DIST_EDGE}, |
|
257 |
{+DIST_EDGE,0,+DIST_EDGE}, |
|
258 |
{0,-DIST_EDGE,+DIST_EDGE}, |
|
259 |
{-DIST_EDGE,0,+DIST_EDGE}, |
|
260 |
{+DIST_EDGE,+DIST_EDGE,0}, |
|
261 |
{+DIST_EDGE,-DIST_EDGE,0}, |
|
262 |
{-DIST_EDGE,-DIST_EDGE,0}, |
|
263 |
{-DIST_EDGE,+DIST_EDGE,0}, |
|
264 |
{0,+DIST_EDGE,-DIST_EDGE}, |
|
265 |
{+DIST_EDGE,0,-DIST_EDGE}, |
|
266 |
{0,-DIST_EDGE,-DIST_EDGE}, |
|
267 |
{-DIST_EDGE,0,-DIST_EDGE} |
|
268 |
}; |
|
245 |
/// CENTERS ////////////////////////////////////////////// |
|
269 | 246 |
|
270 | 247 |
int index=8; |
271 | 248 |
|
272 |
for (float[] edges : edgeTable) |
|
273 |
{ |
|
274 |
float c = 3-numL; |
|
275 |
|
|
276 |
for (int j=0; j<numL-2; j++, c+=2, index++) |
|
277 |
{ |
|
278 |
CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] , |
|
279 |
edges[1]==0 ? c : edges[1] , |
|
280 |
edges[2]==0 ? c : edges[2] }; |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
/// CENTERS ////////////////////////////////////////////// |
|
285 |
|
|
286 | 249 |
final float X= -1000.0f; |
287 | 250 |
final float Y= -1001.0f; |
288 | 251 |
|
... | ... | |
349 | 312 |
} |
350 | 313 |
} |
351 | 314 |
|
315 |
/// EDGES /////////////////////////////////////////////// |
|
316 |
|
|
317 |
final float[][] edgeTable = |
|
318 |
{ |
|
319 |
{0,+DIST_EDGE,+DIST_EDGE}, |
|
320 |
{+DIST_EDGE,0,+DIST_EDGE}, |
|
321 |
{0,-DIST_EDGE,+DIST_EDGE}, |
|
322 |
{-DIST_EDGE,0,+DIST_EDGE}, |
|
323 |
{+DIST_EDGE,+DIST_EDGE,0}, |
|
324 |
{+DIST_EDGE,-DIST_EDGE,0}, |
|
325 |
{-DIST_EDGE,-DIST_EDGE,0}, |
|
326 |
{-DIST_EDGE,+DIST_EDGE,0}, |
|
327 |
{0,+DIST_EDGE,-DIST_EDGE}, |
|
328 |
{+DIST_EDGE,0,-DIST_EDGE}, |
|
329 |
{0,-DIST_EDGE,-DIST_EDGE}, |
|
330 |
{-DIST_EDGE,0,-DIST_EDGE} |
|
331 |
}; |
|
332 |
|
|
333 |
for (float[] edges : edgeTable) |
|
334 |
{ |
|
335 |
float c = 3-numL; |
|
336 |
|
|
337 |
for (int j=0; j<numL-2; j++, c+=2, index++) |
|
338 |
{ |
|
339 |
CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] , |
|
340 |
edges[1]==0 ? c : edges[1] , |
|
341 |
edges[2]==0 ? c : edges[2] }; |
|
342 |
} |
|
343 |
} |
|
344 |
|
|
352 | 345 |
return CENTERS; |
353 | 346 |
} |
354 | 347 |
|
... | ... | |
360 | 353 |
|
361 | 354 |
int numL = numLayers[0]; |
362 | 355 |
int numCorners = getNumCorners(); |
363 |
int numEdges = getNumEdges(numL); |
|
356 |
int numCentersPerFace = getNumCentersPerFace(numL); |
|
357 |
int numCenters = 6*numCentersPerFace; |
|
364 | 358 |
|
365 | 359 |
if( cubit<numCorners ) |
366 | 360 |
{ |
... | ... | |
376 | 370 |
case 7: return new Static4D(SQ2/2,0,-SQ2/2,0); // 180 along (SQ2/2,0,-SQ2/2) |
377 | 371 |
} |
378 | 372 |
} |
379 |
else if( cubit<numCorners+numEdges ) |
|
373 |
else if( cubit<numCorners+numCenters ) |
|
374 |
{ |
|
375 |
int center = (cubit-numCorners)/numCentersPerFace; |
|
376 |
|
|
377 |
switch(center) |
|
378 |
{ |
|
379 |
case 0: return new Static4D(0,-SQ2/2,0,SQ2/2); // -90 along Y |
|
380 |
case 1: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y |
|
381 |
case 2: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X |
|
382 |
case 3: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X |
|
383 |
case 4: return mQuats[0]; // unit quaternion |
|
384 |
case 5: return mQuats[1]; // 180 along X |
|
385 |
} |
|
386 |
} |
|
387 |
else |
|
380 | 388 |
{ |
381 |
int edge = (cubit-numCorners)/(numL-2); |
|
389 |
int edge = (cubit-numCorners-numCenters)/(numL-2);
|
|
382 | 390 |
|
383 | 391 |
switch(edge) |
384 | 392 |
{ |
... | ... | |
396 | 404 |
case 11: return mQuats[ 6]; |
397 | 405 |
} |
398 | 406 |
} |
399 |
else |
|
400 |
{ |
|
401 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numL); |
|
402 |
|
|
403 |
switch(center) |
|
404 |
{ |
|
405 |
case 0: return new Static4D(0,-SQ2/2,0,SQ2/2); // -90 along Y |
|
406 |
case 1: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y |
|
407 |
case 2: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X |
|
408 |
case 3: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X |
|
409 |
case 4: return mQuats[0]; // unit quaternion |
|
410 |
case 5: return mQuats[1]; // 180 along X |
|
411 |
} |
|
412 |
} |
|
413 | 407 |
|
414 | 408 |
return null; |
415 | 409 |
} |
... | ... | |
436 | 430 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 3); |
437 | 431 |
} |
438 | 432 |
else if( variant==1 ) |
439 |
{ |
|
440 |
float[][] vertices = new float[][] { {-1,0,0},{1,0,0},{0,-1,0},{0,0,-1} }; |
|
441 |
int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} }; |
|
442 |
int N = numL==2 ? 7:5; |
|
443 |
int E = numL==2 ? 5:2; |
|
444 |
float[][] bands = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} }; |
|
445 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
|
446 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} }; |
|
447 |
int[] cornerIndices = new int[] { 0,0,1,1 }; |
|
448 |
float[][] centers = new float[][] { {0.0f, -0.5f, -0.5f} }; |
|
449 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
450 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 2); |
|
451 |
} |
|
452 |
else |
|
453 | 433 |
{ |
454 | 434 |
float[][] vertices = new float[][] { {-1,0,0},{0,-1,0},{1,0,0},{0,1,0},{0,0,-1} }; |
455 | 435 |
int[][] vert_indices = new int[][] { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} }; |
... | ... | |
463 | 443 |
int[] centerIndices = new int[] { 0,0,0,0,-1 }; |
464 | 444 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 1); |
465 | 445 |
} |
446 |
else |
|
447 |
{ |
|
448 |
float[][] vertices = new float[][] { {-1,0,0},{1,0,0},{0,-1,0},{0,0,-1} }; |
|
449 |
int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} }; |
|
450 |
int N = numL==2 ? 7:5; |
|
451 |
int E = numL==2 ? 5:2; |
|
452 |
float[][] bands = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} }; |
|
453 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
|
454 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} }; |
|
455 |
int[] cornerIndices = new int[] { 0,0,1,1 }; |
|
456 |
float[][] centers = new float[][] { {0.0f, -0.5f, -0.5f} }; |
|
457 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
458 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 2); |
|
459 |
} |
|
466 | 460 |
} |
467 | 461 |
|
468 | 462 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
469 | 463 |
|
470 | 464 |
public int getNumCubitVariants(int[] numLayers) |
471 | 465 |
{ |
472 |
return 3; |
|
466 |
return numLayers[0]==2 ? 2:3;
|
|
473 | 467 |
} |
474 | 468 |
|
475 | 469 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
476 | 470 |
|
477 | 471 |
public int getCubitVariant(int cubit, int[] numLayers) |
478 | 472 |
{ |
479 |
int numCorners = getNumCorners(); |
|
480 |
if( cubit<numCorners ) return 0; |
|
481 |
int numEdges = getNumEdges(numLayers[0]); |
|
482 |
return cubit<numCorners+numEdges ? 1:2; |
|
473 |
return cubit<8 ? 0 : (cubit<8+6*getNumCentersPerFace(numLayers[0]) ? 1:2); |
|
483 | 474 |
} |
484 | 475 |
|
485 | 476 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
536 | 527 |
|
537 | 528 |
int numL = numLayers[0]; |
538 | 529 |
int numCorners = getNumCorners(); |
539 |
int numEdges = getNumEdges(numL); |
|
530 |
int numCentersPerFace = getNumCentersPerFace(numL); |
|
531 |
int numCenters = 6*numCentersPerFace; |
|
540 | 532 |
|
541 | 533 |
if( cubit<numCorners ) |
542 | 534 |
{ |
543 | 535 |
return mCornerMap[cubit][face]; |
544 | 536 |
} |
545 |
else if( cubit<numCorners+numEdges )
|
|
537 |
else if( cubit<numCorners+numCenters )
|
|
546 | 538 |
{ |
547 |
int edge = (cubit-numCorners)/(numL-2);
|
|
548 |
return mEdgeMap[edge][face];
|
|
539 |
int center = (cubit-numCorners)/numCentersPerFace;
|
|
540 |
return mCenterMap[center][face];
|
|
549 | 541 |
} |
550 | 542 |
else |
551 | 543 |
{ |
552 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numL);
|
|
553 |
return mCenterMap[center][face];
|
|
544 |
int edge = (cubit-numCorners-numCenters)/(numL-2);
|
|
545 |
return mEdgeMap[edge][face];
|
|
554 | 546 |
} |
555 | 547 |
} |
556 | 548 |
|
... | ... | |
563 | 555 |
float[][] STICKERS = new float[][] |
564 | 556 |
{ |
565 | 557 |
{ -0.5f, 0.25f, 0.25f, -0.5f, 0.25f, 0.25f }, |
566 |
{ 0.0f, -0.3333333f, 0.5f, 0.16666667f, -0.5f, 0.16666667f },
|
|
567 |
{ -0.5f, 0.00f, 0.00f, -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
|
|
558 |
{ -0.5f, 0.00f, 0.00f, -0.5f, 0.50f, 0.0f, 0.0f, 0.5f },
|
|
559 |
{ 0.0f, -0.3333333f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }
|
|
568 | 560 |
}; |
569 | 561 |
|
570 | 562 |
final float R1 = 0.025f; |
571 |
final float R2 = 0.025f;
|
|
572 |
final float R3 = 0.055f;
|
|
573 |
final float[][] radii = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
|
|
563 |
final float R2 = 0.055f;
|
|
564 |
final float R3 = 0.025f;
|
|
565 |
final float[][] radii = { { R1,R1,R1 },{ R2,R2,R2,R2 },{ R3,R3,R3 } };
|
|
574 | 566 |
final float[] strokes = { 0.05f, 0.04f, 0.04f }; |
575 | 567 |
|
576 | 568 |
if( ObjectControl.isInIconMode() ) |
Also available in: Unified diff
Progress