Project

General

Profile

« Previous | Next » 

Revision 8cccfb10

Added by Leszek Koltunski over 4 years ago

More progreess porting RubikCube.

View differences:

src/main/java/org/distorted/objects/Cubit.java
21 21

  
22 22
import android.content.SharedPreferences;
23 23

  
24
import org.distorted.library.effect.MatrixEffectQuaternion;
25
import org.distorted.library.main.DistortedEffects;
26 24
import org.distorted.library.type.Static3D;
27 25
import org.distorted.library.type.Static4D;
28 26
import org.distorted.main.RubikSurfaceView;
......
31 29

  
32 30
class Cubit
33 31
  {
34
  private static final Static3D MATRIX_CENTER = new Static3D(0,0,0);
35

  
36 32
  private final Static3D mOrigPosition;
37 33

  
38 34
  private RubikObject mParent;
39 35
  private Static3D mCurrentPosition;
40 36
  private int mNumAxis;
41 37

  
42
  DistortedEffects mEffect;
43 38
  Static4D mQuatScramble;
44 39
  float[] mRotationRow;
45 40

  
......
60 55
    mNumAxis     = mParent.ROTATION_AXIS.length;
61 56
    mRotationRow = new float[mNumAxis];
62 57
    computeRotationRow();
63

  
64
    mEffect = new DistortedEffects();
65
    mEffect.apply( new MatrixEffectQuaternion(mQuatScramble, MATRIX_CENTER));
66 58
    }
67 59

  
68 60
///////////////////////////////////////////////////////////////////////////////////////////////////
......
180 172
      {
181 173
      row = (int)(mRotationRow[axis]+0.5f);
182 174
      result += (1<<(row+accumulativeShift));
183
      accumulativeShift += RubikObjectList.MAX_SIZE;
175
      accumulativeShift += RubikObjectList.MAX_OBJECT_SIZE;
184 176
      }
185 177

  
186 178
    return result;
src/main/java/org/distorted/objects/RubikObject.java
47 47

  
48 48
public abstract class RubikObject extends DistortedNode
49 49
  {
50
  private static final Static3D VERTEX_CENTER = new Static3D(0,0,0);
50
  private static final Static3D CENTER = new Static3D(0,0,0);
51 51
  static final int INTERIOR_COLOR = 0xff000000;
52 52
  public static final int NODE_FBO_SIZE = 600;
53 53
  private static final int POST_ROTATION_MILLISEC = 500;
......
108 108

  
109 109
    mRotationAngle= new Dynamic1D();
110 110
    mRotationAxis = new Static3D(1,0,0);
111
    mRotateEffect = new VertexEffectRotate(mRotationAngle, mRotationAxis, VERTEX_CENTER);
111
    mRotateEffect = new VertexEffectRotate(mRotationAngle, mRotationAxis, CENTER);
112 112

  
113 113
    mRotationAngleStatic = new Static1D(0);
114 114
    mRotationAngleMiddle = new Static1D(0);
115 115
    mRotationAngleFinal  = new Static1D(0);
116 116

  
117
    Static3D center = new Static3D(0,0,0);
118 117
    float scale = OBJECT_SCREEN_RATIO*NODE_FBO_SIZE/mSize;
119 118
    mScaleEffect = new MatrixEffectScale(new Static3D(scale,scale,scale));
120
    mQuatCEffect = new MatrixEffectQuaternion(quatCur, center);
121
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, center);
119
    mQuatCEffect = new MatrixEffectQuaternion(quatCur, CENTER);
120
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, CENTER);
122 121

  
123 122
    MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale);
124 123
    nodeEffects.apply(nodeScaleEffect);
......
392 391

  
393 392
  public void apply(Effect effect, int position)
394 393
    {
395
    for(int i=0; i<NUM_CUBITS; i++) mCubits[i].mEffect.apply(effect, position);
394
    mEffects.apply(effect, position);
396 395
    }
397 396

  
398 397
///////////////////////////////////////////////////////////////////////////////////////////////////
399 398

  
400 399
  public void remove(long effectID)
401 400
    {
402
    for(int i=0; i<NUM_CUBITS; i++) mCubits[i].mEffect.abortById(effectID);
401
    mEffects.abortById(effectID);
403 402
    }
404 403

  
405 404
///////////////////////////////////////////////////////////////////////////////////////////////////
......
473 472
    mRotationAngleStatic.set0(0.0f);
474 473
    mRotationAxis.set( ROTATION_AXIS[axis] );
475 474
    mRotationAngle.add(mRotationAngleStatic);
476
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_SIZE) , -1);
475
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_OBJECT_SIZE) , -1);
477 476
    }
478 477

  
479 478
///////////////////////////////////////////////////////////////////////////////////////////////////
......
489 488
    mRotationAngle.resetToBeginning();
490 489
    mRotationAngle.add(new Static1D(0));
