Project

General

Profile

« Previous | Next » 

Revision 27a70eae

Added by Leszek Koltunski about 4 years ago

Make RubikCube and RubikCubeMovement generic and not visible outside of their package.

View differences:

src/main/java/org/distorted/object/RubikCube.java
28 28
import org.distorted.library.effect.MatrixEffectMove;
29 29
import org.distorted.library.effect.MatrixEffectQuaternion;
30 30
import org.distorted.library.effect.MatrixEffectRotate;
31
import org.distorted.library.effect.MatrixEffectScale;
32
import org.distorted.library.effect.VertexEffectSink;
33 31
import org.distorted.library.main.DistortedEffects;
34 32
import org.distorted.library.main.DistortedNode;
35 33
import org.distorted.library.main.DistortedTexture;
......
42 40
import org.distorted.library.type.Static4D;
43 41
import org.distorted.magic.RubikSurfaceView;
44 42

  
43
import static org.distorted.object.RubikObjectList.VECTX;
44
import static org.distorted.object.RubikObjectList.VECTY;
45
import static org.distorted.object.RubikObjectList.VECTZ;
46

  
45 47
///////////////////////////////////////////////////////////////////////////////////////////////////
46 48

  
47
public class RubikCube extends DistortedNode
49
class RubikCube extends RubikObject
48 50
{
49
            static final float CUBE_SCREEN_RATIO = 0.5f;
50
    private static final int POST_ROTATION_MILLISEC = 500;
51
    private static final int TEXTURE_SIZE = 100;
52

  
53 51
    private static final Static3D VectX = new Static3D(1,0,0);
54 52
    private static final Static3D VectY = new Static3D(0,1,0);
55 53
    private static final Static3D VectZ = new Static3D(0,0,1);
56 54

  
57
    public static final int VECTX = 0;  //
58
    public static final int VECTY = 1;  // don't change this
59
    public static final int VECTZ = 2;  //
60

  
61 55
    private DistortedNode[][][] mNodes;
62 56
    private MeshCubes[][][] mCubes;
63 57
    private DistortedEffects[][][] mEffects;
......
66 60
    private Dynamic1D[][][] mRotationAngle;
67 61
    private Static3D[][][] mCurrentPosition;
68 62
    private MatrixEffectRotate[][][] mRotateEffect;
69
    private Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
70
    private Static3D mMove, mScale, mNodeMove, mNodeScale;
71
    private Static4D mQuatAccumulated;
72
    private DistortedTexture mTexture;
73

  
74
    private int mRotAxis, mRotRow;
75
    private int mSize;
76

  
77
    private DistortedTexture mNodeTexture;
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
    private int computeNearestAngle(float angle)
82
      {
83
      final int NEAREST = 90;
84

  
85
      int tmp = (int)((angle+NEAREST/2)/NEAREST);
86
      if( angle< -(NEAREST*0.5) ) tmp-=1;
87

  
88
      return NEAREST*tmp;
89
      }
90 63

  
91 64
///////////////////////////////////////////////////////////////////////////////////////////////////
92 65
// All legal rotation quats must have all four of their components equal to either
......
158 131
      mQuatScramble[i][j][k].set(x,y,z,w);
159 132
      }
160 133

  
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

  
163
    private float getSinkStrength()
164
      {
165
      switch(mSize)
166
        {
167
        case 1 : return 1.1f;
168
        case 2 : return 1.5f;
169
        case 3 : return 1.8f;
170
        case 4 : return 2.0f;
171
        default: return 3.0f - 4.0f/mSize;
172
        }
173
      }
174

  
175 134
///////////////////////////////////////////////////////////////////////////////////////////////////
176 135

  
177 136
    private boolean belongsToRotation(int x, int y, int z, int vector, int row)
......
212 171
      mCurrentPosition[x][y][z].set2(roundedZ);
213 172
      }
214 173

  
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216
// PUBLIC API
217 174
///////////////////////////////////////////////////////////////////////////////////////////////////
218 175

  
219
    public RubikCube(int size, Static4D quatCur, Static4D quatAcc, DistortedTexture texture, MeshFlat mesh, DistortedEffects effects)
176
    RubikCube(int size, Static4D quatCur, Static4D quatAcc, DistortedTexture texture, MeshFlat mesh, DistortedEffects effects)
