Revision a6aa9a47
Added by Leszek Koltunski over 2 years ago
| 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 |
{
|
| src/main/java/org/distorted/objectlib/main/ObjectType.java | ||
|---|---|---|
| 111 | 111 |
|
| 112 | 112 |
COIH_3 ( TwistyCoinHexahedron.class , 25, R.drawable.coin_3, true, 50, new InitData(new int[] {3,3,3,3,3,3,3})),
|
| 113 | 113 |
|
| 114 |
COIN_3 ( TwistyCoinTetrahedron.class, 15, R.drawable.coin_3, false, 40, new InitData(new int[] {3,3,3,3})),
|
|
| 114 |
COIN_3 ( TwistyCoinTetrahedron.class, 15, R.drawable.coin_3, true, 40, new InitData(new int[] {3,3,3,3})),
|
|
| 115 | 115 |
TINS_5 ( TwistyTins.class , 28, R.drawable.coin_3, false, 60, new InitData(new int[] {5,5,5,5})),
|
| 116 | 116 |
; |
| 117 | 117 |
|
| src/main/java/org/distorted/objectlib/touchcontrol/TouchControl.java | ||
|---|---|---|
| 135 | 135 |
public abstract boolean objectTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera); |
| 136 | 136 |
public abstract void newRotation(int[] output, Static4D rotatedTouchPoint, Static4D quat); |
| 137 | 137 |
public abstract void getCastedRotAxis(float[] output, Static4D quat, int rotIndex); |
| 138 |
public abstract boolean axisAndFaceAgree(int rotIndex); |
|
| 138 | 139 |
public abstract int getTouchedCubitFace(); |
| 139 | 140 |
public abstract int getTouchedCubit(); |
| 140 | 141 |
public abstract float[] getTouchedPuzzleCenter(); |
| src/main/java/org/distorted/objectlib/touchcontrol/TouchControlBall.java | ||
|---|---|---|
| 350 | 350 |
output[1] = 0; |
| 351 | 351 |
} |
| 352 | 352 |
} |
| 353 |
|
|
| 354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 355 |
|
|
| 356 |
public boolean axisAndFaceAgree(int axisIndex) |
|
| 357 |
{
|
|
| 358 |
return false; |
|
| 359 |
} |
|
| 353 | 360 |
} |
| src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeChanging.java | ||
|---|---|---|
| 588 | 588 |
} |
| 589 | 589 |
} |
| 590 | 590 |
|
| 591 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 592 |
|
|
| 593 |
public boolean axisAndFaceAgree(int axisIndex) |
|
| 594 |
{
|
|
| 595 |
return false; |
|
| 596 |
} |
|
| 597 |
|
|
| 591 | 598 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 592 | 599 |
|
| 593 | 600 |
public float[] getTouchedPuzzleCenter() |
| src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeConstant.java | ||
|---|---|---|
| 408 | 408 |
} |
| 409 | 409 |
} |
| 410 | 410 |
|
| 411 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 412 |
|
|
| 413 |
public boolean axisAndFaceAgree(int axisIndex) |
|
| 414 |
{
|
|
| 415 |
Static3D rotAxis = mRotAxis[axisIndex]; |
|
| 416 |
Static3D faceAxis= mFaceAxis[mLastTouchedFace]; |
|
| 417 |
|
|
| 418 |
float rx = rotAxis.get0(); |
|
| 419 |
float ry = rotAxis.get1(); |
|
| 420 |
float rz = rotAxis.get2(); |
|
| 421 |
|
|
| 422 |
float fx = faceAxis.get0(); |
|
| 423 |
float fy = faceAxis.get1(); |
|
| 424 |
float fz = faceAxis.get2(); |
|
| 425 |
|
|
| 426 |
float dx = rx-fx; |
|
| 427 |
float dy = ry-fy; |
|
| 428 |
float dz = rz-fz; |
|
| 429 |
|
|
| 430 |
return (dx*dx + dy*dy + dz*dz) == 0; |
|
| 431 |
} |
|
| 432 |
|
|
| 411 | 433 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 412 | 434 |
|
| 413 | 435 |
public float[] getTouchedPuzzleCenter() |
Also available in: Unified diff
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.