Project

General

Profile

« Previous | Next » 

Revision e46e17fb

Added by Leszek Koltunski about 4 years ago

Adjust rotation speed depending on the row (important in case of Pyraminx - there the top little tetrahedron must rotate much faster than the bottom big layer )

View differences:

src/main/java/org/distorted/magic/RubikSurfaceView.java
65 65
    private float mX, mY;
66 66
    private float mStartRotX, mStartRotY;
67 67
    private float mAxisX, mAxisY;
68
    private float mRotationFactor;
68 69

  
69 70
    private static Static4D mQuatCurrent    = new Static4D(0,0,0,1);
70 71
    private static Static4D mQuatAccumulated= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
......
203 204
      // we have the length of 1D vector 'angle', now the direction:
204 205
      float tmp = mAxisY==0 ? -mAxisX*y : mAxisY*x;
205 206

  
206
      return (tmp>0 ? 1:-1)*len;
207
      return (tmp>0 ? 1:-1)*len*mRotationFactor;
207 208
      }
208 209

  
209 210
///////////////////////////////////////////////////////////////////////////////////////////////////
......
305 306
                                           Static4D touchPoint2 = new Static4D(x, y, 0, 0);
306 307
                                           Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuatAccumulated);
307 308

  
308
                                           Static2D rot = mMovement.newRotation(rotatedTouchPoint2);
309
                                           Static2D res = mMovement.newRotation(rotatedTouchPoint2);
309 310
                                           RubikObject object = mRenderer.getObject();
310 311

  
311
                                           int axis = (int)rot.get0();
312
                                           int axis = (int)res.get0();
313
                                           float offset = res.get1();
312 314
                                           computeCurrentAxis( object.getRotationAxis()[axis] );
315
                                           mRotationFactor = object.returnRotationFactor(offset);
313 316

  
314
                                           object.beginNewRotation( axis, object.returnRowFromOffset(rot.get1()) );
317
                                           object.beginNewRotation( axis, object.returnRowFromOffset(offset) );
315 318

  
316 319
                                           if( RubikState.getCurrentState()==RubikState.SOLV )
317 320
                                             {
......
325 328
                                         }
326 329
                                       else if( mContinuingRotation )
327 330
                                         {
328
                                         //Static4D touchPoint3 = new Static4D(x, y, 0, 0);
329
                                         //Static4D rotatedTouchPoint3= rotateVectorByInvertedQuat(touchPoint3, mQuatAccumulated);
330

  
331 331
                                         float angle = continueRotation(x-mStartRotX,y-mStartRotY);
332
                                         //float angle = mMovement.continueRotation(rotatedTouchPoint3);
333 332
                                         mRenderer.getObject().continueRotation(SWIPING_SENSITIVITY*angle);
334 333
                                         }
335 334
                                       else if( mDragging )

Also available in: Unified diff