220 177
      {
221
      super(texture,effects,mesh);
222

  
223
      mNodeTexture = texture;
224

  
225
      mSize = size;
226

  
227
      mRotationAngleStatic = new Static1D(0);
228
      mRotationAngleMiddle = new Static1D(0);
229
      mRotationAngleFinal  = new Static1D(0);
230

  
231
      mMove     = new Static3D(0,0,0);
232
      mScale    = new Static3D(1,1,1);
233
      mNodeMove = new Static3D(0,0,0);
234
      mNodeScale= new Static3D(1,1,1);
235

  
236
      mQuatAccumulated = quatAcc;
178
      super(size,quatCur,quatAcc,texture,mesh,effects);
237 179

  
238 180
      mRotAxis = VECTX;
239 181
      mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
......
248 190
      mRotateEffect   = new MatrixEffectRotate[mSize][mSize][mSize];
249 191

  
250 192
      Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize];
251

  
252
      Static3D sinkCenter = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
253 193
      Static3D matrCenter = new Static3D(0,0,0);
254
      Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
255

  
256
      VertexEffectSink        sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region );
257
      MatrixEffectMove        moveEffect = new MatrixEffectMove(mMove);
258
      MatrixEffectScale      scaleEffect = new MatrixEffectScale(mScale);
259
      MatrixEffectQuaternion quatCEffect = new MatrixEffectQuaternion(quatCur, matrCenter);
260
      MatrixEffectQuaternion quatAEffect = new MatrixEffectQuaternion(quatAcc, matrCenter);
261

  
262
      MatrixEffectMove       nodeMoveEffect  = new MatrixEffectMove(mNodeMove);
263
      MatrixEffectScale      nodeScaleEffect = new MatrixEffectScale(mNodeScale);
264

  
265
      effects.apply(nodeScaleEffect);
266
      effects.apply(nodeMoveEffect);
267 194

  
268 195
      // 3x2 bitmap = 6 squares:
269 196
      //
......
311 238
              mRotateEffect[x][y][z]    = new MatrixEffectRotate(mRotationAngle[x][y][z], mRotationAxis[x][y][z], matrCenter);
312 239

  
313 240
              mEffects[x][y][z] = new DistortedEffects();
314
              mEffects[x][y][z].apply(sinkEffect);
241
              mEffects[x][y][z].apply(mSinkEffect);
315 242
              mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) );
316 243
              mEffects[x][y][z].apply( new MatrixEffectQuaternion(mQuatScramble[x][y][z], matrCenter));
317 244
              mEffects[x][y][z].apply(mRotateEffect[x][y][z]);
318
              mEffects[x][y][z].apply(quatAEffect);
319
              mEffects[x][y][z].apply(quatCEffect);
320
              mEffects[x][y][z].apply(scaleEffect);
321
              mEffects[x][y][z].apply(moveEffect);
245
              mEffects[x][y][z].apply(mQuatAEffect);
246
              mEffects[x][y][z].apply(mQuatCEffect);
247
              mEffects[x][y][z].apply(mScaleEffect);
248
              mEffects[x][y][z].apply(mMoveEffect);
322 249

  
323 250
              mNodes[x][y][z] = new DistortedNode(mTexture,mEffects[x][y][z],mCubes[x][y][z]);
324 251

  
......
328 255
      }
329 256

  
330 257
///////////////////////////////////////////////////////////////////////////////////////////////////
331

  
332
    public void addNewRotation(int vector, int row )
333
      {
334
      Static3D axis = VectX;
335

  
336
      switch(vector)
337
        {
338
        case VECTX: axis = VectX; break;
339
        case VECTY: axis = VectY; break;
340
        case VECTZ: axis = VectZ; break;
341
        }
342

  
343
      mRotAxis = vector;
344
      mRotRow  = row;
345

  
346
      mRotationAngleStatic.set0(0.0f);
347

  
348
      for(int x=0; x<mSize; x++)
349
        for(int y=0; y<mSize; y++)
350
          for(int z=0; z<mSize; z++)
351
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
352
              {
353
              if( belongsToRotation(x,y,z,vector,mRotRow) )
354
                {
355
                mRotationAxis[x][y][z].set(axis);
356
                mRotationAngle[x][y][z].add(mRotationAngleStatic);
357
                }
358
              }
359
      }
