Revision 27a70eae
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import org.distorted.library.type.Static2D; |
30 | 30 |
import org.distorted.library.type.Static4D; |
31 |
import org.distorted.object.RubikCube;
|
|
32 |
import org.distorted.object.RubikCubeMovement;
|
|
31 |
import org.distorted.object.RubikObject;
|
|
32 |
import org.distorted.object.RubikObjectMovement;
|
|
33 | 33 |
import org.distorted.uistate.RubikState; |
34 | 34 |
import org.distorted.uistate.RubikStateSolving; |
35 | 35 |
|
... | ... | |
48 | 48 |
private final Static4D CAMERA_POINT = new Static4D(0, 0, RubikRenderer.CAMERA_DISTANCE, 0); |
49 | 49 |
|
50 | 50 |
private RubikRenderer mRenderer; |
51 |
private RubikCubeMovement mMovement;
|
|
51 |
private RubikObjectMovement mMovement;
|
|
52 | 52 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
53 | 53 |
private float mX, mY; |
54 | 54 |
private int mScreenWidth, mScreenHeight, mScreenMin; |
... | ... | |
103 | 103 |
return mQuatCurrent; |
104 | 104 |
} |
105 | 105 |
|
106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
107 |
|
|
108 |
void setMovement(RubikObjectMovement movement) |
|
109 |
{ |
|
110 |
mMovement = movement; |
|
111 |
} |
|
112 |
|
|
106 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 114 |
|
108 | 115 |
private Static4D quatFromDrag(float dragX, float dragY) |
... | ... | |
196 | 203 |
if(!isInEditMode()) |
197 | 204 |
{ |
198 | 205 |
mRenderer = new RubikRenderer(this); |
199 |
mMovement = new RubikCubeMovement(); |
|
200 | 206 |
|
201 | 207 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
202 | 208 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
... | ... | |
259 | 265 |
Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuatAccumulated); |
260 | 266 |
|
261 | 267 |
Static2D rot = mMovement.newRotation(rotatedTouchPoint2); |
262 |
RubikCube cube = mRenderer.getCube();
|
|
268 |
RubikObject object = mRenderer.getObject();
|
|
263 | 269 |
|
264 |
cube.addNewRotation( (int)rot.get0(), (int)(cube.getSize()*rot.get1()) );
|
|
270 |
object.beginNewRotation( (int)rot.get0(), (int)(object.getSize()*rot.get1()) );
|
|
265 | 271 |
|
266 | 272 |
if( RubikState.getCurrentState()==RubikState.SOLV ) |
267 | 273 |
{ |
... | ... | |
279 | 285 |
Static4D rotatedTouchPoint3= rotateVectorByInvertedQuat(touchPoint3, mQuatAccumulated); |
280 | 286 |
|
281 | 287 |
float angle = mMovement.continueRotation(rotatedTouchPoint3); |
282 |
mRenderer.getCube().continueRotation(SWIPING_SENSITIVITY*angle);
|
|
288 |
mRenderer.getObject().continueRotation(SWIPING_SENSITIVITY*angle);
|
|
283 | 289 |
} |
284 | 290 |
break; |
285 | 291 |
case MotionEvent.ACTION_UP : if( mDragging ) |
Also available in: Unified diff
Make RubikCube and RubikCubeMovement generic and not visible outside of their package.