Project

General

Profile

« Previous | Next » 

Revision bef47287

Added by Leszek Koltunski about 4 years ago

Progress with object Movement.

View differences:

src/main/java/org/distorted/magic/RubikSurfaceView.java
220 220
        }
221 221
      }
222 222

  
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

  
225
    private void setUpDragOrRotate(float x, float y)
226
      {
227
      Static4D touchPoint1 = new Static4D(x, y, 0, 0);
228
      Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuatAccumulated);
229
      Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuatAccumulated);
230

  
231
      if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
232
        {
233
        mDragging           = false;
234
        mBeginningRotation  = mRenderer.canRotate();
235
        mContinuingRotation = false;
236
        }
237
      else
238
        {
239
        mDragging           = mRenderer.canDrag();
240
        mBeginningRotation  = false;
241
        mContinuingRotation = false;
242
        }
243
      }
244

  
223 245
///////////////////////////////////////////////////////////////////////////////////////////////////
224 246

  
225 247
    @Override
......
233 255
         {
234 256
         case MotionEvent.ACTION_DOWN: mX = x;
235 257
                                       mY = y;
236

  
237
                                       Static4D touchPoint1 = new Static4D(x, y, 0, 0);
238
                                       Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuatAccumulated);
239
                                       Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuatAccumulated);
240

  
241
                                       if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
242
                                         {
243
                                         mDragging           = false;
244
                                         mBeginningRotation  = mRenderer.canRotate();
245
                                         mContinuingRotation = false;
246
                                         }
247
                                       else
248
                                         {
249
                                         mDragging           = mRenderer.canDrag();
250
                                         mBeginningRotation  = false;
251
                                         mContinuingRotation = false;
252
                                         }
258
                                       setUpDragOrRotate(x,y);
253 259
                                       break;
254 260
         case MotionEvent.ACTION_MOVE: if( mBeginningRotation )
255 261
                                         {
......
281 287
                                         float angle = mMovement.continueRotation(rotatedTouchPoint3);
282 288
                                         mRenderer.getObject().continueRotation(SWIPING_SENSITIVITY*angle);
283 289
                                         }
284
                                       else if( mDragging || mRenderer.canDrag() )
290
                                       else if( mDragging )
285 291
                                         {
286
                                         mDragging = true;
287 292
                                         mTempCurrent.set(quatFromDrag(mX-x,y-mY));
288 293
                                         mRenderer.setQuatCurrentOnNextRender();
289 294

  
......
297 302
                                           mRenderer.setQuatAccumulatedOnNextRender();
298 303
                                           }
299 304
                                         }
305
                                       else
306
                                         {
307
                                         setUpDragOrRotate(x,y);
308
                                         }
300 309
                                       break;
301 310
         case MotionEvent.ACTION_UP  : if( mDragging )
302 311
                                         {

Also available in: Unified diff