360

  
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

  
363
    public void continueRotation(float angleInDegrees)
364
      {
365
      mRotationAngleStatic.set0(angleInDegrees);
366
      }
367

  
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

  
370
    public Static4D getRotationQuat()
371
      {
372
      return mQuatAccumulated;
373
      }
374

  
258
// PUBLIC API
375 259
///////////////////////////////////////////////////////////////////////////////////////////////////
376 260
// mSize already saved as RubikStatePlay.mButton
377 261

  
......
419 303

  
420 304
///////////////////////////////////////////////////////////////////////////////////////////////////
421 305

  
422
    public long finishRotationNow(EffectListener listener)
423
      {
424
      boolean first = true;
425
      long effectID=0;
426

  
427
      for(int x=0; x<mSize; x++)
428
        for(int y=0; y<mSize; y++)
429
          for(int z=0; z<mSize; z++)
430
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
431
              {
432
              if( belongsToRotation(x,y,z,mRotAxis,mRotRow) )
433
                {
434
                if( first )
435
                  {
436
                  first = false;
437
                  mRotateEffect[x][y][z].notifyWhenFinished(listener);
438
                  effectID = mRotateEffect[x][y][z].getID();
439
                  int pointNum = mRotationAngle[x][y][z].getNumPoints();
440

  
441
                  if( pointNum>=1 )
442
                    {
443
                    float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get0();
444
                    int nearestAngleInDegrees = computeNearestAngle(startingAngle);
445
                    mRotationAngleStatic.set0(startingAngle);
446
                    mRotationAngleFinal.set0(nearestAngleInDegrees);
447
                    mRotationAngleMiddle.set0( nearestAngleInDegrees + (nearestAngleInDegrees-startingAngle)*0.2f );
448
                    }
449
                  else
450
                    {
451
                    android.util.Log.e("cube", "ERROR finishing rotation!");
452
                    return 0;
453
                    }
454
                  }
455

  
456
                mRotationAngle[x][y][z].setDuration(POST_ROTATION_MILLISEC);
457
                mRotationAngle[x][y][z].resetToBeginning();
458
                mRotationAngle[x][y][z].removeAll();
459
                mRotationAngle[x][y][z].add(mRotationAngleStatic);
460
                mRotationAngle[x][y][z].add(mRotationAngleMiddle);
461
                mRotationAngle[x][y][z].add(mRotationAngleFinal);
462
                }
463
              }
306
   public long finishRotationNow(EffectListener listener)
307
     {
308
     boolean first = true;
309
     long effectID=0;
464 310

  
465
      return effectID;
466
      }
311
     for(int x=0; x<mSize; x++)
312
       for(int y=0; y<mSize; y++)
313
         for(int z=0; z<mSize; z++)
314
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
315
             {
316
             if( belongsToRotation(x,y,z,mRotAxis,mRotRow) )
317
               {
318
               if( first )
319
                 {
320
                 first = false;
321
                 mRotateEffect[x][y][z].notifyWhenFinished(listener);
322
                 effectID = mRotateEffect[x][y][z].getID();
323
                 int pointNum = mRotationAngle[x][y][z].getNumPoints();
324

  
325
                 if( pointNum>=1 )
326
                   {
327
                   float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get0();
328
                   int nearestAngleInDegrees = computeNearestAngle(startingAngle);
329
                   mRotationAngleStatic.set0(startingAngle);
330
                   mRotationAngleFinal.set0(nearestAngleInDegrees);
331
                   mRotationAngleMiddle.set0( nearestAngleInDegrees + (nearestAngleInDegrees-startingAngle)*0.2f );
332
                   }
333
                 else
334
                   {
335
                   android.util.Log.e("cube", "ERROR finishing rotation!");
336
                   return 0;
337
                   }
338
                 }
339

  
340
               mRotationAngle[x][y][z].setDuration(POST_ROTATION_MILLISEC);
341
               mRotationAngle[x][y][z].resetToBeginning();
342
               mRotationAngle[x][y][z].removeAll();
343
               mRotationAngle[x][y][z].add(mRotationAngleStatic);
344
               mRotationAngle[x][y][z].add(mRotationAngleMiddle);
345
               mRotationAngle[x][y][z].add(mRotationAngleFinal);
346
               }
347
             }
348

  
349
     return effectID;
350
     }
