Project

General

Profile

Download (21.2 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / RubikObject.java @ 4da7d87a

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import android.content.SharedPreferences;
23
import android.content.res.Resources;
24
import android.graphics.Bitmap;
25
import android.graphics.Canvas;
26
import android.graphics.Paint;
27

    
28
import com.google.firebase.crashlytics.FirebaseCrashlytics;
29

    
30
import org.distorted.library.effect.Effect;
31
import org.distorted.library.effect.MatrixEffectQuaternion;
32
import org.distorted.library.effect.MatrixEffectScale;
33
import org.distorted.library.effect.VertexEffectQuaternion;
34
import org.distorted.library.effect.VertexEffectRotate;
35
import org.distorted.library.main.DistortedEffects;
36
import org.distorted.library.main.DistortedNode;
37
import org.distorted.library.main.DistortedTexture;
38
import org.distorted.library.mesh.MeshBase;
39
import org.distorted.library.mesh.MeshFile;
40
import org.distorted.library.mesh.MeshRectangles;
41
import org.distorted.library.message.EffectListener;
42
import org.distorted.library.type.Dynamic1D;
43
import org.distorted.library.type.Static1D;
44
import org.distorted.library.type.Static3D;
45
import org.distorted.library.type.Static4D;
46

    
47
import java.io.DataInputStream;
48
import java.io.IOException;
49
import java.io.InputStream;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
public abstract class RubikObject extends DistortedNode
54
  {
55
  private static final Static3D CENTER = new Static3D(0,0,0);
56
  static final int INTERIOR_COLOR = 0xff000000;
57
  public static final int NODE_FBO_SIZE = 600;
58
  private static final int POST_ROTATION_MILLISEC = 500;
59
  private static final int TEXTURE_HEIGHT = 128;
60

    
61
  final Static3D[] ROTATION_AXIS;
62
  final Static4D[] QUATS;
63
  final int NUM_FACES;
64

    
65
  static float OBJECT_SCREEN_RATIO;
66

    
67
  private final int NUM_CUBITS;
68
  private int mRotRowBitmap;
69
  private int mRotAxis;
70
  private Static3D[] mOrigPos;
71
  private Static3D mNodeScale;
72
  private Static4D mQuat;
73
  private Cubit[] mCubits;
74
  private int mSize;
75
  private RubikObjectList mList;
76
  private MeshBase mMesh;
77
  private DistortedEffects mEffects;
78
  private VertexEffectRotate mRotateEffect;
79
  private Dynamic1D mRotationAngle;
80
  private Static3D mRotationAxis;
81

    
82
  float mStart, mStep;
83

    
84
  Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
85
  DistortedTexture mTexture;
86

    
87
  MatrixEffectScale mScaleEffect;
88
  MatrixEffectQuaternion mQuatEffect;
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  RubikObject(int size, int fov, Static4D quat, DistortedTexture nodeTexture, MeshRectangles nodeMesh,
93
              DistortedEffects nodeEffects, int[][] moves, RubikObjectList list, Resources res)
94
    {
95
    super(nodeTexture,nodeEffects,nodeMesh);
96

    
97
    resizeFBO(NODE_FBO_SIZE, NODE_FBO_SIZE);
98

    
99
    mList = list;
100
    mOrigPos = getCubitPositions(size);
101

    
102
    QUATS = getQuats();
103
    NUM_CUBITS  = mOrigPos.length;
104
    ROTATION_AXIS = getRotationAxis();
105
    OBJECT_SCREEN_RATIO = getScreenRatio();
106
    NUM_FACES = getNumFaces();
107

    
108
    mSize = size;
109
    computeStartAndStep(mOrigPos);
110
    mNodeScale= new Static3D(1,1,1);
111
    mQuat = quat;
112

    
113
    mRotationAngle= new Dynamic1D();
114
    mRotationAxis = new Static3D(1,0,0);
115
    mRotateEffect = new VertexEffectRotate(mRotationAngle, mRotationAxis, CENTER);
116

    
117
    mRotationAngleStatic = new Static1D(0);
118
    mRotationAngleMiddle = new Static1D(0);
119
    mRotationAngleFinal  = new Static1D(0);
120

    
121
    float scale = OBJECT_SCREEN_RATIO*NODE_FBO_SIZE/mSize;
122
    mScaleEffect = new MatrixEffectScale(new Static3D(scale,scale,scale));
123
    mQuatEffect  = new MatrixEffectQuaternion(quat, CENTER);
124

    
125
    MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale);
126
    nodeEffects.apply(nodeScaleEffect);
127

    
128
    mCubits = new Cubit[NUM_CUBITS];
129
    mTexture = new DistortedTexture();
130

    
131
    int sizeIndex = RubikObjectList.getSizeIndex(list.ordinal(),mSize);
132
    int resourceID= list.getResourceIDs()[sizeIndex];
133

    
134
    InputStream is = res.openRawResource(resourceID);
135
    DataInputStream dos = new DataInputStream(is);
136
    mMesh = new MeshFile(dos);
137

    
138
    try
139
      {
140
      is.close();
141
      }
142
    catch(IOException e)
143
      {
144
      android.util.Log.e("meshFile", "Error closing InputStream: "+e.toString());
145
      }
146

    
147
    for(int i=0; i<NUM_CUBITS; i++)
148
      {
149
      mCubits[i] = new Cubit(this,mOrigPos[i]);
150
      mMesh.setEffectAssociation(i, mCubits[i].computeAssociation(), 0);
151
      }
152

    
153
    mEffects = new DistortedEffects();
154

    
155
    int num_quats = QUATS.length;
156
    for(int q=0; q<num_quats; q++)
157
      {
158
      VertexEffectQuaternion vq = new VertexEffectQuaternion(QUATS[q],CENTER);
159
      vq.setMeshAssociation(0,q);
160
      mEffects.apply(vq);
161
      }
162

    
163
    mEffects.apply(mRotateEffect);
164
    mEffects.apply(mQuatEffect);
165
    mEffects.apply(mScaleEffect);
166

    
167
    attach( new DistortedNode(mTexture,mEffects,mMesh) );
168

    
169
    setupPosition(moves);
170

    
171
    setProjection(fov, 0.1f);
172
    }
173

    
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175
// Cast centers of all Cubits on the first rotation Axis and compute the leftmost and rightmost
176
// one. From there compute the 'start' (i.e. the leftmost) and 'step' (i.e. distance between two
177
// consecutive).
178
// it is assumed that other rotation axis have the same 'start' and 'step' - this is the case with
179
// the Cube and the Pyraminx.
180
// Start and Step are then needed to compute which rotation row (with respect to a given axis) a
181
// given Cubit belongs to.
182

    
183
  private void computeStartAndStep(Static3D[] pos)
184
    {
185
    float min = Float.MAX_VALUE;
186
    float max = Float.MIN_VALUE;
187
    float axisX = ROTATION_AXIS[0].get0();
188
    float axisY = ROTATION_AXIS[0].get1();
189
    float axisZ = ROTATION_AXIS[0].get2();
190
    float tmp;
191

    
192
    for(int i=0; i<NUM_CUBITS; i++)
193
      {
194
      tmp = pos[i].get0()*axisX + pos[i].get1()*axisY + pos[i].get2()*axisZ;
195
      if( tmp<min ) min=tmp;
196
      if( tmp>max ) max=tmp;
197
      }
198

    
199
    mStart = min;
200
    mStep  = (max-min+1.0f)/mSize;
201
    }
202

    
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204

    
205
  private boolean belongsToRotation( int cubit, int axis, int rowBitmap)
206
    {
207
    int cubitRow = (int)(mCubits[cubit].mRotationRow[axis]+0.5f);
208
    return ((1<<cubitRow)&rowBitmap)!=0;
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212
// we cannot use belongsToRotation for deciding if to texture a face. Counterexample: the 'rotated'
213
// tetrahedrons of Pyraminx nearby the edge: they belong to rotation but their face which is rotated
214
// away from the face of the Pyraminx shouldn't be textured.
215

    
216
  private boolean isOnFace( int cubit, int axis, int row)
217
    {
218
    final float MAX_ERROR = 0.0001f;
219
    float diff = mCubits[cubit].mRotationRow[axis] - row;
220
    return diff*diff < MAX_ERROR;
221
    }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
// note the minus in front of the sin() - we rotate counterclockwise
225
// when looking towards the direction where the axis increases in values.
226

    
227
  private Static4D makeQuaternion(int axisIndex, int angleInDegrees)
228
    {
229
    Static3D axis = ROTATION_AXIS[axisIndex];
230

    
231
    while( angleInDegrees<0 ) angleInDegrees += 360;
232
    angleInDegrees %= 360;
233
    
234
    float cosA = (float)Math.cos(Math.PI*angleInDegrees/360);
235
    float sinA =-(float)Math.sqrt(1-cosA*cosA);
236

    
237
    return new Static4D(axis.get0()*sinA, axis.get1()*sinA, axis.get2()*sinA, cosA);
238
    }
239

    
240
///////////////////////////////////////////////////////////////////////////////////////////////////
241

    
242
  private void setupPosition(int[][] moves)
243
    {
244
    if( moves!=null )
245
      {
246
      Static4D quat;
247
      int index, axis, rowBitmap, angle;
248
      int corr = (360/getBasicAngle());
249

    
250
      for(int[] move: moves)
251
        {
252
        axis     = move[0];
253
        rowBitmap= move[1];
254
        angle    = move[2]*corr;
255
        quat     = makeQuaternion(axis,angle);
256

    
257
        for(int j=0; j<NUM_CUBITS; j++)
258
          if( belongsToRotation(j,axis,rowBitmap) )
259
            {
260
            index = mCubits[j].removeRotationNow(quat);
261
            mMesh.setEffectAssociation(j,mCubits[j].computeAssociation(),index);
262
            }
263
        }
264
      }
265
    }
266

    
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268

    
269
  int getCubitFaceColorIndex(int cubit, int face)
270
    {
271
    Static4D texMap = mMesh.getTextureMap(NUM_FACES*cubit + face);
272
    return (int)(texMap.get0() / texMap.get2());
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
// Clamp all rotated positions to one of those original ones to avoid accumulating errors.
277

    
278
  void clampPos(Static3D pos)
279
    {
280
    float currError, minError = Float.MAX_VALUE;
281
    int minErrorIndex= -1;
282
    float x = pos.get0();
283
    float y = pos.get1();
284
    float z = pos.get2();
285
    float xo,yo,zo;
286

    
287
    for(int i=0; i<NUM_CUBITS; i++)
288
      {
289
      xo = mOrigPos[i].get0();
290
      yo = mOrigPos[i].get1();
291
      zo = mOrigPos[i].get2();
292

    
293
      currError = (xo-x)*(xo-x) + (yo-y)*(yo-y) + (zo-z)*(zo-z);
294

    
295
      if( currError<minError )
296
        {
297
        minError = currError;
298
        minErrorIndex = i;
299
        }
300
      }
301

    
302
    pos.set( mOrigPos[minErrorIndex] );
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306
// the getFaceColors + final black in a horizontal strip.
307

    
308
  public void createTexture()
309
    {
310
    Bitmap bitmap;
311

    
312
    Paint paint = new Paint();
313
    bitmap = Bitmap.createBitmap( (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
314
    Canvas canvas = new Canvas(bitmap);
315

    
316
    paint.setAntiAlias(true);
317
    paint.setTextAlign(Paint.Align.CENTER);
318
    paint.setStyle(Paint.Style.FILL);
319

    
320
    paint.setColor(INTERIOR_COLOR);
321
    canvas.drawRect(0, 0, (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
322

    
323
    for(int i=0; i<NUM_FACES; i++)
324
      {
325
      createFaceTexture(canvas, paint, i, i*TEXTURE_HEIGHT, 0, TEXTURE_HEIGHT);
326
      }
327

    
328
    mTexture.setTexture(bitmap);
329
    }
330

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332

    
333
  public int getSize()
334
    {
335
    return mSize;
336
    }
337

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

    
340
  public void continueRotation(float angleInDegrees)
341
    {
342
    mRotationAngleStatic.set0(angleInDegrees);
343
    }
344

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

    
347
  public Static4D getRotationQuat()
348
      {
349
      return mQuat;
350
      }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

    
354
  public void recomputeScaleFactor(int scrWidth, int scrHeight)
355
    {
356
    float factor = Math.min(scrWidth,scrHeight);
357
    mNodeScale.set(factor,factor,factor);
358
    }
359

    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

    
362
  public void savePreferences(SharedPreferences.Editor editor)
363
    {
364
    for(int i=0; i<NUM_CUBITS; i++) mCubits[i].savePreferences(editor);
365
    }
366

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

    
369
  public void restorePreferences(SharedPreferences preferences)
370
    {
371
    for(int i=0; i<NUM_CUBITS; i++)
372
      {
373
      int index = mCubits[i].restorePreferences(preferences);
374
      mMesh.setEffectAssociation(i,mCubits[i].computeAssociation(),index);
375
      }
376
    }
377

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

    
380
  public void releaseResources()
381
    {
382
    mTexture.markForDeletion();
383
    }
384

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

    
387
  public void apply(Effect effect, int position)
388
    {
389
    mEffects.apply(effect, position);
390
    }
391

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

    
394
  public void remove(long effectID)
395
    {
396
    mEffects.abortById(effectID);
397
    }
398

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

    
401
  public void solve()
402
    {
403
    for(int i=0; i<NUM_CUBITS; i++)
404
      {
405
      mCubits[i].solve();
406
      mMesh.setEffectAssociation(i, mCubits[i].computeAssociation(), 0);
407
      }
408
    }
409

    
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411

    
412
  public boolean isSolved()
413
    {
414
    int index = mCubits[0].mQuatIndex;
415

    
416
    for(int i=1; i<NUM_CUBITS; i++)
417
      {
418
      if( !mCubits[i].thereIsNoVisibleDifference(index) ) return false;
419
      }
420

    
421
    return true;
422
    }
423

    
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

    
426
  public void resetAllTextureMaps()
427
    {
428
    boolean belongs;
429
    final float ratio = 1.0f/(NUM_FACES+1);
430

    
431
    for(int cubit=0; cubit<NUM_CUBITS; cubit++)
432
      {
433
      final Static4D[] maps = new Static4D[NUM_FACES];
434

    
435
      if( 2*ROTATION_AXIS.length == NUM_FACES )  // i.e. there are faces on both ends of the axis (cube)
436
        {
437
        for(int i=0; i<NUM_FACES; i++)
438
          {
439
          belongs = isOnFace(cubit, i/2, i%2==0 ? mSize-1:0 );
440
          maps[i] = new Static4D( (belongs?i:NUM_FACES)*ratio, 0.0f, ratio, 1.0f);
441
          }
442
        }
443
      else if( ROTATION_AXIS.length == NUM_FACES )  // just a single face on the right end of an axis (pyraminx)
444
        {
445
        for(int i=0; i<NUM_FACES; i++)
446
          {
447
          belongs = isOnFace(cubit, i, 0 );
448
          maps[i] = new Static4D( (belongs?i:NUM_FACES)*ratio, 0.0f, ratio, 1.0f);
449
          }
450
        }
451

    
452
      mMesh.setTextureMap(maps,NUM_FACES*cubit);
453
      }
454
    }
455

    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

    
458
  public void setTextureMap(int cubit, int face, int newColor)
459
    {
460
    final float ratio = 1.0f/(NUM_FACES+1);
461
    final Static4D[] maps = new Static4D[NUM_FACES];
462

    
463
    try
464
      {
465
      maps[face] = new Static4D( newColor*ratio, 0.0f, ratio, 1.0f);
466
      mMesh.setTextureMap(maps,NUM_FACES*cubit);
467
      }
468
    catch(ArrayIndexOutOfBoundsException ignored)
469
      {
470
      // the object must have changed in between of us touching the screen and getting here
471
      // (which happens after the next render, i.e. about 30 miliseconds later)
472
      // ignore.
473
      }
474
    }
475

    
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477

    
478
  public void beginNewRotation(int axis, int row )
479
    {
480
    if( axis<0 || axis>=ROTATION_AXIS.length )
481
      {
482
      android.util.Log.e("object", "invalid rotation axis: "+axis);
483
      return;
484
      }
485
    if( row<0 || row>=mSize )
486
      {
487
      android.util.Log.e("object", "invalid rotation row: "+row);
488
      return;
489
      }
490

    
491
    mRotAxis     = axis;
492
    mRotRowBitmap= (1<<row);
493
    mRotationAngleStatic.set0(0.0f);
494
    mRotationAxis.set( ROTATION_AXIS[axis] );
495
    mRotationAngle.add(mRotationAngleStatic);
496
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_OBJECT_SIZE) , -1);
497
    }
498

    
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

    
501
  public long addNewRotation( int axis, int rowBitmap, int angle, long durationMillis, EffectListener listener )
502
    {
503
    mRotAxis     = axis;
504
    mRotRowBitmap= rowBitmap;
505

    
506
    mRotationAngleStatic.set0(0.0f);
507
    mRotationAxis.set( ROTATION_AXIS[axis] );
508
    mRotationAngle.setDuration(durationMillis);
509
    mRotationAngle.resetToBeginning();
510
    mRotationAngle.add(new Static1D(0));
511
    mRotationAngle.add(new Static1D(angle));
512
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_OBJECT_SIZE) , -1);
513
    mRotateEffect.notifyWhenFinished(listener);
514

    
515
    return mRotateEffect.getID();
516
    }
517

    
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

    
520
  public long finishRotationNow(EffectListener listener, int nearestAngleInDegrees)
521
    {
522
    float angle = getAngle();
523
    mRotationAngleStatic.set0(angle);
524
    mRotationAngleFinal.set0(nearestAngleInDegrees);
525
    mRotationAngleMiddle.set0( nearestAngleInDegrees + (nearestAngleInDegrees-angle)*0.2f );
526

    
527
    mRotationAngle.setDuration(POST_ROTATION_MILLISEC);
528
    mRotationAngle.resetToBeginning();
529
    mRotationAngle.removeAll();
530
    mRotationAngle.add(mRotationAngleStatic);
531
    mRotationAngle.add(mRotationAngleMiddle);
532
    mRotationAngle.add(mRotationAngleFinal);
533
    mRotateEffect.notifyWhenFinished(listener);
534

    
535
    return mRotateEffect.getID();
536
    }
537

    
538

    
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540

    
541
  private float getAngle()
542
    {
543
    int pointNum = mRotationAngle.getNumPoints();
544

    
545
    if( pointNum>=1 )
546
      {
547
      return mRotationAngle.getPoint(pointNum-1).get0();
548
      }
549
    else
550
      {
551
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
552
      crashlytics.log("points in RotationAngle: "+pointNum);
553
      return 0;
554
      }
555
    }
556

    
557
///////////////////////////////////////////////////////////////////////////////////////////////////
558

    
559
  public void removeRotationNow()
560
    {
561
    float angle = getAngle();
562
    double nearestAngleInRadians = angle*Math.PI/180;
563
    float sinA =-(float)Math.sin(nearestAngleInRadians*0.5);
564
    float cosA = (float)Math.cos(nearestAngleInRadians*0.5);
565
    float axisX = ROTATION_AXIS[mRotAxis].get0();
566
    float axisY = ROTATION_AXIS[mRotAxis].get1();
567
    float axisZ = ROTATION_AXIS[mRotAxis].get2();
568
    Static4D quat = new Static4D( axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
569

    
570
    mRotationAngle.removeAll();
571
    mRotationAngleStatic.set0(0);
572

    
573
    for(int i=0; i<NUM_CUBITS; i++)
574
      if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
575
        {
576
        int index = mCubits[i].removeRotationNow(quat);
577
        mMesh.setEffectAssociation(i,mCubits[i].computeAssociation(),index);
578
        }
579
    }
580

    
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582

    
583
  public void initializeObject(int[][] moves)
584
    {
585
    solve();
586
    setupPosition(moves);
587
    }
588

    
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

    
591
  public int getCubit(float[] point3D)
592
    {
593
    float dist, minDist = Float. MAX_VALUE;
594
    int currentBest=-1;
595
    float multiplier = returnMultiplier();
596

    
597
    point3D[0] *= multiplier;
598
    point3D[1] *= multiplier;
599
    point3D[2] *= multiplier;
600

    
601
    for(int i=0; i<NUM_CUBITS; i++)
602
      {
603
      dist = mCubits[i].getDistSquared(point3D);
604
      if( dist<minDist )
605
        {
606
        minDist = dist;
607
        currentBest = i;
608
        }
609
      }
610

    
611
    return currentBest;
612
    }
613

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

    
616
  public int computeNearestAngle(float angle, float speed)
617
    {
618
    final int NEAREST = 360/getBasicAngle();
619

    
620
    int tmp = (int)((angle+NEAREST/2)/NEAREST);
621
    if( angle< -(NEAREST*0.5) ) tmp-=1;
622

    
623
    if( tmp!=0 ) return NEAREST*tmp;
624

    
625
    return speed> 1.5f ? NEAREST*(angle>0 ? 1:-1) : 0;
626
    }
627

    
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629

    
630
  public RubikObjectList getObjectList()
631
    {
632
    return mList;
633
    }
634

    
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636

    
637
  abstract float getScreenRatio();
638
  abstract Static3D[] getCubitPositions(int size);
639
  abstract Static4D[] getQuats();
640
  abstract int getNumFaces();
641
  abstract MeshBase createCubitMesh(int cubit);
642
  abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side);
643
  public abstract Static3D[] getRotationAxis();
644
  public abstract int getBasicAngle();
645
  public abstract float returnMultiplier();
646
  public abstract float returnRotationFactor(float offset);
647
  public abstract String retObjectString();
648
  public abstract float[] getRowChances();
649
  }
(4-4/8)