Project

General

Profile

« Previous | Next » 

Revision a135652b

Added by Leszek Koltunski over 2 years ago

Improve cuboids: single-layer cuboids should work. 1x1x1 does!

View differences:

src/main/java/org/distorted/objectlib/main/Movement.java
270 270

  
271 271
  private float[] computeBorder(float[] cuts, boolean[] rotatable, int size)
272 272
    {
273
    if( cuts==null ) return null;
274

  
273 275
    int len = cuts.length;
274 276
    float[] border = new float[len];
275 277

  
......
382 384
  private int computeRowFromOffset(int face, int axisIndex, float offset)
383 385
    {
384 386
    float[] borders = mTouchBorders[axisIndex];
387

  
388
    if( borders==null ) return 0;
389

  
385 390
    int len = borders.length;
386 391
    float A = mA[face][axisIndex];
387 392

  
src/main/java/org/distorted/objectlib/main/ObjectType.java
69 69

  
70 70
  CU_223 ( new int[] {2,3,2}      , 16, R.drawable.s_cube_2, R.drawable.m_cube_2, R.drawable.b_cube_2, R.drawable.h_cube_2),
71 71
  CU_334 ( new int[] {3,4,3}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
72
  CU_122 ( new int[] {1,2,2}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
73
  CU_321 ( new int[] {3,2,1}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
74
  CU_111 ( new int[] {1,1,1}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
72 75
  ;
73 76

  
74 77
  public static final int NUM_OBJECTS = values().length;
......
203 206
      case 31: return new TwistyMirror        (numL, quat, move, texture, mesh, effects, res, scrWidth);
204 207

  
205 208
      case 32:
206
      case 33: return new TwistyCube          (numL, quat, move, texture, mesh, effects, res, scrWidth);
207

  
209
      case 33:
210
      case 34:
211
      case 35:
212
      case 36: return new TwistyCube          (numL, quat, move, texture, mesh, effects, res, scrWidth);
208 213
      }
209 214

  
210 215
    return null;
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