467 351

  
468 352
///////////////////////////////////////////////////////////////////////////////////////////////////
469 353
// all DistortedTextures, DistortedNodes, DistortedFramebuffers, DistortedScreens and all types of
470 354
// Meshes HAVE TO be markedForDeletion when they are no longer needed- otherwise we have a major
471 355
// memory leak.
472 356

  
473
    public void releaseResources()
474
      {
475
      mTexture.markForDeletion();
357
   public void releaseResources()
358
     {
359
     mTexture.markForDeletion();
476 360

  
477
      for(int x=0; x<mSize; x++)
478
        for(int y=0; y<mSize; y++)
479
          for(int z=0; z<mSize; z++)
480
            {
481
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
482
              {
483
              mCubes[x][y][z].markForDeletion();
484
              mNodes[x][y][z].markForDeletion();
485
              }
486
            }
487
      }
361
     for(int x=0; x<mSize; x++)
362
       for(int y=0; y<mSize; y++)
363
         for(int z=0; z<mSize; z++)
364
           {
365
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
366
             {
367
             mCubes[x][y][z].markForDeletion();
368
             mNodes[x][y][z].markForDeletion();
369
             }
370
           }
371
     }
488 372

  
489 373
///////////////////////////////////////////////////////////////////////////////////////////////////
490 374

  
491
    public void createTexture()
492
      {
493
      Bitmap bitmap;
494

  
495
      final int S = 128;
496
      final int W = 3*S;
497
      final int H = 2*S;
498
      final int R = S/10;
499
      final int M = S/20;
500

  
501
      Paint paint = new Paint();
502
      bitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
503
      Canvas canvas = new Canvas(bitmap);
504

  
505
      paint.setAntiAlias(true);
506
      paint.setTextAlign(Paint.Align.CENTER);
507
      paint.setStyle(Paint.Style.FILL);
508

  
509
      // 3x2 bitmap = 6 squares:
510
      //
511
      // RED     GREEN   BLUE
512
      // YELLOW  WHITE   BROWN
513

  
514
      paint.setColor(0xff000000);                                  // BLACK BACKGROUND
515
      canvas.drawRect(0, 0, W, H, paint);                          //
516

  
517
      paint.setColor(0xffff0000);                                  // RED
518
      canvas.drawRoundRect(    M,   M,   S-M,   S-M, R, R, paint); //
519
      paint.setColor(0xff00ff00);                                  // GREEN
520
      canvas.drawRoundRect(  S+M,   M, 2*S-M,   S-M, R, R, paint); //
521
      paint.setColor(0xff0000ff);                                  // BLUE
522
      canvas.drawRoundRect(2*S+M,   M, 3*S-M,   S-M, R, R, paint); //
523
      paint.setColor(0xffffff00);                                  // YELLOW
524
      canvas.drawRoundRect(    M, S+M,   S-M, 2*S-M, R, R, paint); //
525
      paint.setColor(0xffffffff);                                  // WHITE
526
      canvas.drawRoundRect(  S+M, S+M, 2*S-M, 2*S-M, R, R, paint); //
527
      paint.setColor(0xffb5651d);                                  // BROWN
528
      canvas.drawRoundRect(2*S+M, S+M, 3*S-M, 2*S-M, R, R, paint); //
529

  
530
      mTexture.setTexture(bitmap);
531
      }
375
   public void createTexture()
