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 )
src/main/java/org/distorted/object/RubikCube.java
218 218
    {
219 219
    return (int)(getSize()*offset);
220 220
    }
221

  
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223

  
224
  public float returnRotationFactor(float offset)
225
    {
226
    return 1.0f;
227
    }
221 228
}
src/main/java/org/distorted/object/RubikObject.java
473 473
  public abstract Static3D[] getRotationAxis();
474 474
  public abstract int getBasicAngle();
475 475
  public abstract int returnRowFromOffset(float offset);
476
  public abstract float returnRotationFactor(float offset);
476 477
  }
src/main/java/org/distorted/object/RubikPyraminx.java
310 310
    {
311 311
    return (int)(getSize()*offset/(SQ3/2));
312 312
    }
313

  
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315

  
316
  public float returnRotationFactor(float offset)
317
    {
318
    int size = getSize();
319
    int row  = (int)(size*offset/(SQ3/2));
320

  
321
    return ((float)size)/(size-row);
322
    }
313 323
}
src/main/res/values/strings.xml
26 26
    <string name="type">Type:</string>
27 27
    <string name="downloading">Downloading…</string>
28 28
    <string name="credits1">Open Source app developed using the Distorted graphics library. </string>
29
    <string name="credits2">Code, tutorials, learn how to write your own graphics effect: <a href="http://www.distorted.org/cube">Distorted.org</a></string>
29
    <string name="credits2">Code, tutorials, learn how to write your own graphics effect: <a href="https://distorted.org/redmine/projects/magic-cube/wiki">Distorted.org</a></string>
30 30

  
31 31
    <string name="ms_placeholder">%1$d ms</string>
32 32
    <string name="sc_placeholder">Scramble %1$d</string>

Also available in: Unified diff