Revision ee5c2ae1
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/magic/RubikActivity.java | ||
---|---|---|
37 | 37 |
private static final int SMALLEST_SIZE = 2; |
38 | 38 |
private static final int[] button_ids = {R.id.rubikSize2, R.id.rubikSize3, R.id.rubikSize4}; |
39 | 39 |
|
40 |
static int mSize = DEFAULT_SIZE; |
|
40 |
private static int mSize = DEFAULT_SIZE;
|
|
41 | 41 |
|
42 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 43 |
|
src/main/java/org/distorted/magic/RubikRenderer.java | ||
---|---|---|
72 | 72 |
mNewCube = null; |
73 | 73 |
|
74 | 74 |
mTempCurrent = new Static4D(0,0,0,1); |
75 |
mTempAccumulated = initializeQuat();
|
|
75 |
mTempAccumulated = new Static4D(0,0,0,1);
|
|
76 | 76 |
mQuatCurrent = new Static4D(0,0,0,1); |
77 |
mQuatAccumulated = initializeQuat();
|
|
77 |
mQuatAccumulated = new Static4D(0,0,0,1);
|
|
78 | 78 |
|
79 | 79 |
mScreenWidth = mScreenHeight = 0; |
80 | 80 |
|
... | ... | |
360 | 360 |
return mNewCube; |
361 | 361 |
} |
362 | 362 |
|
363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 |
// Initial rotation of the cube. Something semi-random that looks good. |
|
365 |
|
|
366 |
Static4D initializeQuat() |
|
367 |
{ |
|
368 |
return new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
|
369 |
} |
|
370 |
|
|
371 | 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
372 | 364 |
|
373 | 365 |
void setQuatCurrent(Static4D current) |
src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
57 | 57 |
private int mX, mY; |
58 |
private Static4D mQuatCurrent, mQuatAccumulated; |
|
59 | 58 |
private int mRotationVect; |
60 | 59 |
private RubikRenderer mRenderer; |
61 | 60 |
|
... | ... | |
64 | 63 |
private int mScreenWidth, mScreenHeight, mScreenMin; |
65 | 64 |
private float mCameraDistance; |
66 | 65 |
|
66 |
private static Static4D mQuatCurrent =new Static4D(0,0,0,1); |
|
67 |
private static Static4D mQuatAccumulated=new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
|
68 |
|
|
67 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 70 |
|
69 | 71 |
public RubikSurfaceView(Context context, AttributeSet attrs) |
... | ... | |
83 | 85 |
mScreenWidth = mScreenHeight = mScreenMin = 0; |
84 | 86 |
|
85 | 87 |
mRenderer = new RubikRenderer(this); |
86 |
|
|
87 |
mQuatCurrent = new Static4D(0,0,0,1); |
|
88 |
mQuatAccumulated = mRenderer.initializeQuat(); |
|
88 |
mRenderer.setQuatAccumulated(mQuatAccumulated); |
|
89 | 89 |
|
90 | 90 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
91 | 91 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
Also available in: Unified diff
Remember the quaternion.