Project

General

Profile

« Previous | Next » 

Revision 10a2e360

Added by Leszek Koltunski about 4 years ago

Progress towards generalizing belongsToRotation()

View differences:

src/main/java/org/distorted/object/RubikObject.java
76 76

  
77 77
    resizeFBO(NODE_FBO_SIZE, NODE_FBO_SIZE);
78 78

  
79
    Static3D[] positions = getCubitPositions(size);
80

  
79 81
    LEGAL_QUATS = getLegalQuats();
80
    NUM_CUBITS  = getNumCubits(size);
82
    NUM_CUBITS  = positions.length;
81 83
    ROTATION_AXIS = getRotationAxis();
82 84

  
83 85
    mSize = size;
......
106 108
    mTexture = new DistortedTexture();
107 109

  
108 110
    int vertices = (int)(24.0f/mSize + 2.0f);
109
    int[][] positions = getCubitPositions(size);
110 111

  
111 112
    for(int i=0; i<NUM_CUBITS; i++)
112 113
      {
113
      Static3D pos = new Static3D(positions[i][0],positions[i][1],positions[i][2]);
114 114
      MeshBase cubitMesh = createCubitMesh(vertices);
115
      mCubits[i] = new Cubit(this,cubitMesh,pos);
115
      mCubits[i] = new Cubit(this,cubitMesh,positions[i]);
116 116
      textureCubitMesh(cubitMesh,i);
117 117

  
118 118
      attach(mCubits[i].mNode);
......
149 149
    }
150 150

  
151 151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
// TODO: only works for RubikCube
153 152

  
154 153
  private boolean belongsToRotation( int cubit, int axis, int row)
155 154
    {
156
    Static3D position = mCubits[cubit].mCurrentPosition;
157

  
158
    if( axis==0 ) return position.get0()==row;
159
    if( axis==1 ) return position.get1()==row;
160
    if( axis==2 ) return position.get2()==row;
161

  
162
    return false;
155
    return mCubits[cubit].mRotationRow[axis]==row;
163 156
    }
164 157

  
165 158
///////////////////////////////////////////////////////////////////////////////////////////////////
......
403 396

  
404 397
///////////////////////////////////////////////////////////////////////////////////////////////////
405 398

  
406
  abstract int getNumCubits(int size);
407
  abstract int[][] getCubitPositions(int size);
399
  public int getNumRotations()
400
    {
401
    return ROTATION_AXIS.length;
402
    }
403

  
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405

  
406
  abstract Static3D[] getCubitPositions(int size);
408 407
  abstract float[] getLegalQuats();
409 408
  abstract int getNumFaces();
410 409
  abstract void createFaceTexture(Canvas canvas, Paint paint, int face);

Also available in: Unified diff