376
     {
377
     Bitmap bitmap;
378

  
379
     final int S = 128;
380
     final int W = 3*S;
381
     final int H = 2*S;
382
     final int R = S/10;
383
     final int M = S/20;
384

  
385
     Paint paint = new Paint();
386
     bitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
387
     Canvas canvas = new Canvas(bitmap);
388

  
389
     paint.setAntiAlias(true);
390
     paint.setTextAlign(Paint.Align.CENTER);
391
     paint.setStyle(Paint.Style.FILL);
392

  
393
     // 3x2 bitmap = 6 squares:
394
     //
395
     // RED     GREEN   BLUE
396
     // YELLOW  WHITE   BROWN
397

  
398
     paint.setColor(0xff000000);                                  // BLACK BACKGROUND
399
     canvas.drawRect(0, 0, W, H, paint);                          //
400

  
401
     paint.setColor(0xffff0000);                                  // RED
402
     canvas.drawRoundRect(    M,   M,   S-M,   S-M, R, R, paint); //
403
     paint.setColor(0xff00ff00);                                  // GREEN
404
     canvas.drawRoundRect(  S+M,   M, 2*S-M,   S-M, R, R, paint); //
405
     paint.setColor(0xff0000ff);                                  // BLUE
406
     canvas.drawRoundRect(2*S+M,   M, 3*S-M,   S-M, R, R, paint); //
407
     paint.setColor(0xffffff00);                                  // YELLOW
408
     canvas.drawRoundRect(    M, S+M,   S-M, 2*S-M, R, R, paint); //
409
     paint.setColor(0xffffffff);                                  // WHITE
410
     canvas.drawRoundRect(  S+M, S+M, 2*S-M, 2*S-M, R, R, paint); //
411
     paint.setColor(0xffb5651d);                                  // BROWN
412
     canvas.drawRoundRect(2*S+M, S+M, 3*S-M, 2*S-M, R, R, paint); //
413

  
414
     mTexture.setTexture(bitmap);
415
     }
532 416

  
533 417
///////////////////////////////////////////////////////////////////////////////////////////////////
534 418

  
535
    public void recomputeScaleFactor(int screenWidth, int screenHeight)