491 490
    mRotationAngle.add(new Static1D(angle));
492
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_SIZE) , -1);
491
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*RubikObjectList.MAX_OBJECT_SIZE) , -1);
493 492
    mRotateEffect.notifyWhenFinished(listener);
494 493

  
495 494
    return mRotateEffect.getID();
src/main/java/org/distorted/objects/RubikObjectList.java
54 54
  ;
55 55

  
56 56
  public static final int NUM_OBJECTS = values().length;
57
  public static final int MAX_SIZE;
57
  public static final int MAX_NUM_OBJECTS;
58 58
  public static final int MAX_LEVEL;
59
  public static final int MAX_OBJECT_SIZE;
59 60

  
60 61
  private final int[] mObjectSizes, mMaxLevels, mIconIDs;
61 62
  private final Class<? extends RubikObject> mObjectClass;
......
66 67
  static
67 68
    {
68 69
    mNumAll = 0;
69
    int size, i = 0;
70
    int num, i = 0;
70 71
    objects = new RubikObjectList[NUM_OBJECTS];
71
    int maxSize  = Integer.MIN_VALUE;
72
    int maxLevel = Integer.MIN_VALUE;
72
    int maxNum  = Integer.MIN_VALUE;
73
    int maxLevel= Integer.MIN_VALUE;
74
    int maxSize = Integer.MIN_VALUE;
73 75

  
74 76
    for(RubikObjectList object: RubikObjectList.values())
75 77
      {
76 78
      objects[i] = object;
77 79
      i++;
78
      size = object.mObjectSizes.length;
79
      mNumAll += size;
80
      if( size> maxSize ) maxSize = size;
80
      num = object.mObjectSizes.length;
81
      mNumAll += num;
82
      if( num> maxNum ) maxNum = num;
81 83

  
82
      for(int j=0; j<size; j++)
84
      for(int j=0; j<num; j++)
83 85
        {
84 86
        if( object.mMaxLevels[j] > maxLevel ) maxLevel = object.mMaxLevels[j];
87
        if( object.mObjectSizes[j] > maxSize) maxSize  = object.mObjectSizes[j];
85 88
        }
86 89
      }
87 90

  
88
    MAX_SIZE = maxSize;
89
    MAX_LEVEL= maxLevel;
91
    MAX_NUM_OBJECTS = maxNum;
92
    MAX_LEVEL       = maxLevel;
93
    MAX_OBJECT_SIZE = maxSize;
90 94
    }
91 95

  
92 96
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/scores/RubikScores.java
27 27

  
28 28
import java.util.UUID;
29 29

  
30
import static org.distorted.objects.RubikObjectList.MAX_SIZE;
30
import static org.distorted.objects.RubikObjectList.MAX_NUM_OBJECTS;
31 31
import static org.distorted.objects.RubikObjectList.NUM_OBJECTS;
32 32
import static org.distorted.objects.RubikObjectList.MAX_LEVEL;
33 33

  
......
52 52

  
53 53
  private RubikScores()
54 54
    {
55
    mRecords   = new long[NUM_OBJECTS][MAX_SIZE][MAX_LEVEL];
56
    mSubmitted = new int [NUM_OBJECTS][MAX_SIZE][MAX_LEVEL];
55
    mRecords   = new long[NUM_OBJECTS][MAX_NUM_OBJECTS][MAX_LEVEL];
56
    mSubmitted = new int [NUM_OBJECTS][MAX_NUM_OBJECTS][MAX_LEVEL];
57 57

  
58 58
    for(int i=0; i<NUM_OBJECTS; i++)
59
      for(int j=0; j<MAX_SIZE; j++)
59
      for(int j=0; j<MAX_NUM_OBJECTS; j++)
60 60
        for(int k=0; k<MAX_LEVEL; k++)
61 61
          {
62 62
          mRecords[i][j][k]   = NO_RECORD;
......
235 235
            time = Long.parseLong(timeStr);
236 236
            subm = Integer.parseInt(submStr);
237 237

  
238
            if( sizeIndex>=0 && sizeIndex<MAX_SIZE && subm>=0 && subm<=1 )
238
            if( sizeIndex>=0 && sizeIndex<MAX_NUM_OBJECTS && subm>=0 && subm<=1 )
239 239
              {
240 240
              mRecords  [object][sizeIndex][level] = time;
241 241
              mSubmitted[object][sizeIndex][level] = subm;
......
309 309
    mNameIsVerified = true;
310 310

  
311 311
    for(int i=0; i<NUM_OBJECTS; i++)
312
      for(int j=0; j<MAX_SIZE   ; j++)
312
      for(int j=0; j<MAX_NUM_OBJECTS; j++)
313 313
        for(int k=0; k<MAX_LEVEL; k++)
314 314
          {
315 315
          mSubmitted[i][j][k]=1;

Also available in: Unified diff