Project

General

Profile

« Previous | Next » 

Revision a6aa9a47

Added by Leszek Koltunski 12 months ago

Improve the 'rot axis parallel to face axis' touch control mode:
support case when the rot axis is parallel and agrees in direction with the face axis, and the one when they disagreee in direction.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectControl.java
36 36
    public static final int MODE_REPLACE = 2;
37 37
    public static final int MODE_NOTHING = 3;
38 38

  
39
    public static final int ROT_AXIS_NOT_NORMAL = 0;
40
    public static final int ROT_AXIS_NORMAL_OPP = 1;
41
    public static final int ROT_AXIS_NORMAL_AGR = 2;
42

  
39 43
    // Moving the finger from the middle of the vertical screen to the right edge will rotate a
40 44
    // given face by SWIPING_SENSITIVITY/2 degrees.
41 45
    public final static int SWIPING_SENSITIVITY  = 240;
......
73 77
    private int mMeshState, mIconMode;
74 78
    private boolean mRotateOnCreation;
75 79
    private final Static4D mQuat,mTemp;
76
    private boolean mRotAxisIsNormal;
80
    private int mRotAxisType;
77 81
    private final float[] mNormalTouchPoint;
78 82
    private float mNormalRotAngle;
79 83

  
......
250 254

  
251 255
    private void continueRotation(float x, float y)
252 256
      {
253
      if( !mRotAxisIsNormal )
257
      if( mRotAxisType == ROT_AXIS_NOT_NORMAL )
254 258
        {
255 259
        float dx = x-mStartRotX;
256 260
        float dy = y-mStartRotY;
......
272 276
        {
273 277
        float rotAngle = computeNormalRotAngle(mNormalTouchPoint[0]-x,mNormalTouchPoint[1]-y);
274 278
        mCurrentAngle = mNormalRotAngle - rotAngle;
279
        if( mRotAxisType==ROT_AXIS_NORMAL_AGR ) mCurrentAngle = -mCurrentAngle;
275 280
        mPreRender.getObject().continueRotation(mCurrentAngle);
276 281
        addSpeedProbe(mCurrentAngle);
277 282
        }
......
283 288
      {
284 289
      if( mAxis[0]==0 && mAxis[1]==0 )
285 290
        {
286
        mRotAxisIsNormal = true;
287

  
288 291
        // 0. get face center in object space
289 292
        // 1. multiply it by mQuat
290 293
        // 2. multiply if by mObjectRatio. Let the result be (x,y,z)
......
306 309
        float A = D / (D-z);
307 310
        mNormalTouchPoint[0] = A*x;
308 311
        mNormalTouchPoint[1] = A*y;
312

  
313
        boolean agree = mTouchControl.axisAndFaceAgree(mCurrentAxis);
314
        mRotAxisType = (agree ? ROT_AXIS_NORMAL_AGR : ROT_AXIS_NORMAL_OPP);
309 315
        }
310 316
      else
311 317
        {
312
        mRotAxisIsNormal = false;
318
        mRotAxisType = ROT_AXIS_NOT_NORMAL;
313 319
        }
314 320
      }
315 321

  
......
341 347
      mTouchControl.getCastedRotAxis(mAxis,mQuat,mCurrentAxis);
342 348
      correctRotationAxis();
343 349
      mRotationFactor = mTouchControl.returnRotationFactor(numLayers,mCurrentRow);
344
      if( mRotAxisIsNormal ) mNormalRotAngle = computeNormalRotAngle(mNormalTouchPoint[0]-x,mNormalTouchPoint[1]-y);
350
      if( mRotAxisType != ROT_AXIS_NOT_NORMAL ) mNormalRotAngle = computeNormalRotAngle(mNormalTouchPoint[0]-x,mNormalTouchPoint[1]-y);
345 351

  
346 352
      if( object.beginNewRotation( mCurrentAxis, mCurrentRow ) )
347 353
        {

Also available in: Unified diff