34 |
34 |
private int mNumCubitTouches;
|
35 |
35 |
private int[] mNumLeftCyclesPerLayer;
|
36 |
36 |
private int[] mNumCentCyclesPerLayer;
|
|
37 |
private int[] mNumInneCyclesPerLayer;
|
37 |
38 |
|
38 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
40 |
// built-in objects
|
... | ... | |
297 |
298 |
float[][] centers = new float[numCenters][];
|
298 |
299 |
int index = 0;
|
299 |
300 |
|
300 |
|
for(int i = 0; i<mLayer[0]; i++)
|
301 |
|
for(int j = 0; j<mLayer[1]; j++)
|
302 |
|
for(int k = 0; k<mLayer[2]; k++)
|
|
301 |
for(int i=0; i<mLayer[0]; i++)
|
|
302 |
for(int j=0; j<mLayer[1]; j++)
|
|
303 |
for(int k=0; k<mLayer[2]; k++)
|
303 |
304 |
if( (i==0) || (i==mLayer[0]-1) || (j==0) || (j==mLayer[1]-1) || (k==0) || (k==mLayer[2]-1) )
|
304 |
305 |
{
|
305 |
306 |
centers[index++] = new float[] { i+0.5f*(1-mLayer[0]), j+0.5f*(1-mLayer[1]), k+0.5f*(1-mLayer[2]) };
|
... | ... | |
359 |
360 |
}
|
360 |
361 |
}
|
361 |
362 |
}
|
362 |
|
/*
|
363 |
|
android.util.Log.e("D", "num touches="+mNumCubitTouches);
|
364 |
|
|
365 |
|
for(int i=0; i<mNumCubitTouches; i++)
|
366 |
|
{
|
367 |
|
android.util.Log.e("D", mCubitTouch[i][0]+" "+mCubitTouch[i][1]+" "+mCubitTouch[i][2]);
|
368 |
|
}
|
369 |
|
*/
|
370 |
363 |
}
|
371 |
364 |
|
372 |
365 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
379 |
372 |
|
380 |
373 |
mNumLeftCyclesPerLayer = new int[3];
|
381 |
374 |
mNumCentCyclesPerLayer = new int[3];
|
|
375 |
mNumInneCyclesPerLayer = new int[3];
|
382 |
376 |
|
383 |
377 |
if( mLayer[1]==mLayer[2] ) generate4Cycles(cycles0,0);
|
384 |
378 |
else generate2Cycles(cycles0,0);
|
... | ... | |
387 |
381 |
if( mLayer[0]==mLayer[1] ) generate4Cycles(cycles2,2);
|
388 |
382 |
else generate2Cycles(cycles2,2);
|
389 |
383 |
|
390 |
|
android.util.Log.e("D", "0 left="+mNumLeftCyclesPerLayer[0]+" 0 cent="+mNumCentCyclesPerLayer[0]);
|
391 |
|
android.util.Log.e("D", "1 left="+mNumLeftCyclesPerLayer[1]+" 1 cent="+mNumCentCyclesPerLayer[1]);
|
392 |
|
android.util.Log.e("D", "2 left="+mNumLeftCyclesPerLayer[2]+" 2 cent="+mNumCentCyclesPerLayer[2]);
|
393 |
|
|
394 |
384 |
mCycles = new int[3][][][];
|
395 |
385 |
|
396 |
386 |
mCycles[0] = fillUpCycles(cycles0,0,mLayer[0]);
|
... | ... | |
402 |
392 |
|
403 |
393 |
private void generate4Cycles(ArrayList<float[][]> cycles, int axis)
|
404 |
394 |
{
|
405 |
|
android.util.Log.e("D", "generate4Cycles, axis="+axis);
|
406 |
|
|
407 |
395 |
for(int i=0; i<mNumCubitTouches; i++)
|
408 |
396 |
{
|
409 |
397 |
int i0 = rotateIndex(axis,i);
|
... | ... | |
422 |
410 |
|
423 |
411 |
if( l==2 ) mNumLeftCyclesPerLayer[axis]++;
|
424 |
412 |
if( l==1 ) mNumCentCyclesPerLayer[axis]++;
|
425 |
|
|
426 |
|
//android.util.Log.d("D", "generate4Cycles, axis="+axis+" inserting "+i+" "+i0+" "+i1+" "+i2);
|
|
413 |
if( mLayer[axis]>2 && l==3 ) mNumInneCyclesPerLayer[axis]++;
|
427 |
414 |
|
428 |
415 |
float[][] cycle = new float[][] { f0,f1,f2,f3 };
|
429 |
416 |
cycles.add(cycle);
|
... | ... | |
434 |
421 |
|
435 |
422 |
private void generate2Cycles(ArrayList<float[][]> cycles, int axis)
|
436 |
423 |
{
|
437 |
|
android.util.Log.e("D", "generate2Cycles, axis="+axis);
|
438 |
|
|
439 |
424 |
for(int i=0; i<mNumCubitTouches; i++)
|
440 |
425 |
{
|
441 |
426 |
int i0 = rotateIndex2(axis,i);
|
... | ... | |
448 |
433 |
|
449 |
434 |
if( l==2 ) mNumLeftCyclesPerLayer[axis]++;
|
450 |
435 |
if( l==1 ) mNumCentCyclesPerLayer[axis]++;
|
|
436 |
if( mLayer[axis]>2 && l==3 ) mNumInneCyclesPerLayer[axis]++;
|
451 |
437 |
|
452 |
438 |
float[][] cycle = new float[][] { f0,f1 };
|
453 |
439 |
cycles.add(cycle);
|
... | ... | |
462 |
448 |
int[] index = new int[numLayers];
|
463 |
449 |
|
464 |
450 |
int numFirst = mNumCentCyclesPerLayer[axis];
|
465 |
|
int numNext = mNumLeftCyclesPerLayer[axis] + numFirst;
|
|
451 |
int numNext = mNumLeftCyclesPerLayer[axis] + mNumInneCyclesPerLayer[axis];
|
|
452 |
int numLast = mNumLeftCyclesPerLayer[axis] + numFirst;
|
466 |
453 |
|
467 |
454 |
int[][][] ret = new int[numLayers][][];
|
468 |
|
ret[0] = new int[numFirst][];
|
469 |
|
for(int i=1; i<numLayers; i++) ret[i] = new int[numNext][];
|
|
455 |
ret[ 0] = new int[numFirst][];
|
|
456 |
ret[numLayers-1] = new int[numLast][];
|
|
457 |
|
|
458 |
for(int i=1; i<numLayers-1; i++) ret[i] = new int[numNext][];
|
470 |
459 |
|
471 |
460 |
for(int i=0; i<numCycles; i++)
|
472 |
461 |
{
|
... | ... | |
479 |
468 |
int i1 = getIndexOfCubitTouch(cycle[1][0],cycle[1][1],cycle[1][2]);
|
480 |
469 |
int i2 = getIndexOfCubitTouch(cycle[2][0],cycle[2][1],cycle[2][2]);
|
481 |
470 |
int i3 = getIndexOfCubitTouch(cycle[3][0],cycle[3][1],cycle[3][2]);
|
482 |
|
|
483 |
|
if( layer>=numLayers )
|
484 |
|
{
|
485 |
|
android.util.Log.e("D", "4 layer="+layer+" numLayers="+numLayers);
|
486 |
|
}
|
487 |
|
if( index[layer]>=numCycles/numLayers )
|
488 |
|
{
|
489 |
|
android.util.Log.e("D", "4 index[layer]="+index[layer]+" numCycles="+numCycles+" numLayers="+numLayers+" cycleLength="+cycle.length);
|
490 |
|
}
|
491 |
|
|
492 |
471 |
ret[layer][index[layer]] = new int[] {i0,i1,i2,i3};
|
493 |
472 |
index[layer]++;
|
494 |
473 |
}
|
... | ... | |
496 |
475 |
{
|
497 |
476 |
int i0 = getIndexOfCubitTouch(cycle[0][0],cycle[0][1],cycle[0][2]);
|
498 |
477 |
int i1 = getIndexOfCubitTouch(cycle[1][0],cycle[1][1],cycle[1][2]);
|
499 |
|
|
500 |
|
if( layer>=numLayers )
|
501 |
|
{
|
502 |
|
android.util.Log.e("D", "2 layer="+layer+" numLayers="+numLayers);
|
503 |
|
}
|
504 |
|
if( index[layer]>=numCycles/numLayers )
|
505 |
|
{
|
506 |
|
android.util.Log.e("D", "2 index[layer]="+index[layer]+" numCycles="+numCycles+" numLayers="+numLayers+" cycleLength="+cycle.length);
|
507 |
|
}
|
508 |
|
|
509 |
478 |
ret[layer][index[layer]] = new int[] {i0,i1};
|
510 |
479 |
index[layer]++;
|
511 |
480 |
}
|
Fixes for scrambling locally-produced bandaged cuboid.