536
      {
537
      int texW = mNodeTexture.getWidth();
538
      int texH = mNodeTexture.getHeight();
539

  
540
      if( (float)texH/texW > (float)screenHeight/screenWidth )
541
        {
542
        int w = (screenHeight*texW)/texH;
543
        float factor = (float)screenHeight/texH;
544
        mNodeMove.set((screenWidth-w)*0.5f ,0, 0);
545
        mNodeScale.set(factor,factor,factor);
546
        }
547
      else
548
        {
549
        int h = (screenWidth*texH)/texW;
550
        float factor = (float)screenWidth/texW;
551
        mNodeMove.set(0,(screenHeight-h)*0.5f,0);
552
        mNodeScale.set(factor,factor,factor);
553
        }
554

  
555
      float scaleFactor = (CUBE_SCREEN_RATIO*texW/(TEXTURE_SIZE*mSize));
556

  
557
      mMove.set( texW*0.5f , texH*0.5f , 0.0f );
558
      mScale.set(scaleFactor,scaleFactor,scaleFactor);
419
   public void apply(Effect effect, int position)
420
     {
421
     for(int x=0; x<mSize; x++)
422
       for(int y=0; y<mSize; y++)
423
         for(int z=0; z<mSize; z++)
424
           {
425
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
426
             {
427
             mEffects[x][y][z].apply(effect, position);
428
             }
429
           }
559 430
      }
560 431

  
561 432
///////////////////////////////////////////////////////////////////////////////////////////////////
562 433

  
563
    public void apply(Effect effect, int position)
564
      {
565
      for(int x=0; x<mSize; x++)
566
        for(int y=0; y<mSize; y++)
567
          for(int z=0; z<mSize; z++)
568
            {
569
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
570
              {
571
              mEffects[x][y][z].apply(effect, position);
572
              }
573
            }
434
   public void remove(long effectID)
435
     {
436
     for(int x=0; x<mSize; x++)
437
       for(int y=0; y<mSize; y++)
438
         for(int z=0; z<mSize; z++)
439
           {
440
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
441
             {
442
             mEffects[x][y][z].abortById(effectID);
443
             }
444
           }
574 445
      }
575 446

  
576 447
///////////////////////////////////////////////////////////////////////////////////////////////////
577 448

  
578
    public void remove(long effectID)
579
      {
580
      for(int x=0; x<mSize; x++)
581
        for(int y=0; y<mSize; y++)
582
          for(int z=0; z<mSize; z++)
583
            {
584
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
585
              {
586
              mEffects[x][y][z].abortById(effectID);
587
              }
588
            }
449
   public void solve()
450
     {
451
     for(int x=0; x<mSize; x++)
452
       for(int y=0; y<mSize; y++)
453
         for(int z=0; z<mSize; z++)
454
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
455
             {
456
             mQuatScramble[x][y][z].set(0,0,0,1);
457
             mCurrentPosition[x][y][z].set(x,y,z);
458
             }
589 459
      }
590 460

  
591 461
///////////////////////////////////////////////////////////////////////////////////////////////////
592 462

  
593
    public void solve()
594
      {
595
      for(int x=0; x<mSize; x++)
596
        for(int y=0; y<mSize; y++)
597
          for(int z=0; z<mSize; z++)
598
            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
599
              {
600
              mQuatScramble[x][y][z].set(0,0,0,1);
601
              mCurrentPosition[x][y][z].set(x,y,z);
602
              }
603
      }
463
   public boolean isSolved()
464
     {
465
     Static4D q = mQuatScramble[0][0][0];
466

  
467
     float x = q.get0();
468
     float y = q.get1();
469
     float z = q.get2();
470
     float w = q.get3();
471

  
472
     for(int i = 0; i< mSize; i++)
473
       for(int j = 0; j< mSize; j++)
474
         for(int k = 0; k< mSize; k++)
475
           {
476
           if( i==0 || i==mSize-1 || j==0 || j==mSize-1 || k==0 || k==mSize-1 )
477
             {
478
             q = mQuatScramble[i][j][k];
479

  
480
             if( q.get0()!=x || q.get1()!=y || q.get2()!=z || q.get3()!=w )
481
               {
482
               return false;
483
               }
484
             }
485
           }
486

  
487
     return true;
488
     }
604 489

  
605 490
///////////////////////////////////////////////////////////////////////////////////////////////////
606 491

  
607
    public boolean isSolved()
608
      {
609
      Static4D q = mQuatScramble[0][0][0];
610

  
611
      float x = q.get0();
612
      float y = q.get1();
613
      float z = q.get2();
614
      float w = q.get3();
615

  
616
      for(int i = 0; i< mSize; i++)
617
        for(int j = 0; j< mSize; j++)
618
          for(int k = 0; k< mSize; k++)
619
            {
620
            if( i==0 || i==mSize-1 || j==0 || j==mSize-1 || k==0 || k==mSize-1 )
621
              {
622
              q = mQuatScramble[i][j][k];
492
   public void beginNewRotation(int vector, int row )
493
     {
494
     Static3D axis = VectX;
623 495

  
624
              if( q.get0()!=x || q.get1()!=y || q.get2()!=z || q.get3()!=w )
625
                {
626
                return false;
627
                }
628
              }
629
            }
496
     switch(vector)
497
       {
498
       case VECTX: axis = VectX; break;
499
       case VECTY: axis = VectY; break;
500
       case VECTZ: axis = VectZ; break;
501
       }
630 502

  
631
      return true;
632
      }
503
     mRotAxis = vector;
504
     mRotRow  = row;
633 505

  
634
///////////////////////////////////////////////////////////////////////////////////////////////////
506
     mRotationAngleStatic.set0(0.0f);
635 507

  
636
    public int getSize()
637
      {
638
      return mSize;
639
      }
508
     for(int x=0; x<mSize; x++)
509
       for(int y=0; y<mSize; y++)
510
         for(int z=0; z<mSize; z++)
511
           if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
512
             {
513
             if( belongsToRotation(x,y,z,vector,mRotRow) )
514
               {
515
               mRotationAxis[x][y][z].set(axis);
516
               mRotationAngle[x][y][z].add(mRotationAngleStatic);
517
               }
518
             }
519
     }
640 520

  
641 521
///////////////////////////////////////////////////////////////////////////////////////////////////
642 522

  
643
    public long addNewRotation(int vector, int row, int angle, long durationMillis, EffectListener listener )
523
   public long addNewRotation(int vector, int row, int angle, long durationMillis, EffectListener listener )
644 524
      {
645 525
      Static3D axis = VectX;
646 526
      long effectID=0;
......
685 565

  
686 566
///////////////////////////////////////////////////////////////////////////////////////////////////
687 567

  
688
    public void removeRotationNow()
568
   public void removeRotationNow()
689 569
      {
690 570
      float qx=0,qy=0,qz=0;
691 571
      boolean first = true;

Also available in: Unified diff