Revision a135652b
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistyCube.java | ||
---|---|---|
309 | 309 |
final float lenY = 0.5f*(Y-1); |
310 | 310 |
final float lenZ = 0.5f*(Z-1); |
311 | 311 |
|
312 |
if( X==1 || Y==1 || Z==1 ) |
|
312 |
int curPos = 0; |
|
313 |
|
|
314 |
if( X==1 ) |
|
315 |
{ |
|
316 |
float[][] pos = new float[X*Y*Z][]; |
|
317 |
|
|
318 |
for(int y=0; y<Y; y++) |
|
319 |
for(int z=0; z<Z; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ}; |
|
320 |
|
|
321 |
return pos; |
|
322 |
} |
|
323 |
|
|
324 |
if( Y==1 ) |
|
313 | 325 |
{ |
314 |
int numCubits = X*Y*Z; |
|
315 |
float[][] tmp = new float[numCubits][]; |
|
326 |
float[][] pos = new float[X*Y*Z][]; |
|
327 |
|
|
328 |
for(int x=0; x<X; x++) |
|
329 |
for(int z=0; z<Z; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ}; |
|
330 |
|
|
331 |
return pos; |
|
332 |
} |
|
333 |
|
|
334 |
if( Z==1 ) |
|
335 |
{ |
|
336 |
float[][] pos = new float[X*Y*Z][]; |
|
337 |
|
|
338 |
for(int x=0; x<X; x++) |
|
339 |
for(int y=0; y<Y; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ}; |
|
316 | 340 |
|
317 |
// TODO ...
|
|
341 |
return pos;
|
|
318 | 342 |
} |
319 | 343 |
|
320 | 344 |
int numCubits = X*Y*Z - (X-2)*(Y-2)*(Z-2); |
321 |
float[][] tmp = new float[numCubits][]; |
|
322 |
|
|
323 |
int currentPosition = 0; |
|
324 |
|
|
325 |
tmp[currentPosition++] = new float[] {-lenX,-lenY,-lenZ}; |
|
326 |
tmp[currentPosition++] = new float[] {-lenX,-lenY,+lenZ}; |
|
327 |
tmp[currentPosition++] = new float[] {-lenX,+lenY,-lenZ}; |
|
328 |
tmp[currentPosition++] = new float[] {-lenX,+lenY,+lenZ}; |
|
329 |
tmp[currentPosition++] = new float[] {+lenX,-lenY,-lenZ}; |
|
330 |
tmp[currentPosition++] = new float[] {+lenX,-lenY,+lenZ}; |
|
331 |
tmp[currentPosition++] = new float[] {+lenX,+lenY,-lenZ}; |
|
332 |
tmp[currentPosition++] = new float[] {+lenX,+lenY,+lenZ}; |
|
333 |
|
|
334 |
for(int i=1; i<X-1; i++) |
|
335 |
tmp[currentPosition++] = new float[] { i-lenX, -lenY, -lenZ }; |
|
336 |
for(int i=1; i<X-1; i++) |
|
337 |
tmp[currentPosition++] = new float[] { i-lenX, -lenY, +lenZ }; |
|
338 |
for(int i=1; i<X-1; i++) |
|
339 |
tmp[currentPosition++] = new float[] { i-lenX, +lenY, -lenZ }; |
|
340 |
for(int i=1; i<X-1; i++) |
|
341 |
tmp[currentPosition++] = new float[] { i-lenX, +lenY, +lenZ }; |
|
342 |
for(int i=1; i<Y-1; i++) |
|
343 |
tmp[currentPosition++] = new float[] { -lenX, i-lenY, -lenZ }; |
|
344 |
for(int i=1; i<Y-1; i++) |
|
345 |
tmp[currentPosition++] = new float[] { -lenX, i-lenY, +lenZ }; |
|
346 |
for(int i=1; i<Y-1; i++) |
|
347 |
tmp[currentPosition++] = new float[] { +lenX, i-lenY, -lenZ }; |
|
348 |
for(int i=1; i<Y-1; i++) |
|
349 |
tmp[currentPosition++] = new float[] { +lenX, i-lenY, +lenZ }; |
|
350 |
for(int i=1; i<Z-1; i++) |
|
351 |
tmp[currentPosition++] = new float[] { -lenX, -lenY, i-lenZ }; |
|
352 |
for(int i=1; i<Z-1; i++) |
|
353 |
tmp[currentPosition++] = new float[] { -lenX, +lenY, i-lenZ }; |
|
354 |
for(int i=1; i<Z-1; i++) |
|
355 |
tmp[currentPosition++] = new float[] { +lenX, -lenY, i-lenZ }; |
|
356 |
for(int i=1; i<Z-1; i++) |
|
357 |
tmp[currentPosition++] = new float[] { +lenX, +lenY, i-lenZ }; |
|
345 |
float[][] pos = new float[numCubits][]; |
|
346 |
|
|
347 |
pos[curPos++] = new float[] {-lenX,-lenY,-lenZ}; |
|
348 |
pos[curPos++] = new float[] {-lenX,-lenY,+lenZ}; |
|
349 |
pos[curPos++] = new float[] {-lenX,+lenY,-lenZ}; |
|
350 |
pos[curPos++] = new float[] {-lenX,+lenY,+lenZ}; |
|
351 |
pos[curPos++] = new float[] {+lenX,-lenY,-lenZ}; |
|
352 |
pos[curPos++] = new float[] {+lenX,-lenY,+lenZ}; |
|
353 |
pos[curPos++] = new float[] {+lenX,+lenY,-lenZ}; |
|
354 |
pos[curPos++] = new float[] {+lenX,+lenY,+lenZ}; |
|
355 |
|
|
356 |
for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX, -lenY, -lenZ }; |
|
357 |
for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX, -lenY, +lenZ }; |
|
358 |
for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX, +lenY, -lenZ }; |
|
359 |
for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX, +lenY, +lenZ }; |
|
360 |
for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] { -lenX, i-lenY, -lenZ }; |
|
361 |
for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] { -lenX, i-lenY, +lenZ }; |
|
362 |
for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] { +lenX, i-lenY, -lenZ }; |
|
363 |
for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] { +lenX, i-lenY, +lenZ }; |
|
364 |
for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] { -lenX, -lenY, i-lenZ }; |
|
365 |
for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] { -lenX, +lenY, i-lenZ }; |
|
366 |
for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] { +lenX, -lenY, i-lenZ }; |
|
367 |
for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] { +lenX, +lenY, i-lenZ }; |
|
358 | 368 |
|
359 | 369 |
for(int y=1; y<Y-1; y++) |
360 |
for(int z=1; z<Z-1; z++) |
|
361 |
tmp[currentPosition++] = new float[] {+lenX,y-lenY,z-lenZ}; |
|
370 |
for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ}; |
|
362 | 371 |
|
363 | 372 |
for(int y=1; y<Y-1; y++) |
364 |
for(int z=1; z<Z-1; z++) |
|
365 |
tmp[currentPosition++] = new float[] {-lenX,y-lenY,z-lenZ}; |
|
373 |
for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {-lenX,y-lenY,z-lenZ}; |
|
366 | 374 |
|
367 | 375 |
for(int x=1; x<X-1; x++) |
368 |
for(int z=1; z<Z-1; z++) |
|
369 |
tmp[currentPosition++] = new float[] {x-lenX,+lenY,z-lenZ}; |
|
376 |
for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ}; |
|
370 | 377 |
|
371 | 378 |
for(int x=1; x<X-1; x++) |
372 |
for(int z=1; z<Z-1; z++) |
|
373 |
tmp[currentPosition++] = new float[] {x-lenX,-lenY,z-lenZ}; |
|
379 |
for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,-lenY,z-lenZ}; |
|
374 | 380 |
|
375 | 381 |
for(int x=1; x<X-1; x++) |
376 |
for(int y=1; y<Y-1; y++) |
|
377 |
tmp[currentPosition++] = new float[] {x-lenX,y-lenY,+lenZ}; |
|
382 |
for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ}; |
|
378 | 383 |
|
379 | 384 |
for(int x=1; x<X-1; x++) |
380 |
for(int y=1; y<Y-1; y++) |
|
381 |
tmp[currentPosition++] = new float[] {x-lenX,y-lenY,-lenZ}; |
|
385 |
for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,-lenZ}; |
|
382 | 386 |
|
383 |
return tmp;
|
|
387 |
return pos;
|
|
384 | 388 |
} |
385 | 389 |
|
386 | 390 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Improve cuboids: single-layer cuboids should work. 1x1x1 does!