Project

General

Profile

« Previous | Next » 

Revision a31d25de

Added by Leszek Koltunski about 4 years ago

Major progress with Prretty Patterns.

Two things remain:

1) looks like sometimes making/backing Moves in a Pattern gets stuck. ( Pattern.mCanRotate! )
2) we need to add RubikPatternList!

View differences:

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

  
77 77
  RubikObject(int size, int fov, Static4D quatCur, Static4D quatAcc, DistortedTexture nodeTexture,
78
              MeshRectangles nodeMesh, DistortedEffects nodeEffects, String moves, RubikObjectList list)
78
              MeshRectangles nodeMesh, DistortedEffects nodeEffects, int[][] moves, RubikObjectList list)
79 79
    {
80 80
    super(nodeTexture,nodeEffects,nodeMesh);
81 81

  
......
221 221
    }
222 222

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

  
226
  private void setupPosition(String moves)
227
  private Static4D makeQuaternion(int axisIndex, int angleInDegrees)
227 228
    {
228
    android.util.Log.e("object", "initializing: "+moves);
229
/*
230
    int index,tmp, a1,a2,a3, rv, rc, ra;
231

  
232
		numRotations=0;
233
		initializeVertices(mSize);
234

  
235
		int len=moves.length()/4;
236

  
237
		for(int i=0; i<len; i++)
238
		  {
239
			a1=moves.charAt(4*i+1)-'0';
240
			a2=moves.charAt(4*i+2)-'0';
241
			a3=moves.charAt(4*i+3)-'0';
242

  
243
			rv = (10*a1+a2)/32;
244
			rc = (10*a1+a2)%32;
245
			ra = 2-a3;
246

  
247
			rotVector = rv;
248

  
249
			tmp=rc;
250
			index=0;
251

  
252
			while( tmp!=0 )
253
			  {
254
				if( (tmp&0x1)==1 )
255
				  {
256
					rotAngle[index] = ra*90;
257
					RubikWorld.setIdentity(rotMat[index]);
258

  
259
					switch(rotVector)
260
					  {
261
					  case VECTX: RubikWorld.postRotate( rotMat[index], (float)((ra*90)%360), 1f,0f,0f); break;
262
					  case VECTY: RubikWorld.postRotate( rotMat[index], (float)((ra*90)%360), 0f,1f,0f); break;
263
					  case VECTZ: RubikWorld.postRotate( rotMat[index], (float)((ra*90)%360), 0f,0f,1f); break;
264
					  }
265

  
266
					transposeTiles(index);
267
					rotAngle[index]=0;
268
				  }
269

  
270
				tmp/=2;
271
				index++;
272
			  }
273
	  	}
274
 */
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 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
            mCubits[j].removeRotationNow(quat);
261
            }
262
        }
263
      }
275 264
    }
276 265

  
277 266
///////////////////////////////////////////////////////////////////////////////////////////////////
......
523 512

  
524 513
///////////////////////////////////////////////////////////////////////////////////////////////////
525 514

  
526
  public void initializeObject(String moves)
515
  public void initializeObject(int[][] moves)
527 516
    {
528 517
    solve();
529 518
    setupPosition(moves);

Also available in: Unified diff